babylon.module.d.ts 5.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** 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 */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** 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 */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** 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 */
  686. static readonly GEQUAL: number;
  687. /** 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 */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = nearest */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * 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.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Class used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. * @deprecated Please use FromArray instead.
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. * @deprecated Please use FromArrayToRef instead.
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module "babylonjs/Maths/math.path" {
  4617. import { DeepImmutable, Nullable } from "babylonjs/types";
  4618. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4619. /**
  4620. * Defines potential orientation for back face culling
  4621. */
  4622. export enum Orientation {
  4623. /**
  4624. * Clockwise
  4625. */
  4626. CW = 0,
  4627. /** Counter clockwise */
  4628. CCW = 1
  4629. }
  4630. /** Class used to represent a Bezier curve */
  4631. export class BezierCurve {
  4632. /**
  4633. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4634. * @param t defines the time
  4635. * @param x1 defines the left coordinate on X axis
  4636. * @param y1 defines the left coordinate on Y axis
  4637. * @param x2 defines the right coordinate on X axis
  4638. * @param y2 defines the right coordinate on Y axis
  4639. * @returns the interpolated value
  4640. */
  4641. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4642. }
  4643. /**
  4644. * Defines angle representation
  4645. */
  4646. export class Angle {
  4647. private _radians;
  4648. /**
  4649. * Creates an Angle object of "radians" radians (float).
  4650. * @param radians the angle in radians
  4651. */
  4652. constructor(radians: number);
  4653. /**
  4654. * Get value in degrees
  4655. * @returns the Angle value in degrees (float)
  4656. */
  4657. degrees(): number;
  4658. /**
  4659. * Get value in radians
  4660. * @returns the Angle value in radians (float)
  4661. */
  4662. radians(): number;
  4663. /**
  4664. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4665. * @param a defines first vector
  4666. * @param b defines second vector
  4667. * @returns a new Angle
  4668. */
  4669. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4670. /**
  4671. * Gets a new Angle object from the given float in radians
  4672. * @param radians defines the angle value in radians
  4673. * @returns a new Angle
  4674. */
  4675. static FromRadians(radians: number): Angle;
  4676. /**
  4677. * Gets a new Angle object from the given float in degrees
  4678. * @param degrees defines the angle value in degrees
  4679. * @returns a new Angle
  4680. */
  4681. static FromDegrees(degrees: number): Angle;
  4682. }
  4683. /**
  4684. * This represents an arc in a 2d space.
  4685. */
  4686. export class Arc2 {
  4687. /** Defines the start point of the arc */
  4688. startPoint: Vector2;
  4689. /** Defines the mid point of the arc */
  4690. midPoint: Vector2;
  4691. /** Defines the end point of the arc */
  4692. endPoint: Vector2;
  4693. /**
  4694. * Defines the center point of the arc.
  4695. */
  4696. centerPoint: Vector2;
  4697. /**
  4698. * Defines the radius of the arc.
  4699. */
  4700. radius: number;
  4701. /**
  4702. * Defines the angle of the arc (from mid point to end point).
  4703. */
  4704. angle: Angle;
  4705. /**
  4706. * Defines the start angle of the arc (from start point to middle point).
  4707. */
  4708. startAngle: Angle;
  4709. /**
  4710. * Defines the orientation of the arc (clock wise/counter clock wise).
  4711. */
  4712. orientation: Orientation;
  4713. /**
  4714. * Creates an Arc object from the three given points : start, middle and end.
  4715. * @param startPoint Defines the start point of the arc
  4716. * @param midPoint Defines the midlle point of the arc
  4717. * @param endPoint Defines the end point of the arc
  4718. */
  4719. constructor(
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2,
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2,
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2);
  4726. }
  4727. /**
  4728. * Represents a 2D path made up of multiple 2D points
  4729. */
  4730. export class Path2 {
  4731. private _points;
  4732. private _length;
  4733. /**
  4734. * If the path start and end point are the same
  4735. */
  4736. closed: boolean;
  4737. /**
  4738. * Creates a Path2 object from the starting 2D coordinates x and y.
  4739. * @param x the starting points x value
  4740. * @param y the starting points y value
  4741. */
  4742. constructor(x: number, y: number);
  4743. /**
  4744. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4745. * @param x the added points x value
  4746. * @param y the added points y value
  4747. * @returns the updated Path2.
  4748. */
  4749. addLineTo(x: number, y: number): Path2;
  4750. /**
  4751. * 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.
  4752. * @param midX middle point x value
  4753. * @param midY middle point y value
  4754. * @param endX end point x value
  4755. * @param endY end point y value
  4756. * @param numberOfSegments (default: 36)
  4757. * @returns the updated Path2.
  4758. */
  4759. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4760. /**
  4761. * Closes the Path2.
  4762. * @returns the Path2.
  4763. */
  4764. close(): Path2;
  4765. /**
  4766. * Gets the sum of the distance between each sequential point in the path
  4767. * @returns the Path2 total length (float).
  4768. */
  4769. length(): number;
  4770. /**
  4771. * Gets the points which construct the path
  4772. * @returns the Path2 internal array of points.
  4773. */
  4774. getPoints(): Vector2[];
  4775. /**
  4776. * Retreives the point at the distance aways from the starting point
  4777. * @param normalizedLengthPosition the length along the path to retreive the point from
  4778. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4779. */
  4780. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4781. /**
  4782. * Creates a new path starting from an x and y position
  4783. * @param x starting x value
  4784. * @param y starting y value
  4785. * @returns a new Path2 starting at the coordinates (x, y).
  4786. */
  4787. static StartingAt(x: number, y: number): Path2;
  4788. }
  4789. /**
  4790. * Represents a 3D path made up of multiple 3D points
  4791. */
  4792. export class Path3D {
  4793. /**
  4794. * an array of Vector3, the curve axis of the Path3D
  4795. */
  4796. path: Vector3[];
  4797. private _curve;
  4798. private _distances;
  4799. private _tangents;
  4800. private _normals;
  4801. private _binormals;
  4802. private _raw;
  4803. private _alignTangentsWithPath;
  4804. private readonly _pointAtData;
  4805. /**
  4806. * new Path3D(path, normal, raw)
  4807. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4808. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4809. * @param path an array of Vector3, the curve axis of the Path3D
  4810. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4811. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4812. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4813. */
  4814. constructor(
  4815. /**
  4816. * an array of Vector3, the curve axis of the Path3D
  4817. */
  4818. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4819. /**
  4820. * Returns the Path3D array of successive Vector3 designing its curve.
  4821. * @returns the Path3D array of successive Vector3 designing its curve.
  4822. */
  4823. getCurve(): Vector3[];
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getPoints(): Vector3[];
  4829. /**
  4830. * @returns the computed length (float) of the path.
  4831. */
  4832. length(): number;
  4833. /**
  4834. * Returns an array populated with tangent vectors on each Path3D curve point.
  4835. * @returns an array populated with tangent vectors on each Path3D curve point.
  4836. */
  4837. getTangents(): Vector3[];
  4838. /**
  4839. * Returns an array populated with normal vectors on each Path3D curve point.
  4840. * @returns an array populated with normal vectors on each Path3D curve point.
  4841. */
  4842. getNormals(): Vector3[];
  4843. /**
  4844. * Returns an array populated with binormal vectors on each Path3D curve point.
  4845. * @returns an array populated with binormal vectors on each Path3D curve point.
  4846. */
  4847. getBinormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4851. */
  4852. getDistances(): number[];
  4853. /**
  4854. * Returns an interpolated point along this path
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns a new Vector3 as the point
  4857. */
  4858. getPointAt(position: number): Vector3;
  4859. /**
  4860. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4861. * @param position the position of the point along this path, from 0.0 to 1.0
  4862. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4863. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4864. */
  4865. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4870. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4871. */
  4872. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4877. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4878. */
  4879. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4884. */
  4885. getDistanceAt(position: number): number;
  4886. /**
  4887. * Returns the array index of the previous point of an interpolated point along this path
  4888. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4889. * @returns the array index
  4890. */
  4891. getPreviousPointIndexAt(position: number): number;
  4892. /**
  4893. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4894. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4895. * @returns the sub position
  4896. */
  4897. getSubPositionAt(position: number): number;
  4898. /**
  4899. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4900. * @param target the vector of which to get the closest position to
  4901. * @returns the position of the closest virtual point on this path to the target vector
  4902. */
  4903. getClosestPositionTo(target: Vector3): number;
  4904. /**
  4905. * Returns a sub path (slice) of this path
  4906. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4907. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4908. * @returns a sub path (slice) of this path
  4909. */
  4910. slice(start?: number, end?: number): Path3D;
  4911. /**
  4912. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4913. * @param path path which all values are copied into the curves points
  4914. * @param firstNormal which should be projected onto the curve
  4915. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4916. * @returns the same object updated.
  4917. */
  4918. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4919. private _compute;
  4920. private _getFirstNonNullVector;
  4921. private _getLastNonNullVector;
  4922. private _normalVector;
  4923. /**
  4924. * Updates the point at data for an interpolated point along this curve
  4925. * @param position the position of the point along this curve, from 0.0 to 1.0
  4926. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4927. * @returns the (updated) point at data
  4928. */
  4929. private _updatePointAtData;
  4930. /**
  4931. * Updates the point at data from the specified parameters
  4932. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4933. * @param point the interpolated point
  4934. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4935. */
  4936. private _setPointAtData;
  4937. /**
  4938. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4939. */
  4940. private _updateInterpolationMatrix;
  4941. }
  4942. /**
  4943. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4944. * A Curve3 is designed from a series of successive Vector3.
  4945. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4946. */
  4947. export class Curve3 {
  4948. private _points;
  4949. private _length;
  4950. /**
  4951. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4952. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4953. * @param v1 (Vector3) the control point
  4954. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4961. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4962. * @param v1 (Vector3) the first control point
  4963. * @param v2 (Vector3) the second control point
  4964. * @param v3 (Vector3) the end point of the Cubic Bezier
  4965. * @param nbPoints (integer) the wanted number of points in the curve
  4966. * @returns the created Curve3
  4967. */
  4968. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4969. /**
  4970. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4971. * @param p1 (Vector3) the origin point of the Hermite Spline
  4972. * @param t1 (Vector3) the tangent vector at the origin point
  4973. * @param p2 (Vector3) the end point of the Hermite Spline
  4974. * @param t2 (Vector3) the tangent vector at the end point
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a CatmullRom Spline curve :
  4981. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4982. * @param nbPoints (integer) the wanted number of points between each curve control points
  4983. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4984. * @returns the created Curve3
  4985. */
  4986. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4987. /**
  4988. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4989. * A Curve3 is designed from a series of successive Vector3.
  4990. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4991. * @param points points which make up the curve
  4992. */
  4993. constructor(points: Vector3[]);
  4994. /**
  4995. * @returns the Curve3 stored array of successive Vector3
  4996. */
  4997. getPoints(): Vector3[];
  4998. /**
  4999. * @returns the computed length (float) of the curve.
  5000. */
  5001. length(): number;
  5002. /**
  5003. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5004. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5005. * curveA and curveB keep unchanged.
  5006. * @param curve the curve to continue from this curve
  5007. * @returns the newly constructed curve
  5008. */
  5009. continue(curve: DeepImmutable<Curve3>): Curve3;
  5010. private _computeLength;
  5011. }
  5012. }
  5013. declare module "babylonjs/Animations/easing" {
  5014. /**
  5015. * This represents the main contract an easing function should follow.
  5016. * Easing functions are used throughout the animation system.
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export interface IEasingFunction {
  5020. /**
  5021. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5022. * of the easing function.
  5023. * The link below provides some of the most common examples of easing functions.
  5024. * @see https://easings.net/
  5025. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5026. * @returns the corresponding value on the curve defined by the easing function
  5027. */
  5028. ease(gradient: number): number;
  5029. }
  5030. /**
  5031. * Base class used for every default easing function.
  5032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5033. */
  5034. export class EasingFunction implements IEasingFunction {
  5035. /**
  5036. * Interpolation follows the mathematical formula associated with the easing function.
  5037. */
  5038. static readonly EASINGMODE_EASEIN: number;
  5039. /**
  5040. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5041. */
  5042. static readonly EASINGMODE_EASEOUT: number;
  5043. /**
  5044. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5045. */
  5046. static readonly EASINGMODE_EASEINOUT: number;
  5047. private _easingMode;
  5048. /**
  5049. * Sets the easing mode of the current function.
  5050. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5051. */
  5052. setEasingMode(easingMode: number): void;
  5053. /**
  5054. * Gets the current easing mode.
  5055. * @returns the easing mode
  5056. */
  5057. getEasingMode(): number;
  5058. /**
  5059. * @hidden
  5060. */
  5061. easeInCore(gradient: number): number;
  5062. /**
  5063. * Given an input gradient between 0 and 1, this returns the corresponding value
  5064. * of the easing function.
  5065. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5066. * @returns the corresponding value on the curve defined by the easing function
  5067. */
  5068. ease(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a circle shape (see link below).
  5072. * @see https://easings.net/#easeInCirc
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class CircleEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a ease back shape (see link below).
  5081. * @see https://easings.net/#easeInBack
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class BackEase extends EasingFunction implements IEasingFunction {
  5085. /** Defines the amplitude of the function */
  5086. amplitude: number;
  5087. /**
  5088. * Instantiates a back ease easing
  5089. * @see https://easings.net/#easeInBack
  5090. * @param amplitude Defines the amplitude of the function
  5091. */
  5092. constructor(
  5093. /** Defines the amplitude of the function */
  5094. amplitude?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. /**
  5099. * Easing function with a bouncing shape (see link below).
  5100. * @see https://easings.net/#easeInBounce
  5101. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5102. */
  5103. export class BounceEase extends EasingFunction implements IEasingFunction {
  5104. /** Defines the number of bounces */
  5105. bounces: number;
  5106. /** Defines the amplitude of the bounce */
  5107. bounciness: number;
  5108. /**
  5109. * Instantiates a bounce easing
  5110. * @see https://easings.net/#easeInBounce
  5111. * @param bounces Defines the number of bounces
  5112. * @param bounciness Defines the amplitude of the bounce
  5113. */
  5114. constructor(
  5115. /** Defines the number of bounces */
  5116. bounces?: number,
  5117. /** Defines the amplitude of the bounce */
  5118. bounciness?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. /**
  5123. * Easing function with a power of 3 shape (see link below).
  5124. * @see https://easings.net/#easeInCubic
  5125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5126. */
  5127. export class CubicEase extends EasingFunction implements IEasingFunction {
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with an elastic shape (see link below).
  5133. * @see https://easings.net/#easeInElastic
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of oscillations*/
  5138. oscillations: number;
  5139. /** Defines the amplitude of the oscillations*/
  5140. springiness: number;
  5141. /**
  5142. * Instantiates an elastic easing function
  5143. * @see https://easings.net/#easeInElastic
  5144. * @param oscillations Defines the number of oscillations
  5145. * @param springiness Defines the amplitude of the oscillations
  5146. */
  5147. constructor(
  5148. /** Defines the number of oscillations*/
  5149. oscillations?: number,
  5150. /** Defines the amplitude of the oscillations*/
  5151. springiness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with an exponential shape (see link below).
  5157. * @see https://easings.net/#easeInExpo
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5161. /** Defines the exponent of the function */
  5162. exponent: number;
  5163. /**
  5164. * Instantiates an exponential easing function
  5165. * @see https://easings.net/#easeInExpo
  5166. * @param exponent Defines the exponent of the function
  5167. */
  5168. constructor(
  5169. /** Defines the exponent of the function */
  5170. exponent?: number);
  5171. /** @hidden */
  5172. easeInCore(gradient: number): number;
  5173. }
  5174. /**
  5175. * Easing function with a power shape (see link below).
  5176. * @see https://easings.net/#easeInQuad
  5177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5178. */
  5179. export class PowerEase extends EasingFunction implements IEasingFunction {
  5180. /** Defines the power of the function */
  5181. power: number;
  5182. /**
  5183. * Instantiates an power base easing function
  5184. * @see https://easings.net/#easeInQuad
  5185. * @param power Defines the power of the function
  5186. */
  5187. constructor(
  5188. /** Defines the power of the function */
  5189. power?: number);
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a power of 2 shape (see link below).
  5195. * @see https://easings.net/#easeInQuad
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a power of 4 shape (see link below).
  5204. * @see https://easings.net/#easeInQuart
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. /**
  5212. * Easing function with a power of 5 shape (see link below).
  5213. * @see https://easings.net/#easeInQuint
  5214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5215. */
  5216. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a sin shape (see link below).
  5222. * @see https://easings.net/#easeInSine
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class SineEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a bezier shape (see link below).
  5231. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5235. /** Defines the x component of the start tangent in the bezier curve */
  5236. x1: number;
  5237. /** Defines the y component of the start tangent in the bezier curve */
  5238. y1: number;
  5239. /** Defines the x component of the end tangent in the bezier curve */
  5240. x2: number;
  5241. /** Defines the y component of the end tangent in the bezier curve */
  5242. y2: number;
  5243. /**
  5244. * Instantiates a bezier function
  5245. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5246. * @param x1 Defines the x component of the start tangent in the bezier curve
  5247. * @param y1 Defines the y component of the start tangent in the bezier curve
  5248. * @param x2 Defines the x component of the end tangent in the bezier curve
  5249. * @param y2 Defines the y component of the end tangent in the bezier curve
  5250. */
  5251. constructor(
  5252. /** Defines the x component of the start tangent in the bezier curve */
  5253. x1?: number,
  5254. /** Defines the y component of the start tangent in the bezier curve */
  5255. y1?: number,
  5256. /** Defines the x component of the end tangent in the bezier curve */
  5257. x2?: number,
  5258. /** Defines the y component of the end tangent in the bezier curve */
  5259. y2?: number);
  5260. /** @hidden */
  5261. easeInCore(gradient: number): number;
  5262. }
  5263. }
  5264. declare module "babylonjs/Maths/math.color" {
  5265. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5266. /**
  5267. * Class used to hold a RBG color
  5268. */
  5269. export class Color3 {
  5270. /**
  5271. * Defines the red component (between 0 and 1, default is 0)
  5272. */
  5273. r: number;
  5274. /**
  5275. * Defines the green component (between 0 and 1, default is 0)
  5276. */
  5277. g: number;
  5278. /**
  5279. * Defines the blue component (between 0 and 1, default is 0)
  5280. */
  5281. b: number;
  5282. /**
  5283. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5284. * @param r defines the red component (between 0 and 1, default is 0)
  5285. * @param g defines the green component (between 0 and 1, default is 0)
  5286. * @param b defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. constructor(
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r?: number,
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g?: number,
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b?: number);
  5301. /**
  5302. * Creates a string with the Color3 current values
  5303. * @returns the string representation of the Color3 object
  5304. */
  5305. toString(): string;
  5306. /**
  5307. * Returns the string "Color3"
  5308. * @returns "Color3"
  5309. */
  5310. getClassName(): string;
  5311. /**
  5312. * Compute the Color3 hash code
  5313. * @returns an unique number that can be used to hash Color3 objects
  5314. */
  5315. getHashCode(): number;
  5316. /**
  5317. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5318. * @param array defines the array where to store the r,g,b components
  5319. * @param index defines an optional index in the target array to define where to start storing values
  5320. * @returns the current Color3 object
  5321. */
  5322. toArray(array: FloatArray, index?: number): Color3;
  5323. /**
  5324. * Returns a new Color4 object from the current Color3 and the given alpha
  5325. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5326. * @returns a new Color4 object
  5327. */
  5328. toColor4(alpha?: number): Color4;
  5329. /**
  5330. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5331. * @returns the new array
  5332. */
  5333. asArray(): number[];
  5334. /**
  5335. * Returns the luminance value
  5336. * @returns a float value
  5337. */
  5338. toLuminance(): number;
  5339. /**
  5340. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5341. * @param otherColor defines the second operand
  5342. * @returns the new Color3 object
  5343. */
  5344. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5345. /**
  5346. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5347. * @param otherColor defines the second operand
  5348. * @param result defines the Color3 object where to store the result
  5349. * @returns the current Color3
  5350. */
  5351. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5352. /**
  5353. * Determines equality between Color3 objects
  5354. * @param otherColor defines the second operand
  5355. * @returns true if the rgb values are equal to the given ones
  5356. */
  5357. equals(otherColor: DeepImmutable<Color3>): boolean;
  5358. /**
  5359. * Determines equality between the current Color3 object and a set of r,b,g values
  5360. * @param r defines the red component to check
  5361. * @param g defines the green component to check
  5362. * @param b defines the blue component to check
  5363. * @returns true if the rgb values are equal to the given ones
  5364. */
  5365. equalsFloats(r: number, g: number, b: number): boolean;
  5366. /**
  5367. * Multiplies in place each rgb value by scale
  5368. * @param scale defines the scaling factor
  5369. * @returns the updated Color3
  5370. */
  5371. scale(scale: number): Color3;
  5372. /**
  5373. * Multiplies the rgb values by scale and stores the result into "result"
  5374. * @param scale defines the scaling factor
  5375. * @param result defines the Color3 object where to store the result
  5376. * @returns the unmodified current Color3
  5377. */
  5378. scaleToRef(scale: number, result: Color3): Color3;
  5379. /**
  5380. * Scale the current Color3 values by a factor and add the result to a given Color3
  5381. * @param scale defines the scale factor
  5382. * @param result defines color to store the result into
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Clamps the rgb values by the min and max values and stores the result into "result"
  5388. * @param min defines minimum clamping value (default is 0)
  5389. * @param max defines maximum clamping value (default is 1)
  5390. * @param result defines color to store the result into
  5391. * @returns the original Color3
  5392. */
  5393. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5394. /**
  5395. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5396. * @param otherColor defines the second operand
  5397. * @returns the new Color3
  5398. */
  5399. add(otherColor: DeepImmutable<Color3>): Color3;
  5400. /**
  5401. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5402. * @param otherColor defines the second operand
  5403. * @param result defines Color3 object to store the result into
  5404. * @returns the unmodified current Color3
  5405. */
  5406. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5407. /**
  5408. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5409. * @param otherColor defines the second operand
  5410. * @returns the new Color3
  5411. */
  5412. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5413. /**
  5414. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5415. * @param otherColor defines the second operand
  5416. * @param result defines Color3 object to store the result into
  5417. * @returns the unmodified current Color3
  5418. */
  5419. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5420. /**
  5421. * Copy the current object
  5422. * @returns a new Color3 copied the current one
  5423. */
  5424. clone(): Color3;
  5425. /**
  5426. * Copies the rgb values from the source in the current Color3
  5427. * @param source defines the source Color3 object
  5428. * @returns the updated Color3 object
  5429. */
  5430. copyFrom(source: DeepImmutable<Color3>): Color3;
  5431. /**
  5432. * Updates the Color3 rgb values from the given floats
  5433. * @param r defines the red component to read from
  5434. * @param g defines the green component to read from
  5435. * @param b defines the blue component to read from
  5436. * @returns the current Color3 object
  5437. */
  5438. copyFromFloats(r: number, g: number, b: number): Color3;
  5439. /**
  5440. * Updates the Color3 rgb values from the given floats
  5441. * @param r defines the red component to read from
  5442. * @param g defines the green component to read from
  5443. * @param b defines the blue component to read from
  5444. * @returns the current Color3 object
  5445. */
  5446. set(r: number, g: number, b: number): Color3;
  5447. /**
  5448. * Compute the Color3 hexadecimal code as a string
  5449. * @returns a string containing the hexadecimal representation of the Color3 object
  5450. */
  5451. toHexString(): string;
  5452. /**
  5453. * Computes a new Color3 converted from the current one to linear space
  5454. * @returns a new Color3 object
  5455. */
  5456. toLinearSpace(): Color3;
  5457. /**
  5458. * Converts current color in rgb space to HSV values
  5459. * @returns a new color3 representing the HSV values
  5460. */
  5461. toHSV(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @param result defines the Color3 where to store the HSV values
  5465. */
  5466. toHSVToRef(result: Color3): void;
  5467. /**
  5468. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5469. * @param convertedColor defines the Color3 object where to store the linear space version
  5470. * @returns the unmodified Color3
  5471. */
  5472. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5473. /**
  5474. * Computes a new Color3 converted from the current one to gamma space
  5475. * @returns a new Color3 object
  5476. */
  5477. toGammaSpace(): Color3;
  5478. /**
  5479. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5480. * @param convertedColor defines the Color3 object where to store the gamma space version
  5481. * @returns the unmodified Color3
  5482. */
  5483. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5484. private static _BlackReadOnly;
  5485. /**
  5486. * Convert Hue, saturation and value to a Color3 (RGB)
  5487. * @param hue defines the hue
  5488. * @param saturation defines the saturation
  5489. * @param value defines the value
  5490. * @param result defines the Color3 where to store the RGB values
  5491. */
  5492. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5493. /**
  5494. * Creates a new Color3 from the string containing valid hexadecimal values
  5495. * @param hex defines a string containing valid hexadecimal values
  5496. * @returns a new Color3 object
  5497. */
  5498. static FromHexString(hex: string): Color3;
  5499. /**
  5500. * Creates a new Color3 from the starting index of the given array
  5501. * @param array defines the source array
  5502. * @param offset defines an offset in the source array
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5506. /**
  5507. * Creates a new Color3 from integer values (< 256)
  5508. * @param r defines the red component to read from (value between 0 and 255)
  5509. * @param g defines the green component to read from (value between 0 and 255)
  5510. * @param b defines the blue component to read from (value between 0 and 255)
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromInts(r: number, g: number, b: number): Color3;
  5514. /**
  5515. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5516. * @param start defines the start Color3 value
  5517. * @param end defines the end Color3 value
  5518. * @param amount defines the gradient value between start and end
  5519. * @returns a new Color3 object
  5520. */
  5521. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5522. /**
  5523. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5524. * @param left defines the start value
  5525. * @param right defines the end value
  5526. * @param amount defines the gradient factor
  5527. * @param result defines the Color3 object where to store the result
  5528. */
  5529. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5530. /**
  5531. * Returns a Color3 value containing a red color
  5532. * @returns a new Color3 object
  5533. */
  5534. static Red(): Color3;
  5535. /**
  5536. * Returns a Color3 value containing a green color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Green(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a blue color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Blue(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a black color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Black(): Color3;
  5550. /**
  5551. * Gets a Color3 value containing a black color that must not be updated
  5552. */
  5553. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5554. /**
  5555. * Returns a Color3 value containing a white color
  5556. * @returns a new Color3 object
  5557. */
  5558. static White(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a purple color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Purple(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a magenta color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Magenta(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a yellow color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Yellow(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a gray color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Gray(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a teal color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Teal(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a random color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Random(): Color3;
  5589. }
  5590. /**
  5591. * Class used to hold a RBGA color
  5592. */
  5593. export class Color4 {
  5594. /**
  5595. * Defines the red component (between 0 and 1, default is 0)
  5596. */
  5597. r: number;
  5598. /**
  5599. * Defines the green component (between 0 and 1, default is 0)
  5600. */
  5601. g: number;
  5602. /**
  5603. * Defines the blue component (between 0 and 1, default is 0)
  5604. */
  5605. b: number;
  5606. /**
  5607. * Defines the alpha component (between 0 and 1, default is 1)
  5608. */
  5609. a: number;
  5610. /**
  5611. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5612. * @param r defines the red component (between 0 and 1, default is 0)
  5613. * @param g defines the green component (between 0 and 1, default is 0)
  5614. * @param b defines the blue component (between 0 and 1, default is 0)
  5615. * @param a defines the alpha component (between 0 and 1, default is 1)
  5616. */
  5617. constructor(
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r?: number,
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g?: number,
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b?: number,
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a?: number);
  5634. /**
  5635. * Adds in place the given Color4 values to the current Color4 object
  5636. * @param right defines the second operand
  5637. * @returns the current updated Color4 object
  5638. */
  5639. addInPlace(right: DeepImmutable<Color4>): Color4;
  5640. /**
  5641. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5642. * @returns the new array
  5643. */
  5644. asArray(): number[];
  5645. /**
  5646. * Stores from the starting index in the given array the Color4 successive values
  5647. * @param array defines the array where to store the r,g,b components
  5648. * @param index defines an optional index in the target array to define where to start storing values
  5649. * @returns the current Color4 object
  5650. */
  5651. toArray(array: number[], index?: number): Color4;
  5652. /**
  5653. * Determines equality between Color4 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgba values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color4>): boolean;
  5658. /**
  5659. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5660. * @param right defines the second operand
  5661. * @returns a new Color4 object
  5662. */
  5663. add(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5666. * @param right defines the second operand
  5667. * @returns a new Color4 object
  5668. */
  5669. subtract(right: DeepImmutable<Color4>): Color4;
  5670. /**
  5671. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5672. * @param right defines the second operand
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the current Color4 object
  5675. */
  5676. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5677. /**
  5678. * Creates a new Color4 with the current Color4 values multiplied by scale
  5679. * @param scale defines the scaling factor to apply
  5680. * @returns a new Color4 object
  5681. */
  5682. scale(scale: number): Color4;
  5683. /**
  5684. * Multiplies the current Color4 values by scale and stores the result in "result"
  5685. * @param scale defines the scaling factor to apply
  5686. * @param result defines the Color4 object where to store the result
  5687. * @returns the current unmodified Color4
  5688. */
  5689. scaleToRef(scale: number, result: Color4): Color4;
  5690. /**
  5691. * Scale the current Color4 values by a factor and add the result to a given Color4
  5692. * @param scale defines the scale factor
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the unmodified current Color4
  5695. */
  5696. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Clamps the rgb values by the min and max values and stores the result into "result"
  5699. * @param min defines minimum clamping value (default is 0)
  5700. * @param max defines maximum clamping value (default is 1)
  5701. * @param result defines color to store the result into.
  5702. * @returns the cuurent Color4
  5703. */
  5704. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5705. /**
  5706. * Multipy an Color4 value by another and return a new Color4 object
  5707. * @param color defines the Color4 value to multiply by
  5708. * @returns a new Color4 object
  5709. */
  5710. multiply(color: Color4): Color4;
  5711. /**
  5712. * Multipy a Color4 value by another and push the result in a reference value
  5713. * @param color defines the Color4 value to multiply by
  5714. * @param result defines the Color4 to fill the result in
  5715. * @returns the result Color4
  5716. */
  5717. multiplyToRef(color: Color4, result: Color4): Color4;
  5718. /**
  5719. * Creates a string with the Color4 current values
  5720. * @returns the string representation of the Color4 object
  5721. */
  5722. toString(): string;
  5723. /**
  5724. * Returns the string "Color4"
  5725. * @returns "Color4"
  5726. */
  5727. getClassName(): string;
  5728. /**
  5729. * Compute the Color4 hash code
  5730. * @returns an unique number that can be used to hash Color4 objects
  5731. */
  5732. getHashCode(): number;
  5733. /**
  5734. * Creates a new Color4 copied from the current one
  5735. * @returns a new Color4 object
  5736. */
  5737. clone(): Color4;
  5738. /**
  5739. * Copies the given Color4 values into the current one
  5740. * @param source defines the source Color4 object
  5741. * @returns the current updated Color4 object
  5742. */
  5743. copyFrom(source: Color4): Color4;
  5744. /**
  5745. * Copies the given float values into the current one
  5746. * @param r defines the red component to read from
  5747. * @param g defines the green component to read from
  5748. * @param b defines the blue component to read from
  5749. * @param a defines the alpha component to read from
  5750. * @returns the current updated Color4 object
  5751. */
  5752. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5753. /**
  5754. * Copies the given float values into the current one
  5755. * @param r defines the red component to read from
  5756. * @param g defines the green component to read from
  5757. * @param b defines the blue component to read from
  5758. * @param a defines the alpha component to read from
  5759. * @returns the current updated Color4 object
  5760. */
  5761. set(r: number, g: number, b: number, a: number): Color4;
  5762. /**
  5763. * Compute the Color4 hexadecimal code as a string
  5764. * @returns a string containing the hexadecimal representation of the Color4 object
  5765. */
  5766. toHexString(): string;
  5767. /**
  5768. * Computes a new Color4 converted from the current one to linear space
  5769. * @returns a new Color4 object
  5770. */
  5771. toLinearSpace(): Color4;
  5772. /**
  5773. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5774. * @param convertedColor defines the Color4 object where to store the linear space version
  5775. * @returns the unmodified Color4
  5776. */
  5777. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5778. /**
  5779. * Computes a new Color4 converted from the current one to gamma space
  5780. * @returns a new Color4 object
  5781. */
  5782. toGammaSpace(): Color4;
  5783. /**
  5784. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5785. * @param convertedColor defines the Color4 object where to store the gamma space version
  5786. * @returns the unmodified Color4
  5787. */
  5788. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5789. /**
  5790. * Creates a new Color4 from the string containing valid hexadecimal values
  5791. * @param hex defines a string containing valid hexadecimal values
  5792. * @returns a new Color4 object
  5793. */
  5794. static FromHexString(hex: string): Color4;
  5795. /**
  5796. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5797. * @param left defines the start value
  5798. * @param right defines the end value
  5799. * @param amount defines the gradient factor
  5800. * @returns a new Color4 object
  5801. */
  5802. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5803. /**
  5804. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5805. * @param left defines the start value
  5806. * @param right defines the end value
  5807. * @param amount defines the gradient factor
  5808. * @param result defines the Color4 object where to store data
  5809. */
  5810. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5811. /**
  5812. * Creates a new Color4 from a Color3 and an alpha value
  5813. * @param color3 defines the source Color3 to read from
  5814. * @param alpha defines the alpha component (1.0 by default)
  5815. * @returns a new Color4 object
  5816. */
  5817. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5818. /**
  5819. * Creates a new Color4 from the starting index element of the given array
  5820. * @param array defines the source array to read from
  5821. * @param offset defines the offset in the source array
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5825. /**
  5826. * Creates a new Color3 from integer values (< 256)
  5827. * @param r defines the red component to read from (value between 0 and 255)
  5828. * @param g defines the green component to read from (value between 0 and 255)
  5829. * @param b defines the blue component to read from (value between 0 and 255)
  5830. * @param a defines the alpha component to read from (value between 0 and 255)
  5831. * @returns a new Color3 object
  5832. */
  5833. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5834. /**
  5835. * Check the content of a given array and convert it to an array containing RGBA data
  5836. * If the original array was already containing count * 4 values then it is returned directly
  5837. * @param colors defines the array to check
  5838. * @param count defines the number of RGBA data to expect
  5839. * @returns an array containing count * 4 values (RGBA)
  5840. */
  5841. static CheckColors4(colors: number[], count: number): number[];
  5842. }
  5843. /**
  5844. * @hidden
  5845. */
  5846. export class TmpColors {
  5847. static Color3: Color3[];
  5848. static Color4: Color4[];
  5849. }
  5850. }
  5851. declare module "babylonjs/Animations/animationKey" {
  5852. /**
  5853. * Defines an interface which represents an animation key frame
  5854. */
  5855. export interface IAnimationKey {
  5856. /**
  5857. * Frame of the key frame
  5858. */
  5859. frame: number;
  5860. /**
  5861. * Value at the specifies key frame
  5862. */
  5863. value: any;
  5864. /**
  5865. * The input tangent for the cubic hermite spline
  5866. */
  5867. inTangent?: any;
  5868. /**
  5869. * The output tangent for the cubic hermite spline
  5870. */
  5871. outTangent?: any;
  5872. /**
  5873. * The animation interpolation type
  5874. */
  5875. interpolation?: AnimationKeyInterpolation;
  5876. }
  5877. /**
  5878. * Enum for the animation key frame interpolation type
  5879. */
  5880. export enum AnimationKeyInterpolation {
  5881. /**
  5882. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5883. */
  5884. STEP = 1
  5885. }
  5886. }
  5887. declare module "babylonjs/Animations/animationRange" {
  5888. /**
  5889. * Represents the range of an animation
  5890. */
  5891. export class AnimationRange {
  5892. /**The name of the animation range**/
  5893. name: string;
  5894. /**The starting frame of the animation */
  5895. from: number;
  5896. /**The ending frame of the animation*/
  5897. to: number;
  5898. /**
  5899. * Initializes the range of an animation
  5900. * @param name The name of the animation range
  5901. * @param from The starting frame of the animation
  5902. * @param to The ending frame of the animation
  5903. */
  5904. constructor(
  5905. /**The name of the animation range**/
  5906. name: string,
  5907. /**The starting frame of the animation */
  5908. from: number,
  5909. /**The ending frame of the animation*/
  5910. to: number);
  5911. /**
  5912. * Makes a copy of the animation range
  5913. * @returns A copy of the animation range
  5914. */
  5915. clone(): AnimationRange;
  5916. }
  5917. }
  5918. declare module "babylonjs/Animations/animationEvent" {
  5919. /**
  5920. * Composed of a frame, and an action function
  5921. */
  5922. export class AnimationEvent {
  5923. /** The frame for which the event is triggered **/
  5924. frame: number;
  5925. /** The event to perform when triggered **/
  5926. action: (currentFrame: number) => void;
  5927. /** Specifies if the event should be triggered only once**/
  5928. onlyOnce?: boolean | undefined;
  5929. /**
  5930. * Specifies if the animation event is done
  5931. */
  5932. isDone: boolean;
  5933. /**
  5934. * Initializes the animation event
  5935. * @param frame The frame for which the event is triggered
  5936. * @param action The event to perform when triggered
  5937. * @param onlyOnce Specifies if the event should be triggered only once
  5938. */
  5939. constructor(
  5940. /** The frame for which the event is triggered **/
  5941. frame: number,
  5942. /** The event to perform when triggered **/
  5943. action: (currentFrame: number) => void,
  5944. /** Specifies if the event should be triggered only once**/
  5945. onlyOnce?: boolean | undefined);
  5946. /** @hidden */
  5947. _clone(): AnimationEvent;
  5948. }
  5949. }
  5950. declare module "babylonjs/Behaviors/behavior" {
  5951. import { Nullable } from "babylonjs/types";
  5952. /**
  5953. * Interface used to define a behavior
  5954. */
  5955. export interface Behavior<T> {
  5956. /** gets or sets behavior's name */
  5957. name: string;
  5958. /**
  5959. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5960. */
  5961. init(): void;
  5962. /**
  5963. * Called when the behavior is attached to a target
  5964. * @param target defines the target where the behavior is attached to
  5965. */
  5966. attach(target: T): void;
  5967. /**
  5968. * Called when the behavior is detached from its target
  5969. */
  5970. detach(): void;
  5971. }
  5972. /**
  5973. * Interface implemented by classes supporting behaviors
  5974. */
  5975. export interface IBehaviorAware<T> {
  5976. /**
  5977. * Attach a behavior
  5978. * @param behavior defines the behavior to attach
  5979. * @returns the current host
  5980. */
  5981. addBehavior(behavior: Behavior<T>): T;
  5982. /**
  5983. * Remove a behavior from the current object
  5984. * @param behavior defines the behavior to detach
  5985. * @returns the current host
  5986. */
  5987. removeBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Gets a behavior using its name to search
  5990. * @param name defines the name to search
  5991. * @returns the behavior or null if not found
  5992. */
  5993. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5994. }
  5995. }
  5996. declare module "babylonjs/Misc/smartArray" {
  5997. /**
  5998. * Defines an array and its length.
  5999. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6000. */
  6001. export interface ISmartArrayLike<T> {
  6002. /**
  6003. * The data of the array.
  6004. */
  6005. data: Array<T>;
  6006. /**
  6007. * The active length of the array.
  6008. */
  6009. length: number;
  6010. }
  6011. /**
  6012. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6013. */
  6014. export class SmartArray<T> implements ISmartArrayLike<T> {
  6015. /**
  6016. * The full set of data from the array.
  6017. */
  6018. data: Array<T>;
  6019. /**
  6020. * The active length of the array.
  6021. */
  6022. length: number;
  6023. protected _id: number;
  6024. /**
  6025. * Instantiates a Smart Array.
  6026. * @param capacity defines the default capacity of the array.
  6027. */
  6028. constructor(capacity: number);
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * @param value defines the object to push in the array.
  6032. */
  6033. push(value: T): void;
  6034. /**
  6035. * Iterates over the active data and apply the lambda to them.
  6036. * @param func defines the action to apply on each value.
  6037. */
  6038. forEach(func: (content: T) => void): void;
  6039. /**
  6040. * Sorts the full sets of data.
  6041. * @param compareFn defines the comparison function to apply.
  6042. */
  6043. sort(compareFn: (a: T, b: T) => number): void;
  6044. /**
  6045. * Resets the active data to an empty array.
  6046. */
  6047. reset(): void;
  6048. /**
  6049. * Releases all the data from the array as well as the array.
  6050. */
  6051. dispose(): void;
  6052. /**
  6053. * Concats the active data with a given array.
  6054. * @param array defines the data to concatenate with.
  6055. */
  6056. concat(array: any): void;
  6057. /**
  6058. * Returns the position of a value in the active data.
  6059. * @param value defines the value to find the index for
  6060. * @returns the index if found in the active data otherwise -1
  6061. */
  6062. indexOf(value: T): number;
  6063. /**
  6064. * Returns whether an element is part of the active data.
  6065. * @param value defines the value to look for
  6066. * @returns true if found in the active data otherwise false
  6067. */
  6068. contains(value: T): boolean;
  6069. private static _GlobalId;
  6070. }
  6071. /**
  6072. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6073. * The data in this array can only be present once
  6074. */
  6075. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6076. private _duplicateId;
  6077. /**
  6078. * Pushes a value at the end of the active data.
  6079. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6080. * @param value defines the object to push in the array.
  6081. */
  6082. push(value: T): void;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * If the data is already present, it won t be added again
  6086. * @param value defines the object to push in the array.
  6087. * @returns true if added false if it was already present
  6088. */
  6089. pushNoDuplicate(value: T): boolean;
  6090. /**
  6091. * Resets the active data to an empty array.
  6092. */
  6093. reset(): void;
  6094. /**
  6095. * Concats the active data with a given array.
  6096. * This ensures no dupplicate will be present in the result.
  6097. * @param array defines the data to concatenate with.
  6098. */
  6099. concatWithNoDuplicate(array: any): void;
  6100. }
  6101. }
  6102. declare module "babylonjs/Cameras/cameraInputsManager" {
  6103. import { Nullable } from "babylonjs/types";
  6104. import { Camera } from "babylonjs/Cameras/camera";
  6105. /**
  6106. * @ignore
  6107. * This is a list of all the different input types that are available in the application.
  6108. * Fo instance: ArcRotateCameraGamepadInput...
  6109. */
  6110. export var CameraInputTypes: {};
  6111. /**
  6112. * This is the contract to implement in order to create a new input class.
  6113. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6114. */
  6115. export interface ICameraInput<TCamera extends Camera> {
  6116. /**
  6117. * Defines the camera the input is attached to.
  6118. */
  6119. camera: Nullable<TCamera>;
  6120. /**
  6121. * Gets the class name of the current intput.
  6122. * @returns the class name
  6123. */
  6124. getClassName(): string;
  6125. /**
  6126. * Get the friendly name associated with the input class.
  6127. * @returns the input friendly name
  6128. */
  6129. getSimpleName(): string;
  6130. /**
  6131. * Attach the input controls to a specific dom element to get the input from.
  6132. * @param element Defines the element the controls should be listened from
  6133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6134. */
  6135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6136. /**
  6137. * Detach the current controls from the specified dom element.
  6138. * @param element Defines the element to stop listening the inputs from
  6139. */
  6140. detachControl(element: Nullable<HTMLElement>): void;
  6141. /**
  6142. * Update the current camera state depending on the inputs that have been used this frame.
  6143. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6144. */
  6145. checkInputs?: () => void;
  6146. }
  6147. /**
  6148. * Represents a map of input types to input instance or input index to input instance.
  6149. */
  6150. export interface CameraInputsMap<TCamera extends Camera> {
  6151. /**
  6152. * Accessor to the input by input type.
  6153. */
  6154. [name: string]: ICameraInput<TCamera>;
  6155. /**
  6156. * Accessor to the input by input index.
  6157. */
  6158. [idx: number]: ICameraInput<TCamera>;
  6159. }
  6160. /**
  6161. * This represents the input manager used within a camera.
  6162. * It helps dealing with all the different kind of input attached to a camera.
  6163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6164. */
  6165. export class CameraInputsManager<TCamera extends Camera> {
  6166. /**
  6167. * Defines the list of inputs attahed to the camera.
  6168. */
  6169. attached: CameraInputsMap<TCamera>;
  6170. /**
  6171. * Defines the dom element the camera is collecting inputs from.
  6172. * This is null if the controls have not been attached.
  6173. */
  6174. attachedElement: Nullable<HTMLElement>;
  6175. /**
  6176. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6177. */
  6178. noPreventDefault: boolean;
  6179. /**
  6180. * Defined the camera the input manager belongs to.
  6181. */
  6182. camera: TCamera;
  6183. /**
  6184. * Update the current camera state depending on the inputs that have been used this frame.
  6185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6186. */
  6187. checkInputs: () => void;
  6188. /**
  6189. * Instantiate a new Camera Input Manager.
  6190. * @param camera Defines the camera the input manager blongs to
  6191. */
  6192. constructor(camera: TCamera);
  6193. /**
  6194. * Add an input method to a camera
  6195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6196. * @param input camera input method
  6197. */
  6198. add(input: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input method from a camera
  6201. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6202. * @param inputToRemove camera input method
  6203. */
  6204. remove(inputToRemove: ICameraInput<TCamera>): void;
  6205. /**
  6206. * Remove a specific input type from a camera
  6207. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6208. * @param inputType the type of the input to remove
  6209. */
  6210. removeByType(inputType: string): void;
  6211. private _addCheckInputs;
  6212. /**
  6213. * Attach the input controls to the currently attached dom element to listen the events from.
  6214. * @param input Defines the input to attach
  6215. */
  6216. attachInput(input: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6221. */
  6222. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6223. /**
  6224. * Detach the current manager inputs controls from a specific dom element.
  6225. * @param element Defines the dom element to collect the events from
  6226. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6227. */
  6228. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6229. /**
  6230. * Rebuild the dynamic inputCheck function from the current list of
  6231. * defined inputs in the manager.
  6232. */
  6233. rebuildInputCheck(): void;
  6234. /**
  6235. * Remove all attached input methods from a camera
  6236. */
  6237. clear(): void;
  6238. /**
  6239. * Serialize the current input manager attached to a camera.
  6240. * This ensures than once parsed,
  6241. * the input associated to the camera will be identical to the current ones
  6242. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6243. */
  6244. serialize(serializedCamera: any): void;
  6245. /**
  6246. * Parses an input manager serialized JSON to restore the previous list of inputs
  6247. * and states associated to a camera.
  6248. * @param parsedCamera Defines the JSON to parse
  6249. */
  6250. parse(parsedCamera: any): void;
  6251. }
  6252. }
  6253. declare module "babylonjs/Meshes/buffer" {
  6254. import { Nullable, DataArray } from "babylonjs/types";
  6255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6256. /**
  6257. * Class used to store data that will be store in GPU memory
  6258. */
  6259. export class Buffer {
  6260. private _engine;
  6261. private _buffer;
  6262. /** @hidden */
  6263. _data: Nullable<DataArray>;
  6264. private _updatable;
  6265. private _instanced;
  6266. private _divisor;
  6267. /**
  6268. * Gets the byte stride.
  6269. */
  6270. readonly byteStride: number;
  6271. /**
  6272. * Constructor
  6273. * @param engine the engine
  6274. * @param data the data to use for this buffer
  6275. * @param updatable whether the data is updatable
  6276. * @param stride the stride (optional)
  6277. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6278. * @param instanced whether the buffer is instanced (optional)
  6279. * @param useBytes set to true if the stride in in bytes (optional)
  6280. * @param divisor sets an optional divisor for instances (1 by default)
  6281. */
  6282. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6283. /**
  6284. * Create a new VertexBuffer based on the current buffer
  6285. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6286. * @param offset defines offset in the buffer (0 by default)
  6287. * @param size defines the size in floats of attributes (position is 3 for instance)
  6288. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6289. * @param instanced defines if the vertex buffer contains indexed data
  6290. * @param useBytes defines if the offset and stride are in bytes *
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. * @returns the new vertex buffer
  6293. */
  6294. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6295. /**
  6296. * Gets a boolean indicating if the Buffer is updatable?
  6297. * @returns true if the buffer is updatable
  6298. */
  6299. isUpdatable(): boolean;
  6300. /**
  6301. * Gets current buffer's data
  6302. * @returns a DataArray or null
  6303. */
  6304. getData(): Nullable<DataArray>;
  6305. /**
  6306. * Gets underlying native buffer
  6307. * @returns underlying native buffer
  6308. */
  6309. getBuffer(): Nullable<DataBuffer>;
  6310. /**
  6311. * Gets the stride in float32 units (i.e. byte stride / 4).
  6312. * May not be an integer if the byte stride is not divisible by 4.
  6313. * @returns the stride in float32 units
  6314. * @deprecated Please use byteStride instead.
  6315. */
  6316. getStrideSize(): number;
  6317. /**
  6318. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6319. * @param data defines the data to store
  6320. */
  6321. create(data?: Nullable<DataArray>): void;
  6322. /** @hidden */
  6323. _rebuild(): void;
  6324. /**
  6325. * Update current buffer data
  6326. * @param data defines the data to store
  6327. */
  6328. update(data: DataArray): void;
  6329. /**
  6330. * Updates the data directly.
  6331. * @param data the new data
  6332. * @param offset the new offset
  6333. * @param vertexCount the vertex count (optional)
  6334. * @param useBytes set to true if the offset is in bytes
  6335. */
  6336. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6337. /**
  6338. * Release all resources
  6339. */
  6340. dispose(): void;
  6341. }
  6342. /**
  6343. * Specialized buffer used to store vertex data
  6344. */
  6345. export class VertexBuffer {
  6346. /** @hidden */
  6347. _buffer: Buffer;
  6348. private _kind;
  6349. private _size;
  6350. private _ownsBuffer;
  6351. private _instanced;
  6352. private _instanceDivisor;
  6353. /**
  6354. * The byte type.
  6355. */
  6356. static readonly BYTE: number;
  6357. /**
  6358. * The unsigned byte type.
  6359. */
  6360. static readonly UNSIGNED_BYTE: number;
  6361. /**
  6362. * The short type.
  6363. */
  6364. static readonly SHORT: number;
  6365. /**
  6366. * The unsigned short type.
  6367. */
  6368. static readonly UNSIGNED_SHORT: number;
  6369. /**
  6370. * The integer type.
  6371. */
  6372. static readonly INT: number;
  6373. /**
  6374. * The unsigned integer type.
  6375. */
  6376. static readonly UNSIGNED_INT: number;
  6377. /**
  6378. * The float type.
  6379. */
  6380. static readonly FLOAT: number;
  6381. /**
  6382. * Gets or sets the instance divisor when in instanced mode
  6383. */
  6384. instanceDivisor: number;
  6385. /**
  6386. * Gets the byte stride.
  6387. */
  6388. readonly byteStride: number;
  6389. /**
  6390. * Gets the byte offset.
  6391. */
  6392. readonly byteOffset: number;
  6393. /**
  6394. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6395. */
  6396. readonly normalized: boolean;
  6397. /**
  6398. * Gets the data type of each component in the array.
  6399. */
  6400. readonly type: number;
  6401. /**
  6402. * Constructor
  6403. * @param engine the engine
  6404. * @param data the data to use for this vertex buffer
  6405. * @param kind the vertex buffer kind
  6406. * @param updatable whether the data is updatable
  6407. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6408. * @param stride the stride (optional)
  6409. * @param instanced whether the buffer is instanced (optional)
  6410. * @param offset the offset of the data (optional)
  6411. * @param size the number of components (optional)
  6412. * @param type the type of the component (optional)
  6413. * @param normalized whether the data contains normalized data (optional)
  6414. * @param useBytes set to true if stride and offset are in bytes (optional)
  6415. * @param divisor defines the instance divisor to use (1 by default)
  6416. */
  6417. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6418. /** @hidden */
  6419. _rebuild(): void;
  6420. /**
  6421. * Returns the kind of the VertexBuffer (string)
  6422. * @returns a string
  6423. */
  6424. getKind(): string;
  6425. /**
  6426. * Gets a boolean indicating if the VertexBuffer is updatable?
  6427. * @returns true if the buffer is updatable
  6428. */
  6429. isUpdatable(): boolean;
  6430. /**
  6431. * Gets current buffer's data
  6432. * @returns a DataArray or null
  6433. */
  6434. getData(): Nullable<DataArray>;
  6435. /**
  6436. * Gets underlying native buffer
  6437. * @returns underlying native buffer
  6438. */
  6439. getBuffer(): Nullable<DataBuffer>;
  6440. /**
  6441. * Gets the stride in float32 units (i.e. byte stride / 4).
  6442. * May not be an integer if the byte stride is not divisible by 4.
  6443. * @returns the stride in float32 units
  6444. * @deprecated Please use byteStride instead.
  6445. */
  6446. getStrideSize(): number;
  6447. /**
  6448. * Returns the offset as a multiple of the type byte length.
  6449. * @returns the offset in bytes
  6450. * @deprecated Please use byteOffset instead.
  6451. */
  6452. getOffset(): number;
  6453. /**
  6454. * Returns the number of components per vertex attribute (integer)
  6455. * @returns the size in float
  6456. */
  6457. getSize(): number;
  6458. /**
  6459. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6460. * @returns true if this buffer is instanced
  6461. */
  6462. getIsInstanced(): boolean;
  6463. /**
  6464. * Returns the instancing divisor, zero for non-instanced (integer).
  6465. * @returns a number
  6466. */
  6467. getInstanceDivisor(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: DataArray): void;
  6473. /**
  6474. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6475. * This function will create a new buffer if the current one is not updatable
  6476. * @param data defines the data to store
  6477. */
  6478. update(data: DataArray): void;
  6479. /**
  6480. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6481. * Returns the directly updated WebGLBuffer.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param useBytes set to true if the offset is in bytes
  6485. */
  6486. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6487. /**
  6488. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6489. */
  6490. dispose(): void;
  6491. /**
  6492. * Enumerates each value of this vertex buffer as numbers.
  6493. * @param count the number of values to enumerate
  6494. * @param callback the callback function called for each value
  6495. */
  6496. forEach(count: number, callback: (value: number, index: number) => void): void;
  6497. /**
  6498. * Positions
  6499. */
  6500. static readonly PositionKind: string;
  6501. /**
  6502. * Normals
  6503. */
  6504. static readonly NormalKind: string;
  6505. /**
  6506. * Tangents
  6507. */
  6508. static readonly TangentKind: string;
  6509. /**
  6510. * Texture coordinates
  6511. */
  6512. static readonly UVKind: string;
  6513. /**
  6514. * Texture coordinates 2
  6515. */
  6516. static readonly UV2Kind: string;
  6517. /**
  6518. * Texture coordinates 3
  6519. */
  6520. static readonly UV3Kind: string;
  6521. /**
  6522. * Texture coordinates 4
  6523. */
  6524. static readonly UV4Kind: string;
  6525. /**
  6526. * Texture coordinates 5
  6527. */
  6528. static readonly UV5Kind: string;
  6529. /**
  6530. * Texture coordinates 6
  6531. */
  6532. static readonly UV6Kind: string;
  6533. /**
  6534. * Colors
  6535. */
  6536. static readonly ColorKind: string;
  6537. /**
  6538. * Matrix indices (for bones)
  6539. */
  6540. static readonly MatricesIndicesKind: string;
  6541. /**
  6542. * Matrix weights (for bones)
  6543. */
  6544. static readonly MatricesWeightsKind: string;
  6545. /**
  6546. * Additional matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesExtraKind: string;
  6549. /**
  6550. * Additional matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsExtraKind: string;
  6553. /**
  6554. * Deduces the stride given a kind.
  6555. * @param kind The kind string to deduce
  6556. * @returns The deduced stride
  6557. */
  6558. static DeduceStride(kind: string): number;
  6559. /**
  6560. * Gets the byte length of the given type.
  6561. * @param type the type
  6562. * @returns the number of bytes
  6563. */
  6564. static GetTypeByteLength(type: number): number;
  6565. /**
  6566. * Enumerates each value of the given parameters as numbers.
  6567. * @param data the data to enumerate
  6568. * @param byteOffset the byte offset of the data
  6569. * @param byteStride the byte stride of the data
  6570. * @param componentCount the number of components per element
  6571. * @param componentType the type of the component
  6572. * @param count the number of values to enumerate
  6573. * @param normalized whether the data is normalized
  6574. * @param callback the callback function called for each value
  6575. */
  6576. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6577. private static _GetFloatValue;
  6578. }
  6579. }
  6580. declare module "babylonjs/Collisions/intersectionInfo" {
  6581. import { Nullable } from "babylonjs/types";
  6582. /**
  6583. * @hidden
  6584. */
  6585. export class IntersectionInfo {
  6586. bu: Nullable<number>;
  6587. bv: Nullable<number>;
  6588. distance: number;
  6589. faceId: number;
  6590. subMeshId: number;
  6591. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6592. }
  6593. }
  6594. declare module "babylonjs/Maths/math.plane" {
  6595. import { DeepImmutable } from "babylonjs/types";
  6596. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6597. /**
  6598. * Represens a plane by the equation ax + by + cz + d = 0
  6599. */
  6600. export class Plane {
  6601. private static _TmpMatrix;
  6602. /**
  6603. * Normal of the plane (a,b,c)
  6604. */
  6605. normal: Vector3;
  6606. /**
  6607. * d component of the plane
  6608. */
  6609. d: number;
  6610. /**
  6611. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6612. * @param a a component of the plane
  6613. * @param b b component of the plane
  6614. * @param c c component of the plane
  6615. * @param d d component of the plane
  6616. */
  6617. constructor(a: number, b: number, c: number, d: number);
  6618. /**
  6619. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6620. */
  6621. asArray(): number[];
  6622. /**
  6623. * @returns a new plane copied from the current Plane.
  6624. */
  6625. clone(): Plane;
  6626. /**
  6627. * @returns the string "Plane".
  6628. */
  6629. getClassName(): string;
  6630. /**
  6631. * @returns the Plane hash code.
  6632. */
  6633. getHashCode(): number;
  6634. /**
  6635. * Normalize the current Plane in place.
  6636. * @returns the updated Plane.
  6637. */
  6638. normalize(): Plane;
  6639. /**
  6640. * Applies a transformation the plane and returns the result
  6641. * @param transformation the transformation matrix to be applied to the plane
  6642. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6643. */
  6644. transform(transformation: DeepImmutable<Matrix>): Plane;
  6645. /**
  6646. * Calcualtte the dot product between the point and the plane normal
  6647. * @param point point to calculate the dot product with
  6648. * @returns the dot product (float) of the point coordinates and the plane normal.
  6649. */
  6650. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6651. /**
  6652. * Updates the current Plane from the plane defined by the three given points.
  6653. * @param point1 one of the points used to contruct the plane
  6654. * @param point2 one of the points used to contruct the plane
  6655. * @param point3 one of the points used to contruct the plane
  6656. * @returns the updated Plane.
  6657. */
  6658. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6659. /**
  6660. * Checks if the plane is facing a given direction
  6661. * @param direction the direction to check if the plane is facing
  6662. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6663. * @returns True is the vector "direction" is the same side than the plane normal.
  6664. */
  6665. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6666. /**
  6667. * Calculates the distance to a point
  6668. * @param point point to calculate distance to
  6669. * @returns the signed distance (float) from the given point to the Plane.
  6670. */
  6671. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6672. /**
  6673. * Creates a plane from an array
  6674. * @param array the array to create a plane from
  6675. * @returns a new Plane from the given array.
  6676. */
  6677. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6678. /**
  6679. * Creates a plane from three points
  6680. * @param point1 point used to create the plane
  6681. * @param point2 point used to create the plane
  6682. * @param point3 point used to create the plane
  6683. * @returns a new Plane defined by the three given points.
  6684. */
  6685. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6686. /**
  6687. * Creates a plane from an origin point and a normal
  6688. * @param origin origin of the plane to be constructed
  6689. * @param normal normal of the plane to be constructed
  6690. * @returns a new Plane the normal vector to this plane at the given origin point.
  6691. * Note : the vector "normal" is updated because normalized.
  6692. */
  6693. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Calculates the distance from a plane and a point
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @param point point to calculate distance to
  6699. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6700. */
  6701. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6702. }
  6703. }
  6704. declare module "babylonjs/Culling/boundingSphere" {
  6705. import { DeepImmutable } from "babylonjs/types";
  6706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6707. import { Plane } from "babylonjs/Maths/math.plane";
  6708. /**
  6709. * Class used to store bounding sphere information
  6710. */
  6711. export class BoundingSphere {
  6712. /**
  6713. * Gets the center of the bounding sphere in local space
  6714. */
  6715. readonly center: Vector3;
  6716. /**
  6717. * Radius of the bounding sphere in local space
  6718. */
  6719. radius: number;
  6720. /**
  6721. * Gets the center of the bounding sphere in world space
  6722. */
  6723. readonly centerWorld: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in world space
  6726. */
  6727. radiusWorld: number;
  6728. /**
  6729. * Gets the minimum vector in local space
  6730. */
  6731. readonly minimum: Vector3;
  6732. /**
  6733. * Gets the maximum vector in local space
  6734. */
  6735. readonly maximum: Vector3;
  6736. private _worldMatrix;
  6737. private static readonly TmpVector3;
  6738. /**
  6739. * Creates a new bounding sphere
  6740. * @param min defines the minimum vector (in local space)
  6741. * @param max defines the maximum vector (in local space)
  6742. * @param worldMatrix defines the new world matrix
  6743. */
  6744. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6745. /**
  6746. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6747. * @param min defines the new minimum vector (in local space)
  6748. * @param max defines the new maximum vector (in local space)
  6749. * @param worldMatrix defines the new world matrix
  6750. */
  6751. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Scale the current bounding sphere by applying a scale factor
  6754. * @param factor defines the scale factor to apply
  6755. * @returns the current bounding box
  6756. */
  6757. scale(factor: number): BoundingSphere;
  6758. /**
  6759. * Gets the world matrix of the bounding box
  6760. * @returns a matrix
  6761. */
  6762. getWorldMatrix(): DeepImmutable<Matrix>;
  6763. /** @hidden */
  6764. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6765. /**
  6766. * Tests if the bounding sphere is intersecting the frustum planes
  6767. * @param frustumPlanes defines the frustum planes to test
  6768. * @returns true if there is an intersection
  6769. */
  6770. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6771. /**
  6772. * Tests if the bounding sphere center is in between the frustum planes.
  6773. * Used for optimistic fast inclusion.
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @returns true if the sphere center is in between the frustum planes
  6776. */
  6777. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. /**
  6779. * Tests if a point is inside the bounding sphere
  6780. * @param point defines the point to test
  6781. * @returns true if the point is inside the bounding sphere
  6782. */
  6783. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6784. /**
  6785. * Checks if two sphere intersct
  6786. * @param sphere0 sphere 0
  6787. * @param sphere1 sphere 1
  6788. * @returns true if the speres intersect
  6789. */
  6790. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6791. }
  6792. }
  6793. declare module "babylonjs/Culling/boundingBox" {
  6794. import { DeepImmutable } from "babylonjs/types";
  6795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6796. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6797. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6798. import { Plane } from "babylonjs/Maths/math.plane";
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/collider" {
  6944. import { Nullable, IndicesArray } from "babylonjs/types";
  6945. import { Vector3 } from "babylonjs/Maths/math.vector";
  6946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6947. import { Plane } from "babylonjs/Maths/math.plane";
  6948. /** @hidden */
  6949. export class Collider {
  6950. /** Define if a collision was found */
  6951. collisionFound: boolean;
  6952. /**
  6953. * Define last intersection point in local space
  6954. */
  6955. intersectionPoint: Vector3;
  6956. /**
  6957. * Define last collided mesh
  6958. */
  6959. collidedMesh: Nullable<AbstractMesh>;
  6960. private _collisionPoint;
  6961. private _planeIntersectionPoint;
  6962. private _tempVector;
  6963. private _tempVector2;
  6964. private _tempVector3;
  6965. private _tempVector4;
  6966. private _edge;
  6967. private _baseToVertex;
  6968. private _destinationPoint;
  6969. private _slidePlaneNormal;
  6970. private _displacementVector;
  6971. /** @hidden */
  6972. _radius: Vector3;
  6973. /** @hidden */
  6974. _retry: number;
  6975. private _velocity;
  6976. private _basePoint;
  6977. private _epsilon;
  6978. /** @hidden */
  6979. _velocityWorldLength: number;
  6980. /** @hidden */
  6981. _basePointWorld: Vector3;
  6982. private _velocityWorld;
  6983. private _normalizedVelocity;
  6984. /** @hidden */
  6985. _initialVelocity: Vector3;
  6986. /** @hidden */
  6987. _initialPosition: Vector3;
  6988. private _nearestDistance;
  6989. private _collisionMask;
  6990. collisionMask: number;
  6991. /**
  6992. * Gets the plane normal used to compute the sliding response (in local space)
  6993. */
  6994. readonly slidePlaneNormal: Vector3;
  6995. /** @hidden */
  6996. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6997. /** @hidden */
  6998. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6999. /** @hidden */
  7000. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7001. /** @hidden */
  7002. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _getResponse(pos: Vector3, vel: Vector3): void;
  7007. }
  7008. }
  7009. declare module "babylonjs/Culling/boundingInfo" {
  7010. import { DeepImmutable } from "babylonjs/types";
  7011. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7012. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7013. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7014. import { Plane } from "babylonjs/Maths/math.plane";
  7015. import { Collider } from "babylonjs/Collisions/collider";
  7016. /**
  7017. * Interface for cullable objects
  7018. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7019. */
  7020. export interface ICullable {
  7021. /**
  7022. * Checks if the object or part of the object is in the frustum
  7023. * @param frustumPlanes Camera near/planes
  7024. * @returns true if the object is in frustum otherwise false
  7025. */
  7026. isInFrustum(frustumPlanes: Plane[]): boolean;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7034. }
  7035. /**
  7036. * Info for a bounding data of a mesh
  7037. */
  7038. export class BoundingInfo implements ICullable {
  7039. /**
  7040. * Bounding box for the mesh
  7041. */
  7042. readonly boundingBox: BoundingBox;
  7043. /**
  7044. * Bounding sphere for the mesh
  7045. */
  7046. readonly boundingSphere: BoundingSphere;
  7047. private _isLocked;
  7048. private static readonly TmpVector3;
  7049. /**
  7050. * Constructs bounding info
  7051. * @param minimum min vector of the bounding box/sphere
  7052. * @param maximum max vector of the bounding box/sphere
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * min vector of the bounding box/sphere
  7065. */
  7066. readonly minimum: Vector3;
  7067. /**
  7068. * max vector of the bounding box/sphere
  7069. */
  7070. readonly maximum: Vector3;
  7071. /**
  7072. * If the info is locked and won't be updated to avoid perf overhead
  7073. */
  7074. isLocked: boolean;
  7075. /**
  7076. * Updates the bounding sphere and box
  7077. * @param world world matrix to be used to update
  7078. */
  7079. update(world: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7082. * @param center New center of the bounding info
  7083. * @param extend New extend of the bounding info
  7084. * @returns the current bounding info
  7085. */
  7086. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7087. /**
  7088. * Scale the current bounding info by applying a scale factor
  7089. * @param factor defines the scale factor to apply
  7090. * @returns the current bounding info
  7091. */
  7092. scale(factor: number): BoundingInfo;
  7093. /**
  7094. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7095. * @param frustumPlanes defines the frustum to test
  7096. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7097. * @returns true if the bounding info is in the frustum planes
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7100. /**
  7101. * Gets the world distance between the min and max points of the bounding box
  7102. */
  7103. readonly diagonalLength: number;
  7104. /**
  7105. * Checks if a cullable object (mesh...) is in the camera frustum
  7106. * Unlike isInFrustum this cheks the full bounding box
  7107. * @param frustumPlanes Camera near/planes
  7108. * @returns true if the object is in frustum otherwise false
  7109. */
  7110. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7111. /** @hidden */
  7112. _checkCollision(collider: Collider): boolean;
  7113. /**
  7114. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param point the point to check intersection with
  7117. * @returns if the point intersects
  7118. */
  7119. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7120. /**
  7121. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7122. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7123. * @param boundingInfo the bounding info to check intersection with
  7124. * @param precise if the intersection should be done using OBB
  7125. * @returns if the bounding info intersects
  7126. */
  7127. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7128. }
  7129. }
  7130. declare module "babylonjs/Maths/math.functions" {
  7131. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7132. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7161. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7162. /** @hidden */
  7163. export class WebGLDataBuffer extends DataBuffer {
  7164. private _buffer;
  7165. constructor(resource: WebGLBuffer);
  7166. readonly underlyingResource: any;
  7167. }
  7168. }
  7169. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7171. import { Nullable } from "babylonjs/types";
  7172. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7173. /** @hidden */
  7174. export class WebGLPipelineContext implements IPipelineContext {
  7175. engine: ThinEngine;
  7176. program: Nullable<WebGLProgram>;
  7177. context?: WebGLRenderingContext;
  7178. vertexShader?: WebGLShader;
  7179. fragmentShader?: WebGLShader;
  7180. isParallelCompiled: boolean;
  7181. onCompiled?: () => void;
  7182. transformFeedback?: WebGLTransformFeedback | null;
  7183. readonly isAsync: boolean;
  7184. readonly isReady: boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. }
  7187. }
  7188. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7189. import { FloatArray, Nullable } from "babylonjs/types";
  7190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7192. module "babylonjs/Engines/thinEngine" {
  7193. interface ThinEngine {
  7194. /**
  7195. * Create an uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Create a dynamic uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param elements defines the content of the uniform buffer
  7205. * @returns the webGL uniform buffer
  7206. */
  7207. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7208. /**
  7209. * Update an existing uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param uniformBuffer defines the target uniform buffer
  7212. * @param elements defines the content to update
  7213. * @param offset defines the offset in the uniform buffer where update should start
  7214. * @param count defines the size of the data to update
  7215. */
  7216. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7217. /**
  7218. * Bind an uniform buffer to the current webGL context
  7219. * @param buffer defines the buffer to bind
  7220. */
  7221. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7222. /**
  7223. * Bind a buffer to the current webGL context at a given location
  7224. * @param buffer defines the buffer to bind
  7225. * @param location defines the index where to bind the buffer
  7226. */
  7227. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7228. /**
  7229. * Bind a specific block at a given index in a specific shader program
  7230. * @param pipelineContext defines the pipeline context to use
  7231. * @param blockName defines the block name
  7232. * @param index defines the index where to bind the block
  7233. */
  7234. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7235. }
  7236. }
  7237. }
  7238. declare module "babylonjs/Materials/uniformBuffer" {
  7239. import { Nullable, FloatArray } from "babylonjs/types";
  7240. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7241. import { Engine } from "babylonjs/Engines/engine";
  7242. import { Effect } from "babylonjs/Materials/effect";
  7243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7244. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7245. import { Color3 } from "babylonjs/Maths/math.color";
  7246. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7247. /**
  7248. * Uniform buffer objects.
  7249. *
  7250. * Handles blocks of uniform on the GPU.
  7251. *
  7252. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7253. *
  7254. * For more information, please refer to :
  7255. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7256. */
  7257. export class UniformBuffer {
  7258. private _engine;
  7259. private _buffer;
  7260. private _data;
  7261. private _bufferData;
  7262. private _dynamic?;
  7263. private _uniformLocations;
  7264. private _uniformSizes;
  7265. private _uniformLocationPointer;
  7266. private _needSync;
  7267. private _noUBO;
  7268. private _currentEffect;
  7269. /** @hidden */
  7270. _alreadyBound: boolean;
  7271. private static _MAX_UNIFORM_SIZE;
  7272. private static _tempBuffer;
  7273. /**
  7274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7279. /**
  7280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7285. /**
  7286. * Lambda to Update a single float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat: (name: string, x: number) => void;
  7291. /**
  7292. * Lambda to Update a vec2 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a vec3 of float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7303. /**
  7304. * Lambda to Update a vec4 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix: (name: string, mat: Matrix) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateVector3: (name: string, vector: Vector3) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateVector4: (name: string, vector: Vector4) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7339. /**
  7340. * Instantiates a new Uniform buffer objects.
  7341. *
  7342. * Handles blocks of uniform on the GPU.
  7343. *
  7344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7345. *
  7346. * For more information, please refer to :
  7347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7348. * @param engine Define the engine the buffer is associated with
  7349. * @param data Define the data contained in the buffer
  7350. * @param dynamic Define if the buffer is updatable
  7351. */
  7352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7353. /**
  7354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7355. * or just falling back on setUniformXXX calls.
  7356. */
  7357. readonly useUbo: boolean;
  7358. /**
  7359. * Indicates if the WebGL underlying uniform buffer is in sync
  7360. * with the javascript cache data.
  7361. */
  7362. readonly isSync: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7365. * Also, a dynamic UniformBuffer will disable cache verification and always
  7366. * update the underlying WebGL uniform buffer to the GPU.
  7367. * @returns if Dynamic, otherwise false
  7368. */
  7369. isDynamic(): boolean;
  7370. /**
  7371. * The data cache on JS side.
  7372. * @returns the underlying data as a float array
  7373. */
  7374. getData(): Float32Array;
  7375. /**
  7376. * The underlying WebGL Uniform buffer.
  7377. * @returns the webgl buffer
  7378. */
  7379. getBuffer(): Nullable<DataBuffer>;
  7380. /**
  7381. * std140 layout specifies how to align data within an UBO structure.
  7382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7383. * for specs.
  7384. */
  7385. private _fillAlignment;
  7386. /**
  7387. * Adds an uniform in the buffer.
  7388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7389. * for the layout to be correct !
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param size Data size, or data directly.
  7392. */
  7393. addUniform(name: string, size: number | number[]): void;
  7394. /**
  7395. * Adds a Matrix 4x4 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param mat A 4x4 matrix.
  7398. */
  7399. addMatrix(name: string, mat: Matrix): void;
  7400. /**
  7401. * Adds a vec2 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param x Define the x component value of the vec2
  7404. * @param y Define the y component value of the vec2
  7405. */
  7406. addFloat2(name: string, x: number, y: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param x Define the x component value of the vec3
  7411. * @param y Define the y component value of the vec3
  7412. * @param z Define the z component value of the vec3
  7413. */
  7414. addFloat3(name: string, x: number, y: number, z: number): void;
  7415. /**
  7416. * Adds a vec3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. * @param color Define the vec3 from a Color
  7419. */
  7420. addColor3(name: string, color: Color3): void;
  7421. /**
  7422. * Adds a vec4 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param color Define the rgb components from a Color
  7425. * @param alpha Define the a component of the vec4
  7426. */
  7427. addColor4(name: string, color: Color3, alpha: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param vector Define the vec3 components from a Vector
  7432. */
  7433. addVector3(name: string, vector: Vector3): void;
  7434. /**
  7435. * Adds a Matrix 3x3 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. */
  7438. addMatrix3x3(name: string): void;
  7439. /**
  7440. * Adds a Matrix 2x2 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix2x2(name: string): void;
  7444. /**
  7445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7446. */
  7447. create(): void;
  7448. /** @hidden */
  7449. _rebuild(): void;
  7450. /**
  7451. * Updates the WebGL Uniform Buffer on the GPU.
  7452. * If the `dynamic` flag is set to true, no cache comparison is done.
  7453. * Otherwise, the buffer will be updated only if the cache differs.
  7454. */
  7455. update(): void;
  7456. /**
  7457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7459. * @param data Define the flattened data
  7460. * @param size Define the size of the data.
  7461. */
  7462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7463. private _valueCache;
  7464. private _cacheMatrix;
  7465. private _updateMatrix3x3ForUniform;
  7466. private _updateMatrix3x3ForEffect;
  7467. private _updateMatrix2x2ForEffect;
  7468. private _updateMatrix2x2ForUniform;
  7469. private _updateFloatForEffect;
  7470. private _updateFloatForUniform;
  7471. private _updateFloat2ForEffect;
  7472. private _updateFloat2ForUniform;
  7473. private _updateFloat3ForEffect;
  7474. private _updateFloat3ForUniform;
  7475. private _updateFloat4ForEffect;
  7476. private _updateFloat4ForUniform;
  7477. private _updateMatrixForEffect;
  7478. private _updateMatrixForUniform;
  7479. private _updateVector3ForEffect;
  7480. private _updateVector3ForUniform;
  7481. private _updateVector4ForEffect;
  7482. private _updateVector4ForUniform;
  7483. private _updateColor3ForEffect;
  7484. private _updateColor3ForUniform;
  7485. private _updateColor4ForEffect;
  7486. private _updateColor4ForUniform;
  7487. /**
  7488. * Sets a sampler uniform on the effect.
  7489. * @param name Define the name of the sampler.
  7490. * @param texture Define the texture to set in the sampler
  7491. */
  7492. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7493. /**
  7494. * Directly updates the value of the uniform in the cache AND on the GPU.
  7495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7496. * @param data Define the flattened data
  7497. */
  7498. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7499. /**
  7500. * Binds this uniform buffer to an effect.
  7501. * @param effect Define the effect to bind the buffer to
  7502. * @param name Name of the uniform block in the shader.
  7503. */
  7504. bindToEffect(effect: Effect, name: string): void;
  7505. /**
  7506. * Disposes the uniform buffer.
  7507. */
  7508. dispose(): void;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/iInspectable" {
  7512. /**
  7513. * Enum that determines the text-wrapping mode to use.
  7514. */
  7515. export enum InspectableType {
  7516. /**
  7517. * Checkbox for booleans
  7518. */
  7519. Checkbox = 0,
  7520. /**
  7521. * Sliders for numbers
  7522. */
  7523. Slider = 1,
  7524. /**
  7525. * Vector3
  7526. */
  7527. Vector3 = 2,
  7528. /**
  7529. * Quaternions
  7530. */
  7531. Quaternion = 3,
  7532. /**
  7533. * Color3
  7534. */
  7535. Color3 = 4,
  7536. /**
  7537. * String
  7538. */
  7539. String = 5
  7540. }
  7541. /**
  7542. * Interface used to define custom inspectable properties.
  7543. * This interface is used by the inspector to display custom property grids
  7544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7545. */
  7546. export interface IInspectable {
  7547. /**
  7548. * Gets the label to display
  7549. */
  7550. label: string;
  7551. /**
  7552. * Gets the name of the property to edit
  7553. */
  7554. propertyName: string;
  7555. /**
  7556. * Gets the type of the editor to use
  7557. */
  7558. type: InspectableType;
  7559. /**
  7560. * Gets the minimum value of the property when using in "slider" mode
  7561. */
  7562. min?: number;
  7563. /**
  7564. * Gets the maximum value of the property when using in "slider" mode
  7565. */
  7566. max?: number;
  7567. /**
  7568. * Gets the setp to use when using in "slider" mode
  7569. */
  7570. step?: number;
  7571. }
  7572. }
  7573. declare module "babylonjs/Misc/timingTools" {
  7574. /**
  7575. * Class used to provide helper for timing
  7576. */
  7577. export class TimingTools {
  7578. /**
  7579. * Polyfill for setImmediate
  7580. * @param action defines the action to execute after the current execution block
  7581. */
  7582. static SetImmediate(action: () => void): void;
  7583. }
  7584. }
  7585. declare module "babylonjs/Misc/instantiationTools" {
  7586. /**
  7587. * Class used to enable instatition of objects by class name
  7588. */
  7589. export class InstantiationTools {
  7590. /**
  7591. * Use this object to register external classes like custom textures or material
  7592. * to allow the laoders to instantiate them
  7593. */
  7594. static RegisteredExternalClasses: {
  7595. [key: string]: Object;
  7596. };
  7597. /**
  7598. * Tries to instantiate a new object from a given class name
  7599. * @param className defines the class name to instantiate
  7600. * @returns the new object or null if the system was not able to do the instantiation
  7601. */
  7602. static Instantiate(className: string): any;
  7603. }
  7604. }
  7605. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7606. /**
  7607. * Define options used to create a depth texture
  7608. */
  7609. export class DepthTextureCreationOptions {
  7610. /** Specifies whether or not a stencil should be allocated in the texture */
  7611. generateStencil?: boolean;
  7612. /** Specifies whether or not bilinear filtering is enable on the texture */
  7613. bilinearFiltering?: boolean;
  7614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7615. comparisonFunction?: number;
  7616. /** Specifies if the created texture is a cube texture */
  7617. isCube?: boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7622. import { Nullable } from "babylonjs/types";
  7623. import { Scene } from "babylonjs/scene";
  7624. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7626. module "babylonjs/Engines/thinEngine" {
  7627. interface ThinEngine {
  7628. /**
  7629. * Creates a depth stencil cube texture.
  7630. * This is only available in WebGL 2.
  7631. * @param size The size of face edge in the cube texture.
  7632. * @param options The options defining the cube texture.
  7633. * @returns The cube texture
  7634. */
  7635. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7650. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. 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;
  7654. /**
  7655. * Creates a cube texture
  7656. * @param rootUrl defines the url where the files to load is located
  7657. * @param scene defines the current scene
  7658. * @param files defines the list of files to load (1 per face)
  7659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7660. * @param onLoad defines an optional callback raised when the texture is loaded
  7661. * @param onError defines an optional callback raised if there is an issue to load the texture
  7662. * @param format defines the format of the data
  7663. * @param forcedExtension defines the extension to use to pick the right loader
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. 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;
  7667. /**
  7668. * Creates a cube texture
  7669. * @param rootUrl defines the url where the files to load is located
  7670. * @param scene defines the current scene
  7671. * @param files defines the list of files to load (1 per face)
  7672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7673. * @param onLoad defines an optional callback raised when the texture is loaded
  7674. * @param onError defines an optional callback raised if there is an issue to load the texture
  7675. * @param format defines the format of the data
  7676. * @param forcedExtension defines the extension to use to pick the right loader
  7677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @returns the cube texture as an InternalTexture
  7681. */
  7682. 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;
  7683. /** @hidden */
  7684. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7687. /** @hidden */
  7688. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /** @hidden */
  7690. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7691. /**
  7692. * @hidden
  7693. */
  7694. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7695. }
  7696. }
  7697. }
  7698. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7699. import { Nullable } from "babylonjs/types";
  7700. import { Scene } from "babylonjs/scene";
  7701. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7703. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * The url of the texture
  7711. */
  7712. url: string;
  7713. /**
  7714. * Gets or sets the center of the bounding box associated with the cube texture.
  7715. * It must define where the camera used to render the texture was set
  7716. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7717. */
  7718. boundingBoxPosition: Vector3;
  7719. private _boundingBoxSize;
  7720. /**
  7721. * Gets or sets the size of the bounding box associated with the cube texture
  7722. * When defined, the cubemap will switch to local mode
  7723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7724. * @example https://www.babylonjs-playground.com/#RNASML
  7725. */
  7726. /**
  7727. * Returns the bounding box size
  7728. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7729. */
  7730. boundingBoxSize: Vector3;
  7731. protected _rotationY: number;
  7732. /**
  7733. * Sets texture matrix rotation angle around Y axis in radians.
  7734. */
  7735. /**
  7736. * Gets texture matrix rotation angle around Y axis radians.
  7737. */
  7738. rotationY: number;
  7739. /**
  7740. * Are mip maps generated for this texture or not.
  7741. */
  7742. readonly noMipmap: boolean;
  7743. private _noMipmap;
  7744. private _files;
  7745. protected _forcedExtension: Nullable<string>;
  7746. private _extensions;
  7747. private _textureMatrix;
  7748. private _format;
  7749. private _createPolynomials;
  7750. /** @hidden */
  7751. _prefiltered: boolean;
  7752. /**
  7753. * Creates a cube texture from an array of image urls
  7754. * @param files defines an array of image urls
  7755. * @param scene defines the hosting scene
  7756. * @param noMipmap specifies if mip maps are not used
  7757. * @returns a cube texture
  7758. */
  7759. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7760. /**
  7761. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7762. * @param url defines the url of the prefiltered texture
  7763. * @param scene defines the scene the texture is attached to
  7764. * @param forcedExtension defines the extension of the file if different from the url
  7765. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7766. * @return the prefiltered texture
  7767. */
  7768. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7769. /**
  7770. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7771. * as prefiltered data.
  7772. * @param rootUrl defines the url of the texture or the root name of the six images
  7773. * @param scene defines the scene the texture is attached to
  7774. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7775. * @param noMipmap defines if mipmaps should be created or not
  7776. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7777. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7778. * @param onError defines a callback triggered in case of error during load
  7779. * @param format defines the internal format to use for the texture once loaded
  7780. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7781. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7782. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7783. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7784. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7785. * @return the cube texture
  7786. */
  7787. 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);
  7788. /**
  7789. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7790. */
  7791. readonly isPrefiltered: boolean;
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module "babylonjs/Materials/materialDefines" {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. readonly isDirty: boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module "babylonjs/Materials/colorCurves" {
  7935. import { Effect } from "babylonjs/Materials/effect";
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * 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;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * 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).
  7958. */
  7959. /**
  7960. * Sets the global Hue value.
  7961. * 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).
  7962. */
  7963. globalHue: number;
  7964. /**
  7965. * Gets the global Density value.
  7966. * 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.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. /**
  7970. * Sets the global Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. globalDensity: number;
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * 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.
  7978. */
  7979. /**
  7980. * Sets the global Saturation value.
  7981. * 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.
  7982. */
  7983. globalSaturation: number;
  7984. /**
  7985. * Gets the global Exposure value.
  7986. * 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.
  7987. */
  7988. /**
  7989. * Sets the global Exposure value.
  7990. * 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.
  7991. */
  7992. globalExposure: number;
  7993. private _highlightsHue;
  7994. private _highlightsDensity;
  7995. private _highlightsSaturation;
  7996. private _highlightsExposure;
  7997. /**
  7998. * Gets the highlights Hue value.
  7999. * 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).
  8000. */
  8001. /**
  8002. * Sets the highlights Hue value.
  8003. * 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).
  8004. */
  8005. highlightsHue: number;
  8006. /**
  8007. * Gets the highlights Density value.
  8008. * 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.
  8009. * Values less than zero provide a filter of opposite hue.
  8010. */
  8011. /**
  8012. * Sets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. highlightsDensity: number;
  8017. /**
  8018. * Gets the highlights Saturation value.
  8019. * 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.
  8020. */
  8021. /**
  8022. * Sets the highlights Saturation value.
  8023. * 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.
  8024. */
  8025. highlightsSaturation: number;
  8026. /**
  8027. * Gets the highlights Exposure value.
  8028. * 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.
  8029. */
  8030. /**
  8031. * Sets the highlights Exposure value.
  8032. * 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.
  8033. */
  8034. highlightsExposure: number;
  8035. private _midtonesHue;
  8036. private _midtonesDensity;
  8037. private _midtonesSaturation;
  8038. private _midtonesExposure;
  8039. /**
  8040. * Gets the midtones Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. /**
  8044. * Sets the midtones Hue value.
  8045. * 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).
  8046. */
  8047. midtonesHue: number;
  8048. /**
  8049. * Gets the midtones Density value.
  8050. * 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.
  8051. * Values less than zero provide a filter of opposite hue.
  8052. */
  8053. /**
  8054. * Sets the midtones Density value.
  8055. * 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.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. midtonesDensity: number;
  8059. /**
  8060. * Gets the midtones Saturation value.
  8061. * 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.
  8062. */
  8063. /**
  8064. * Sets the midtones Saturation value.
  8065. * 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.
  8066. */
  8067. midtonesSaturation: number;
  8068. /**
  8069. * Gets the midtones Exposure value.
  8070. * 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.
  8071. */
  8072. /**
  8073. * Sets the midtones Exposure value.
  8074. * 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.
  8075. */
  8076. midtonesExposure: number;
  8077. private _shadowsHue;
  8078. private _shadowsDensity;
  8079. private _shadowsSaturation;
  8080. private _shadowsExposure;
  8081. /**
  8082. * Gets the shadows Hue value.
  8083. * 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).
  8084. */
  8085. /**
  8086. * Sets the shadows Hue value.
  8087. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8088. */
  8089. shadowsHue: number;
  8090. /**
  8091. * Gets the shadows Density value.
  8092. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. /**
  8096. * Sets the shadows Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. shadowsDensity: number;
  8101. /**
  8102. * Gets the shadows Saturation value.
  8103. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8104. */
  8105. /**
  8106. * Sets the shadows Saturation value.
  8107. * 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.
  8108. */
  8109. shadowsSaturation: number;
  8110. /**
  8111. * Gets the shadows Exposure value.
  8112. * 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.
  8113. */
  8114. /**
  8115. * Sets the shadows Exposure value.
  8116. * 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.
  8117. */
  8118. shadowsExposure: number;
  8119. /**
  8120. * Returns the class name
  8121. * @returns The class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Binds the color curves to the shader.
  8126. * @param colorCurves The color curve to bind
  8127. * @param effect The effect to bind to
  8128. * @param positiveUniform The positive uniform shader parameter
  8129. * @param neutralUniform The neutral uniform shader parameter
  8130. * @param negativeUniform The negative uniform shader parameter
  8131. */
  8132. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8133. /**
  8134. * Prepare the list of uniforms associated with the ColorCurves effects.
  8135. * @param uniformsList The list of uniforms used in the effect
  8136. */
  8137. static PrepareUniforms(uniformsList: string[]): void;
  8138. /**
  8139. * Returns color grading data based on a hue, density, saturation and exposure value.
  8140. * @param filterHue The hue of the color filter.
  8141. * @param filterDensity The density of the color filter.
  8142. * @param saturation The saturation.
  8143. * @param exposure The exposure.
  8144. * @param result The result data container.
  8145. */
  8146. private getColorGradingDataToRef;
  8147. /**
  8148. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8149. * @param value The input slider value in range [-100,100].
  8150. * @returns Adjusted value.
  8151. */
  8152. private static applyColorGradingSliderNonlinear;
  8153. /**
  8154. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8155. * @param hue The hue (H) input.
  8156. * @param saturation The saturation (S) input.
  8157. * @param brightness The brightness (B) input.
  8158. * @result An RGBA color represented as Vector4.
  8159. */
  8160. private static fromHSBToRef;
  8161. /**
  8162. * Returns a value clamped between min and max
  8163. * @param value The value to clamp
  8164. * @param min The minimum of value
  8165. * @param max The maximum of value
  8166. * @returns The clamped value.
  8167. */
  8168. private static clamp;
  8169. /**
  8170. * Clones the current color curve instance.
  8171. * @return The cloned curves
  8172. */
  8173. clone(): ColorCurves;
  8174. /**
  8175. * Serializes the current color curve instance to a json representation.
  8176. * @return a JSON representation
  8177. */
  8178. serialize(): any;
  8179. /**
  8180. * Parses the color curve from a json representation.
  8181. * @param source the JSON source to parse
  8182. * @return The parsed curves
  8183. */
  8184. static Parse(source: any): ColorCurves;
  8185. }
  8186. }
  8187. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8188. import { Observable } from "babylonjs/Misc/observable";
  8189. import { Nullable } from "babylonjs/types";
  8190. import { Color4 } from "babylonjs/Maths/math.color";
  8191. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8192. import { Effect } from "babylonjs/Materials/effect";
  8193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8194. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8195. /**
  8196. * Interface to follow in your material defines to integrate easily the
  8197. * Image proccessing functions.
  8198. * @hidden
  8199. */
  8200. export interface IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. EXPOSURE: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. }
  8216. /**
  8217. * @hidden
  8218. */
  8219. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8220. IMAGEPROCESSING: boolean;
  8221. VIGNETTE: boolean;
  8222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8223. VIGNETTEBLENDMODEOPAQUE: boolean;
  8224. TONEMAPPING: boolean;
  8225. TONEMAPPING_ACES: boolean;
  8226. CONTRAST: boolean;
  8227. COLORCURVES: boolean;
  8228. COLORGRADING: boolean;
  8229. COLORGRADING3D: boolean;
  8230. SAMPLER3DGREENDEPTH: boolean;
  8231. SAMPLER3DBGRMAP: boolean;
  8232. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8233. EXPOSURE: boolean;
  8234. constructor();
  8235. }
  8236. /**
  8237. * This groups together the common properties used for image processing either in direct forward pass
  8238. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8239. * or not.
  8240. */
  8241. export class ImageProcessingConfiguration {
  8242. /**
  8243. * Default tone mapping applied in BabylonJS.
  8244. */
  8245. static readonly TONEMAPPING_STANDARD: number;
  8246. /**
  8247. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8248. * to other engines rendering to increase portability.
  8249. */
  8250. static readonly TONEMAPPING_ACES: number;
  8251. /**
  8252. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8253. */
  8254. colorCurves: Nullable<ColorCurves>;
  8255. private _colorCurvesEnabled;
  8256. /**
  8257. * Gets wether the color curves effect is enabled.
  8258. */
  8259. /**
  8260. * Sets wether the color curves effect is enabled.
  8261. */
  8262. colorCurvesEnabled: boolean;
  8263. private _colorGradingTexture;
  8264. /**
  8265. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8266. */
  8267. /**
  8268. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8269. */
  8270. colorGradingTexture: Nullable<BaseTexture>;
  8271. private _colorGradingEnabled;
  8272. /**
  8273. * Gets wether the color grading effect is enabled.
  8274. */
  8275. /**
  8276. * Sets wether the color grading effect is enabled.
  8277. */
  8278. colorGradingEnabled: boolean;
  8279. private _colorGradingWithGreenDepth;
  8280. /**
  8281. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8282. */
  8283. /**
  8284. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8285. */
  8286. colorGradingWithGreenDepth: boolean;
  8287. private _colorGradingBGR;
  8288. /**
  8289. * Gets wether the color grading texture contains BGR values.
  8290. */
  8291. /**
  8292. * Sets wether the color grading texture contains BGR values.
  8293. */
  8294. colorGradingBGR: boolean;
  8295. /** @hidden */
  8296. _exposure: number;
  8297. /**
  8298. * Gets the Exposure used in the effect.
  8299. */
  8300. /**
  8301. * Sets the Exposure used in the effect.
  8302. */
  8303. exposure: number;
  8304. private _toneMappingEnabled;
  8305. /**
  8306. * Gets wether the tone mapping effect is enabled.
  8307. */
  8308. /**
  8309. * Sets wether the tone mapping effect is enabled.
  8310. */
  8311. toneMappingEnabled: boolean;
  8312. private _toneMappingType;
  8313. /**
  8314. * Gets the type of tone mapping effect.
  8315. */
  8316. /**
  8317. * Sets the type of tone mapping effect used in BabylonJS.
  8318. */
  8319. toneMappingType: number;
  8320. protected _contrast: number;
  8321. /**
  8322. * Gets the contrast used in the effect.
  8323. */
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. contrast: number;
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. /**
  8358. * Sets the vignette blend mode allowing different kind of effect.
  8359. */
  8360. vignetteBlendMode: number;
  8361. private _vignetteEnabled;
  8362. /**
  8363. * Gets wether the vignette effect is enabled.
  8364. */
  8365. /**
  8366. * Sets wether the vignette effect is enabled.
  8367. */
  8368. vignetteEnabled: boolean;
  8369. private _applyByPostProcess;
  8370. /**
  8371. * Gets wether the image processing is applied through a post process or not.
  8372. */
  8373. /**
  8374. * Sets wether the image processing is applied through a post process or not.
  8375. */
  8376. applyByPostProcess: boolean;
  8377. private _isEnabled;
  8378. /**
  8379. * Gets wether the image processing is enabled or not.
  8380. */
  8381. /**
  8382. * Sets wether the image processing is enabled or not.
  8383. */
  8384. isEnabled: boolean;
  8385. /**
  8386. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8387. */
  8388. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8389. /**
  8390. * Method called each time the image processing information changes requires to recompile the effect.
  8391. */
  8392. protected _updateParameters(): void;
  8393. /**
  8394. * Gets the current class name.
  8395. * @return "ImageProcessingConfiguration"
  8396. */
  8397. getClassName(): string;
  8398. /**
  8399. * Prepare the list of uniforms associated with the Image Processing effects.
  8400. * @param uniforms The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of samplers associated with the Image Processing effects.
  8406. * @param samplersList The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of defines associated to the shader.
  8412. * @param defines the list of defines to complete
  8413. * @param forPostProcess Define if we are currently in post process mode or not
  8414. */
  8415. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8416. /**
  8417. * Returns true if all the image processing information are ready.
  8418. * @returns True if ready, otherwise, false
  8419. */
  8420. isReady(): boolean;
  8421. /**
  8422. * Binds the image processing to the shader.
  8423. * @param effect The effect to bind to
  8424. * @param overrideAspectRatio Override the aspect ratio of the effect
  8425. */
  8426. bind(effect: Effect, overrideAspectRatio?: number): void;
  8427. /**
  8428. * Clones the current image processing instance.
  8429. * @return The cloned image processing
  8430. */
  8431. clone(): ImageProcessingConfiguration;
  8432. /**
  8433. * Serializes the current image processing instance to a json representation.
  8434. * @return a JSON representation
  8435. */
  8436. serialize(): any;
  8437. /**
  8438. * Parses the image processing from a json representation.
  8439. * @param source the JSON source to parse
  8440. * @return The parsed image processing
  8441. */
  8442. static Parse(source: any): ImageProcessingConfiguration;
  8443. private static _VIGNETTEMODE_MULTIPLY;
  8444. private static _VIGNETTEMODE_OPAQUE;
  8445. /**
  8446. * Used to apply the vignette as a mix with the pixel color.
  8447. */
  8448. static readonly VIGNETTEMODE_MULTIPLY: number;
  8449. /**
  8450. * Used to apply the vignette as a replacement of the pixel color.
  8451. */
  8452. static readonly VIGNETTEMODE_OPAQUE: number;
  8453. }
  8454. }
  8455. declare module "babylonjs/Shaders/postprocess.vertex" {
  8456. /** @hidden */
  8457. export var postprocessVertexShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8464. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8465. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8466. module "babylonjs/Engines/thinEngine" {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8478. /**
  8479. * Creates a depth stencil texture.
  8480. * This is only available in WebGL 2 or with the depth texture extension available.
  8481. * @param size The size of face edge in the texture.
  8482. * @param options The options defining the texture.
  8483. * @returns The texture
  8484. */
  8485. createDepthStencilTexture(size: number | {
  8486. width: number;
  8487. height: number;
  8488. }, options: DepthTextureCreationOptions): InternalTexture;
  8489. /** @hidden */
  8490. _createDepthStencilTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. }, options: DepthTextureCreationOptions): InternalTexture;
  8494. }
  8495. }
  8496. }
  8497. declare module "babylonjs/Maths/math.axis" {
  8498. import { Vector3 } from "babylonjs/Maths/math.vector";
  8499. /** Defines supported spaces */
  8500. export enum Space {
  8501. /** Local (object) space */
  8502. LOCAL = 0,
  8503. /** World space */
  8504. WORLD = 1,
  8505. /** Bone space */
  8506. BONE = 2
  8507. }
  8508. /** Defines the 3 main axes */
  8509. export class Axis {
  8510. /** X axis */
  8511. static X: Vector3;
  8512. /** Y axis */
  8513. static Y: Vector3;
  8514. /** Z axis */
  8515. static Z: Vector3;
  8516. }
  8517. }
  8518. declare module "babylonjs/Cameras/targetCamera" {
  8519. import { Nullable } from "babylonjs/types";
  8520. import { Camera } from "babylonjs/Cameras/camera";
  8521. import { Scene } from "babylonjs/scene";
  8522. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8523. /**
  8524. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8525. * This is the base of the follow, arc rotate cameras and Free camera
  8526. * @see http://doc.babylonjs.com/features/cameras
  8527. */
  8528. export class TargetCamera extends Camera {
  8529. private static _RigCamTransformMatrix;
  8530. private static _TargetTransformMatrix;
  8531. private static _TargetFocalPoint;
  8532. /**
  8533. * Define the current direction the camera is moving to
  8534. */
  8535. cameraDirection: Vector3;
  8536. /**
  8537. * Define the current rotation the camera is rotating to
  8538. */
  8539. cameraRotation: Vector2;
  8540. /**
  8541. * When set, the up vector of the camera will be updated by the rotation of the camera
  8542. */
  8543. updateUpVectorFromRotation: boolean;
  8544. private _tmpQuaternion;
  8545. /**
  8546. * Define the current rotation of the camera
  8547. */
  8548. rotation: Vector3;
  8549. /**
  8550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8551. */
  8552. rotationQuaternion: Quaternion;
  8553. /**
  8554. * Define the current speed of the camera
  8555. */
  8556. speed: number;
  8557. /**
  8558. * Add constraint to the camera to prevent it to move freely in all directions and
  8559. * around all axis.
  8560. */
  8561. noRotationConstraint: boolean;
  8562. /**
  8563. * Define the current target of the camera as an object or a position.
  8564. */
  8565. lockedTarget: any;
  8566. /** @hidden */
  8567. _currentTarget: Vector3;
  8568. /** @hidden */
  8569. _initialFocalDistance: number;
  8570. /** @hidden */
  8571. _viewMatrix: Matrix;
  8572. /** @hidden */
  8573. _camMatrix: Matrix;
  8574. /** @hidden */
  8575. _cameraTransformMatrix: Matrix;
  8576. /** @hidden */
  8577. _cameraRotationMatrix: Matrix;
  8578. /** @hidden */
  8579. _referencePoint: Vector3;
  8580. /** @hidden */
  8581. _transformedReferencePoint: Vector3;
  8582. protected _globalCurrentTarget: Vector3;
  8583. protected _globalCurrentUpVector: Vector3;
  8584. /** @hidden */
  8585. _reset: () => void;
  8586. private _defaultUp;
  8587. /**
  8588. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8589. * This is the base of the follow, arc rotate cameras and Free camera
  8590. * @see http://doc.babylonjs.com/features/cameras
  8591. * @param name Defines the name of the camera in the scene
  8592. * @param position Defines the start position of the camera in the scene
  8593. * @param scene Defines the scene the camera belongs to
  8594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8595. */
  8596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8597. /**
  8598. * Gets the position in front of the camera at a given distance.
  8599. * @param distance The distance from the camera we want the position to be
  8600. * @returns the position
  8601. */
  8602. getFrontPosition(distance: number): Vector3;
  8603. /** @hidden */
  8604. _getLockedTargetPosition(): Nullable<Vector3>;
  8605. private _storedPosition;
  8606. private _storedRotation;
  8607. private _storedRotationQuaternion;
  8608. /**
  8609. * Store current camera state of the camera (fov, position, rotation, etc..)
  8610. * @returns the camera
  8611. */
  8612. storeState(): Camera;
  8613. /**
  8614. * Restored camera state. You must call storeState() first
  8615. * @returns whether it was successful or not
  8616. * @hidden
  8617. */
  8618. _restoreStateValues(): boolean;
  8619. /** @hidden */
  8620. _initCache(): void;
  8621. /** @hidden */
  8622. _updateCache(ignoreParentClass?: boolean): void;
  8623. /** @hidden */
  8624. _isSynchronizedViewMatrix(): boolean;
  8625. /** @hidden */
  8626. _computeLocalCameraSpeed(): number;
  8627. /**
  8628. * Defines the target the camera should look at.
  8629. * @param target Defines the new target as a Vector or a mesh
  8630. */
  8631. setTarget(target: Vector3): void;
  8632. /**
  8633. * Return the current target position of the camera. This value is expressed in local space.
  8634. * @returns the target position
  8635. */
  8636. getTarget(): Vector3;
  8637. /** @hidden */
  8638. _decideIfNeedsToMove(): boolean;
  8639. /** @hidden */
  8640. _updatePosition(): void;
  8641. /** @hidden */
  8642. _checkInputs(): void;
  8643. protected _updateCameraRotationMatrix(): void;
  8644. /**
  8645. * 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)
  8646. * @returns the current camera
  8647. */
  8648. private _rotateUpVectorWithCameraRotationMatrix;
  8649. private _cachedRotationZ;
  8650. private _cachedQuaternionRotationZ;
  8651. /** @hidden */
  8652. _getViewMatrix(): Matrix;
  8653. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8654. /**
  8655. * @hidden
  8656. */
  8657. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8658. /**
  8659. * @hidden
  8660. */
  8661. _updateRigCameras(): void;
  8662. private _getRigCamPositionAndTarget;
  8663. /**
  8664. * Gets the current object class name.
  8665. * @return the class name
  8666. */
  8667. getClassName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. }
  8915. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/effectFallbacks" {
  9052. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9053. import { Effect } from "babylonjs/Materials/effect";
  9054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9055. /**
  9056. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9057. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9058. */
  9059. export class EffectFallbacks implements IEffectFallbacks {
  9060. private _defines;
  9061. private _currentRank;
  9062. private _maxRank;
  9063. private _mesh;
  9064. /**
  9065. * Removes the fallback from the bound mesh.
  9066. */
  9067. unBindMesh(): void;
  9068. /**
  9069. * Adds a fallback on the specified property.
  9070. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9071. * @param define The name of the define in the shader
  9072. */
  9073. addFallback(rank: number, define: string): void;
  9074. /**
  9075. * Sets the mesh to use CPU skinning when needing to fallback.
  9076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9077. * @param mesh The mesh to use the fallbacks.
  9078. */
  9079. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9080. /**
  9081. * Checks to see if more fallbacks are still availible.
  9082. */
  9083. readonly hasMoreFallbacks: boolean;
  9084. /**
  9085. * Removes the defines that should be removed when falling back.
  9086. * @param currentDefines defines the current define statements for the shader.
  9087. * @param effect defines the current effect we try to compile
  9088. * @returns The resulting defines with defines of the current rank removed.
  9089. */
  9090. reduce(currentDefines: string, effect: Effect): string;
  9091. }
  9092. }
  9093. declare module "babylonjs/Materials/materialHelper" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { Scene } from "babylonjs/scene";
  9096. import { Engine } from "babylonjs/Engines/engine";
  9097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9098. import { Light } from "babylonjs/Lights/light";
  9099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9100. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9103. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9104. /**
  9105. * "Static Class" containing the most commonly used helper while dealing with material for
  9106. * rendering purpose.
  9107. *
  9108. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9109. *
  9110. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9111. */
  9112. export class MaterialHelper {
  9113. /**
  9114. * Bind the current view position to an effect.
  9115. * @param effect The effect to be bound
  9116. * @param scene The scene the eyes position is used from
  9117. */
  9118. static BindEyePosition(effect: Effect, scene: Scene): void;
  9119. /**
  9120. * Helps preparing the defines values about the UVs in used in the effect.
  9121. * UVs are shared as much as we can accross channels in the shaders.
  9122. * @param texture The texture we are preparing the UVs for
  9123. * @param defines The defines to update
  9124. * @param key The channel key "diffuse", "specular"... used in the shader
  9125. */
  9126. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9127. /**
  9128. * Binds a texture matrix value to its corrsponding uniform
  9129. * @param texture The texture to bind the matrix for
  9130. * @param uniformBuffer The uniform buffer receivin the data
  9131. * @param key The channel key "diffuse", "specular"... used in the shader
  9132. */
  9133. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9134. /**
  9135. * Gets the current status of the fog (should it be enabled?)
  9136. * @param mesh defines the mesh to evaluate for fog support
  9137. * @param scene defines the hosting scene
  9138. * @returns true if fog must be enabled
  9139. */
  9140. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9141. /**
  9142. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9143. * @param mesh defines the current mesh
  9144. * @param scene defines the current scene
  9145. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9146. * @param pointsCloud defines if point cloud rendering has to be turned on
  9147. * @param fogEnabled defines if fog has to be turned on
  9148. * @param alphaTest defines if alpha testing has to be turned on
  9149. * @param defines defines the current list of defines
  9150. */
  9151. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9152. /**
  9153. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9154. * @param scene defines the current scene
  9155. * @param engine defines the current engine
  9156. * @param defines specifies the list of active defines
  9157. * @param useInstances defines if instances have to be turned on
  9158. * @param useClipPlane defines if clip plane have to be turned on
  9159. */
  9160. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9161. /**
  9162. * Prepares the defines for bones
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. */
  9166. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9167. /**
  9168. * Prepares the defines for morph targets
  9169. * @param mesh The mesh containing the geometry data we will draw
  9170. * @param defines The defines to update
  9171. */
  9172. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9173. /**
  9174. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9175. * @param mesh The mesh containing the geometry data we will draw
  9176. * @param defines The defines to update
  9177. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9178. * @param useBones Precise whether bones should be used or not (override mesh info)
  9179. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9180. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9181. * @returns false if defines are considered not dirty and have not been checked
  9182. */
  9183. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9184. /**
  9185. * Prepares the defines related to multiview
  9186. * @param scene The scene we are intending to draw
  9187. * @param defines The defines to update
  9188. */
  9189. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9190. /**
  9191. * Prepares the defines related to the light information passed in parameter
  9192. * @param scene The scene we are intending to draw
  9193. * @param mesh The mesh the effect is compiling for
  9194. * @param light The light the effect is compiling for
  9195. * @param lightIndex The index of the light
  9196. * @param defines The defines to update
  9197. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9198. * @param state Defines the current state regarding what is needed (normals, etc...)
  9199. */
  9200. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9201. needNormals: boolean;
  9202. needRebuild: boolean;
  9203. shadowEnabled: boolean;
  9204. specularEnabled: boolean;
  9205. lightmapMode: boolean;
  9206. }): void;
  9207. /**
  9208. * Prepares the defines related to the light information passed in parameter
  9209. * @param scene The scene we are intending to draw
  9210. * @param mesh The mesh the effect is compiling for
  9211. * @param defines The defines to update
  9212. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9213. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9214. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9215. * @returns true if normals will be required for the rest of the effect
  9216. */
  9217. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9218. /**
  9219. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9220. * @param lightIndex defines the light index
  9221. * @param uniformsList The uniform list
  9222. * @param samplersList The sampler list
  9223. * @param projectedLightTexture defines if projected texture must be used
  9224. * @param uniformBuffersList defines an optional list of uniform buffers
  9225. */
  9226. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9227. /**
  9228. * Prepares the uniforms and samplers list to be used in the effect
  9229. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9230. * @param samplersList The sampler list
  9231. * @param defines The defines helping in the list generation
  9232. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9233. */
  9234. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9235. /**
  9236. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9237. * @param defines The defines to update while falling back
  9238. * @param fallbacks The authorized effect fallbacks
  9239. * @param maxSimultaneousLights The maximum number of lights allowed
  9240. * @param rank the current rank of the Effect
  9241. * @returns The newly affected rank
  9242. */
  9243. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9244. private static _TmpMorphInfluencers;
  9245. /**
  9246. * Prepares the list of attributes required for morph targets according to the effect defines.
  9247. * @param attribs The current list of supported attribs
  9248. * @param mesh The mesh to prepare the morph targets attributes for
  9249. * @param influencers The number of influencers
  9250. */
  9251. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9252. /**
  9253. * Prepares the list of attributes required for morph targets according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param mesh The mesh to prepare the morph targets attributes for
  9256. * @param defines The current Defines of the effect
  9257. */
  9258. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9259. /**
  9260. * Prepares the list of attributes required for bones according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the bones attributes for
  9263. * @param defines The current Defines of the effect
  9264. * @param fallbacks The current efffect fallback strategy
  9265. */
  9266. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9267. /**
  9268. * Check and prepare the list of attributes required for instances according to the effect defines.
  9269. * @param attribs The current list of supported attribs
  9270. * @param defines The current MaterialDefines of the effect
  9271. */
  9272. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9273. /**
  9274. * Add the list of attributes required for instances to the attribs array.
  9275. * @param attribs The current list of supported attribs
  9276. */
  9277. static PushAttributesForInstances(attribs: string[]): void;
  9278. /**
  9279. * Binds the light information to the effect.
  9280. * @param light The light containing the generator
  9281. * @param effect The effect we are binding the data to
  9282. * @param lightIndex The light index in the effect used to render
  9283. */
  9284. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9285. /**
  9286. * Binds the lights information from the scene to the effect for the given mesh.
  9287. * @param light Light to bind
  9288. * @param lightIndex Light index
  9289. * @param scene The scene where the light belongs to
  9290. * @param effect The effect we are binding the data to
  9291. * @param useSpecular Defines if specular is supported
  9292. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9293. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9294. */
  9295. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9296. /**
  9297. * Binds the lights information from the scene to the effect for the given mesh.
  9298. * @param scene The scene the lights belongs to
  9299. * @param mesh The mesh we are binding the information to render
  9300. * @param effect The effect we are binding the data to
  9301. * @param defines The generated defines for the effect
  9302. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9303. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9304. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9305. */
  9306. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9307. private static _tempFogColor;
  9308. /**
  9309. * Binds the fog information from the scene to the effect for the given mesh.
  9310. * @param scene The scene the lights belongs to
  9311. * @param mesh The mesh we are binding the information to render
  9312. * @param effect The effect we are binding the data to
  9313. * @param linearSpace Defines if the fog effect is applied in linear space
  9314. */
  9315. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9316. /**
  9317. * Binds the bones information from the mesh to the effect.
  9318. * @param mesh The mesh we are binding the information to render
  9319. * @param effect The effect we are binding the data to
  9320. */
  9321. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9322. /**
  9323. * Binds the morph targets information from the mesh to the effect.
  9324. * @param abstractMesh The mesh we are binding the information to render
  9325. * @param effect The effect we are binding the data to
  9326. */
  9327. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9328. /**
  9329. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9330. * @param defines The generated defines used in the effect
  9331. * @param effect The effect we are binding the data to
  9332. * @param scene The scene we are willing to render with logarithmic scale for
  9333. */
  9334. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9335. /**
  9336. * Binds the clip plane information from the scene to the effect.
  9337. * @param scene The scene the clip plane information are extracted from
  9338. * @param effect The effect we are binding the data to
  9339. */
  9340. static BindClipPlane(effect: Effect, scene: Scene): void;
  9341. }
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9344. /** @hidden */
  9345. export var packingFunctions: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9351. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9352. /** @hidden */
  9353. export var shadowMapPixelShader: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9359. /** @hidden */
  9360. export var bonesDeclaration: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9366. /** @hidden */
  9367. export var morphTargetsVertexGlobalDeclaration: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9373. /** @hidden */
  9374. export var morphTargetsVertexDeclaration: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9380. /** @hidden */
  9381. export var instancesDeclaration: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9387. /** @hidden */
  9388. export var helperFunctions: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9394. /** @hidden */
  9395. export var morphTargetsVertex: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9401. /** @hidden */
  9402. export var instancesVertex: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9408. /** @hidden */
  9409. export var bonesVertex: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9415. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9418. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9423. /** @hidden */
  9424. export var shadowMapVertexShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9430. /** @hidden */
  9431. export var depthBoxBlurPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9437. import { Nullable } from "babylonjs/types";
  9438. import { Scene } from "babylonjs/scene";
  9439. import { Matrix } from "babylonjs/Maths/math.vector";
  9440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9442. import { Mesh } from "babylonjs/Meshes/mesh";
  9443. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9444. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9445. import { Effect } from "babylonjs/Materials/effect";
  9446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9447. import "babylonjs/Shaders/shadowMap.fragment";
  9448. import "babylonjs/Shaders/shadowMap.vertex";
  9449. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. /**
  9452. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9453. */
  9454. export interface ICustomShaderOptions {
  9455. /**
  9456. * Gets or sets the custom shader name to use
  9457. */
  9458. shaderName: string;
  9459. /**
  9460. * The list of attribute names used in the shader
  9461. */
  9462. attributes?: string[];
  9463. /**
  9464. * The list of unifrom names used in the shader
  9465. */
  9466. uniforms?: string[];
  9467. /**
  9468. * The list of sampler names used in the shader
  9469. */
  9470. samplers?: string[];
  9471. /**
  9472. * The list of defines used in the shader
  9473. */
  9474. defines?: string[];
  9475. }
  9476. /**
  9477. * Interface to implement to create a shadow generator compatible with BJS.
  9478. */
  9479. export interface IShadowGenerator {
  9480. /**
  9481. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9482. * @returns The render target texture if present otherwise, null
  9483. */
  9484. getShadowMap(): Nullable<RenderTargetTexture>;
  9485. /**
  9486. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9487. * @returns The render target texture if the shadow map is present otherwise, null
  9488. */
  9489. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9492. * @param subMesh The submesh we want to render in the shadow map
  9493. * @param useInstances Defines wether will draw in the map using instances
  9494. * @returns true if ready otherwise, false
  9495. */
  9496. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9497. /**
  9498. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9499. * @param defines Defines of the material we want to update
  9500. * @param lightIndex Index of the light in the enabled light list of the material
  9501. */
  9502. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9503. /**
  9504. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9505. * defined in the generator but impacting the effect).
  9506. * It implies the unifroms available on the materials are the standard BJS ones.
  9507. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9508. * @param effect The effect we are binfing the information for
  9509. */
  9510. bindShadowLight(lightIndex: string, effect: Effect): void;
  9511. /**
  9512. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9513. * (eq to shadow prjection matrix * light transform matrix)
  9514. * @returns The transform matrix used to create the shadow map
  9515. */
  9516. getTransformMatrix(): Matrix;
  9517. /**
  9518. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9519. * Cube and 2D textures for instance.
  9520. */
  9521. recreateShadowMap(): void;
  9522. /**
  9523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9524. * @param onCompiled Callback triggered at the and of the effects compilation
  9525. * @param options Sets of optional options forcing the compilation with different modes
  9526. */
  9527. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9528. useInstances: boolean;
  9529. }>): void;
  9530. /**
  9531. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9532. * @param options Sets of optional options forcing the compilation with different modes
  9533. * @returns A promise that resolves when the compilation completes
  9534. */
  9535. forceCompilationAsync(options?: Partial<{
  9536. useInstances: boolean;
  9537. }>): Promise<void>;
  9538. /**
  9539. * Serializes the shadow generator setup to a json object.
  9540. * @returns The serialized JSON object
  9541. */
  9542. serialize(): any;
  9543. /**
  9544. * Disposes the Shadow map and related Textures and effects.
  9545. */
  9546. dispose(): void;
  9547. }
  9548. /**
  9549. * Default implementation IShadowGenerator.
  9550. * This is the main object responsible of generating shadows in the framework.
  9551. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9552. */
  9553. export class ShadowGenerator implements IShadowGenerator {
  9554. /**
  9555. * Shadow generator mode None: no filtering applied.
  9556. */
  9557. static readonly FILTER_NONE: number;
  9558. /**
  9559. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9561. */
  9562. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9563. /**
  9564. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9565. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9566. */
  9567. static readonly FILTER_POISSONSAMPLING: number;
  9568. /**
  9569. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9570. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9571. */
  9572. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9575. * edge artifacts on steep falloff.
  9576. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9577. */
  9578. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9579. /**
  9580. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9581. * edge artifacts on steep falloff.
  9582. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9583. */
  9584. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9585. /**
  9586. * Shadow generator mode PCF: Percentage Closer Filtering
  9587. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9588. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9589. */
  9590. static readonly FILTER_PCF: number;
  9591. /**
  9592. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9593. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9594. * Contact Hardening
  9595. */
  9596. static readonly FILTER_PCSS: number;
  9597. /**
  9598. * Reserved for PCF and PCSS
  9599. * Highest Quality.
  9600. *
  9601. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9602. *
  9603. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9604. */
  9605. static readonly QUALITY_HIGH: number;
  9606. /**
  9607. * Reserved for PCF and PCSS
  9608. * Good tradeoff for quality/perf cross devices
  9609. *
  9610. * Execute PCF on a 3*3 kernel.
  9611. *
  9612. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9613. */
  9614. static readonly QUALITY_MEDIUM: number;
  9615. /**
  9616. * Reserved for PCF and PCSS
  9617. * The lowest quality but the fastest.
  9618. *
  9619. * Execute PCF on a 1*1 kernel.
  9620. *
  9621. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9622. */
  9623. static readonly QUALITY_LOW: number;
  9624. /** Gets or sets the custom shader name to use */
  9625. customShaderOptions: ICustomShaderOptions;
  9626. /**
  9627. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9628. */
  9629. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9630. /**
  9631. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9632. */
  9633. onAfterShadowMapRenderObservable: Observable<Effect>;
  9634. /**
  9635. * Observable triggered before a mesh is rendered in the shadow map.
  9636. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9637. */
  9638. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9639. /**
  9640. * Observable triggered after a mesh is rendered in the shadow map.
  9641. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9642. */
  9643. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9644. private _bias;
  9645. /**
  9646. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9647. */
  9648. /**
  9649. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9650. */
  9651. bias: number;
  9652. private _normalBias;
  9653. /**
  9654. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9655. */
  9656. /**
  9657. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9658. */
  9659. normalBias: number;
  9660. private _blurBoxOffset;
  9661. /**
  9662. * Gets the blur box offset: offset applied during the blur pass.
  9663. * Only useful if useKernelBlur = false
  9664. */
  9665. /**
  9666. * Sets the blur box offset: offset applied during the blur pass.
  9667. * Only useful if useKernelBlur = false
  9668. */
  9669. blurBoxOffset: number;
  9670. private _blurScale;
  9671. /**
  9672. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9673. * 2 means half of the size.
  9674. */
  9675. /**
  9676. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9677. * 2 means half of the size.
  9678. */
  9679. blurScale: number;
  9680. private _blurKernel;
  9681. /**
  9682. * Gets the blur kernel: kernel size of the blur pass.
  9683. * Only useful if useKernelBlur = true
  9684. */
  9685. /**
  9686. * Sets the blur kernel: kernel size of the blur pass.
  9687. * Only useful if useKernelBlur = true
  9688. */
  9689. blurKernel: number;
  9690. private _useKernelBlur;
  9691. /**
  9692. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9693. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9694. */
  9695. /**
  9696. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9697. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9698. */
  9699. useKernelBlur: boolean;
  9700. private _depthScale;
  9701. /**
  9702. * Gets the depth scale used in ESM mode.
  9703. */
  9704. /**
  9705. * Sets the depth scale used in ESM mode.
  9706. * This can override the scale stored on the light.
  9707. */
  9708. depthScale: number;
  9709. private _filter;
  9710. /**
  9711. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9712. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9713. */
  9714. /**
  9715. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9716. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9717. */
  9718. filter: number;
  9719. /**
  9720. * Gets if the current filter is set to Poisson Sampling.
  9721. */
  9722. /**
  9723. * Sets the current filter to Poisson Sampling.
  9724. */
  9725. usePoissonSampling: boolean;
  9726. /**
  9727. * Gets if the current filter is set to ESM.
  9728. */
  9729. /**
  9730. * Sets the current filter is to ESM.
  9731. */
  9732. useExponentialShadowMap: boolean;
  9733. /**
  9734. * Gets if the current filter is set to filtered ESM.
  9735. */
  9736. /**
  9737. * Gets if the current filter is set to filtered ESM.
  9738. */
  9739. useBlurExponentialShadowMap: boolean;
  9740. /**
  9741. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9742. * exponential to prevent steep falloff artifacts).
  9743. */
  9744. /**
  9745. * Sets the current filter to "close ESM" (using the inverse of the
  9746. * exponential to prevent steep falloff artifacts).
  9747. */
  9748. useCloseExponentialShadowMap: boolean;
  9749. /**
  9750. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. /**
  9754. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9755. * exponential to prevent steep falloff artifacts).
  9756. */
  9757. useBlurCloseExponentialShadowMap: boolean;
  9758. /**
  9759. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9760. */
  9761. /**
  9762. * Sets the current filter to "PCF" (percentage closer filtering).
  9763. */
  9764. usePercentageCloserFiltering: boolean;
  9765. private _filteringQuality;
  9766. /**
  9767. * Gets the PCF or PCSS Quality.
  9768. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9769. */
  9770. /**
  9771. * Sets the PCF or PCSS Quality.
  9772. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9773. */
  9774. filteringQuality: number;
  9775. /**
  9776. * Gets if the current filter is set to "PCSS" (contact hardening).
  9777. */
  9778. /**
  9779. * Sets the current filter to "PCSS" (contact hardening).
  9780. */
  9781. useContactHardeningShadow: boolean;
  9782. private _contactHardeningLightSizeUVRatio;
  9783. /**
  9784. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9785. * Using a ratio helps keeping shape stability independently of the map size.
  9786. *
  9787. * It does not account for the light projection as it was having too much
  9788. * instability during the light setup or during light position changes.
  9789. *
  9790. * Only valid if useContactHardeningShadow is true.
  9791. */
  9792. /**
  9793. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9794. * Using a ratio helps keeping shape stability independently of the map size.
  9795. *
  9796. * It does not account for the light projection as it was having too much
  9797. * instability during the light setup or during light position changes.
  9798. *
  9799. * Only valid if useContactHardeningShadow is true.
  9800. */
  9801. contactHardeningLightSizeUVRatio: number;
  9802. private _darkness;
  9803. /** Gets or sets the actual darkness of a shadow */
  9804. darkness: number;
  9805. /**
  9806. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9807. * 0 means strongest and 1 would means no shadow.
  9808. * @returns the darkness.
  9809. */
  9810. getDarkness(): number;
  9811. /**
  9812. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9813. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9814. * @returns the shadow generator allowing fluent coding.
  9815. */
  9816. setDarkness(darkness: number): ShadowGenerator;
  9817. private _transparencyShadow;
  9818. /** Gets or sets the ability to have transparent shadow */
  9819. transparencyShadow: boolean;
  9820. /**
  9821. * Sets the ability to have transparent shadow (boolean).
  9822. * @param transparent True if transparent else False
  9823. * @returns the shadow generator allowing fluent coding
  9824. */
  9825. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9826. private _shadowMap;
  9827. private _shadowMap2;
  9828. /**
  9829. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9830. * @returns The render target texture if present otherwise, null
  9831. */
  9832. getShadowMap(): Nullable<RenderTargetTexture>;
  9833. /**
  9834. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9835. * @returns The render target texture if the shadow map is present otherwise, null
  9836. */
  9837. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9838. /**
  9839. * Gets the class name of that object
  9840. * @returns "ShadowGenerator"
  9841. */
  9842. getClassName(): string;
  9843. /**
  9844. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9845. * @param mesh Mesh to add
  9846. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9847. * @returns the Shadow Generator itself
  9848. */
  9849. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9850. /**
  9851. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9852. * @param mesh Mesh to remove
  9853. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9854. * @returns the Shadow Generator itself
  9855. */
  9856. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9857. /**
  9858. * Controls the extent to which the shadows fade out at the edge of the frustum
  9859. * Used only by directionals and spots
  9860. */
  9861. frustumEdgeFalloff: number;
  9862. private _light;
  9863. /**
  9864. * Returns the associated light object.
  9865. * @returns the light generating the shadow
  9866. */
  9867. getLight(): IShadowLight;
  9868. /**
  9869. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9870. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9871. * It might on the other hand introduce peter panning.
  9872. */
  9873. forceBackFacesOnly: boolean;
  9874. private _scene;
  9875. private _lightDirection;
  9876. private _effect;
  9877. private _viewMatrix;
  9878. private _projectionMatrix;
  9879. private _transformMatrix;
  9880. private _cachedPosition;
  9881. private _cachedDirection;
  9882. private _cachedDefines;
  9883. private _currentRenderID;
  9884. private _boxBlurPostprocess;
  9885. private _kernelBlurXPostprocess;
  9886. private _kernelBlurYPostprocess;
  9887. private _blurPostProcesses;
  9888. private _mapSize;
  9889. private _currentFaceIndex;
  9890. private _currentFaceIndexCache;
  9891. private _textureType;
  9892. private _defaultTextureMatrix;
  9893. private _storedUniqueId;
  9894. /** @hidden */
  9895. static _SceneComponentInitialization: (scene: Scene) => void;
  9896. /**
  9897. * Creates a ShadowGenerator object.
  9898. * A ShadowGenerator is the required tool to use the shadows.
  9899. * Each light casting shadows needs to use its own ShadowGenerator.
  9900. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9901. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9902. * @param light The light object generating the shadows.
  9903. * @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.
  9904. */
  9905. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9906. private _initializeGenerator;
  9907. private _initializeShadowMap;
  9908. private _initializeBlurRTTAndPostProcesses;
  9909. private _renderForShadowMap;
  9910. private _renderSubMeshForShadowMap;
  9911. private _applyFilterValues;
  9912. /**
  9913. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9914. * @param onCompiled Callback triggered at the and of the effects compilation
  9915. * @param options Sets of optional options forcing the compilation with different modes
  9916. */
  9917. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9918. useInstances: boolean;
  9919. }>): void;
  9920. /**
  9921. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9922. * @param options Sets of optional options forcing the compilation with different modes
  9923. * @returns A promise that resolves when the compilation completes
  9924. */
  9925. forceCompilationAsync(options?: Partial<{
  9926. useInstances: boolean;
  9927. }>): Promise<void>;
  9928. /**
  9929. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9930. * @param subMesh The submesh we want to render in the shadow map
  9931. * @param useInstances Defines wether will draw in the map using instances
  9932. * @returns true if ready otherwise, false
  9933. */
  9934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9935. /**
  9936. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9937. * @param defines Defines of the material we want to update
  9938. * @param lightIndex Index of the light in the enabled light list of the material
  9939. */
  9940. prepareDefines(defines: any, lightIndex: number): void;
  9941. /**
  9942. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9943. * defined in the generator but impacting the effect).
  9944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9945. * @param effect The effect we are binfing the information for
  9946. */
  9947. bindShadowLight(lightIndex: string, effect: Effect): void;
  9948. /**
  9949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9950. * (eq to shadow prjection matrix * light transform matrix)
  9951. * @returns The transform matrix used to create the shadow map
  9952. */
  9953. getTransformMatrix(): Matrix;
  9954. /**
  9955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9956. * Cube and 2D textures for instance.
  9957. */
  9958. recreateShadowMap(): void;
  9959. private _disposeBlurPostProcesses;
  9960. private _disposeRTTandPostProcesses;
  9961. /**
  9962. * Disposes the ShadowGenerator.
  9963. * Returns nothing.
  9964. */
  9965. dispose(): void;
  9966. /**
  9967. * Serializes the shadow generator setup to a json object.
  9968. * @returns The serialized JSON object
  9969. */
  9970. serialize(): any;
  9971. /**
  9972. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9973. * @param parsedShadowGenerator The JSON object to parse
  9974. * @param scene The scene to create the shadow map for
  9975. * @returns The parsed shadow generator
  9976. */
  9977. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9978. }
  9979. }
  9980. declare module "babylonjs/Lights/light" {
  9981. import { Nullable } from "babylonjs/types";
  9982. import { Scene } from "babylonjs/scene";
  9983. import { Vector3 } from "babylonjs/Maths/math.vector";
  9984. import { Color3 } from "babylonjs/Maths/math.color";
  9985. import { Node } from "babylonjs/node";
  9986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9987. import { Effect } from "babylonjs/Materials/effect";
  9988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9989. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9990. /**
  9991. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9992. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9993. * 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.
  9994. */
  9995. export abstract class Light extends Node {
  9996. /**
  9997. * Falloff Default: light is falling off following the material specification:
  9998. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9999. */
  10000. static readonly FALLOFF_DEFAULT: number;
  10001. /**
  10002. * Falloff Physical: light is falling off following the inverse squared distance law.
  10003. */
  10004. static readonly FALLOFF_PHYSICAL: number;
  10005. /**
  10006. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10007. * to enhance interoperability with other engines.
  10008. */
  10009. static readonly FALLOFF_GLTF: number;
  10010. /**
  10011. * Falloff Standard: light is falling off like in the standard material
  10012. * to enhance interoperability with other materials.
  10013. */
  10014. static readonly FALLOFF_STANDARD: number;
  10015. /**
  10016. * If every light affecting the material is in this lightmapMode,
  10017. * material.lightmapTexture adds or multiplies
  10018. * (depends on material.useLightmapAsShadowmap)
  10019. * after every other light calculations.
  10020. */
  10021. static readonly LIGHTMAP_DEFAULT: number;
  10022. /**
  10023. * material.lightmapTexture as only diffuse lighting from this light
  10024. * adds only specular lighting from this light
  10025. * adds dynamic shadows
  10026. */
  10027. static readonly LIGHTMAP_SPECULAR: number;
  10028. /**
  10029. * material.lightmapTexture as only lighting
  10030. * no light calculation from this light
  10031. * only adds dynamic shadows from this light
  10032. */
  10033. static readonly LIGHTMAP_SHADOWSONLY: number;
  10034. /**
  10035. * Each light type uses the default quantity according to its type:
  10036. * point/spot lights use luminous intensity
  10037. * directional lights use illuminance
  10038. */
  10039. static readonly INTENSITYMODE_AUTOMATIC: number;
  10040. /**
  10041. * lumen (lm)
  10042. */
  10043. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10044. /**
  10045. * candela (lm/sr)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10048. /**
  10049. * lux (lm/m^2)
  10050. */
  10051. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10052. /**
  10053. * nit (cd/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINANCE: number;
  10056. /**
  10057. * Light type const id of the point light.
  10058. */
  10059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10060. /**
  10061. * Light type const id of the directional light.
  10062. */
  10063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10064. /**
  10065. * Light type const id of the spot light.
  10066. */
  10067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10068. /**
  10069. * Light type const id of the hemispheric light.
  10070. */
  10071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10072. /**
  10073. * Diffuse gives the basic color to an object.
  10074. */
  10075. diffuse: Color3;
  10076. /**
  10077. * Specular produces a highlight color on an object.
  10078. * Note: This is note affecting PBR materials.
  10079. */
  10080. specular: Color3;
  10081. /**
  10082. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10083. * falling off base on range or angle.
  10084. * This can be set to any values in Light.FALLOFF_x.
  10085. *
  10086. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10087. * other types of materials.
  10088. */
  10089. falloffType: number;
  10090. /**
  10091. * Strength of the light.
  10092. * Note: By default it is define in the framework own unit.
  10093. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10094. */
  10095. intensity: number;
  10096. private _range;
  10097. protected _inverseSquaredRange: number;
  10098. /**
  10099. * Defines how far from the source the light is impacting in scene units.
  10100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10101. */
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. range: number;
  10107. /**
  10108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10109. * of light.
  10110. */
  10111. private _photometricScale;
  10112. private _intensityMode;
  10113. /**
  10114. * Gets the photometric scale used to interpret the intensity.
  10115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10116. */
  10117. /**
  10118. * Sets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. intensityMode: number;
  10122. private _radius;
  10123. /**
  10124. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10125. */
  10126. /**
  10127. * sets the light radius used by PBR Materials to simulate soft area lights.
  10128. */
  10129. radius: number;
  10130. private _renderPriority;
  10131. /**
  10132. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10133. * exceeding the number allowed of the materials.
  10134. */
  10135. renderPriority: number;
  10136. private _shadowEnabled;
  10137. /**
  10138. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. /**
  10142. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. shadowEnabled: boolean;
  10146. private _includedOnlyMeshes;
  10147. /**
  10148. * Gets the only meshes impacted by this light.
  10149. */
  10150. /**
  10151. * Sets the only meshes impacted by this light.
  10152. */
  10153. includedOnlyMeshes: AbstractMesh[];
  10154. private _excludedMeshes;
  10155. /**
  10156. * Gets the meshes not impacted by this light.
  10157. */
  10158. /**
  10159. * Sets the meshes not impacted by this light.
  10160. */
  10161. excludedMeshes: AbstractMesh[];
  10162. private _excludeWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are not impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. excludeWithLayerMask: number;
  10172. private _includeOnlyWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. includeOnlyWithLayerMask: number;
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. /**
  10187. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10188. */
  10189. lightmapMode: number;
  10190. /**
  10191. * Shadow generator associted to the light.
  10192. * @hidden Internal use only.
  10193. */
  10194. _shadowGenerator: Nullable<IShadowGenerator>;
  10195. /**
  10196. * @hidden Internal use only.
  10197. */
  10198. _excludedMeshesIds: string[];
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _includedOnlyMeshesIds: string[];
  10203. /**
  10204. * The current light unifom buffer.
  10205. * @hidden Internal use only.
  10206. */
  10207. _uniformBuffer: UniformBuffer;
  10208. /** @hidden */
  10209. _renderId: number;
  10210. /**
  10211. * Creates a Light object in the scene.
  10212. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10213. * @param name The firendly name of the light
  10214. * @param scene The scene the light belongs too
  10215. */
  10216. constructor(name: string, scene: Scene);
  10217. protected abstract _buildUniformLayout(): void;
  10218. /**
  10219. * Sets the passed Effect "effect" with the Light information.
  10220. * @param effect The effect to update
  10221. * @param lightIndex The index of the light in the effect to update
  10222. * @returns The light
  10223. */
  10224. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10225. /**
  10226. * Sets the passed Effect "effect" with the Light information.
  10227. * @param effect The effect to update
  10228. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10229. * @returns The light
  10230. */
  10231. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10232. /**
  10233. * Returns the string "Light".
  10234. * @returns the class name
  10235. */
  10236. getClassName(): string;
  10237. /** @hidden */
  10238. readonly _isLight: boolean;
  10239. /**
  10240. * Converts the light information to a readable string for debug purpose.
  10241. * @param fullDetails Supports for multiple levels of logging within scene loading
  10242. * @returns the human readable light info
  10243. */
  10244. toString(fullDetails?: boolean): string;
  10245. /** @hidden */
  10246. protected _syncParentEnabledState(): void;
  10247. /**
  10248. * Set the enabled state of this node.
  10249. * @param value - the new enabled state
  10250. */
  10251. setEnabled(value: boolean): void;
  10252. /**
  10253. * Returns the Light associated shadow generator if any.
  10254. * @return the associated shadow generator.
  10255. */
  10256. getShadowGenerator(): Nullable<IShadowGenerator>;
  10257. /**
  10258. * Returns a Vector3, the absolute light position in the World.
  10259. * @returns the world space position of the light
  10260. */
  10261. getAbsolutePosition(): Vector3;
  10262. /**
  10263. * Specifies if the light will affect the passed mesh.
  10264. * @param mesh The mesh to test against the light
  10265. * @return true the mesh is affected otherwise, false.
  10266. */
  10267. canAffectMesh(mesh: AbstractMesh): boolean;
  10268. /**
  10269. * Sort function to order lights for rendering.
  10270. * @param a First Light object to compare to second.
  10271. * @param b Second Light object to compare first.
  10272. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10273. */
  10274. static CompareLightsPriority(a: Light, b: Light): number;
  10275. /**
  10276. * Releases resources associated with this node.
  10277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10279. */
  10280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10281. /**
  10282. * Returns the light type ID (integer).
  10283. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10284. */
  10285. getTypeID(): number;
  10286. /**
  10287. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10288. * @returns the scaled intensity in intensity mode unit
  10289. */
  10290. getScaledIntensity(): number;
  10291. /**
  10292. * Returns a new Light object, named "name", from the current one.
  10293. * @param name The name of the cloned light
  10294. * @returns the new created light
  10295. */
  10296. clone(name: string): Nullable<Light>;
  10297. /**
  10298. * Serializes the current light into a Serialization object.
  10299. * @returns the serialized object.
  10300. */
  10301. serialize(): any;
  10302. /**
  10303. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10304. * This new light is named "name" and added to the passed scene.
  10305. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10306. * @param name The friendly name of the light
  10307. * @param scene The scene the new light will belong to
  10308. * @returns the constructor function
  10309. */
  10310. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10311. /**
  10312. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10313. * @param parsedLight The JSON representation of the light
  10314. * @param scene The scene to create the parsed light in
  10315. * @returns the created light after parsing
  10316. */
  10317. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10318. private _hookArrayForExcluded;
  10319. private _hookArrayForIncludedOnly;
  10320. private _resyncMeshes;
  10321. /**
  10322. * Forces the meshes to update their light related information in their rendering used effects
  10323. * @hidden Internal Use Only
  10324. */
  10325. _markMeshesAsLightDirty(): void;
  10326. /**
  10327. * Recomputes the cached photometric scale if needed.
  10328. */
  10329. private _computePhotometricScale;
  10330. /**
  10331. * Returns the Photometric Scale according to the light type and intensity mode.
  10332. */
  10333. private _getPhotometricScale;
  10334. /**
  10335. * Reorder the light in the scene according to their defined priority.
  10336. * @hidden Internal Use Only
  10337. */
  10338. _reorderLightsInScene(): void;
  10339. /**
  10340. * Prepares the list of defines specific to the light type.
  10341. * @param defines the list of defines
  10342. * @param lightIndex defines the index of the light for the effect
  10343. */
  10344. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10345. }
  10346. }
  10347. declare module "babylonjs/Actions/action" {
  10348. import { Observable } from "babylonjs/Misc/observable";
  10349. import { Condition } from "babylonjs/Actions/condition";
  10350. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10351. import { ActionManager } from "babylonjs/Actions/actionManager";
  10352. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10353. /**
  10354. * Interface used to define Action
  10355. */
  10356. export interface IAction {
  10357. /**
  10358. * Trigger for the action
  10359. */
  10360. trigger: number;
  10361. /** Options of the trigger */
  10362. triggerOptions: any;
  10363. /**
  10364. * Gets the trigger parameters
  10365. * @returns the trigger parameters
  10366. */
  10367. getTriggerParameter(): any;
  10368. /**
  10369. * Internal only - executes current action event
  10370. * @hidden
  10371. */
  10372. _executeCurrent(evt?: ActionEvent): void;
  10373. /**
  10374. * Serialize placeholder for child classes
  10375. * @param parent of child
  10376. * @returns the serialized object
  10377. */
  10378. serialize(parent: any): any;
  10379. /**
  10380. * Internal only
  10381. * @hidden
  10382. */
  10383. _prepare(): void;
  10384. /**
  10385. * Internal only - manager for action
  10386. * @hidden
  10387. */
  10388. _actionManager: AbstractActionManager;
  10389. /**
  10390. * Adds action to chain of actions, may be a DoNothingAction
  10391. * @param action defines the next action to execute
  10392. * @returns The action passed in
  10393. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10394. */
  10395. then(action: IAction): IAction;
  10396. }
  10397. /**
  10398. * The action to be carried out following a trigger
  10399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10400. */
  10401. export class Action implements IAction {
  10402. /** the trigger, with or without parameters, for the action */
  10403. triggerOptions: any;
  10404. /**
  10405. * Trigger for the action
  10406. */
  10407. trigger: number;
  10408. /**
  10409. * Internal only - manager for action
  10410. * @hidden
  10411. */
  10412. _actionManager: ActionManager;
  10413. private _nextActiveAction;
  10414. private _child;
  10415. private _condition?;
  10416. private _triggerParameter;
  10417. /**
  10418. * An event triggered prior to action being executed.
  10419. */
  10420. onBeforeExecuteObservable: Observable<Action>;
  10421. /**
  10422. * Creates a new Action
  10423. * @param triggerOptions the trigger, with or without parameters, for the action
  10424. * @param condition an optional determinant of action
  10425. */
  10426. constructor(
  10427. /** the trigger, with or without parameters, for the action */
  10428. triggerOptions: any, condition?: Condition);
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. _prepare(): void;
  10434. /**
  10435. * Gets the trigger parameters
  10436. * @returns the trigger parameters
  10437. */
  10438. getTriggerParameter(): any;
  10439. /**
  10440. * Internal only - executes current action event
  10441. * @hidden
  10442. */
  10443. _executeCurrent(evt?: ActionEvent): void;
  10444. /**
  10445. * Execute placeholder for child classes
  10446. * @param evt optional action event
  10447. */
  10448. execute(evt?: ActionEvent): void;
  10449. /**
  10450. * Skips to next active action
  10451. */
  10452. skipToNextActiveAction(): void;
  10453. /**
  10454. * Adds action to chain of actions, may be a DoNothingAction
  10455. * @param action defines the next action to execute
  10456. * @returns The action passed in
  10457. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10458. */
  10459. then(action: Action): Action;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _getProperty(propertyPath: string): string;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. _getEffectiveTarget(target: any, propertyPath: string): any;
  10470. /**
  10471. * Serialize placeholder for child classes
  10472. * @param parent of child
  10473. * @returns the serialized object
  10474. */
  10475. serialize(parent: any): any;
  10476. /**
  10477. * Internal only called by serialize
  10478. * @hidden
  10479. */
  10480. protected _serialize(serializedAction: any, parent?: any): any;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. static _SerializeValueAsString: (value: any) => string;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10491. name: string;
  10492. targetType: string;
  10493. value: string;
  10494. };
  10495. }
  10496. }
  10497. declare module "babylonjs/Actions/condition" {
  10498. import { ActionManager } from "babylonjs/Actions/actionManager";
  10499. /**
  10500. * A Condition applied to an Action
  10501. */
  10502. export class Condition {
  10503. /**
  10504. * Internal only - manager for action
  10505. * @hidden
  10506. */
  10507. _actionManager: ActionManager;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _evaluationId: number;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _currentResult: boolean;
  10518. /**
  10519. * Creates a new Condition
  10520. * @param actionManager the manager of the action the condition is applied to
  10521. */
  10522. constructor(actionManager: ActionManager);
  10523. /**
  10524. * Check if the current condition is valid
  10525. * @returns a boolean
  10526. */
  10527. isValid(): boolean;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. _getProperty(propertyPath: string): string;
  10533. /**
  10534. * Internal only
  10535. * @hidden
  10536. */
  10537. _getEffectiveTarget(target: any, propertyPath: string): any;
  10538. /**
  10539. * Serialize placeholder for child classes
  10540. * @returns the serialized object
  10541. */
  10542. serialize(): any;
  10543. /**
  10544. * Internal only
  10545. * @hidden
  10546. */
  10547. protected _serialize(serializedCondition: any): any;
  10548. }
  10549. /**
  10550. * Defines specific conditional operators as extensions of Condition
  10551. */
  10552. export class ValueCondition extends Condition {
  10553. /** path to specify the property of the target the conditional operator uses */
  10554. propertyPath: string;
  10555. /** the value compared by the conditional operator against the current value of the property */
  10556. value: any;
  10557. /** the conditional operator, default ValueCondition.IsEqual */
  10558. operator: number;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. private static _IsEqual;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. private static _IsDifferent;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private static _IsGreater;
  10574. /**
  10575. * Internal only
  10576. * @hidden
  10577. */
  10578. private static _IsLesser;
  10579. /**
  10580. * returns the number for IsEqual
  10581. */
  10582. static readonly IsEqual: number;
  10583. /**
  10584. * Returns the number for IsDifferent
  10585. */
  10586. static readonly IsDifferent: number;
  10587. /**
  10588. * Returns the number for IsGreater
  10589. */
  10590. static readonly IsGreater: number;
  10591. /**
  10592. * Returns the number for IsLesser
  10593. */
  10594. static readonly IsLesser: number;
  10595. /**
  10596. * Internal only The action manager for the condition
  10597. * @hidden
  10598. */
  10599. _actionManager: ActionManager;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. private _target;
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. private _effectiveTarget;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. private _property;
  10615. /**
  10616. * Creates a new ValueCondition
  10617. * @param actionManager manager for the action the condition applies to
  10618. * @param target for the action
  10619. * @param propertyPath path to specify the property of the target the conditional operator uses
  10620. * @param value the value compared by the conditional operator against the current value of the property
  10621. * @param operator the conditional operator, default ValueCondition.IsEqual
  10622. */
  10623. constructor(actionManager: ActionManager, target: any,
  10624. /** path to specify the property of the target the conditional operator uses */
  10625. propertyPath: string,
  10626. /** the value compared by the conditional operator against the current value of the property */
  10627. value: any,
  10628. /** the conditional operator, default ValueCondition.IsEqual */
  10629. operator?: number);
  10630. /**
  10631. * Compares the given value with the property value for the specified conditional operator
  10632. * @returns the result of the comparison
  10633. */
  10634. isValid(): boolean;
  10635. /**
  10636. * Serialize the ValueCondition into a JSON compatible object
  10637. * @returns serialization object
  10638. */
  10639. serialize(): any;
  10640. /**
  10641. * Gets the name of the conditional operator for the ValueCondition
  10642. * @param operator the conditional operator
  10643. * @returns the name
  10644. */
  10645. static GetOperatorName(operator: number): string;
  10646. }
  10647. /**
  10648. * Defines a predicate condition as an extension of Condition
  10649. */
  10650. export class PredicateCondition extends Condition {
  10651. /** defines the predicate function used to validate the condition */
  10652. predicate: () => boolean;
  10653. /**
  10654. * Internal only - manager for action
  10655. * @hidden
  10656. */
  10657. _actionManager: ActionManager;
  10658. /**
  10659. * Creates a new PredicateCondition
  10660. * @param actionManager manager for the action the condition applies to
  10661. * @param predicate defines the predicate function used to validate the condition
  10662. */
  10663. constructor(actionManager: ActionManager,
  10664. /** defines the predicate function used to validate the condition */
  10665. predicate: () => boolean);
  10666. /**
  10667. * @returns the validity of the predicate condition
  10668. */
  10669. isValid(): boolean;
  10670. }
  10671. /**
  10672. * Defines a state condition as an extension of Condition
  10673. */
  10674. export class StateCondition extends Condition {
  10675. /** Value to compare with target state */
  10676. value: string;
  10677. /**
  10678. * Internal only - manager for action
  10679. * @hidden
  10680. */
  10681. _actionManager: ActionManager;
  10682. /**
  10683. * Internal only
  10684. * @hidden
  10685. */
  10686. private _target;
  10687. /**
  10688. * Creates a new StateCondition
  10689. * @param actionManager manager for the action the condition applies to
  10690. * @param target of the condition
  10691. * @param value to compare with target state
  10692. */
  10693. constructor(actionManager: ActionManager, target: any,
  10694. /** Value to compare with target state */
  10695. value: string);
  10696. /**
  10697. * Gets a boolean indicating if the current condition is met
  10698. * @returns the validity of the state
  10699. */
  10700. isValid(): boolean;
  10701. /**
  10702. * Serialize the StateCondition into a JSON compatible object
  10703. * @returns serialization object
  10704. */
  10705. serialize(): any;
  10706. }
  10707. }
  10708. declare module "babylonjs/Actions/directActions" {
  10709. import { Action } from "babylonjs/Actions/action";
  10710. import { Condition } from "babylonjs/Actions/condition";
  10711. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10712. /**
  10713. * This defines an action responsible to toggle a boolean once triggered.
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10715. */
  10716. export class SwitchBooleanAction extends Action {
  10717. /**
  10718. * The path to the boolean property in the target object
  10719. */
  10720. propertyPath: string;
  10721. private _target;
  10722. private _effectiveTarget;
  10723. private _property;
  10724. /**
  10725. * Instantiate the action
  10726. * @param triggerOptions defines the trigger options
  10727. * @param target defines the object containing the boolean
  10728. * @param propertyPath defines the path to the boolean property in the target object
  10729. * @param condition defines the trigger related conditions
  10730. */
  10731. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10732. /** @hidden */
  10733. _prepare(): void;
  10734. /**
  10735. * Execute the action toggle the boolean value.
  10736. */
  10737. execute(): void;
  10738. /**
  10739. * Serializes the actions and its related information.
  10740. * @param parent defines the object to serialize in
  10741. * @returns the serialized object
  10742. */
  10743. serialize(parent: any): any;
  10744. }
  10745. /**
  10746. * This defines an action responsible to set a the state field of the target
  10747. * to a desired value once triggered.
  10748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10749. */
  10750. export class SetStateAction extends Action {
  10751. /**
  10752. * The value to store in the state field.
  10753. */
  10754. value: string;
  10755. private _target;
  10756. /**
  10757. * Instantiate the action
  10758. * @param triggerOptions defines the trigger options
  10759. * @param target defines the object containing the state property
  10760. * @param value defines the value to store in the state field
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10764. /**
  10765. * Execute the action and store the value on the target state property.
  10766. */
  10767. execute(): void;
  10768. /**
  10769. * Serializes the actions and its related information.
  10770. * @param parent defines the object to serialize in
  10771. * @returns the serialized object
  10772. */
  10773. serialize(parent: any): any;
  10774. }
  10775. /**
  10776. * This defines an action responsible to set a property of the target
  10777. * to a desired value once triggered.
  10778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10779. */
  10780. export class SetValueAction extends Action {
  10781. /**
  10782. * The path of the property to set in the target.
  10783. */
  10784. propertyPath: string;
  10785. /**
  10786. * The value to set in the property
  10787. */
  10788. value: any;
  10789. private _target;
  10790. private _effectiveTarget;
  10791. private _property;
  10792. /**
  10793. * Instantiate the action
  10794. * @param triggerOptions defines the trigger options
  10795. * @param target defines the object containing the property
  10796. * @param propertyPath defines the path of the property to set in the target
  10797. * @param value defines the value to set in the property
  10798. * @param condition defines the trigger related conditions
  10799. */
  10800. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10801. /** @hidden */
  10802. _prepare(): void;
  10803. /**
  10804. * Execute the action and set the targetted property to the desired value.
  10805. */
  10806. execute(): void;
  10807. /**
  10808. * Serializes the actions and its related information.
  10809. * @param parent defines the object to serialize in
  10810. * @returns the serialized object
  10811. */
  10812. serialize(parent: any): any;
  10813. }
  10814. /**
  10815. * This defines an action responsible to increment the target value
  10816. * to a desired value once triggered.
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10818. */
  10819. export class IncrementValueAction extends Action {
  10820. /**
  10821. * The path of the property to increment in the target.
  10822. */
  10823. propertyPath: string;
  10824. /**
  10825. * The value we should increment the property by.
  10826. */
  10827. value: any;
  10828. private _target;
  10829. private _effectiveTarget;
  10830. private _property;
  10831. /**
  10832. * Instantiate the action
  10833. * @param triggerOptions defines the trigger options
  10834. * @param target defines the object containing the property
  10835. * @param propertyPath defines the path of the property to increment in the target
  10836. * @param value defines the value value we should increment the property by
  10837. * @param condition defines the trigger related conditions
  10838. */
  10839. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10840. /** @hidden */
  10841. _prepare(): void;
  10842. /**
  10843. * Execute the action and increment the target of the value amount.
  10844. */
  10845. execute(): void;
  10846. /**
  10847. * Serializes the actions and its related information.
  10848. * @param parent defines the object to serialize in
  10849. * @returns the serialized object
  10850. */
  10851. serialize(parent: any): any;
  10852. }
  10853. /**
  10854. * This defines an action responsible to start an animation once triggered.
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10856. */
  10857. export class PlayAnimationAction extends Action {
  10858. /**
  10859. * Where the animation should start (animation frame)
  10860. */
  10861. from: number;
  10862. /**
  10863. * Where the animation should stop (animation frame)
  10864. */
  10865. to: number;
  10866. /**
  10867. * Define if the animation should loop or stop after the first play.
  10868. */
  10869. loop?: boolean;
  10870. private _target;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param target defines the target animation or animation name
  10875. * @param from defines from where the animation should start (animation frame)
  10876. * @param end defines where the animation should stop (animation frame)
  10877. * @param loop defines if the animation should loop or stop after the first play
  10878. * @param condition defines the trigger related conditions
  10879. */
  10880. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10881. /** @hidden */
  10882. _prepare(): void;
  10883. /**
  10884. * Execute the action and play the animation.
  10885. */
  10886. execute(): void;
  10887. /**
  10888. * Serializes the actions and its related information.
  10889. * @param parent defines the object to serialize in
  10890. * @returns the serialized object
  10891. */
  10892. serialize(parent: any): any;
  10893. }
  10894. /**
  10895. * This defines an action responsible to stop an animation once triggered.
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10897. */
  10898. export class StopAnimationAction extends Action {
  10899. private _target;
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param target defines the target animation or animation name
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, target: any, condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and stop the animation.
  10911. */
  10912. execute(): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible that does nothing once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class DoNothingAction extends Action {
  10925. /**
  10926. * Instantiate the action
  10927. * @param triggerOptions defines the trigger options
  10928. * @param condition defines the trigger related conditions
  10929. */
  10930. constructor(triggerOptions?: any, condition?: Condition);
  10931. /**
  10932. * Execute the action and do nothing.
  10933. */
  10934. execute(): void;
  10935. /**
  10936. * Serializes the actions and its related information.
  10937. * @param parent defines the object to serialize in
  10938. * @returns the serialized object
  10939. */
  10940. serialize(parent: any): any;
  10941. }
  10942. /**
  10943. * This defines an action responsible to trigger several actions once triggered.
  10944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10945. */
  10946. export class CombineAction extends Action {
  10947. /**
  10948. * The list of aggregated animations to run.
  10949. */
  10950. children: Action[];
  10951. /**
  10952. * Instantiate the action
  10953. * @param triggerOptions defines the trigger options
  10954. * @param children defines the list of aggregated animations to run
  10955. * @param condition defines the trigger related conditions
  10956. */
  10957. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10958. /** @hidden */
  10959. _prepare(): void;
  10960. /**
  10961. * Execute the action and executes all the aggregated actions.
  10962. */
  10963. execute(evt: ActionEvent): void;
  10964. /**
  10965. * Serializes the actions and its related information.
  10966. * @param parent defines the object to serialize in
  10967. * @returns the serialized object
  10968. */
  10969. serialize(parent: any): any;
  10970. }
  10971. /**
  10972. * This defines an action responsible to run code (external event) once triggered.
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10974. */
  10975. export class ExecuteCodeAction extends Action {
  10976. /**
  10977. * The callback function to run.
  10978. */
  10979. func: (evt: ActionEvent) => void;
  10980. /**
  10981. * Instantiate the action
  10982. * @param triggerOptions defines the trigger options
  10983. * @param func defines the callback function to run
  10984. * @param condition defines the trigger related conditions
  10985. */
  10986. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10987. /**
  10988. * Execute the action and run the attached code.
  10989. */
  10990. execute(evt: ActionEvent): void;
  10991. }
  10992. /**
  10993. * This defines an action responsible to set the parent property of the target once triggered.
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10995. */
  10996. export class SetParentAction extends Action {
  10997. private _parent;
  10998. private _target;
  10999. /**
  11000. * Instantiate the action
  11001. * @param triggerOptions defines the trigger options
  11002. * @param target defines the target containing the parent property
  11003. * @param parent defines from where the animation should start (animation frame)
  11004. * @param condition defines the trigger related conditions
  11005. */
  11006. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11007. /** @hidden */
  11008. _prepare(): void;
  11009. /**
  11010. * Execute the action and set the parent property.
  11011. */
  11012. execute(): void;
  11013. /**
  11014. * Serializes the actions and its related information.
  11015. * @param parent defines the object to serialize in
  11016. * @returns the serialized object
  11017. */
  11018. serialize(parent: any): any;
  11019. }
  11020. }
  11021. declare module "babylonjs/Actions/actionManager" {
  11022. import { Nullable } from "babylonjs/types";
  11023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11024. import { Scene } from "babylonjs/scene";
  11025. import { IAction } from "babylonjs/Actions/action";
  11026. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11027. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11028. /**
  11029. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11030. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11032. */
  11033. export class ActionManager extends AbstractActionManager {
  11034. /**
  11035. * Nothing
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly NothingTrigger: number;
  11039. /**
  11040. * On pick
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPickTrigger: number;
  11044. /**
  11045. * On left pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnLeftPickTrigger: number;
  11049. /**
  11050. * On right pick
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnRightPickTrigger: number;
  11054. /**
  11055. * On center pick
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnCenterPickTrigger: number;
  11059. /**
  11060. * On pick down
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnPickDownTrigger: number;
  11064. /**
  11065. * On double pick
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnDoublePickTrigger: number;
  11069. /**
  11070. * On pick up
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11072. */
  11073. static readonly OnPickUpTrigger: number;
  11074. /**
  11075. * On pick out.
  11076. * This trigger will only be raised if you also declared a OnPickDown
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnPickOutTrigger: number;
  11080. /**
  11081. * On long press
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnLongPressTrigger: number;
  11085. /**
  11086. * On pointer over
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPointerOverTrigger: number;
  11090. /**
  11091. * On pointer out
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnPointerOutTrigger: number;
  11095. /**
  11096. * On every frame
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnEveryFrameTrigger: number;
  11100. /**
  11101. * On intersection enter
  11102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11103. */
  11104. static readonly OnIntersectionEnterTrigger: number;
  11105. /**
  11106. * On intersection exit
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11108. */
  11109. static readonly OnIntersectionExitTrigger: number;
  11110. /**
  11111. * On key down
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11113. */
  11114. static readonly OnKeyDownTrigger: number;
  11115. /**
  11116. * On key up
  11117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11118. */
  11119. static readonly OnKeyUpTrigger: number;
  11120. private _scene;
  11121. /**
  11122. * Creates a new action manager
  11123. * @param scene defines the hosting scene
  11124. */
  11125. constructor(scene: Scene);
  11126. /**
  11127. * Releases all associated resources
  11128. */
  11129. dispose(): void;
  11130. /**
  11131. * Gets hosting scene
  11132. * @returns the hosting scene
  11133. */
  11134. getScene(): Scene;
  11135. /**
  11136. * Does this action manager handles actions of any of the given triggers
  11137. * @param triggers defines the triggers to be tested
  11138. * @return a boolean indicating whether one (or more) of the triggers is handled
  11139. */
  11140. hasSpecificTriggers(triggers: number[]): boolean;
  11141. /**
  11142. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11143. * speed.
  11144. * @param triggerA defines the trigger to be tested
  11145. * @param triggerB defines the trigger to be tested
  11146. * @return a boolean indicating whether one (or more) of the triggers is handled
  11147. */
  11148. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11149. /**
  11150. * Does this action manager handles actions of a given trigger
  11151. * @param trigger defines the trigger to be tested
  11152. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11153. * @return whether the trigger is handled
  11154. */
  11155. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11156. /**
  11157. * Does this action manager has pointer triggers
  11158. */
  11159. readonly hasPointerTriggers: boolean;
  11160. /**
  11161. * Does this action manager has pick triggers
  11162. */
  11163. readonly hasPickTriggers: boolean;
  11164. /**
  11165. * Registers an action to this action manager
  11166. * @param action defines the action to be registered
  11167. * @return the action amended (prepared) after registration
  11168. */
  11169. registerAction(action: IAction): Nullable<IAction>;
  11170. /**
  11171. * Unregisters an action to this action manager
  11172. * @param action defines the action to be unregistered
  11173. * @return a boolean indicating whether the action has been unregistered
  11174. */
  11175. unregisterAction(action: IAction): Boolean;
  11176. /**
  11177. * Process a specific trigger
  11178. * @param trigger defines the trigger to process
  11179. * @param evt defines the event details to be processed
  11180. */
  11181. processTrigger(trigger: number, evt?: IActionEvent): void;
  11182. /** @hidden */
  11183. _getEffectiveTarget(target: any, propertyPath: string): any;
  11184. /** @hidden */
  11185. _getProperty(propertyPath: string): string;
  11186. /**
  11187. * Serialize this manager to a JSON object
  11188. * @param name defines the property name to store this manager
  11189. * @returns a JSON representation of this manager
  11190. */
  11191. serialize(name: string): any;
  11192. /**
  11193. * Creates a new ActionManager from a JSON data
  11194. * @param parsedActions defines the JSON data to read from
  11195. * @param object defines the hosting mesh
  11196. * @param scene defines the hosting scene
  11197. */
  11198. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11199. /**
  11200. * Get a trigger name by index
  11201. * @param trigger defines the trigger index
  11202. * @returns a trigger name
  11203. */
  11204. static GetTriggerName(trigger: number): string;
  11205. }
  11206. }
  11207. declare module "babylonjs/Culling/ray" {
  11208. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11209. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11211. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11212. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11213. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11214. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11215. import { Plane } from "babylonjs/Maths/math.plane";
  11216. /**
  11217. * Class representing a ray with position and direction
  11218. */
  11219. export class Ray {
  11220. /** origin point */
  11221. origin: Vector3;
  11222. /** direction */
  11223. direction: Vector3;
  11224. /** length of the ray */
  11225. length: number;
  11226. private static readonly TmpVector3;
  11227. private _tmpRay;
  11228. /**
  11229. * Creates a new ray
  11230. * @param origin origin point
  11231. * @param direction direction
  11232. * @param length length of the ray
  11233. */
  11234. constructor(
  11235. /** origin point */
  11236. origin: Vector3,
  11237. /** direction */
  11238. direction: Vector3,
  11239. /** length of the ray */
  11240. length?: number);
  11241. /**
  11242. * Checks if the ray intersects a box
  11243. * @param minimum bound of the box
  11244. * @param maximum bound of the box
  11245. * @param intersectionTreshold extra extend to be added to the box in all direction
  11246. * @returns if the box was hit
  11247. */
  11248. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11249. /**
  11250. * Checks if the ray intersects a box
  11251. * @param box the bounding box to check
  11252. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11253. * @returns if the box was hit
  11254. */
  11255. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11256. /**
  11257. * If the ray hits a sphere
  11258. * @param sphere the bounding sphere to check
  11259. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11260. * @returns true if it hits the sphere
  11261. */
  11262. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11263. /**
  11264. * If the ray hits a triange
  11265. * @param vertex0 triangle vertex
  11266. * @param vertex1 triangle vertex
  11267. * @param vertex2 triangle vertex
  11268. * @returns intersection information if hit
  11269. */
  11270. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11271. /**
  11272. * Checks if ray intersects a plane
  11273. * @param plane the plane to check
  11274. * @returns the distance away it was hit
  11275. */
  11276. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11277. /**
  11278. * Calculate the intercept of a ray on a given axis
  11279. * @param axis to check 'x' | 'y' | 'z'
  11280. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11281. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11282. */
  11283. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11284. /**
  11285. * Checks if ray intersects a mesh
  11286. * @param mesh the mesh to check
  11287. * @param fastCheck if only the bounding box should checked
  11288. * @returns picking info of the intersecton
  11289. */
  11290. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11291. /**
  11292. * Checks if ray intersects a mesh
  11293. * @param meshes the meshes to check
  11294. * @param fastCheck if only the bounding box should checked
  11295. * @param results array to store result in
  11296. * @returns Array of picking infos
  11297. */
  11298. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11299. private _comparePickingInfo;
  11300. private static smallnum;
  11301. private static rayl;
  11302. /**
  11303. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11304. * @param sega the first point of the segment to test the intersection against
  11305. * @param segb the second point of the segment to test the intersection against
  11306. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11307. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11308. */
  11309. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11310. /**
  11311. * Update the ray from viewport position
  11312. * @param x position
  11313. * @param y y position
  11314. * @param viewportWidth viewport width
  11315. * @param viewportHeight viewport height
  11316. * @param world world matrix
  11317. * @param view view matrix
  11318. * @param projection projection matrix
  11319. * @returns this ray updated
  11320. */
  11321. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11322. /**
  11323. * Creates a ray with origin and direction of 0,0,0
  11324. * @returns the new ray
  11325. */
  11326. static Zero(): Ray;
  11327. /**
  11328. * Creates a new ray from screen space and viewport
  11329. * @param x position
  11330. * @param y y position
  11331. * @param viewportWidth viewport width
  11332. * @param viewportHeight viewport height
  11333. * @param world world matrix
  11334. * @param view view matrix
  11335. * @param projection projection matrix
  11336. * @returns new ray
  11337. */
  11338. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11339. /**
  11340. * 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
  11341. * transformed to the given world matrix.
  11342. * @param origin The origin point
  11343. * @param end The end point
  11344. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11345. * @returns the new ray
  11346. */
  11347. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11348. /**
  11349. * Transforms a ray by a matrix
  11350. * @param ray ray to transform
  11351. * @param matrix matrix to apply
  11352. * @returns the resulting new ray
  11353. */
  11354. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11355. /**
  11356. * Transforms a ray by a matrix
  11357. * @param ray ray to transform
  11358. * @param matrix matrix to apply
  11359. * @param result ray to store result in
  11360. */
  11361. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11362. /**
  11363. * Unproject a ray from screen space to object space
  11364. * @param sourceX defines the screen space x coordinate to use
  11365. * @param sourceY defines the screen space y coordinate to use
  11366. * @param viewportWidth defines the current width of the viewport
  11367. * @param viewportHeight defines the current height of the viewport
  11368. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11369. * @param view defines the view matrix to use
  11370. * @param projection defines the projection matrix to use
  11371. */
  11372. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11373. }
  11374. /**
  11375. * Type used to define predicate used to select faces when a mesh intersection is detected
  11376. */
  11377. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11378. module "babylonjs/scene" {
  11379. interface Scene {
  11380. /** @hidden */
  11381. _tempPickingRay: Nullable<Ray>;
  11382. /** @hidden */
  11383. _cachedRayForTransform: Ray;
  11384. /** @hidden */
  11385. _pickWithRayInverseMatrix: Matrix;
  11386. /** @hidden */
  11387. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11388. /** @hidden */
  11389. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11390. }
  11391. }
  11392. }
  11393. declare module "babylonjs/sceneComponent" {
  11394. import { Scene } from "babylonjs/scene";
  11395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11397. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11398. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11399. import { Nullable } from "babylonjs/types";
  11400. import { Camera } from "babylonjs/Cameras/camera";
  11401. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11402. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11403. import { AbstractScene } from "babylonjs/abstractScene";
  11404. import { Mesh } from "babylonjs/Meshes/mesh";
  11405. /**
  11406. * Groups all the scene component constants in one place to ease maintenance.
  11407. * @hidden
  11408. */
  11409. export class SceneComponentConstants {
  11410. static readonly NAME_EFFECTLAYER: string;
  11411. static readonly NAME_LAYER: string;
  11412. static readonly NAME_LENSFLARESYSTEM: string;
  11413. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11414. static readonly NAME_PARTICLESYSTEM: string;
  11415. static readonly NAME_GAMEPAD: string;
  11416. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11417. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11418. static readonly NAME_DEPTHRENDERER: string;
  11419. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11420. static readonly NAME_SPRITE: string;
  11421. static readonly NAME_OUTLINERENDERER: string;
  11422. static readonly NAME_PROCEDURALTEXTURE: string;
  11423. static readonly NAME_SHADOWGENERATOR: string;
  11424. static readonly NAME_OCTREE: string;
  11425. static readonly NAME_PHYSICSENGINE: string;
  11426. static readonly NAME_AUDIO: string;
  11427. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11428. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11429. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11430. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11431. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11432. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11433. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11434. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11435. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11436. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11437. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11438. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11439. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11440. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11441. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11442. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11443. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11444. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11445. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11446. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11447. static readonly STEP_AFTERRENDER_AUDIO: number;
  11448. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11449. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11450. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11451. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11452. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11453. static readonly STEP_POINTERMOVE_SPRITE: number;
  11454. static readonly STEP_POINTERDOWN_SPRITE: number;
  11455. static readonly STEP_POINTERUP_SPRITE: number;
  11456. }
  11457. /**
  11458. * This represents a scene component.
  11459. *
  11460. * This is used to decouple the dependency the scene is having on the different workloads like
  11461. * layers, post processes...
  11462. */
  11463. export interface ISceneComponent {
  11464. /**
  11465. * The name of the component. Each component must have a unique name.
  11466. */
  11467. name: string;
  11468. /**
  11469. * The scene the component belongs to.
  11470. */
  11471. scene: Scene;
  11472. /**
  11473. * Register the component to one instance of a scene.
  11474. */
  11475. register(): void;
  11476. /**
  11477. * Rebuilds the elements related to this component in case of
  11478. * context lost for instance.
  11479. */
  11480. rebuild(): void;
  11481. /**
  11482. * Disposes the component and the associated ressources.
  11483. */
  11484. dispose(): void;
  11485. }
  11486. /**
  11487. * This represents a SERIALIZABLE scene component.
  11488. *
  11489. * This extends Scene Component to add Serialization methods on top.
  11490. */
  11491. export interface ISceneSerializableComponent extends ISceneComponent {
  11492. /**
  11493. * Adds all the elements from the container to the scene
  11494. * @param container the container holding the elements
  11495. */
  11496. addFromContainer(container: AbstractScene): void;
  11497. /**
  11498. * Removes all the elements in the container from the scene
  11499. * @param container contains the elements to remove
  11500. * @param dispose if the removed element should be disposed (default: false)
  11501. */
  11502. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11503. /**
  11504. * Serializes the component data to the specified json object
  11505. * @param serializationObject The object to serialize to
  11506. */
  11507. serialize(serializationObject: any): void;
  11508. }
  11509. /**
  11510. * Strong typing of a Mesh related stage step action
  11511. */
  11512. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11513. /**
  11514. * Strong typing of a Evaluate Sub Mesh related stage step action
  11515. */
  11516. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11517. /**
  11518. * Strong typing of a Active Mesh related stage step action
  11519. */
  11520. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11521. /**
  11522. * Strong typing of a Camera related stage step action
  11523. */
  11524. export type CameraStageAction = (camera: Camera) => void;
  11525. /**
  11526. * Strong typing of a Camera Frame buffer related stage step action
  11527. */
  11528. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11529. /**
  11530. * Strong typing of a Render Target related stage step action
  11531. */
  11532. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11533. /**
  11534. * Strong typing of a RenderingGroup related stage step action
  11535. */
  11536. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11537. /**
  11538. * Strong typing of a Mesh Render related stage step action
  11539. */
  11540. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11541. /**
  11542. * Strong typing of a simple stage step action
  11543. */
  11544. export type SimpleStageAction = () => void;
  11545. /**
  11546. * Strong typing of a render target action.
  11547. */
  11548. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11549. /**
  11550. * Strong typing of a pointer move action.
  11551. */
  11552. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11553. /**
  11554. * Strong typing of a pointer up/down action.
  11555. */
  11556. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11557. /**
  11558. * Representation of a stage in the scene (Basically a list of ordered steps)
  11559. * @hidden
  11560. */
  11561. export class Stage<T extends Function> extends Array<{
  11562. index: number;
  11563. component: ISceneComponent;
  11564. action: T;
  11565. }> {
  11566. /**
  11567. * Hide ctor from the rest of the world.
  11568. * @param items The items to add.
  11569. */
  11570. private constructor();
  11571. /**
  11572. * Creates a new Stage.
  11573. * @returns A new instance of a Stage
  11574. */
  11575. static Create<T extends Function>(): Stage<T>;
  11576. /**
  11577. * Registers a step in an ordered way in the targeted stage.
  11578. * @param index Defines the position to register the step in
  11579. * @param component Defines the component attached to the step
  11580. * @param action Defines the action to launch during the step
  11581. */
  11582. registerStep(index: number, component: ISceneComponent, action: T): void;
  11583. /**
  11584. * Clears all the steps from the stage.
  11585. */
  11586. clear(): void;
  11587. }
  11588. }
  11589. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11590. import { Nullable } from "babylonjs/types";
  11591. import { Observable } from "babylonjs/Misc/observable";
  11592. import { Scene } from "babylonjs/scene";
  11593. import { Sprite } from "babylonjs/Sprites/sprite";
  11594. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11595. import { Ray } from "babylonjs/Culling/ray";
  11596. import { Camera } from "babylonjs/Cameras/camera";
  11597. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11598. import { ISceneComponent } from "babylonjs/sceneComponent";
  11599. module "babylonjs/scene" {
  11600. interface Scene {
  11601. /** @hidden */
  11602. _pointerOverSprite: Nullable<Sprite>;
  11603. /** @hidden */
  11604. _pickedDownSprite: Nullable<Sprite>;
  11605. /** @hidden */
  11606. _tempSpritePickingRay: Nullable<Ray>;
  11607. /**
  11608. * All of the sprite managers added to this scene
  11609. * @see http://doc.babylonjs.com/babylon101/sprites
  11610. */
  11611. spriteManagers: Array<ISpriteManager>;
  11612. /**
  11613. * An event triggered when sprites rendering is about to start
  11614. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11615. */
  11616. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11617. /**
  11618. * An event triggered when sprites rendering is done
  11619. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11620. */
  11621. onAfterSpritesRenderingObservable: Observable<Scene>;
  11622. /** @hidden */
  11623. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11624. /** Launch a ray to try to pick a sprite in the scene
  11625. * @param x position on screen
  11626. * @param y position on screen
  11627. * @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
  11628. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11629. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11630. * @returns a PickingInfo
  11631. */
  11632. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11633. /** Use the given ray to pick a sprite in the scene
  11634. * @param ray The ray (in world space) to use to pick meshes
  11635. * @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
  11636. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11637. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11638. * @returns a PickingInfo
  11639. */
  11640. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11641. /** @hidden */
  11642. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11643. /** Launch a ray to try to pick sprites in the scene
  11644. * @param x position on screen
  11645. * @param y position on screen
  11646. * @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
  11647. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11648. * @returns a PickingInfo array
  11649. */
  11650. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11651. /** Use the given ray to pick sprites in the scene
  11652. * @param ray The ray (in world space) to use to pick meshes
  11653. * @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
  11654. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11655. * @returns a PickingInfo array
  11656. */
  11657. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11658. /**
  11659. * Force the sprite under the pointer
  11660. * @param sprite defines the sprite to use
  11661. */
  11662. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11663. /**
  11664. * Gets the sprite under the pointer
  11665. * @returns a Sprite or null if no sprite is under the pointer
  11666. */
  11667. getPointerOverSprite(): Nullable<Sprite>;
  11668. }
  11669. }
  11670. /**
  11671. * Defines the sprite scene component responsible to manage sprites
  11672. * in a given scene.
  11673. */
  11674. export class SpriteSceneComponent implements ISceneComponent {
  11675. /**
  11676. * The component name helpfull to identify the component in the list of scene components.
  11677. */
  11678. readonly name: string;
  11679. /**
  11680. * The scene the component belongs to.
  11681. */
  11682. scene: Scene;
  11683. /** @hidden */
  11684. private _spritePredicate;
  11685. /**
  11686. * Creates a new instance of the component for the given scene
  11687. * @param scene Defines the scene to register the component in
  11688. */
  11689. constructor(scene: Scene);
  11690. /**
  11691. * Registers the component in a given scene
  11692. */
  11693. register(): void;
  11694. /**
  11695. * Rebuilds the elements related to this component in case of
  11696. * context lost for instance.
  11697. */
  11698. rebuild(): void;
  11699. /**
  11700. * Disposes the component and the associated ressources.
  11701. */
  11702. dispose(): void;
  11703. private _pickSpriteButKeepRay;
  11704. private _pointerMove;
  11705. private _pointerDown;
  11706. private _pointerUp;
  11707. }
  11708. }
  11709. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11710. /** @hidden */
  11711. export var fogFragmentDeclaration: {
  11712. name: string;
  11713. shader: string;
  11714. };
  11715. }
  11716. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11717. /** @hidden */
  11718. export var fogFragment: {
  11719. name: string;
  11720. shader: string;
  11721. };
  11722. }
  11723. declare module "babylonjs/Shaders/sprites.fragment" {
  11724. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11725. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11726. /** @hidden */
  11727. export var spritesPixelShader: {
  11728. name: string;
  11729. shader: string;
  11730. };
  11731. }
  11732. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11733. /** @hidden */
  11734. export var fogVertexDeclaration: {
  11735. name: string;
  11736. shader: string;
  11737. };
  11738. }
  11739. declare module "babylonjs/Shaders/sprites.vertex" {
  11740. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11741. /** @hidden */
  11742. export var spritesVertexShader: {
  11743. name: string;
  11744. shader: string;
  11745. };
  11746. }
  11747. declare module "babylonjs/Sprites/spriteManager" {
  11748. import { IDisposable, Scene } from "babylonjs/scene";
  11749. import { Nullable } from "babylonjs/types";
  11750. import { Observable } from "babylonjs/Misc/observable";
  11751. import { Sprite } from "babylonjs/Sprites/sprite";
  11752. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11753. import { Camera } from "babylonjs/Cameras/camera";
  11754. import { Texture } from "babylonjs/Materials/Textures/texture";
  11755. import "babylonjs/Shaders/sprites.fragment";
  11756. import "babylonjs/Shaders/sprites.vertex";
  11757. import { Ray } from "babylonjs/Culling/ray";
  11758. /**
  11759. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11760. */
  11761. export interface ISpriteManager extends IDisposable {
  11762. /**
  11763. * Restricts the camera to viewing objects with the same layerMask.
  11764. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11765. */
  11766. layerMask: number;
  11767. /**
  11768. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11769. */
  11770. isPickable: boolean;
  11771. /**
  11772. * Specifies the rendering group id for this mesh (0 by default)
  11773. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11774. */
  11775. renderingGroupId: number;
  11776. /**
  11777. * Defines the list of sprites managed by the manager.
  11778. */
  11779. sprites: Array<Sprite>;
  11780. /**
  11781. * Tests the intersection of a sprite with a specific ray.
  11782. * @param ray The ray we are sending to test the collision
  11783. * @param camera The camera space we are sending rays in
  11784. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11785. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11786. * @returns picking info or null.
  11787. */
  11788. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11789. /**
  11790. * Intersects the sprites with a ray
  11791. * @param ray defines the ray to intersect with
  11792. * @param camera defines the current active camera
  11793. * @param predicate defines a predicate used to select candidate sprites
  11794. * @returns null if no hit or a PickingInfo array
  11795. */
  11796. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11797. /**
  11798. * Renders the list of sprites on screen.
  11799. */
  11800. render(): void;
  11801. }
  11802. /**
  11803. * Class used to manage multiple sprites on the same spritesheet
  11804. * @see http://doc.babylonjs.com/babylon101/sprites
  11805. */
  11806. export class SpriteManager implements ISpriteManager {
  11807. /** defines the manager's name */
  11808. name: string;
  11809. /** Gets the list of sprites */
  11810. sprites: Sprite[];
  11811. /** Gets or sets the rendering group id (0 by default) */
  11812. renderingGroupId: number;
  11813. /** Gets or sets camera layer mask */
  11814. layerMask: number;
  11815. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11816. fogEnabled: boolean;
  11817. /** Gets or sets a boolean indicating if the sprites are pickable */
  11818. isPickable: boolean;
  11819. /** Defines the default width of a cell in the spritesheet */
  11820. cellWidth: number;
  11821. /** Defines the default height of a cell in the spritesheet */
  11822. cellHeight: number;
  11823. /** Associative array from JSON sprite data file */
  11824. private _cellData;
  11825. /** Array of sprite names from JSON sprite data file */
  11826. private _spriteMap;
  11827. /** True when packed cell data from JSON file is ready*/
  11828. private _packedAndReady;
  11829. /**
  11830. * An event triggered when the manager is disposed.
  11831. */
  11832. onDisposeObservable: Observable<SpriteManager>;
  11833. private _onDisposeObserver;
  11834. /**
  11835. * Callback called when the manager is disposed
  11836. */
  11837. onDispose: () => void;
  11838. private _capacity;
  11839. private _fromPacked;
  11840. private _spriteTexture;
  11841. private _epsilon;
  11842. private _scene;
  11843. private _vertexData;
  11844. private _buffer;
  11845. private _vertexBuffers;
  11846. private _indexBuffer;
  11847. private _effectBase;
  11848. private _effectFog;
  11849. /**
  11850. * Gets or sets the spritesheet texture
  11851. */
  11852. texture: Texture;
  11853. /**
  11854. * Creates a new sprite manager
  11855. * @param name defines the manager's name
  11856. * @param imgUrl defines the sprite sheet url
  11857. * @param capacity defines the maximum allowed number of sprites
  11858. * @param cellSize defines the size of a sprite cell
  11859. * @param scene defines the hosting scene
  11860. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11861. * @param samplingMode defines the smapling mode to use with spritesheet
  11862. * @param fromPacked set to false; do not alter
  11863. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11864. */
  11865. constructor(
  11866. /** defines the manager's name */
  11867. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11868. private _makePacked;
  11869. private _appendSpriteVertex;
  11870. /**
  11871. * Intersects the sprites with a ray
  11872. * @param ray defines the ray to intersect with
  11873. * @param camera defines the current active camera
  11874. * @param predicate defines a predicate used to select candidate sprites
  11875. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11876. * @returns null if no hit or a PickingInfo
  11877. */
  11878. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11879. /**
  11880. * Intersects the sprites with a ray
  11881. * @param ray defines the ray to intersect with
  11882. * @param camera defines the current active camera
  11883. * @param predicate defines a predicate used to select candidate sprites
  11884. * @returns null if no hit or a PickingInfo array
  11885. */
  11886. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11887. /**
  11888. * Render all child sprites
  11889. */
  11890. render(): void;
  11891. /**
  11892. * Release associated resources
  11893. */
  11894. dispose(): void;
  11895. }
  11896. }
  11897. declare module "babylonjs/Sprites/sprite" {
  11898. import { Vector3 } from "babylonjs/Maths/math.vector";
  11899. import { Nullable } from "babylonjs/types";
  11900. import { ActionManager } from "babylonjs/Actions/actionManager";
  11901. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11902. import { Color4 } from "babylonjs/Maths/math.color";
  11903. /**
  11904. * Class used to represent a sprite
  11905. * @see http://doc.babylonjs.com/babylon101/sprites
  11906. */
  11907. export class Sprite {
  11908. /** defines the name */
  11909. name: string;
  11910. /** Gets or sets the current world position */
  11911. position: Vector3;
  11912. /** Gets or sets the main color */
  11913. color: Color4;
  11914. /** Gets or sets the width */
  11915. width: number;
  11916. /** Gets or sets the height */
  11917. height: number;
  11918. /** Gets or sets rotation angle */
  11919. angle: number;
  11920. /** Gets or sets the cell index in the sprite sheet */
  11921. cellIndex: number;
  11922. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11923. cellRef: string;
  11924. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11925. invertU: number;
  11926. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11927. invertV: number;
  11928. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11929. disposeWhenFinishedAnimating: boolean;
  11930. /** Gets the list of attached animations */
  11931. animations: Animation[];
  11932. /** Gets or sets a boolean indicating if the sprite can be picked */
  11933. isPickable: boolean;
  11934. /**
  11935. * Gets or sets the associated action manager
  11936. */
  11937. actionManager: Nullable<ActionManager>;
  11938. private _animationStarted;
  11939. private _loopAnimation;
  11940. private _fromIndex;
  11941. private _toIndex;
  11942. private _delay;
  11943. private _direction;
  11944. private _manager;
  11945. private _time;
  11946. private _onAnimationEnd;
  11947. /**
  11948. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11949. */
  11950. isVisible: boolean;
  11951. /**
  11952. * Gets or sets the sprite size
  11953. */
  11954. size: number;
  11955. /**
  11956. * Creates a new Sprite
  11957. * @param name defines the name
  11958. * @param manager defines the manager
  11959. */
  11960. constructor(
  11961. /** defines the name */
  11962. name: string, manager: ISpriteManager);
  11963. /**
  11964. * Starts an animation
  11965. * @param from defines the initial key
  11966. * @param to defines the end key
  11967. * @param loop defines if the animation must loop
  11968. * @param delay defines the start delay (in ms)
  11969. * @param onAnimationEnd defines a callback to call when animation ends
  11970. */
  11971. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11972. /** Stops current animation (if any) */
  11973. stopAnimation(): void;
  11974. /** @hidden */
  11975. _animate(deltaTime: number): void;
  11976. /** Release associated resources */
  11977. dispose(): void;
  11978. }
  11979. }
  11980. declare module "babylonjs/Collisions/pickingInfo" {
  11981. import { Nullable } from "babylonjs/types";
  11982. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11984. import { Sprite } from "babylonjs/Sprites/sprite";
  11985. import { Ray } from "babylonjs/Culling/ray";
  11986. /**
  11987. * Information about the result of picking within a scene
  11988. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11989. */
  11990. export class PickingInfo {
  11991. /** @hidden */
  11992. _pickingUnavailable: boolean;
  11993. /**
  11994. * If the pick collided with an object
  11995. */
  11996. hit: boolean;
  11997. /**
  11998. * Distance away where the pick collided
  11999. */
  12000. distance: number;
  12001. /**
  12002. * The location of pick collision
  12003. */
  12004. pickedPoint: Nullable<Vector3>;
  12005. /**
  12006. * The mesh corresponding the the pick collision
  12007. */
  12008. pickedMesh: Nullable<AbstractMesh>;
  12009. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12010. bu: number;
  12011. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12012. bv: number;
  12013. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12014. faceId: number;
  12015. /** Id of the the submesh that was picked */
  12016. subMeshId: number;
  12017. /** If a sprite was picked, this will be the sprite the pick collided with */
  12018. pickedSprite: Nullable<Sprite>;
  12019. /**
  12020. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12021. */
  12022. originMesh: Nullable<AbstractMesh>;
  12023. /**
  12024. * The ray that was used to perform the picking.
  12025. */
  12026. ray: Nullable<Ray>;
  12027. /**
  12028. * Gets the normal correspodning to the face the pick collided with
  12029. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12030. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12031. * @returns The normal correspodning to the face the pick collided with
  12032. */
  12033. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12034. /**
  12035. * Gets the texture coordinates of where the pick occured
  12036. * @returns the vector containing the coordnates of the texture
  12037. */
  12038. getTextureCoordinates(): Nullable<Vector2>;
  12039. }
  12040. }
  12041. declare module "babylonjs/Events/pointerEvents" {
  12042. import { Nullable } from "babylonjs/types";
  12043. import { Vector2 } from "babylonjs/Maths/math.vector";
  12044. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12045. import { Ray } from "babylonjs/Culling/ray";
  12046. /**
  12047. * Gather the list of pointer event types as constants.
  12048. */
  12049. export class PointerEventTypes {
  12050. /**
  12051. * 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.
  12052. */
  12053. static readonly POINTERDOWN: number;
  12054. /**
  12055. * The pointerup event is fired when a pointer is no longer active.
  12056. */
  12057. static readonly POINTERUP: number;
  12058. /**
  12059. * The pointermove event is fired when a pointer changes coordinates.
  12060. */
  12061. static readonly POINTERMOVE: number;
  12062. /**
  12063. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12064. */
  12065. static readonly POINTERWHEEL: number;
  12066. /**
  12067. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12068. */
  12069. static readonly POINTERPICK: number;
  12070. /**
  12071. * The pointertap event is fired when a the object has been touched and released without drag.
  12072. */
  12073. static readonly POINTERTAP: number;
  12074. /**
  12075. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12076. */
  12077. static readonly POINTERDOUBLETAP: number;
  12078. }
  12079. /**
  12080. * Base class of pointer info types.
  12081. */
  12082. export class PointerInfoBase {
  12083. /**
  12084. * Defines the type of event (PointerEventTypes)
  12085. */
  12086. type: number;
  12087. /**
  12088. * Defines the related dom event
  12089. */
  12090. event: PointerEvent | MouseWheelEvent;
  12091. /**
  12092. * Instantiates the base class of pointers info.
  12093. * @param type Defines the type of event (PointerEventTypes)
  12094. * @param event Defines the related dom event
  12095. */
  12096. constructor(
  12097. /**
  12098. * Defines the type of event (PointerEventTypes)
  12099. */
  12100. type: number,
  12101. /**
  12102. * Defines the related dom event
  12103. */
  12104. event: PointerEvent | MouseWheelEvent);
  12105. }
  12106. /**
  12107. * This class is used to store pointer related info for the onPrePointerObservable event.
  12108. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12109. */
  12110. export class PointerInfoPre extends PointerInfoBase {
  12111. /**
  12112. * Ray from a pointer if availible (eg. 6dof controller)
  12113. */
  12114. ray: Nullable<Ray>;
  12115. /**
  12116. * Defines the local position of the pointer on the canvas.
  12117. */
  12118. localPosition: Vector2;
  12119. /**
  12120. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12121. */
  12122. skipOnPointerObservable: boolean;
  12123. /**
  12124. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12125. * @param type Defines the type of event (PointerEventTypes)
  12126. * @param event Defines the related dom event
  12127. * @param localX Defines the local x coordinates of the pointer when the event occured
  12128. * @param localY Defines the local y coordinates of the pointer when the event occured
  12129. */
  12130. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12131. }
  12132. /**
  12133. * This type contains all the data related to a pointer event in Babylon.js.
  12134. * 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.
  12135. */
  12136. export class PointerInfo extends PointerInfoBase {
  12137. /**
  12138. * Defines the picking info associated to the info (if any)\
  12139. */
  12140. pickInfo: Nullable<PickingInfo>;
  12141. /**
  12142. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12143. * @param type Defines the type of event (PointerEventTypes)
  12144. * @param event Defines the related dom event
  12145. * @param pickInfo Defines the picking info associated to the info (if any)\
  12146. */
  12147. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12148. /**
  12149. * Defines the picking info associated to the info (if any)\
  12150. */
  12151. pickInfo: Nullable<PickingInfo>);
  12152. }
  12153. /**
  12154. * Data relating to a touch event on the screen.
  12155. */
  12156. export interface PointerTouch {
  12157. /**
  12158. * X coordinate of touch.
  12159. */
  12160. x: number;
  12161. /**
  12162. * Y coordinate of touch.
  12163. */
  12164. y: number;
  12165. /**
  12166. * Id of touch. Unique for each finger.
  12167. */
  12168. pointerId: number;
  12169. /**
  12170. * Event type passed from DOM.
  12171. */
  12172. type: any;
  12173. }
  12174. }
  12175. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12176. import { Observable } from "babylonjs/Misc/observable";
  12177. import { Nullable } from "babylonjs/types";
  12178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12179. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12180. /**
  12181. * Manage the mouse inputs to control the movement of a free camera.
  12182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12183. */
  12184. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12185. /**
  12186. * Define if touch is enabled in the mouse input
  12187. */
  12188. touchEnabled: boolean;
  12189. /**
  12190. * Defines the camera the input is attached to.
  12191. */
  12192. camera: FreeCamera;
  12193. /**
  12194. * Defines the buttons associated with the input to handle camera move.
  12195. */
  12196. buttons: number[];
  12197. /**
  12198. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12199. */
  12200. angularSensibility: number;
  12201. private _pointerInput;
  12202. private _onMouseMove;
  12203. private _observer;
  12204. private previousPosition;
  12205. /**
  12206. * Observable for when a pointer move event occurs containing the move offset
  12207. */
  12208. onPointerMovedObservable: Observable<{
  12209. offsetX: number;
  12210. offsetY: number;
  12211. }>;
  12212. /**
  12213. * @hidden
  12214. * If the camera should be rotated automatically based on pointer movement
  12215. */
  12216. _allowCameraRotation: boolean;
  12217. /**
  12218. * Manage the mouse inputs to control the movement of a free camera.
  12219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12220. * @param touchEnabled Defines if touch is enabled or not
  12221. */
  12222. constructor(
  12223. /**
  12224. * Define if touch is enabled in the mouse input
  12225. */
  12226. touchEnabled?: boolean);
  12227. /**
  12228. * Attach the input controls to a specific dom element to get the input from.
  12229. * @param element Defines the element the controls should be listened from
  12230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12231. */
  12232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12233. /**
  12234. * Called on JS contextmenu event.
  12235. * Override this method to provide functionality.
  12236. */
  12237. protected onContextMenu(evt: PointerEvent): void;
  12238. /**
  12239. * Detach the current controls from the specified dom element.
  12240. * @param element Defines the element to stop listening the inputs from
  12241. */
  12242. detachControl(element: Nullable<HTMLElement>): void;
  12243. /**
  12244. * Gets the class name of the current intput.
  12245. * @returns the class name
  12246. */
  12247. getClassName(): string;
  12248. /**
  12249. * Get the friendly name associated with the input class.
  12250. * @returns the input friendly name
  12251. */
  12252. getSimpleName(): string;
  12253. }
  12254. }
  12255. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12256. import { Nullable } from "babylonjs/types";
  12257. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12258. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12259. /**
  12260. * Manage the touch inputs to control the movement of a free camera.
  12261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12262. */
  12263. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12264. /**
  12265. * Defines the camera the input is attached to.
  12266. */
  12267. camera: FreeCamera;
  12268. /**
  12269. * Defines the touch sensibility for rotation.
  12270. * The higher the faster.
  12271. */
  12272. touchAngularSensibility: number;
  12273. /**
  12274. * Defines the touch sensibility for move.
  12275. * The higher the faster.
  12276. */
  12277. touchMoveSensibility: number;
  12278. private _offsetX;
  12279. private _offsetY;
  12280. private _pointerPressed;
  12281. private _pointerInput;
  12282. private _observer;
  12283. private _onLostFocus;
  12284. /**
  12285. * Attach the input controls to a specific dom element to get the input from.
  12286. * @param element Defines the element the controls should be listened from
  12287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12288. */
  12289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12290. /**
  12291. * Detach the current controls from the specified dom element.
  12292. * @param element Defines the element to stop listening the inputs from
  12293. */
  12294. detachControl(element: Nullable<HTMLElement>): void;
  12295. /**
  12296. * Update the current camera state depending on the inputs that have been used this frame.
  12297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12298. */
  12299. checkInputs(): void;
  12300. /**
  12301. * Gets the class name of the current intput.
  12302. * @returns the class name
  12303. */
  12304. getClassName(): string;
  12305. /**
  12306. * Get the friendly name associated with the input class.
  12307. * @returns the input friendly name
  12308. */
  12309. getSimpleName(): string;
  12310. }
  12311. }
  12312. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12313. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12314. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12315. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12316. import { Nullable } from "babylonjs/types";
  12317. /**
  12318. * Default Inputs manager for the FreeCamera.
  12319. * It groups all the default supported inputs for ease of use.
  12320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12321. */
  12322. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12323. /**
  12324. * @hidden
  12325. */
  12326. _mouseInput: Nullable<FreeCameraMouseInput>;
  12327. /**
  12328. * Instantiates a new FreeCameraInputsManager.
  12329. * @param camera Defines the camera the inputs belong to
  12330. */
  12331. constructor(camera: FreeCamera);
  12332. /**
  12333. * Add keyboard input support to the input manager.
  12334. * @returns the current input manager
  12335. */
  12336. addKeyboard(): FreeCameraInputsManager;
  12337. /**
  12338. * Add mouse input support to the input manager.
  12339. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12340. * @returns the current input manager
  12341. */
  12342. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12343. /**
  12344. * Removes the mouse input support from the manager
  12345. * @returns the current input manager
  12346. */
  12347. removeMouse(): FreeCameraInputsManager;
  12348. /**
  12349. * Add touch input support to the input manager.
  12350. * @returns the current input manager
  12351. */
  12352. addTouch(): FreeCameraInputsManager;
  12353. /**
  12354. * Remove all attached input methods from a camera
  12355. */
  12356. clear(): void;
  12357. }
  12358. }
  12359. declare module "babylonjs/Cameras/freeCamera" {
  12360. import { Vector3 } from "babylonjs/Maths/math.vector";
  12361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12362. import { Scene } from "babylonjs/scene";
  12363. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12364. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12365. /**
  12366. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12367. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12368. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12369. */
  12370. export class FreeCamera extends TargetCamera {
  12371. /**
  12372. * Define the collision ellipsoid of the camera.
  12373. * This is helpful to simulate a camera body like the player body around the camera
  12374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12375. */
  12376. ellipsoid: Vector3;
  12377. /**
  12378. * Define an offset for the position of the ellipsoid around the camera.
  12379. * This can be helpful to determine the center of the body near the gravity center of the body
  12380. * instead of its head.
  12381. */
  12382. ellipsoidOffset: Vector3;
  12383. /**
  12384. * Enable or disable collisions of the camera with the rest of the scene objects.
  12385. */
  12386. checkCollisions: boolean;
  12387. /**
  12388. * Enable or disable gravity on the camera.
  12389. */
  12390. applyGravity: boolean;
  12391. /**
  12392. * Define the input manager associated to the camera.
  12393. */
  12394. inputs: FreeCameraInputsManager;
  12395. /**
  12396. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12397. * Higher values reduce sensitivity.
  12398. */
  12399. /**
  12400. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12401. * Higher values reduce sensitivity.
  12402. */
  12403. angularSensibility: number;
  12404. /**
  12405. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12406. */
  12407. keysUp: number[];
  12408. /**
  12409. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12410. */
  12411. keysDown: number[];
  12412. /**
  12413. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12414. */
  12415. keysLeft: number[];
  12416. /**
  12417. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12418. */
  12419. keysRight: number[];
  12420. /**
  12421. * Event raised when the camera collide with a mesh in the scene.
  12422. */
  12423. onCollide: (collidedMesh: AbstractMesh) => void;
  12424. private _collider;
  12425. private _needMoveForGravity;
  12426. private _oldPosition;
  12427. private _diffPosition;
  12428. private _newPosition;
  12429. /** @hidden */
  12430. _localDirection: Vector3;
  12431. /** @hidden */
  12432. _transformedDirection: Vector3;
  12433. /**
  12434. * Instantiates a Free Camera.
  12435. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12436. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12437. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12438. * @param name Define the name of the camera in the scene
  12439. * @param position Define the start position of the camera in the scene
  12440. * @param scene Define the scene the camera belongs to
  12441. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12442. */
  12443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12444. /**
  12445. * Attached controls to the current camera.
  12446. * @param element Defines the element the controls should be listened from
  12447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12448. */
  12449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12450. /**
  12451. * Detach the current controls from the camera.
  12452. * The camera will stop reacting to inputs.
  12453. * @param element Defines the element to stop listening the inputs from
  12454. */
  12455. detachControl(element: HTMLElement): void;
  12456. private _collisionMask;
  12457. /**
  12458. * Define a collision mask to limit the list of object the camera can collide with
  12459. */
  12460. collisionMask: number;
  12461. /** @hidden */
  12462. _collideWithWorld(displacement: Vector3): void;
  12463. private _onCollisionPositionChange;
  12464. /** @hidden */
  12465. _checkInputs(): void;
  12466. /** @hidden */
  12467. _decideIfNeedsToMove(): boolean;
  12468. /** @hidden */
  12469. _updatePosition(): void;
  12470. /**
  12471. * Destroy the camera and release the current resources hold by it.
  12472. */
  12473. dispose(): void;
  12474. /**
  12475. * Gets the current object class name.
  12476. * @return the class name
  12477. */
  12478. getClassName(): string;
  12479. }
  12480. }
  12481. declare module "babylonjs/Gamepads/gamepad" {
  12482. import { Observable } from "babylonjs/Misc/observable";
  12483. /**
  12484. * Represents a gamepad control stick position
  12485. */
  12486. export class StickValues {
  12487. /**
  12488. * The x component of the control stick
  12489. */
  12490. x: number;
  12491. /**
  12492. * The y component of the control stick
  12493. */
  12494. y: number;
  12495. /**
  12496. * Initializes the gamepad x and y control stick values
  12497. * @param x The x component of the gamepad control stick value
  12498. * @param y The y component of the gamepad control stick value
  12499. */
  12500. constructor(
  12501. /**
  12502. * The x component of the control stick
  12503. */
  12504. x: number,
  12505. /**
  12506. * The y component of the control stick
  12507. */
  12508. y: number);
  12509. }
  12510. /**
  12511. * An interface which manages callbacks for gamepad button changes
  12512. */
  12513. export interface GamepadButtonChanges {
  12514. /**
  12515. * Called when a gamepad has been changed
  12516. */
  12517. changed: boolean;
  12518. /**
  12519. * Called when a gamepad press event has been triggered
  12520. */
  12521. pressChanged: boolean;
  12522. /**
  12523. * Called when a touch event has been triggered
  12524. */
  12525. touchChanged: boolean;
  12526. /**
  12527. * Called when a value has changed
  12528. */
  12529. valueChanged: boolean;
  12530. }
  12531. /**
  12532. * Represents a gamepad
  12533. */
  12534. export class Gamepad {
  12535. /**
  12536. * The id of the gamepad
  12537. */
  12538. id: string;
  12539. /**
  12540. * The index of the gamepad
  12541. */
  12542. index: number;
  12543. /**
  12544. * The browser gamepad
  12545. */
  12546. browserGamepad: any;
  12547. /**
  12548. * Specifies what type of gamepad this represents
  12549. */
  12550. type: number;
  12551. private _leftStick;
  12552. private _rightStick;
  12553. /** @hidden */
  12554. _isConnected: boolean;
  12555. private _leftStickAxisX;
  12556. private _leftStickAxisY;
  12557. private _rightStickAxisX;
  12558. private _rightStickAxisY;
  12559. /**
  12560. * Triggered when the left control stick has been changed
  12561. */
  12562. private _onleftstickchanged;
  12563. /**
  12564. * Triggered when the right control stick has been changed
  12565. */
  12566. private _onrightstickchanged;
  12567. /**
  12568. * Represents a gamepad controller
  12569. */
  12570. static GAMEPAD: number;
  12571. /**
  12572. * Represents a generic controller
  12573. */
  12574. static GENERIC: number;
  12575. /**
  12576. * Represents an XBox controller
  12577. */
  12578. static XBOX: number;
  12579. /**
  12580. * Represents a pose-enabled controller
  12581. */
  12582. static POSE_ENABLED: number;
  12583. /**
  12584. * Represents an Dual Shock controller
  12585. */
  12586. static DUALSHOCK: number;
  12587. /**
  12588. * Specifies whether the left control stick should be Y-inverted
  12589. */
  12590. protected _invertLeftStickY: boolean;
  12591. /**
  12592. * Specifies if the gamepad has been connected
  12593. */
  12594. readonly isConnected: boolean;
  12595. /**
  12596. * Initializes the gamepad
  12597. * @param id The id of the gamepad
  12598. * @param index The index of the gamepad
  12599. * @param browserGamepad The browser gamepad
  12600. * @param leftStickX The x component of the left joystick
  12601. * @param leftStickY The y component of the left joystick
  12602. * @param rightStickX The x component of the right joystick
  12603. * @param rightStickY The y component of the right joystick
  12604. */
  12605. constructor(
  12606. /**
  12607. * The id of the gamepad
  12608. */
  12609. id: string,
  12610. /**
  12611. * The index of the gamepad
  12612. */
  12613. index: number,
  12614. /**
  12615. * The browser gamepad
  12616. */
  12617. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12618. /**
  12619. * Callback triggered when the left joystick has changed
  12620. * @param callback
  12621. */
  12622. onleftstickchanged(callback: (values: StickValues) => void): void;
  12623. /**
  12624. * Callback triggered when the right joystick has changed
  12625. * @param callback
  12626. */
  12627. onrightstickchanged(callback: (values: StickValues) => void): void;
  12628. /**
  12629. * Gets the left joystick
  12630. */
  12631. /**
  12632. * Sets the left joystick values
  12633. */
  12634. leftStick: StickValues;
  12635. /**
  12636. * Gets the right joystick
  12637. */
  12638. /**
  12639. * Sets the right joystick value
  12640. */
  12641. rightStick: StickValues;
  12642. /**
  12643. * Updates the gamepad joystick positions
  12644. */
  12645. update(): void;
  12646. /**
  12647. * Disposes the gamepad
  12648. */
  12649. dispose(): void;
  12650. }
  12651. /**
  12652. * Represents a generic gamepad
  12653. */
  12654. export class GenericPad extends Gamepad {
  12655. private _buttons;
  12656. private _onbuttondown;
  12657. private _onbuttonup;
  12658. /**
  12659. * Observable triggered when a button has been pressed
  12660. */
  12661. onButtonDownObservable: Observable<number>;
  12662. /**
  12663. * Observable triggered when a button has been released
  12664. */
  12665. onButtonUpObservable: Observable<number>;
  12666. /**
  12667. * Callback triggered when a button has been pressed
  12668. * @param callback Called when a button has been pressed
  12669. */
  12670. onbuttondown(callback: (buttonPressed: number) => void): void;
  12671. /**
  12672. * Callback triggered when a button has been released
  12673. * @param callback Called when a button has been released
  12674. */
  12675. onbuttonup(callback: (buttonReleased: number) => void): void;
  12676. /**
  12677. * Initializes the generic gamepad
  12678. * @param id The id of the generic gamepad
  12679. * @param index The index of the generic gamepad
  12680. * @param browserGamepad The browser gamepad
  12681. */
  12682. constructor(id: string, index: number, browserGamepad: any);
  12683. private _setButtonValue;
  12684. /**
  12685. * Updates the generic gamepad
  12686. */
  12687. update(): void;
  12688. /**
  12689. * Disposes the generic gamepad
  12690. */
  12691. dispose(): void;
  12692. }
  12693. }
  12694. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12695. import { Nullable } from "babylonjs/types";
  12696. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12697. import { Scene } from "babylonjs/scene";
  12698. module "babylonjs/Engines/engine" {
  12699. interface Engine {
  12700. /**
  12701. * Creates a raw texture
  12702. * @param data defines the data to store in the texture
  12703. * @param width defines the width of the texture
  12704. * @param height defines the height of the texture
  12705. * @param format defines the format of the data
  12706. * @param generateMipMaps defines if the engine should generate the mip levels
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12709. * @param compression defines the compression used (null by default)
  12710. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12711. * @returns the raw texture inside an InternalTexture
  12712. */
  12713. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12714. /**
  12715. * Update a raw texture
  12716. * @param texture defines the texture to update
  12717. * @param data defines the data to store in the texture
  12718. * @param format defines the format of the data
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. */
  12721. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12722. /**
  12723. * Update a raw texture
  12724. * @param texture defines the texture to update
  12725. * @param data defines the data to store in the texture
  12726. * @param format defines the format of the data
  12727. * @param invertY defines if data must be stored with Y axis inverted
  12728. * @param compression defines the compression used (null by default)
  12729. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12730. */
  12731. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12732. /**
  12733. * Creates a new raw cube texture
  12734. * @param data defines the array of data to use to create each face
  12735. * @param size defines the size of the textures
  12736. * @param format defines the format of the data
  12737. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12738. * @param generateMipMaps defines if the engine should generate the mip levels
  12739. * @param invertY defines if data must be stored with Y axis inverted
  12740. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12741. * @param compression defines the compression used (null by default)
  12742. * @returns the cube texture as an InternalTexture
  12743. */
  12744. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12745. /**
  12746. * Update a raw cube texture
  12747. * @param texture defines the texture to udpdate
  12748. * @param data defines the data to store
  12749. * @param format defines the data format
  12750. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12751. * @param invertY defines if data must be stored with Y axis inverted
  12752. */
  12753. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12754. /**
  12755. * Update a raw cube texture
  12756. * @param texture defines the texture to udpdate
  12757. * @param data defines the data to store
  12758. * @param format defines the data format
  12759. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12760. * @param invertY defines if data must be stored with Y axis inverted
  12761. * @param compression defines the compression used (null by default)
  12762. */
  12763. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12764. /**
  12765. * Update a raw cube texture
  12766. * @param texture defines the texture to udpdate
  12767. * @param data defines the data to store
  12768. * @param format defines the data format
  12769. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12770. * @param invertY defines if data must be stored with Y axis inverted
  12771. * @param compression defines the compression used (null by default)
  12772. * @param level defines which level of the texture to update
  12773. */
  12774. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12775. /**
  12776. * Creates a new raw cube texture from a specified url
  12777. * @param url defines the url where the data is located
  12778. * @param scene defines the current scene
  12779. * @param size defines the size of the textures
  12780. * @param format defines the format of the data
  12781. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12782. * @param noMipmap defines if the engine should avoid generating the mip levels
  12783. * @param callback defines a callback used to extract texture data from loaded data
  12784. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12785. * @param onLoad defines a callback called when texture is loaded
  12786. * @param onError defines a callback called if there is an error
  12787. * @returns the cube texture as an InternalTexture
  12788. */
  12789. 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;
  12790. /**
  12791. * Creates a new raw cube texture from a specified url
  12792. * @param url defines the url where the data is located
  12793. * @param scene defines the current scene
  12794. * @param size defines the size of the textures
  12795. * @param format defines the format of the data
  12796. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12797. * @param noMipmap defines if the engine should avoid generating the mip levels
  12798. * @param callback defines a callback used to extract texture data from loaded data
  12799. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12800. * @param onLoad defines a callback called when texture is loaded
  12801. * @param onError defines a callback called if there is an error
  12802. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12803. * @param invertY defines if data must be stored with Y axis inverted
  12804. * @returns the cube texture as an InternalTexture
  12805. */
  12806. 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;
  12807. /**
  12808. * Creates a new raw 3D texture
  12809. * @param data defines the data used to create the texture
  12810. * @param width defines the width of the texture
  12811. * @param height defines the height of the texture
  12812. * @param depth defines the depth of the texture
  12813. * @param format defines the format of the texture
  12814. * @param generateMipMaps defines if the engine must generate mip levels
  12815. * @param invertY defines if data must be stored with Y axis inverted
  12816. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12817. * @param compression defines the compressed used (can be null)
  12818. * @param textureType defines the compressed used (can be null)
  12819. * @returns a new raw 3D texture (stored in an InternalTexture)
  12820. */
  12821. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12822. /**
  12823. * Update a raw 3D texture
  12824. * @param texture defines the texture to update
  12825. * @param data defines the data to store
  12826. * @param format defines the data format
  12827. * @param invertY defines if data must be stored with Y axis inverted
  12828. */
  12829. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12830. /**
  12831. * Update a raw 3D texture
  12832. * @param texture defines the texture to update
  12833. * @param data defines the data to store
  12834. * @param format defines the data format
  12835. * @param invertY defines if data must be stored with Y axis inverted
  12836. * @param compression defines the used compression (can be null)
  12837. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12838. */
  12839. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12840. /**
  12841. * Creates a new raw 2D array texture
  12842. * @param data defines the data used to create the texture
  12843. * @param width defines the width of the texture
  12844. * @param height defines the height of the texture
  12845. * @param depth defines the number of layers of the texture
  12846. * @param format defines the format of the texture
  12847. * @param generateMipMaps defines if the engine must generate mip levels
  12848. * @param invertY defines if data must be stored with Y axis inverted
  12849. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12850. * @param compression defines the compressed used (can be null)
  12851. * @param textureType defines the compressed used (can be null)
  12852. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12853. */
  12854. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12855. /**
  12856. * Update a raw 2D array texture
  12857. * @param texture defines the texture to update
  12858. * @param data defines the data to store
  12859. * @param format defines the data format
  12860. * @param invertY defines if data must be stored with Y axis inverted
  12861. */
  12862. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12863. /**
  12864. * Update a raw 2D array texture
  12865. * @param texture defines the texture to update
  12866. * @param data defines the data to store
  12867. * @param format defines the data format
  12868. * @param invertY defines if data must be stored with Y axis inverted
  12869. * @param compression defines the used compression (can be null)
  12870. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12871. */
  12872. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12873. }
  12874. }
  12875. }
  12876. declare module "babylonjs/Materials/Textures/rawTexture" {
  12877. import { Scene } from "babylonjs/scene";
  12878. import { Texture } from "babylonjs/Materials/Textures/texture";
  12879. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12880. /**
  12881. * Raw texture can help creating a texture directly from an array of data.
  12882. * This can be super useful if you either get the data from an uncompressed source or
  12883. * if you wish to create your texture pixel by pixel.
  12884. */
  12885. export class RawTexture extends Texture {
  12886. /**
  12887. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12888. */
  12889. format: number;
  12890. private _engine;
  12891. /**
  12892. * Instantiates a new RawTexture.
  12893. * Raw texture can help creating a texture directly from an array of data.
  12894. * This can be super useful if you either get the data from an uncompressed source or
  12895. * if you wish to create your texture pixel by pixel.
  12896. * @param data define the array of data to use to create the texture
  12897. * @param width define the width of the texture
  12898. * @param height define the height of the texture
  12899. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12900. * @param scene define the scene the texture belongs to
  12901. * @param generateMipMaps define whether mip maps should be generated or not
  12902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12905. */
  12906. constructor(data: ArrayBufferView, width: number, height: number,
  12907. /**
  12908. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12909. */
  12910. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12911. /**
  12912. * Updates the texture underlying data.
  12913. * @param data Define the new data of the texture
  12914. */
  12915. update(data: ArrayBufferView): void;
  12916. /**
  12917. * Creates a luminance texture from some data.
  12918. * @param data Define the texture data
  12919. * @param width Define the width of the texture
  12920. * @param height Define the height of the texture
  12921. * @param scene Define the scene the texture belongs to
  12922. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12923. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12924. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12925. * @returns the luminance texture
  12926. */
  12927. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12928. /**
  12929. * Creates a luminance alpha texture from some data.
  12930. * @param data Define the texture data
  12931. * @param width Define the width of the texture
  12932. * @param height Define the height of the texture
  12933. * @param scene Define the scene the texture belongs to
  12934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12937. * @returns the luminance alpha texture
  12938. */
  12939. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12940. /**
  12941. * Creates an alpha texture from some data.
  12942. * @param data Define the texture data
  12943. * @param width Define the width of the texture
  12944. * @param height Define the height of the texture
  12945. * @param scene Define the scene the texture belongs to
  12946. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12947. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12948. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12949. * @returns the alpha texture
  12950. */
  12951. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12952. /**
  12953. * Creates a RGB texture from some data.
  12954. * @param data Define the texture data
  12955. * @param width Define the width of the texture
  12956. * @param height Define the height of the texture
  12957. * @param scene Define the scene the texture belongs to
  12958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12962. * @returns the RGB alpha texture
  12963. */
  12964. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12965. /**
  12966. * Creates a RGBA texture from some data.
  12967. * @param data Define the texture data
  12968. * @param width Define the width of the texture
  12969. * @param height Define the height of the texture
  12970. * @param scene Define the scene the texture belongs to
  12971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12975. * @returns the RGBA texture
  12976. */
  12977. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12978. /**
  12979. * Creates a R texture from some data.
  12980. * @param data Define the texture data
  12981. * @param width Define the width of the texture
  12982. * @param height Define the height of the texture
  12983. * @param scene Define the scene the texture belongs to
  12984. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12985. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12986. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12987. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12988. * @returns the R texture
  12989. */
  12990. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12991. }
  12992. }
  12993. declare module "babylonjs/Maths/math.size" {
  12994. /**
  12995. * Interface for the size containing width and height
  12996. */
  12997. export interface ISize {
  12998. /**
  12999. * Width
  13000. */
  13001. width: number;
  13002. /**
  13003. * Heighht
  13004. */
  13005. height: number;
  13006. }
  13007. /**
  13008. * Size containing widht and height
  13009. */
  13010. export class Size implements ISize {
  13011. /**
  13012. * Width
  13013. */
  13014. width: number;
  13015. /**
  13016. * Height
  13017. */
  13018. height: number;
  13019. /**
  13020. * Creates a Size object from the given width and height (floats).
  13021. * @param width width of the new size
  13022. * @param height height of the new size
  13023. */
  13024. constructor(width: number, height: number);
  13025. /**
  13026. * Returns a string with the Size width and height
  13027. * @returns a string with the Size width and height
  13028. */
  13029. toString(): string;
  13030. /**
  13031. * "Size"
  13032. * @returns the string "Size"
  13033. */
  13034. getClassName(): string;
  13035. /**
  13036. * Returns the Size hash code.
  13037. * @returns a hash code for a unique width and height
  13038. */
  13039. getHashCode(): number;
  13040. /**
  13041. * Updates the current size from the given one.
  13042. * @param src the given size
  13043. */
  13044. copyFrom(src: Size): void;
  13045. /**
  13046. * Updates in place the current Size from the given floats.
  13047. * @param width width of the new size
  13048. * @param height height of the new size
  13049. * @returns the updated Size.
  13050. */
  13051. copyFromFloats(width: number, height: number): Size;
  13052. /**
  13053. * Updates in place the current Size from the given floats.
  13054. * @param width width to set
  13055. * @param height height to set
  13056. * @returns the updated Size.
  13057. */
  13058. set(width: number, height: number): Size;
  13059. /**
  13060. * Multiplies the width and height by numbers
  13061. * @param w factor to multiple the width by
  13062. * @param h factor to multiple the height by
  13063. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13064. */
  13065. multiplyByFloats(w: number, h: number): Size;
  13066. /**
  13067. * Clones the size
  13068. * @returns a new Size copied from the given one.
  13069. */
  13070. clone(): Size;
  13071. /**
  13072. * True if the current Size and the given one width and height are strictly equal.
  13073. * @param other the other size to compare against
  13074. * @returns True if the current Size and the given one width and height are strictly equal.
  13075. */
  13076. equals(other: Size): boolean;
  13077. /**
  13078. * The surface of the Size : width * height (float).
  13079. */
  13080. readonly surface: number;
  13081. /**
  13082. * Create a new size of zero
  13083. * @returns a new Size set to (0.0, 0.0)
  13084. */
  13085. static Zero(): Size;
  13086. /**
  13087. * Sums the width and height of two sizes
  13088. * @param otherSize size to add to this size
  13089. * @returns a new Size set as the addition result of the current Size and the given one.
  13090. */
  13091. add(otherSize: Size): Size;
  13092. /**
  13093. * Subtracts the width and height of two
  13094. * @param otherSize size to subtract to this size
  13095. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13096. */
  13097. subtract(otherSize: Size): Size;
  13098. /**
  13099. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13100. * @param start starting size to lerp between
  13101. * @param end end size to lerp between
  13102. * @param amount amount to lerp between the start and end values
  13103. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13104. */
  13105. static Lerp(start: Size, end: Size, amount: number): Size;
  13106. }
  13107. }
  13108. declare module "babylonjs/Animations/runtimeAnimation" {
  13109. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13110. import { Animatable } from "babylonjs/Animations/animatable";
  13111. import { Scene } from "babylonjs/scene";
  13112. /**
  13113. * Defines a runtime animation
  13114. */
  13115. export class RuntimeAnimation {
  13116. private _events;
  13117. /**
  13118. * The current frame of the runtime animation
  13119. */
  13120. private _currentFrame;
  13121. /**
  13122. * The animation used by the runtime animation
  13123. */
  13124. private _animation;
  13125. /**
  13126. * The target of the runtime animation
  13127. */
  13128. private _target;
  13129. /**
  13130. * The initiating animatable
  13131. */
  13132. private _host;
  13133. /**
  13134. * The original value of the runtime animation
  13135. */
  13136. private _originalValue;
  13137. /**
  13138. * The original blend value of the runtime animation
  13139. */
  13140. private _originalBlendValue;
  13141. /**
  13142. * The offsets cache of the runtime animation
  13143. */
  13144. private _offsetsCache;
  13145. /**
  13146. * The high limits cache of the runtime animation
  13147. */
  13148. private _highLimitsCache;
  13149. /**
  13150. * Specifies if the runtime animation has been stopped
  13151. */
  13152. private _stopped;
  13153. /**
  13154. * The blending factor of the runtime animation
  13155. */
  13156. private _blendingFactor;
  13157. /**
  13158. * The BabylonJS scene
  13159. */
  13160. private _scene;
  13161. /**
  13162. * The current value of the runtime animation
  13163. */
  13164. private _currentValue;
  13165. /** @hidden */
  13166. _animationState: _IAnimationState;
  13167. /**
  13168. * The active target of the runtime animation
  13169. */
  13170. private _activeTargets;
  13171. private _currentActiveTarget;
  13172. private _directTarget;
  13173. /**
  13174. * The target path of the runtime animation
  13175. */
  13176. private _targetPath;
  13177. /**
  13178. * The weight of the runtime animation
  13179. */
  13180. private _weight;
  13181. /**
  13182. * The ratio offset of the runtime animation
  13183. */
  13184. private _ratioOffset;
  13185. /**
  13186. * The previous delay of the runtime animation
  13187. */
  13188. private _previousDelay;
  13189. /**
  13190. * The previous ratio of the runtime animation
  13191. */
  13192. private _previousRatio;
  13193. private _enableBlending;
  13194. private _keys;
  13195. private _minFrame;
  13196. private _maxFrame;
  13197. private _minValue;
  13198. private _maxValue;
  13199. private _targetIsArray;
  13200. /**
  13201. * Gets the current frame of the runtime animation
  13202. */
  13203. readonly currentFrame: number;
  13204. /**
  13205. * Gets the weight of the runtime animation
  13206. */
  13207. readonly weight: number;
  13208. /**
  13209. * Gets the current value of the runtime animation
  13210. */
  13211. readonly currentValue: any;
  13212. /**
  13213. * Gets the target path of the runtime animation
  13214. */
  13215. readonly targetPath: string;
  13216. /**
  13217. * Gets the actual target of the runtime animation
  13218. */
  13219. readonly target: any;
  13220. /** @hidden */
  13221. _onLoop: () => void;
  13222. /**
  13223. * Create a new RuntimeAnimation object
  13224. * @param target defines the target of the animation
  13225. * @param animation defines the source animation object
  13226. * @param scene defines the hosting scene
  13227. * @param host defines the initiating Animatable
  13228. */
  13229. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13230. private _preparePath;
  13231. /**
  13232. * Gets the animation from the runtime animation
  13233. */
  13234. readonly animation: Animation;
  13235. /**
  13236. * Resets the runtime animation to the beginning
  13237. * @param restoreOriginal defines whether to restore the target property to the original value
  13238. */
  13239. reset(restoreOriginal?: boolean): void;
  13240. /**
  13241. * Specifies if the runtime animation is stopped
  13242. * @returns Boolean specifying if the runtime animation is stopped
  13243. */
  13244. isStopped(): boolean;
  13245. /**
  13246. * Disposes of the runtime animation
  13247. */
  13248. dispose(): void;
  13249. /**
  13250. * Apply the interpolated value to the target
  13251. * @param currentValue defines the value computed by the animation
  13252. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13253. */
  13254. setValue(currentValue: any, weight: number): void;
  13255. private _getOriginalValues;
  13256. private _setValue;
  13257. /**
  13258. * Gets the loop pmode of the runtime animation
  13259. * @returns Loop Mode
  13260. */
  13261. private _getCorrectLoopMode;
  13262. /**
  13263. * Move the current animation to a given frame
  13264. * @param frame defines the frame to move to
  13265. */
  13266. goToFrame(frame: number): void;
  13267. /**
  13268. * @hidden Internal use only
  13269. */
  13270. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13271. /**
  13272. * Execute the current animation
  13273. * @param delay defines the delay to add to the current frame
  13274. * @param from defines the lower bound of the animation range
  13275. * @param to defines the upper bound of the animation range
  13276. * @param loop defines if the current animation must loop
  13277. * @param speedRatio defines the current speed ratio
  13278. * @param weight defines the weight of the animation (default is -1 so no weight)
  13279. * @param onLoop optional callback called when animation loops
  13280. * @returns a boolean indicating if the animation is running
  13281. */
  13282. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13283. }
  13284. }
  13285. declare module "babylonjs/Animations/animatable" {
  13286. import { Animation } from "babylonjs/Animations/animation";
  13287. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13288. import { Nullable } from "babylonjs/types";
  13289. import { Observable } from "babylonjs/Misc/observable";
  13290. import { Scene } from "babylonjs/scene";
  13291. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13292. import { Node } from "babylonjs/node";
  13293. /**
  13294. * Class used to store an actual running animation
  13295. */
  13296. export class Animatable {
  13297. /** defines the target object */
  13298. target: any;
  13299. /** defines the starting frame number (default is 0) */
  13300. fromFrame: number;
  13301. /** defines the ending frame number (default is 100) */
  13302. toFrame: number;
  13303. /** defines if the animation must loop (default is false) */
  13304. loopAnimation: boolean;
  13305. /** defines a callback to call when animation ends if it is not looping */
  13306. onAnimationEnd?: (() => void) | null | undefined;
  13307. /** defines a callback to call when animation loops */
  13308. onAnimationLoop?: (() => void) | null | undefined;
  13309. private _localDelayOffset;
  13310. private _pausedDelay;
  13311. private _runtimeAnimations;
  13312. private _paused;
  13313. private _scene;
  13314. private _speedRatio;
  13315. private _weight;
  13316. private _syncRoot;
  13317. /**
  13318. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13319. * This will only apply for non looping animation (default is true)
  13320. */
  13321. disposeOnEnd: boolean;
  13322. /**
  13323. * Gets a boolean indicating if the animation has started
  13324. */
  13325. animationStarted: boolean;
  13326. /**
  13327. * Observer raised when the animation ends
  13328. */
  13329. onAnimationEndObservable: Observable<Animatable>;
  13330. /**
  13331. * Observer raised when the animation loops
  13332. */
  13333. onAnimationLoopObservable: Observable<Animatable>;
  13334. /**
  13335. * Gets the root Animatable used to synchronize and normalize animations
  13336. */
  13337. readonly syncRoot: Nullable<Animatable>;
  13338. /**
  13339. * Gets the current frame of the first RuntimeAnimation
  13340. * Used to synchronize Animatables
  13341. */
  13342. readonly masterFrame: number;
  13343. /**
  13344. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13345. */
  13346. weight: number;
  13347. /**
  13348. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13349. */
  13350. speedRatio: number;
  13351. /**
  13352. * Creates a new Animatable
  13353. * @param scene defines the hosting scene
  13354. * @param target defines the target object
  13355. * @param fromFrame defines the starting frame number (default is 0)
  13356. * @param toFrame defines the ending frame number (default is 100)
  13357. * @param loopAnimation defines if the animation must loop (default is false)
  13358. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13359. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13360. * @param animations defines a group of animation to add to the new Animatable
  13361. * @param onAnimationLoop defines a callback to call when animation loops
  13362. */
  13363. constructor(scene: Scene,
  13364. /** defines the target object */
  13365. target: any,
  13366. /** defines the starting frame number (default is 0) */
  13367. fromFrame?: number,
  13368. /** defines the ending frame number (default is 100) */
  13369. toFrame?: number,
  13370. /** defines if the animation must loop (default is false) */
  13371. loopAnimation?: boolean, speedRatio?: number,
  13372. /** defines a callback to call when animation ends if it is not looping */
  13373. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13374. /** defines a callback to call when animation loops */
  13375. onAnimationLoop?: (() => void) | null | undefined);
  13376. /**
  13377. * Synchronize and normalize current Animatable with a source Animatable
  13378. * This is useful when using animation weights and when animations are not of the same length
  13379. * @param root defines the root Animatable to synchronize with
  13380. * @returns the current Animatable
  13381. */
  13382. syncWith(root: Animatable): Animatable;
  13383. /**
  13384. * Gets the list of runtime animations
  13385. * @returns an array of RuntimeAnimation
  13386. */
  13387. getAnimations(): RuntimeAnimation[];
  13388. /**
  13389. * Adds more animations to the current animatable
  13390. * @param target defines the target of the animations
  13391. * @param animations defines the new animations to add
  13392. */
  13393. appendAnimations(target: any, animations: Animation[]): void;
  13394. /**
  13395. * Gets the source animation for a specific property
  13396. * @param property defines the propertyu to look for
  13397. * @returns null or the source animation for the given property
  13398. */
  13399. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13400. /**
  13401. * Gets the runtime animation for a specific property
  13402. * @param property defines the propertyu to look for
  13403. * @returns null or the runtime animation for the given property
  13404. */
  13405. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13406. /**
  13407. * Resets the animatable to its original state
  13408. */
  13409. reset(): void;
  13410. /**
  13411. * Allows the animatable to blend with current running animations
  13412. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13413. * @param blendingSpeed defines the blending speed to use
  13414. */
  13415. enableBlending(blendingSpeed: number): void;
  13416. /**
  13417. * Disable animation blending
  13418. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13419. */
  13420. disableBlending(): void;
  13421. /**
  13422. * Jump directly to a given frame
  13423. * @param frame defines the frame to jump to
  13424. */
  13425. goToFrame(frame: number): void;
  13426. /**
  13427. * Pause the animation
  13428. */
  13429. pause(): void;
  13430. /**
  13431. * Restart the animation
  13432. */
  13433. restart(): void;
  13434. private _raiseOnAnimationEnd;
  13435. /**
  13436. * Stop and delete the current animation
  13437. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13438. * @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)
  13439. */
  13440. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13441. /**
  13442. * Wait asynchronously for the animation to end
  13443. * @returns a promise which will be fullfilled when the animation ends
  13444. */
  13445. waitAsync(): Promise<Animatable>;
  13446. /** @hidden */
  13447. _animate(delay: number): boolean;
  13448. }
  13449. module "babylonjs/scene" {
  13450. interface Scene {
  13451. /** @hidden */
  13452. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13453. /** @hidden */
  13454. _processLateAnimationBindingsForMatrices(holder: {
  13455. totalWeight: number;
  13456. animations: RuntimeAnimation[];
  13457. originalValue: Matrix;
  13458. }): any;
  13459. /** @hidden */
  13460. _processLateAnimationBindingsForQuaternions(holder: {
  13461. totalWeight: number;
  13462. animations: RuntimeAnimation[];
  13463. originalValue: Quaternion;
  13464. }, refQuaternion: Quaternion): Quaternion;
  13465. /** @hidden */
  13466. _processLateAnimationBindings(): void;
  13467. /**
  13468. * Will start the animation sequence of a given target
  13469. * @param target defines the target
  13470. * @param from defines from which frame should animation start
  13471. * @param to defines until which frame should animation run.
  13472. * @param weight defines the weight to apply to the animation (1.0 by default)
  13473. * @param loop defines if the animation loops
  13474. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13475. * @param onAnimationEnd defines the function to be executed when the animation ends
  13476. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13477. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13478. * @param onAnimationLoop defines the callback to call when an animation loops
  13479. * @returns the animatable object created for this animation
  13480. */
  13481. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13482. /**
  13483. * Will start the animation sequence of a given target
  13484. * @param target defines the target
  13485. * @param from defines from which frame should animation start
  13486. * @param to defines until which frame should animation run.
  13487. * @param loop defines if the animation loops
  13488. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13489. * @param onAnimationEnd defines the function to be executed when the animation ends
  13490. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13491. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13492. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13493. * @param onAnimationLoop defines the callback to call when an animation loops
  13494. * @returns the animatable object created for this animation
  13495. */
  13496. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13497. /**
  13498. * Will start the animation sequence of a given target and its hierarchy
  13499. * @param target defines the target
  13500. * @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.
  13501. * @param from defines from which frame should animation start
  13502. * @param to defines until which frame should animation run.
  13503. * @param loop defines if the animation loops
  13504. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13505. * @param onAnimationEnd defines the function to be executed when the animation ends
  13506. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13507. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13508. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13509. * @param onAnimationLoop defines the callback to call when an animation loops
  13510. * @returns the list of created animatables
  13511. */
  13512. 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[];
  13513. /**
  13514. * Begin a new animation on a given node
  13515. * @param target defines the target where the animation will take place
  13516. * @param animations defines the list of animations to start
  13517. * @param from defines the initial value
  13518. * @param to defines the final value
  13519. * @param loop defines if you want animation to loop (off by default)
  13520. * @param speedRatio defines the speed ratio to apply to all animations
  13521. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13522. * @param onAnimationLoop defines the callback to call when an animation loops
  13523. * @returns the list of created animatables
  13524. */
  13525. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13526. /**
  13527. * Begin a new animation on a given node and its hierarchy
  13528. * @param target defines the root node where the animation will take place
  13529. * @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.
  13530. * @param animations defines the list of animations to start
  13531. * @param from defines the initial value
  13532. * @param to defines the final value
  13533. * @param loop defines if you want animation to loop (off by default)
  13534. * @param speedRatio defines the speed ratio to apply to all animations
  13535. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13536. * @param onAnimationLoop defines the callback to call when an animation loops
  13537. * @returns the list of animatables created for all nodes
  13538. */
  13539. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13540. /**
  13541. * Gets the animatable associated with a specific target
  13542. * @param target defines the target of the animatable
  13543. * @returns the required animatable if found
  13544. */
  13545. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13546. /**
  13547. * Gets all animatables associated with a given target
  13548. * @param target defines the target to look animatables for
  13549. * @returns an array of Animatables
  13550. */
  13551. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13552. /**
  13553. * Stops and removes all animations that have been applied to the scene
  13554. */
  13555. stopAllAnimations(): void;
  13556. /**
  13557. * Gets the current delta time used by animation engine
  13558. */
  13559. deltaTime: number;
  13560. }
  13561. }
  13562. module "babylonjs/Bones/bone" {
  13563. interface Bone {
  13564. /**
  13565. * Copy an animation range from another bone
  13566. * @param source defines the source bone
  13567. * @param rangeName defines the range name to copy
  13568. * @param frameOffset defines the frame offset
  13569. * @param rescaleAsRequired defines if rescaling must be applied if required
  13570. * @param skelDimensionsRatio defines the scaling ratio
  13571. * @returns true if operation was successful
  13572. */
  13573. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13574. }
  13575. }
  13576. }
  13577. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13578. /**
  13579. * Class used to override all child animations of a given target
  13580. */
  13581. export class AnimationPropertiesOverride {
  13582. /**
  13583. * Gets or sets a value indicating if animation blending must be used
  13584. */
  13585. enableBlending: boolean;
  13586. /**
  13587. * Gets or sets the blending speed to use when enableBlending is true
  13588. */
  13589. blendingSpeed: number;
  13590. /**
  13591. * Gets or sets the default loop mode to use
  13592. */
  13593. loopMode: number;
  13594. }
  13595. }
  13596. declare module "babylonjs/Bones/skeleton" {
  13597. import { Bone } from "babylonjs/Bones/bone";
  13598. import { Observable } from "babylonjs/Misc/observable";
  13599. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13600. import { Scene } from "babylonjs/scene";
  13601. import { Nullable } from "babylonjs/types";
  13602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13603. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13604. import { Animatable } from "babylonjs/Animations/animatable";
  13605. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13606. import { Animation } from "babylonjs/Animations/animation";
  13607. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13608. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13609. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13610. /**
  13611. * Class used to handle skinning animations
  13612. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13613. */
  13614. export class Skeleton implements IAnimatable {
  13615. /** defines the skeleton name */
  13616. name: string;
  13617. /** defines the skeleton Id */
  13618. id: string;
  13619. /**
  13620. * Defines the list of child bones
  13621. */
  13622. bones: Bone[];
  13623. /**
  13624. * Defines an estimate of the dimension of the skeleton at rest
  13625. */
  13626. dimensionsAtRest: Vector3;
  13627. /**
  13628. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13629. */
  13630. needInitialSkinMatrix: boolean;
  13631. /**
  13632. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13633. */
  13634. overrideMesh: Nullable<AbstractMesh>;
  13635. /**
  13636. * Gets the list of animations attached to this skeleton
  13637. */
  13638. animations: Array<Animation>;
  13639. private _scene;
  13640. private _isDirty;
  13641. private _transformMatrices;
  13642. private _transformMatrixTexture;
  13643. private _meshesWithPoseMatrix;
  13644. private _animatables;
  13645. private _identity;
  13646. private _synchronizedWithMesh;
  13647. private _ranges;
  13648. private _lastAbsoluteTransformsUpdateId;
  13649. private _canUseTextureForBones;
  13650. private _uniqueId;
  13651. /** @hidden */
  13652. _numBonesWithLinkedTransformNode: number;
  13653. /** @hidden */
  13654. _hasWaitingData: Nullable<boolean>;
  13655. /**
  13656. * Specifies if the skeleton should be serialized
  13657. */
  13658. doNotSerialize: boolean;
  13659. private _useTextureToStoreBoneMatrices;
  13660. /**
  13661. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13662. * Please note that this option is not available if the hardware does not support it
  13663. */
  13664. useTextureToStoreBoneMatrices: boolean;
  13665. private _animationPropertiesOverride;
  13666. /**
  13667. * Gets or sets the animation properties override
  13668. */
  13669. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13670. /**
  13671. * List of inspectable custom properties (used by the Inspector)
  13672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13673. */
  13674. inspectableCustomProperties: IInspectable[];
  13675. /**
  13676. * An observable triggered before computing the skeleton's matrices
  13677. */
  13678. onBeforeComputeObservable: Observable<Skeleton>;
  13679. /**
  13680. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13681. */
  13682. readonly isUsingTextureForMatrices: boolean;
  13683. /**
  13684. * Gets the unique ID of this skeleton
  13685. */
  13686. readonly uniqueId: number;
  13687. /**
  13688. * Creates a new skeleton
  13689. * @param name defines the skeleton name
  13690. * @param id defines the skeleton Id
  13691. * @param scene defines the hosting scene
  13692. */
  13693. constructor(
  13694. /** defines the skeleton name */
  13695. name: string,
  13696. /** defines the skeleton Id */
  13697. id: string, scene: Scene);
  13698. /**
  13699. * Gets the current object class name.
  13700. * @return the class name
  13701. */
  13702. getClassName(): string;
  13703. /**
  13704. * Returns an array containing the root bones
  13705. * @returns an array containing the root bones
  13706. */
  13707. getChildren(): Array<Bone>;
  13708. /**
  13709. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13710. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13711. * @returns a Float32Array containing matrices data
  13712. */
  13713. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13714. /**
  13715. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13716. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13717. * @returns a raw texture containing the data
  13718. */
  13719. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13720. /**
  13721. * Gets the current hosting scene
  13722. * @returns a scene object
  13723. */
  13724. getScene(): Scene;
  13725. /**
  13726. * Gets a string representing the current skeleton data
  13727. * @param fullDetails defines a boolean indicating if we want a verbose version
  13728. * @returns a string representing the current skeleton data
  13729. */
  13730. toString(fullDetails?: boolean): string;
  13731. /**
  13732. * Get bone's index searching by name
  13733. * @param name defines bone's name to search for
  13734. * @return the indice of the bone. Returns -1 if not found
  13735. */
  13736. getBoneIndexByName(name: string): number;
  13737. /**
  13738. * Creater a new animation range
  13739. * @param name defines the name of the range
  13740. * @param from defines the start key
  13741. * @param to defines the end key
  13742. */
  13743. createAnimationRange(name: string, from: number, to: number): void;
  13744. /**
  13745. * Delete a specific animation range
  13746. * @param name defines the name of the range
  13747. * @param deleteFrames defines if frames must be removed as well
  13748. */
  13749. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13750. /**
  13751. * Gets a specific animation range
  13752. * @param name defines the name of the range to look for
  13753. * @returns the requested animation range or null if not found
  13754. */
  13755. getAnimationRange(name: string): Nullable<AnimationRange>;
  13756. /**
  13757. * Gets the list of all animation ranges defined on this skeleton
  13758. * @returns an array
  13759. */
  13760. getAnimationRanges(): Nullable<AnimationRange>[];
  13761. /**
  13762. * Copy animation range from a source skeleton.
  13763. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13764. * @param source defines the source skeleton
  13765. * @param name defines the name of the range to copy
  13766. * @param rescaleAsRequired defines if rescaling must be applied if required
  13767. * @returns true if operation was successful
  13768. */
  13769. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13770. /**
  13771. * Forces the skeleton to go to rest pose
  13772. */
  13773. returnToRest(): void;
  13774. private _getHighestAnimationFrame;
  13775. /**
  13776. * Begin a specific animation range
  13777. * @param name defines the name of the range to start
  13778. * @param loop defines if looping must be turned on (false by default)
  13779. * @param speedRatio defines the speed ratio to apply (1 by default)
  13780. * @param onAnimationEnd defines a callback which will be called when animation will end
  13781. * @returns a new animatable
  13782. */
  13783. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13784. /** @hidden */
  13785. _markAsDirty(): void;
  13786. /** @hidden */
  13787. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13788. /** @hidden */
  13789. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13790. private _computeTransformMatrices;
  13791. /**
  13792. * Build all resources required to render a skeleton
  13793. */
  13794. prepare(): void;
  13795. /**
  13796. * Gets the list of animatables currently running for this skeleton
  13797. * @returns an array of animatables
  13798. */
  13799. getAnimatables(): IAnimatable[];
  13800. /**
  13801. * Clone the current skeleton
  13802. * @param name defines the name of the new skeleton
  13803. * @param id defines the id of the new skeleton
  13804. * @returns the new skeleton
  13805. */
  13806. clone(name: string, id?: string): Skeleton;
  13807. /**
  13808. * Enable animation blending for this skeleton
  13809. * @param blendingSpeed defines the blending speed to apply
  13810. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13811. */
  13812. enableBlending(blendingSpeed?: number): void;
  13813. /**
  13814. * Releases all resources associated with the current skeleton
  13815. */
  13816. dispose(): void;
  13817. /**
  13818. * Serialize the skeleton in a JSON object
  13819. * @returns a JSON object
  13820. */
  13821. serialize(): any;
  13822. /**
  13823. * Creates a new skeleton from serialized data
  13824. * @param parsedSkeleton defines the serialized data
  13825. * @param scene defines the hosting scene
  13826. * @returns a new skeleton
  13827. */
  13828. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13829. /**
  13830. * Compute all node absolute transforms
  13831. * @param forceUpdate defines if computation must be done even if cache is up to date
  13832. */
  13833. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13834. /**
  13835. * Gets the root pose matrix
  13836. * @returns a matrix
  13837. */
  13838. getPoseMatrix(): Nullable<Matrix>;
  13839. /**
  13840. * Sorts bones per internal index
  13841. */
  13842. sortBones(): void;
  13843. private _sortBones;
  13844. }
  13845. }
  13846. declare module "babylonjs/Bones/bone" {
  13847. import { Skeleton } from "babylonjs/Bones/skeleton";
  13848. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13849. import { Nullable } from "babylonjs/types";
  13850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13851. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13852. import { Node } from "babylonjs/node";
  13853. import { Space } from "babylonjs/Maths/math.axis";
  13854. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13855. /**
  13856. * Class used to store bone information
  13857. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13858. */
  13859. export class Bone extends Node {
  13860. /**
  13861. * defines the bone name
  13862. */
  13863. name: string;
  13864. private static _tmpVecs;
  13865. private static _tmpQuat;
  13866. private static _tmpMats;
  13867. /**
  13868. * Gets the list of child bones
  13869. */
  13870. children: Bone[];
  13871. /** Gets the animations associated with this bone */
  13872. animations: import("babylonjs/Animations/animation").Animation[];
  13873. /**
  13874. * Gets or sets bone length
  13875. */
  13876. length: number;
  13877. /**
  13878. * @hidden Internal only
  13879. * Set this value to map this bone to a different index in the transform matrices
  13880. * Set this value to -1 to exclude the bone from the transform matrices
  13881. */
  13882. _index: Nullable<number>;
  13883. private _skeleton;
  13884. private _localMatrix;
  13885. private _restPose;
  13886. private _baseMatrix;
  13887. private _absoluteTransform;
  13888. private _invertedAbsoluteTransform;
  13889. private _parent;
  13890. private _scalingDeterminant;
  13891. private _worldTransform;
  13892. private _localScaling;
  13893. private _localRotation;
  13894. private _localPosition;
  13895. private _needToDecompose;
  13896. private _needToCompose;
  13897. /** @hidden */
  13898. _linkedTransformNode: Nullable<TransformNode>;
  13899. /** @hidden */
  13900. _waitingTransformNodeId: Nullable<string>;
  13901. /** @hidden */
  13902. /** @hidden */
  13903. _matrix: Matrix;
  13904. /**
  13905. * Create a new bone
  13906. * @param name defines the bone name
  13907. * @param skeleton defines the parent skeleton
  13908. * @param parentBone defines the parent (can be null if the bone is the root)
  13909. * @param localMatrix defines the local matrix
  13910. * @param restPose defines the rest pose matrix
  13911. * @param baseMatrix defines the base matrix
  13912. * @param index defines index of the bone in the hiearchy
  13913. */
  13914. constructor(
  13915. /**
  13916. * defines the bone name
  13917. */
  13918. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13919. /**
  13920. * Gets the current object class name.
  13921. * @return the class name
  13922. */
  13923. getClassName(): string;
  13924. /**
  13925. * Gets the parent skeleton
  13926. * @returns a skeleton
  13927. */
  13928. getSkeleton(): Skeleton;
  13929. /**
  13930. * Gets parent bone
  13931. * @returns a bone or null if the bone is the root of the bone hierarchy
  13932. */
  13933. getParent(): Nullable<Bone>;
  13934. /**
  13935. * Returns an array containing the root bones
  13936. * @returns an array containing the root bones
  13937. */
  13938. getChildren(): Array<Bone>;
  13939. /**
  13940. * Gets the node index in matrix array generated for rendering
  13941. * @returns the node index
  13942. */
  13943. getIndex(): number;
  13944. /**
  13945. * Sets the parent bone
  13946. * @param parent defines the parent (can be null if the bone is the root)
  13947. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13948. */
  13949. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13950. /**
  13951. * Gets the local matrix
  13952. * @returns a matrix
  13953. */
  13954. getLocalMatrix(): Matrix;
  13955. /**
  13956. * Gets the base matrix (initial matrix which remains unchanged)
  13957. * @returns a matrix
  13958. */
  13959. getBaseMatrix(): Matrix;
  13960. /**
  13961. * Gets the rest pose matrix
  13962. * @returns a matrix
  13963. */
  13964. getRestPose(): Matrix;
  13965. /**
  13966. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13967. */
  13968. getWorldMatrix(): Matrix;
  13969. /**
  13970. * Sets the local matrix to rest pose matrix
  13971. */
  13972. returnToRest(): void;
  13973. /**
  13974. * Gets the inverse of the absolute transform matrix.
  13975. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13976. * @returns a matrix
  13977. */
  13978. getInvertedAbsoluteTransform(): Matrix;
  13979. /**
  13980. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13981. * @returns a matrix
  13982. */
  13983. getAbsoluteTransform(): Matrix;
  13984. /**
  13985. * Links with the given transform node.
  13986. * The local matrix of this bone is copied from the transform node every frame.
  13987. * @param transformNode defines the transform node to link to
  13988. */
  13989. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13990. /**
  13991. * Gets the node used to drive the bone's transformation
  13992. * @returns a transform node or null
  13993. */
  13994. getTransformNode(): Nullable<TransformNode>;
  13995. /** Gets or sets current position (in local space) */
  13996. position: Vector3;
  13997. /** Gets or sets current rotation (in local space) */
  13998. rotation: Vector3;
  13999. /** Gets or sets current rotation quaternion (in local space) */
  14000. rotationQuaternion: Quaternion;
  14001. /** Gets or sets current scaling (in local space) */
  14002. scaling: Vector3;
  14003. /**
  14004. * Gets the animation properties override
  14005. */
  14006. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14007. private _decompose;
  14008. private _compose;
  14009. /**
  14010. * Update the base and local matrices
  14011. * @param matrix defines the new base or local matrix
  14012. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14013. * @param updateLocalMatrix defines if the local matrix should be updated
  14014. */
  14015. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14016. /** @hidden */
  14017. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14018. /**
  14019. * Flag the bone as dirty (Forcing it to update everything)
  14020. */
  14021. markAsDirty(): void;
  14022. /** @hidden */
  14023. _markAsDirtyAndCompose(): void;
  14024. private _markAsDirtyAndDecompose;
  14025. /**
  14026. * Translate the bone in local or world space
  14027. * @param vec The amount to translate the bone
  14028. * @param space The space that the translation is in
  14029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14030. */
  14031. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14032. /**
  14033. * Set the postion of the bone in local or world space
  14034. * @param position The position to set the bone
  14035. * @param space The space that the position is in
  14036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14037. */
  14038. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14039. /**
  14040. * Set the absolute position of the bone (world space)
  14041. * @param position The position to set the bone
  14042. * @param mesh The mesh that this bone is attached to
  14043. */
  14044. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14045. /**
  14046. * Scale the bone on the x, y and z axes (in local space)
  14047. * @param x The amount to scale the bone on the x axis
  14048. * @param y The amount to scale the bone on the y axis
  14049. * @param z The amount to scale the bone on the z axis
  14050. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14051. */
  14052. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14053. /**
  14054. * Set the bone scaling in local space
  14055. * @param scale defines the scaling vector
  14056. */
  14057. setScale(scale: Vector3): void;
  14058. /**
  14059. * Gets the current scaling in local space
  14060. * @returns the current scaling vector
  14061. */
  14062. getScale(): Vector3;
  14063. /**
  14064. * Gets the current scaling in local space and stores it in a target vector
  14065. * @param result defines the target vector
  14066. */
  14067. getScaleToRef(result: Vector3): void;
  14068. /**
  14069. * Set the yaw, pitch, and roll of the bone in local or world space
  14070. * @param yaw The rotation of the bone on the y axis
  14071. * @param pitch The rotation of the bone on the x axis
  14072. * @param roll The rotation of the bone on the z axis
  14073. * @param space The space that the axes of rotation are in
  14074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14075. */
  14076. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14077. /**
  14078. * Add a rotation to the bone on an axis in local or world space
  14079. * @param axis The axis to rotate the bone on
  14080. * @param amount The amount to rotate the bone
  14081. * @param space The space that the axis is in
  14082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14083. */
  14084. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14085. /**
  14086. * Set the rotation of the bone to a particular axis angle in local or world space
  14087. * @param axis The axis to rotate the bone on
  14088. * @param angle The angle that the bone should be rotated to
  14089. * @param space The space that the axis is in
  14090. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14091. */
  14092. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14093. /**
  14094. * Set the euler rotation of the bone in local of world space
  14095. * @param rotation The euler rotation that the bone should be set to
  14096. * @param space The space that the rotation is in
  14097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14098. */
  14099. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14100. /**
  14101. * Set the quaternion rotation of the bone in local of world space
  14102. * @param quat The quaternion rotation that the bone should be set to
  14103. * @param space The space that the rotation is in
  14104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14105. */
  14106. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14107. /**
  14108. * Set the rotation matrix of the bone in local of world space
  14109. * @param rotMat The rotation matrix that the bone should be set to
  14110. * @param space The space that the rotation is in
  14111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14112. */
  14113. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14114. private _rotateWithMatrix;
  14115. private _getNegativeRotationToRef;
  14116. /**
  14117. * Get the position of the bone in local or world space
  14118. * @param space The space that the returned position is in
  14119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14120. * @returns The position of the bone
  14121. */
  14122. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14123. /**
  14124. * Copy the position of the bone to a vector3 in local or world space
  14125. * @param space The space that the returned position is in
  14126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14127. * @param result The vector3 to copy the position to
  14128. */
  14129. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14130. /**
  14131. * Get the absolute position of the bone (world space)
  14132. * @param mesh The mesh that this bone is attached to
  14133. * @returns The absolute position of the bone
  14134. */
  14135. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14136. /**
  14137. * Copy the absolute position of the bone (world space) to the result param
  14138. * @param mesh The mesh that this bone is attached to
  14139. * @param result The vector3 to copy the absolute position to
  14140. */
  14141. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14142. /**
  14143. * Compute the absolute transforms of this bone and its children
  14144. */
  14145. computeAbsoluteTransforms(): void;
  14146. /**
  14147. * Get the world direction from an axis that is in the local space of the bone
  14148. * @param localAxis The local direction that is used to compute the world direction
  14149. * @param mesh The mesh that this bone is attached to
  14150. * @returns The world direction
  14151. */
  14152. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14153. /**
  14154. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14155. * @param localAxis The local direction that is used to compute the world direction
  14156. * @param mesh The mesh that this bone is attached to
  14157. * @param result The vector3 that the world direction will be copied to
  14158. */
  14159. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14160. /**
  14161. * Get the euler rotation of the bone in local or world space
  14162. * @param space The space that the rotation should be in
  14163. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14164. * @returns The euler rotation
  14165. */
  14166. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14167. /**
  14168. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14169. * @param space The space that the rotation should be in
  14170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14171. * @param result The vector3 that the rotation should be copied to
  14172. */
  14173. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14174. /**
  14175. * Get the quaternion rotation of the bone in either local or world space
  14176. * @param space The space that the rotation should be in
  14177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14178. * @returns The quaternion rotation
  14179. */
  14180. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14181. /**
  14182. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14183. * @param space The space that the rotation should be in
  14184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14185. * @param result The quaternion that the rotation should be copied to
  14186. */
  14187. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14188. /**
  14189. * Get the rotation matrix of the bone in local or world space
  14190. * @param space The space that the rotation should be in
  14191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14192. * @returns The rotation matrix
  14193. */
  14194. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14195. /**
  14196. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14197. * @param space The space that the rotation should be in
  14198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14199. * @param result The quaternion that the rotation should be copied to
  14200. */
  14201. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14202. /**
  14203. * Get the world position of a point that is in the local space of the bone
  14204. * @param position The local position
  14205. * @param mesh The mesh that this bone is attached to
  14206. * @returns The world position
  14207. */
  14208. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14209. /**
  14210. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14211. * @param position The local position
  14212. * @param mesh The mesh that this bone is attached to
  14213. * @param result The vector3 that the world position should be copied to
  14214. */
  14215. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14216. /**
  14217. * Get the local position of a point that is in world space
  14218. * @param position The world position
  14219. * @param mesh The mesh that this bone is attached to
  14220. * @returns The local position
  14221. */
  14222. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14223. /**
  14224. * Get the local position of a point that is in world space and copy it to the result param
  14225. * @param position The world position
  14226. * @param mesh The mesh that this bone is attached to
  14227. * @param result The vector3 that the local position should be copied to
  14228. */
  14229. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14230. }
  14231. }
  14232. declare module "babylonjs/Meshes/transformNode" {
  14233. import { DeepImmutable } from "babylonjs/types";
  14234. import { Observable } from "babylonjs/Misc/observable";
  14235. import { Nullable } from "babylonjs/types";
  14236. import { Camera } from "babylonjs/Cameras/camera";
  14237. import { Scene } from "babylonjs/scene";
  14238. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14239. import { Node } from "babylonjs/node";
  14240. import { Bone } from "babylonjs/Bones/bone";
  14241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14242. import { Space } from "babylonjs/Maths/math.axis";
  14243. /**
  14244. * 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.
  14245. * @see https://doc.babylonjs.com/how_to/transformnode
  14246. */
  14247. export class TransformNode extends Node {
  14248. /**
  14249. * Object will not rotate to face the camera
  14250. */
  14251. static BILLBOARDMODE_NONE: number;
  14252. /**
  14253. * Object will rotate to face the camera but only on the x axis
  14254. */
  14255. static BILLBOARDMODE_X: number;
  14256. /**
  14257. * Object will rotate to face the camera but only on the y axis
  14258. */
  14259. static BILLBOARDMODE_Y: number;
  14260. /**
  14261. * Object will rotate to face the camera but only on the z axis
  14262. */
  14263. static BILLBOARDMODE_Z: number;
  14264. /**
  14265. * Object will rotate to face the camera
  14266. */
  14267. static BILLBOARDMODE_ALL: number;
  14268. /**
  14269. * Object will rotate to face the camera's position instead of orientation
  14270. */
  14271. static BILLBOARDMODE_USE_POSITION: number;
  14272. private _forward;
  14273. private _forwardInverted;
  14274. private _up;
  14275. private _right;
  14276. private _rightInverted;
  14277. private _position;
  14278. private _rotation;
  14279. private _rotationQuaternion;
  14280. protected _scaling: Vector3;
  14281. protected _isDirty: boolean;
  14282. private _transformToBoneReferal;
  14283. private _isAbsoluteSynced;
  14284. private _billboardMode;
  14285. /**
  14286. * Gets or sets the billboard mode. Default is 0.
  14287. *
  14288. * | Value | Type | Description |
  14289. * | --- | --- | --- |
  14290. * | 0 | BILLBOARDMODE_NONE | |
  14291. * | 1 | BILLBOARDMODE_X | |
  14292. * | 2 | BILLBOARDMODE_Y | |
  14293. * | 4 | BILLBOARDMODE_Z | |
  14294. * | 7 | BILLBOARDMODE_ALL | |
  14295. *
  14296. */
  14297. billboardMode: number;
  14298. private _preserveParentRotationForBillboard;
  14299. /**
  14300. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14301. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14302. */
  14303. preserveParentRotationForBillboard: boolean;
  14304. /**
  14305. * 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
  14306. */
  14307. scalingDeterminant: number;
  14308. private _infiniteDistance;
  14309. /**
  14310. * Gets or sets the distance of the object to max, often used by skybox
  14311. */
  14312. infiniteDistance: boolean;
  14313. /**
  14314. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14315. * By default the system will update normals to compensate
  14316. */
  14317. ignoreNonUniformScaling: boolean;
  14318. /**
  14319. * 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
  14320. */
  14321. reIntegrateRotationIntoRotationQuaternion: boolean;
  14322. /** @hidden */
  14323. _poseMatrix: Nullable<Matrix>;
  14324. /** @hidden */
  14325. _localMatrix: Matrix;
  14326. private _usePivotMatrix;
  14327. private _absolutePosition;
  14328. private _absoluteScaling;
  14329. private _absoluteRotationQuaternion;
  14330. private _pivotMatrix;
  14331. private _pivotMatrixInverse;
  14332. protected _postMultiplyPivotMatrix: boolean;
  14333. protected _isWorldMatrixFrozen: boolean;
  14334. /** @hidden */
  14335. _indexInSceneTransformNodesArray: number;
  14336. /**
  14337. * An event triggered after the world matrix is updated
  14338. */
  14339. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14340. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14341. /**
  14342. * Gets a string identifying the name of the class
  14343. * @returns "TransformNode" string
  14344. */
  14345. getClassName(): string;
  14346. /**
  14347. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14348. */
  14349. position: Vector3;
  14350. /**
  14351. * 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)).
  14352. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14353. */
  14354. rotation: Vector3;
  14355. /**
  14356. * 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)).
  14357. */
  14358. scaling: Vector3;
  14359. /**
  14360. * 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).
  14361. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14362. */
  14363. rotationQuaternion: Nullable<Quaternion>;
  14364. /**
  14365. * The forward direction of that transform in world space.
  14366. */
  14367. readonly forward: Vector3;
  14368. /**
  14369. * The up direction of that transform in world space.
  14370. */
  14371. readonly up: Vector3;
  14372. /**
  14373. * The right direction of that transform in world space.
  14374. */
  14375. readonly right: Vector3;
  14376. /**
  14377. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14378. * @param matrix the matrix to copy the pose from
  14379. * @returns this TransformNode.
  14380. */
  14381. updatePoseMatrix(matrix: Matrix): TransformNode;
  14382. /**
  14383. * Returns the mesh Pose matrix.
  14384. * @returns the pose matrix
  14385. */
  14386. getPoseMatrix(): Matrix;
  14387. /** @hidden */
  14388. _isSynchronized(): boolean;
  14389. /** @hidden */
  14390. _initCache(): void;
  14391. /**
  14392. * Flag the transform node as dirty (Forcing it to update everything)
  14393. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14394. * @returns this transform node
  14395. */
  14396. markAsDirty(property: string): TransformNode;
  14397. /**
  14398. * Returns the current mesh absolute position.
  14399. * Returns a Vector3.
  14400. */
  14401. readonly absolutePosition: Vector3;
  14402. /**
  14403. * Returns the current mesh absolute scaling.
  14404. * Returns a Vector3.
  14405. */
  14406. readonly absoluteScaling: Vector3;
  14407. /**
  14408. * Returns the current mesh absolute rotation.
  14409. * Returns a Quaternion.
  14410. */
  14411. readonly absoluteRotationQuaternion: Quaternion;
  14412. /**
  14413. * Sets a new matrix to apply before all other transformation
  14414. * @param matrix defines the transform matrix
  14415. * @returns the current TransformNode
  14416. */
  14417. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14418. /**
  14419. * Sets a new pivot matrix to the current node
  14420. * @param matrix defines the new pivot matrix to use
  14421. * @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
  14422. * @returns the current TransformNode
  14423. */
  14424. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14425. /**
  14426. * Returns the mesh pivot matrix.
  14427. * Default : Identity.
  14428. * @returns the matrix
  14429. */
  14430. getPivotMatrix(): Matrix;
  14431. /**
  14432. * Instantiate (when possible) or clone that node with its hierarchy
  14433. * @param newParent defines the new parent to use for the instance (or clone)
  14434. * @param options defines options to configure how copy is done
  14435. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14436. * @returns an instance (or a clone) of the current node with its hiearchy
  14437. */
  14438. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14439. doNotInstantiate: boolean;
  14440. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14441. /**
  14442. * Prevents the World matrix to be computed any longer
  14443. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14444. * @returns the TransformNode.
  14445. */
  14446. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14447. /**
  14448. * Allows back the World matrix computation.
  14449. * @returns the TransformNode.
  14450. */
  14451. unfreezeWorldMatrix(): this;
  14452. /**
  14453. * True if the World matrix has been frozen.
  14454. */
  14455. readonly isWorldMatrixFrozen: boolean;
  14456. /**
  14457. * Retuns the mesh absolute position in the World.
  14458. * @returns a Vector3.
  14459. */
  14460. getAbsolutePosition(): Vector3;
  14461. /**
  14462. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14463. * @param absolutePosition the absolute position to set
  14464. * @returns the TransformNode.
  14465. */
  14466. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14467. /**
  14468. * Sets the mesh position in its local space.
  14469. * @param vector3 the position to set in localspace
  14470. * @returns the TransformNode.
  14471. */
  14472. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14473. /**
  14474. * Returns the mesh position in the local space from the current World matrix values.
  14475. * @returns a new Vector3.
  14476. */
  14477. getPositionExpressedInLocalSpace(): Vector3;
  14478. /**
  14479. * Translates the mesh along the passed Vector3 in its local space.
  14480. * @param vector3 the distance to translate in localspace
  14481. * @returns the TransformNode.
  14482. */
  14483. locallyTranslate(vector3: Vector3): TransformNode;
  14484. private static _lookAtVectorCache;
  14485. /**
  14486. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14487. * @param targetPoint the position (must be in same space as current mesh) to look at
  14488. * @param yawCor optional yaw (y-axis) correction in radians
  14489. * @param pitchCor optional pitch (x-axis) correction in radians
  14490. * @param rollCor optional roll (z-axis) correction in radians
  14491. * @param space the choosen space of the target
  14492. * @returns the TransformNode.
  14493. */
  14494. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14495. /**
  14496. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14497. * This Vector3 is expressed in the World space.
  14498. * @param localAxis axis to rotate
  14499. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14500. */
  14501. getDirection(localAxis: Vector3): Vector3;
  14502. /**
  14503. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14504. * localAxis is expressed in the mesh local space.
  14505. * result is computed in the Wordl space from the mesh World matrix.
  14506. * @param localAxis axis to rotate
  14507. * @param result the resulting transformnode
  14508. * @returns this TransformNode.
  14509. */
  14510. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14511. /**
  14512. * Sets this transform node rotation to the given local axis.
  14513. * @param localAxis the axis in local space
  14514. * @param yawCor optional yaw (y-axis) correction in radians
  14515. * @param pitchCor optional pitch (x-axis) correction in radians
  14516. * @param rollCor optional roll (z-axis) correction in radians
  14517. * @returns this TransformNode
  14518. */
  14519. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14520. /**
  14521. * Sets a new pivot point to the current node
  14522. * @param point defines the new pivot point to use
  14523. * @param space defines if the point is in world or local space (local by default)
  14524. * @returns the current TransformNode
  14525. */
  14526. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14527. /**
  14528. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14529. * @returns the pivot point
  14530. */
  14531. getPivotPoint(): Vector3;
  14532. /**
  14533. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14534. * @param result the vector3 to store the result
  14535. * @returns this TransformNode.
  14536. */
  14537. getPivotPointToRef(result: Vector3): TransformNode;
  14538. /**
  14539. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14540. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14541. */
  14542. getAbsolutePivotPoint(): Vector3;
  14543. /**
  14544. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14545. * @param result vector3 to store the result
  14546. * @returns this TransformNode.
  14547. */
  14548. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14549. /**
  14550. * Defines the passed node as the parent of the current node.
  14551. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14552. * @see https://doc.babylonjs.com/how_to/parenting
  14553. * @param node the node ot set as the parent
  14554. * @returns this TransformNode.
  14555. */
  14556. setParent(node: Nullable<Node>): TransformNode;
  14557. private _nonUniformScaling;
  14558. /**
  14559. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14560. */
  14561. readonly nonUniformScaling: boolean;
  14562. /** @hidden */
  14563. _updateNonUniformScalingState(value: boolean): boolean;
  14564. /**
  14565. * Attach the current TransformNode to another TransformNode associated with a bone
  14566. * @param bone Bone affecting the TransformNode
  14567. * @param affectedTransformNode TransformNode associated with the bone
  14568. * @returns this object
  14569. */
  14570. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14571. /**
  14572. * Detach the transform node if its associated with a bone
  14573. * @returns this object
  14574. */
  14575. detachFromBone(): TransformNode;
  14576. private static _rotationAxisCache;
  14577. /**
  14578. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14579. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14580. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14581. * The passed axis is also normalized.
  14582. * @param axis the axis to rotate around
  14583. * @param amount the amount to rotate in radians
  14584. * @param space Space to rotate in (Default: local)
  14585. * @returns the TransformNode.
  14586. */
  14587. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14588. /**
  14589. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14590. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14591. * The passed axis is also normalized. .
  14592. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14593. * @param point the point to rotate around
  14594. * @param axis the axis to rotate around
  14595. * @param amount the amount to rotate in radians
  14596. * @returns the TransformNode
  14597. */
  14598. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14599. /**
  14600. * Translates the mesh along the axis vector for the passed distance in the given space.
  14601. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14602. * @param axis the axis to translate in
  14603. * @param distance the distance to translate
  14604. * @param space Space to rotate in (Default: local)
  14605. * @returns the TransformNode.
  14606. */
  14607. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14608. /**
  14609. * Adds a rotation step to the mesh current rotation.
  14610. * x, y, z are Euler angles expressed in radians.
  14611. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14612. * This means this rotation is made in the mesh local space only.
  14613. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14614. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14615. * ```javascript
  14616. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14617. * ```
  14618. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14619. * 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.
  14620. * @param x Rotation to add
  14621. * @param y Rotation to add
  14622. * @param z Rotation to add
  14623. * @returns the TransformNode.
  14624. */
  14625. addRotation(x: number, y: number, z: number): TransformNode;
  14626. /**
  14627. * @hidden
  14628. */
  14629. protected _getEffectiveParent(): Nullable<Node>;
  14630. /**
  14631. * Computes the world matrix of the node
  14632. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14633. * @returns the world matrix
  14634. */
  14635. computeWorldMatrix(force?: boolean): Matrix;
  14636. protected _afterComputeWorldMatrix(): void;
  14637. /**
  14638. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14639. * @param func callback function to add
  14640. *
  14641. * @returns the TransformNode.
  14642. */
  14643. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14644. /**
  14645. * Removes a registered callback function.
  14646. * @param func callback function to remove
  14647. * @returns the TransformNode.
  14648. */
  14649. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14650. /**
  14651. * Gets the position of the current mesh in camera space
  14652. * @param camera defines the camera to use
  14653. * @returns a position
  14654. */
  14655. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14656. /**
  14657. * Returns the distance from the mesh to the active camera
  14658. * @param camera defines the camera to use
  14659. * @returns the distance
  14660. */
  14661. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14662. /**
  14663. * Clone the current transform node
  14664. * @param name Name of the new clone
  14665. * @param newParent New parent for the clone
  14666. * @param doNotCloneChildren Do not clone children hierarchy
  14667. * @returns the new transform node
  14668. */
  14669. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14670. /**
  14671. * Serializes the objects information.
  14672. * @param currentSerializationObject defines the object to serialize in
  14673. * @returns the serialized object
  14674. */
  14675. serialize(currentSerializationObject?: any): any;
  14676. /**
  14677. * Returns a new TransformNode object parsed from the source provided.
  14678. * @param parsedTransformNode is the source.
  14679. * @param scene the scne the object belongs to
  14680. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14681. * @returns a new TransformNode object parsed from the source provided.
  14682. */
  14683. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14684. /**
  14685. * Get all child-transformNodes of this node
  14686. * @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
  14687. * @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
  14688. * @returns an array of TransformNode
  14689. */
  14690. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14691. /**
  14692. * Releases resources associated with this transform node.
  14693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14695. */
  14696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14697. /**
  14698. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14699. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14700. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14701. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14702. * @returns the current mesh
  14703. */
  14704. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14705. private _syncAbsoluteScalingAndRotation;
  14706. }
  14707. }
  14708. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14709. import { Observable } from "babylonjs/Misc/observable";
  14710. import { Nullable } from "babylonjs/types";
  14711. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14712. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14714. import { Ray } from "babylonjs/Culling/ray";
  14715. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14716. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14717. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14718. /**
  14719. * Defines the types of pose enabled controllers that are supported
  14720. */
  14721. export enum PoseEnabledControllerType {
  14722. /**
  14723. * HTC Vive
  14724. */
  14725. VIVE = 0,
  14726. /**
  14727. * Oculus Rift
  14728. */
  14729. OCULUS = 1,
  14730. /**
  14731. * Windows mixed reality
  14732. */
  14733. WINDOWS = 2,
  14734. /**
  14735. * Samsung gear VR
  14736. */
  14737. GEAR_VR = 3,
  14738. /**
  14739. * Google Daydream
  14740. */
  14741. DAYDREAM = 4,
  14742. /**
  14743. * Generic
  14744. */
  14745. GENERIC = 5
  14746. }
  14747. /**
  14748. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14749. */
  14750. export interface MutableGamepadButton {
  14751. /**
  14752. * Value of the button/trigger
  14753. */
  14754. value: number;
  14755. /**
  14756. * If the button/trigger is currently touched
  14757. */
  14758. touched: boolean;
  14759. /**
  14760. * If the button/trigger is currently pressed
  14761. */
  14762. pressed: boolean;
  14763. }
  14764. /**
  14765. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14766. * @hidden
  14767. */
  14768. export interface ExtendedGamepadButton extends GamepadButton {
  14769. /**
  14770. * If the button/trigger is currently pressed
  14771. */
  14772. readonly pressed: boolean;
  14773. /**
  14774. * If the button/trigger is currently touched
  14775. */
  14776. readonly touched: boolean;
  14777. /**
  14778. * Value of the button/trigger
  14779. */
  14780. readonly value: number;
  14781. }
  14782. /** @hidden */
  14783. export interface _GamePadFactory {
  14784. /**
  14785. * Returns wether or not the current gamepad can be created for this type of controller.
  14786. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14787. * @returns true if it can be created, otherwise false
  14788. */
  14789. canCreate(gamepadInfo: any): boolean;
  14790. /**
  14791. * Creates a new instance of the Gamepad.
  14792. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14793. * @returns the new gamepad instance
  14794. */
  14795. create(gamepadInfo: any): Gamepad;
  14796. }
  14797. /**
  14798. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14799. */
  14800. export class PoseEnabledControllerHelper {
  14801. /** @hidden */
  14802. static _ControllerFactories: _GamePadFactory[];
  14803. /** @hidden */
  14804. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14805. /**
  14806. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14807. * @param vrGamepad the gamepad to initialized
  14808. * @returns a vr controller of the type the gamepad identified as
  14809. */
  14810. static InitiateController(vrGamepad: any): Gamepad;
  14811. }
  14812. /**
  14813. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14814. */
  14815. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14816. /**
  14817. * If the controller is used in a webXR session
  14818. */
  14819. isXR: boolean;
  14820. private _deviceRoomPosition;
  14821. private _deviceRoomRotationQuaternion;
  14822. /**
  14823. * The device position in babylon space
  14824. */
  14825. devicePosition: Vector3;
  14826. /**
  14827. * The device rotation in babylon space
  14828. */
  14829. deviceRotationQuaternion: Quaternion;
  14830. /**
  14831. * The scale factor of the device in babylon space
  14832. */
  14833. deviceScaleFactor: number;
  14834. /**
  14835. * (Likely devicePosition should be used instead) The device position in its room space
  14836. */
  14837. position: Vector3;
  14838. /**
  14839. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14840. */
  14841. rotationQuaternion: Quaternion;
  14842. /**
  14843. * The type of controller (Eg. Windows mixed reality)
  14844. */
  14845. controllerType: PoseEnabledControllerType;
  14846. protected _calculatedPosition: Vector3;
  14847. private _calculatedRotation;
  14848. /**
  14849. * The raw pose from the device
  14850. */
  14851. rawPose: DevicePose;
  14852. private _trackPosition;
  14853. private _maxRotationDistFromHeadset;
  14854. private _draggedRoomRotation;
  14855. /**
  14856. * @hidden
  14857. */
  14858. _disableTrackPosition(fixedPosition: Vector3): void;
  14859. /**
  14860. * Internal, the mesh attached to the controller
  14861. * @hidden
  14862. */
  14863. _mesh: Nullable<AbstractMesh>;
  14864. private _poseControlledCamera;
  14865. private _leftHandSystemQuaternion;
  14866. /**
  14867. * Internal, matrix used to convert room space to babylon space
  14868. * @hidden
  14869. */
  14870. _deviceToWorld: Matrix;
  14871. /**
  14872. * Node to be used when casting a ray from the controller
  14873. * @hidden
  14874. */
  14875. _pointingPoseNode: Nullable<TransformNode>;
  14876. /**
  14877. * Name of the child mesh that can be used to cast a ray from the controller
  14878. */
  14879. static readonly POINTING_POSE: string;
  14880. /**
  14881. * Creates a new PoseEnabledController from a gamepad
  14882. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14883. */
  14884. constructor(browserGamepad: any);
  14885. private _workingMatrix;
  14886. /**
  14887. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14888. */
  14889. update(): void;
  14890. /**
  14891. * Updates only the pose device and mesh without doing any button event checking
  14892. */
  14893. protected _updatePoseAndMesh(): void;
  14894. /**
  14895. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14896. * @param poseData raw pose fromthe device
  14897. */
  14898. updateFromDevice(poseData: DevicePose): void;
  14899. /**
  14900. * @hidden
  14901. */
  14902. _meshAttachedObservable: Observable<AbstractMesh>;
  14903. /**
  14904. * Attaches a mesh to the controller
  14905. * @param mesh the mesh to be attached
  14906. */
  14907. attachToMesh(mesh: AbstractMesh): void;
  14908. /**
  14909. * Attaches the controllers mesh to a camera
  14910. * @param camera the camera the mesh should be attached to
  14911. */
  14912. attachToPoseControlledCamera(camera: TargetCamera): void;
  14913. /**
  14914. * Disposes of the controller
  14915. */
  14916. dispose(): void;
  14917. /**
  14918. * The mesh that is attached to the controller
  14919. */
  14920. readonly mesh: Nullable<AbstractMesh>;
  14921. /**
  14922. * Gets the ray of the controller in the direction the controller is pointing
  14923. * @param length the length the resulting ray should be
  14924. * @returns a ray in the direction the controller is pointing
  14925. */
  14926. getForwardRay(length?: number): Ray;
  14927. }
  14928. }
  14929. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14930. import { Observable } from "babylonjs/Misc/observable";
  14931. import { Scene } from "babylonjs/scene";
  14932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14933. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14934. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14935. import { Nullable } from "babylonjs/types";
  14936. /**
  14937. * Defines the WebVRController object that represents controllers tracked in 3D space
  14938. */
  14939. export abstract class WebVRController extends PoseEnabledController {
  14940. /**
  14941. * Internal, the default controller model for the controller
  14942. */
  14943. protected _defaultModel: Nullable<AbstractMesh>;
  14944. /**
  14945. * Fired when the trigger state has changed
  14946. */
  14947. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14948. /**
  14949. * Fired when the main button state has changed
  14950. */
  14951. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14952. /**
  14953. * Fired when the secondary button state has changed
  14954. */
  14955. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14956. /**
  14957. * Fired when the pad state has changed
  14958. */
  14959. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14960. /**
  14961. * Fired when controllers stick values have changed
  14962. */
  14963. onPadValuesChangedObservable: Observable<StickValues>;
  14964. /**
  14965. * Array of button availible on the controller
  14966. */
  14967. protected _buttons: Array<MutableGamepadButton>;
  14968. private _onButtonStateChange;
  14969. /**
  14970. * Fired when a controller button's state has changed
  14971. * @param callback the callback containing the button that was modified
  14972. */
  14973. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14974. /**
  14975. * X and Y axis corresponding to the controllers joystick
  14976. */
  14977. pad: StickValues;
  14978. /**
  14979. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14980. */
  14981. hand: string;
  14982. /**
  14983. * The default controller model for the controller
  14984. */
  14985. readonly defaultModel: Nullable<AbstractMesh>;
  14986. /**
  14987. * Creates a new WebVRController from a gamepad
  14988. * @param vrGamepad the gamepad that the WebVRController should be created from
  14989. */
  14990. constructor(vrGamepad: any);
  14991. /**
  14992. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14993. */
  14994. update(): void;
  14995. /**
  14996. * Function to be called when a button is modified
  14997. */
  14998. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14999. /**
  15000. * Loads a mesh and attaches it to the controller
  15001. * @param scene the scene the mesh should be added to
  15002. * @param meshLoaded callback for when the mesh has been loaded
  15003. */
  15004. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15005. private _setButtonValue;
  15006. private _changes;
  15007. private _checkChanges;
  15008. /**
  15009. * Disposes of th webVRCOntroller
  15010. */
  15011. dispose(): void;
  15012. }
  15013. }
  15014. declare module "babylonjs/Lights/hemisphericLight" {
  15015. import { Nullable } from "babylonjs/types";
  15016. import { Scene } from "babylonjs/scene";
  15017. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15018. import { Color3 } from "babylonjs/Maths/math.color";
  15019. import { Effect } from "babylonjs/Materials/effect";
  15020. import { Light } from "babylonjs/Lights/light";
  15021. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15022. /**
  15023. * The HemisphericLight simulates the ambient environment light,
  15024. * so the passed direction is the light reflection direction, not the incoming direction.
  15025. */
  15026. export class HemisphericLight extends Light {
  15027. /**
  15028. * The groundColor is the light in the opposite direction to the one specified during creation.
  15029. * 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.
  15030. */
  15031. groundColor: Color3;
  15032. /**
  15033. * The light reflection direction, not the incoming direction.
  15034. */
  15035. direction: Vector3;
  15036. /**
  15037. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15038. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15039. * The HemisphericLight can't cast shadows.
  15040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15041. * @param name The friendly name of the light
  15042. * @param direction The direction of the light reflection
  15043. * @param scene The scene the light belongs to
  15044. */
  15045. constructor(name: string, direction: Vector3, scene: Scene);
  15046. protected _buildUniformLayout(): void;
  15047. /**
  15048. * Returns the string "HemisphericLight".
  15049. * @return The class name
  15050. */
  15051. getClassName(): string;
  15052. /**
  15053. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15054. * Returns the updated direction.
  15055. * @param target The target the direction should point to
  15056. * @return The computed direction
  15057. */
  15058. setDirectionToTarget(target: Vector3): Vector3;
  15059. /**
  15060. * Returns the shadow generator associated to the light.
  15061. * @returns Always null for hemispheric lights because it does not support shadows.
  15062. */
  15063. getShadowGenerator(): Nullable<IShadowGenerator>;
  15064. /**
  15065. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15066. * @param effect The effect to update
  15067. * @param lightIndex The index of the light in the effect to update
  15068. * @returns The hemispheric light
  15069. */
  15070. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15071. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15072. /**
  15073. * Computes the world matrix of the node
  15074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15075. * @param useWasUpdatedFlag defines a reserved property
  15076. * @returns the world matrix
  15077. */
  15078. computeWorldMatrix(): Matrix;
  15079. /**
  15080. * Returns the integer 3.
  15081. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15082. */
  15083. getTypeID(): number;
  15084. /**
  15085. * Prepares the list of defines specific to the light type.
  15086. * @param defines the list of defines
  15087. * @param lightIndex defines the index of the light for the effect
  15088. */
  15089. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15090. }
  15091. }
  15092. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15093. /** @hidden */
  15094. export var vrMultiviewToSingleviewPixelShader: {
  15095. name: string;
  15096. shader: string;
  15097. };
  15098. }
  15099. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15100. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15101. import { Scene } from "babylonjs/scene";
  15102. /**
  15103. * Renders to multiple views with a single draw call
  15104. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15105. */
  15106. export class MultiviewRenderTarget extends RenderTargetTexture {
  15107. /**
  15108. * Creates a multiview render target
  15109. * @param scene scene used with the render target
  15110. * @param size the size of the render target (used for each view)
  15111. */
  15112. constructor(scene: Scene, size?: number | {
  15113. width: number;
  15114. height: number;
  15115. } | {
  15116. ratio: number;
  15117. });
  15118. /**
  15119. * @hidden
  15120. * @param faceIndex the face index, if its a cube texture
  15121. */
  15122. _bindFrameBuffer(faceIndex?: number): void;
  15123. /**
  15124. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15125. * @returns the view count
  15126. */
  15127. getViewCount(): number;
  15128. }
  15129. }
  15130. declare module "babylonjs/Maths/math.frustum" {
  15131. import { Matrix } from "babylonjs/Maths/math.vector";
  15132. import { DeepImmutable } from "babylonjs/types";
  15133. import { Plane } from "babylonjs/Maths/math.plane";
  15134. /**
  15135. * Represents a camera frustum
  15136. */
  15137. export class Frustum {
  15138. /**
  15139. * Gets the planes representing the frustum
  15140. * @param transform matrix to be applied to the returned planes
  15141. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15142. */
  15143. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15144. /**
  15145. * Gets the near frustum plane transformed by the transform matrix
  15146. * @param transform transformation matrix to be applied to the resulting frustum plane
  15147. * @param frustumPlane the resuling frustum plane
  15148. */
  15149. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15150. /**
  15151. * Gets the far frustum plane transformed by the transform matrix
  15152. * @param transform transformation matrix to be applied to the resulting frustum plane
  15153. * @param frustumPlane the resuling frustum plane
  15154. */
  15155. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15156. /**
  15157. * Gets the left frustum plane transformed by the transform matrix
  15158. * @param transform transformation matrix to be applied to the resulting frustum plane
  15159. * @param frustumPlane the resuling frustum plane
  15160. */
  15161. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15162. /**
  15163. * Gets the right frustum plane transformed by the transform matrix
  15164. * @param transform transformation matrix to be applied to the resulting frustum plane
  15165. * @param frustumPlane the resuling frustum plane
  15166. */
  15167. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15168. /**
  15169. * Gets the top frustum plane transformed by the transform matrix
  15170. * @param transform transformation matrix to be applied to the resulting frustum plane
  15171. * @param frustumPlane the resuling frustum plane
  15172. */
  15173. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15174. /**
  15175. * Gets the bottom frustum plane transformed by the transform matrix
  15176. * @param transform transformation matrix to be applied to the resulting frustum plane
  15177. * @param frustumPlane the resuling frustum plane
  15178. */
  15179. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15180. /**
  15181. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15182. * @param transform transformation matrix to be applied to the resulting frustum planes
  15183. * @param frustumPlanes the resuling frustum planes
  15184. */
  15185. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15186. }
  15187. }
  15188. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15189. import { Camera } from "babylonjs/Cameras/camera";
  15190. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15191. import { Nullable } from "babylonjs/types";
  15192. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15193. import { Matrix } from "babylonjs/Maths/math.vector";
  15194. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15195. module "babylonjs/Engines/engine" {
  15196. interface Engine {
  15197. /**
  15198. * Creates a new multiview render target
  15199. * @param width defines the width of the texture
  15200. * @param height defines the height of the texture
  15201. * @returns the created multiview texture
  15202. */
  15203. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15204. /**
  15205. * Binds a multiview framebuffer to be drawn to
  15206. * @param multiviewTexture texture to bind
  15207. */
  15208. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15209. }
  15210. }
  15211. module "babylonjs/Cameras/camera" {
  15212. interface Camera {
  15213. /**
  15214. * @hidden
  15215. * 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)
  15216. */
  15217. _useMultiviewToSingleView: boolean;
  15218. /**
  15219. * @hidden
  15220. * 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)
  15221. */
  15222. _multiviewTexture: Nullable<RenderTargetTexture>;
  15223. /**
  15224. * @hidden
  15225. * ensures the multiview texture of the camera exists and has the specified width/height
  15226. * @param width height to set on the multiview texture
  15227. * @param height width to set on the multiview texture
  15228. */
  15229. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15230. }
  15231. }
  15232. module "babylonjs/scene" {
  15233. interface Scene {
  15234. /** @hidden */
  15235. _transformMatrixR: Matrix;
  15236. /** @hidden */
  15237. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15238. /** @hidden */
  15239. _createMultiviewUbo(): void;
  15240. /** @hidden */
  15241. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15242. /** @hidden */
  15243. _renderMultiviewToSingleView(camera: Camera): void;
  15244. }
  15245. }
  15246. }
  15247. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15248. import { Camera } from "babylonjs/Cameras/camera";
  15249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15250. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15251. import "babylonjs/Engines/Extensions/engine.multiview";
  15252. /**
  15253. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15254. * This will not be used for webXR as it supports displaying texture arrays directly
  15255. */
  15256. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15257. /**
  15258. * Initializes a VRMultiviewToSingleview
  15259. * @param name name of the post process
  15260. * @param camera camera to be applied to
  15261. * @param scaleFactor scaling factor to the size of the output texture
  15262. */
  15263. constructor(name: string, camera: Camera, scaleFactor: number);
  15264. }
  15265. }
  15266. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15267. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15268. import { Nullable } from "babylonjs/types";
  15269. import { Size } from "babylonjs/Maths/math.size";
  15270. import { Observable } from "babylonjs/Misc/observable";
  15271. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15272. /**
  15273. * Interface used to define additional presentation attributes
  15274. */
  15275. export interface IVRPresentationAttributes {
  15276. /**
  15277. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15278. */
  15279. highRefreshRate: boolean;
  15280. /**
  15281. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15282. */
  15283. foveationLevel: number;
  15284. }
  15285. module "babylonjs/Engines/engine" {
  15286. interface Engine {
  15287. /** @hidden */
  15288. _vrDisplay: any;
  15289. /** @hidden */
  15290. _vrSupported: boolean;
  15291. /** @hidden */
  15292. _oldSize: Size;
  15293. /** @hidden */
  15294. _oldHardwareScaleFactor: number;
  15295. /** @hidden */
  15296. _vrExclusivePointerMode: boolean;
  15297. /** @hidden */
  15298. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15299. /** @hidden */
  15300. _onVRDisplayPointerRestricted: () => void;
  15301. /** @hidden */
  15302. _onVRDisplayPointerUnrestricted: () => void;
  15303. /** @hidden */
  15304. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15305. /** @hidden */
  15306. _onVrDisplayDisconnect: Nullable<() => void>;
  15307. /** @hidden */
  15308. _onVrDisplayPresentChange: Nullable<() => void>;
  15309. /**
  15310. * Observable signaled when VR display mode changes
  15311. */
  15312. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15313. /**
  15314. * Observable signaled when VR request present is complete
  15315. */
  15316. onVRRequestPresentComplete: Observable<boolean>;
  15317. /**
  15318. * Observable signaled when VR request present starts
  15319. */
  15320. onVRRequestPresentStart: Observable<Engine>;
  15321. /**
  15322. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15323. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15324. */
  15325. isInVRExclusivePointerMode: boolean;
  15326. /**
  15327. * Gets a boolean indicating if a webVR device was detected
  15328. * @returns true if a webVR device was detected
  15329. */
  15330. isVRDevicePresent(): boolean;
  15331. /**
  15332. * Gets the current webVR device
  15333. * @returns the current webVR device (or null)
  15334. */
  15335. getVRDevice(): any;
  15336. /**
  15337. * Initializes a webVR display and starts listening to display change events
  15338. * The onVRDisplayChangedObservable will be notified upon these changes
  15339. * @returns A promise containing a VRDisplay and if vr is supported
  15340. */
  15341. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15342. /** @hidden */
  15343. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15344. /**
  15345. * Gets or sets the presentation attributes used to configure VR rendering
  15346. */
  15347. vrPresentationAttributes?: IVRPresentationAttributes;
  15348. /**
  15349. * Call this function to switch to webVR mode
  15350. * Will do nothing if webVR is not supported or if there is no webVR device
  15351. * @param options the webvr options provided to the camera. mainly used for multiview
  15352. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15353. */
  15354. enableVR(options: WebVROptions): void;
  15355. /** @hidden */
  15356. _onVRFullScreenTriggered(): void;
  15357. }
  15358. }
  15359. }
  15360. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15361. import { Nullable } from "babylonjs/types";
  15362. import { Observable } from "babylonjs/Misc/observable";
  15363. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15364. import { Scene } from "babylonjs/scene";
  15365. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15366. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15367. import { Node } from "babylonjs/node";
  15368. import { Ray } from "babylonjs/Culling/ray";
  15369. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15370. import "babylonjs/Engines/Extensions/engine.webVR";
  15371. /**
  15372. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15373. * IMPORTANT!! The data is right-hand data.
  15374. * @export
  15375. * @interface DevicePose
  15376. */
  15377. export interface DevicePose {
  15378. /**
  15379. * The position of the device, values in array are [x,y,z].
  15380. */
  15381. readonly position: Nullable<Float32Array>;
  15382. /**
  15383. * The linearVelocity of the device, values in array are [x,y,z].
  15384. */
  15385. readonly linearVelocity: Nullable<Float32Array>;
  15386. /**
  15387. * The linearAcceleration of the device, values in array are [x,y,z].
  15388. */
  15389. readonly linearAcceleration: Nullable<Float32Array>;
  15390. /**
  15391. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15392. */
  15393. readonly orientation: Nullable<Float32Array>;
  15394. /**
  15395. * The angularVelocity of the device, values in array are [x,y,z].
  15396. */
  15397. readonly angularVelocity: Nullable<Float32Array>;
  15398. /**
  15399. * The angularAcceleration of the device, values in array are [x,y,z].
  15400. */
  15401. readonly angularAcceleration: Nullable<Float32Array>;
  15402. }
  15403. /**
  15404. * Interface representing a pose controlled object in Babylon.
  15405. * A pose controlled object has both regular pose values as well as pose values
  15406. * from an external device such as a VR head mounted display
  15407. */
  15408. export interface PoseControlled {
  15409. /**
  15410. * The position of the object in babylon space.
  15411. */
  15412. position: Vector3;
  15413. /**
  15414. * The rotation quaternion of the object in babylon space.
  15415. */
  15416. rotationQuaternion: Quaternion;
  15417. /**
  15418. * The position of the device in babylon space.
  15419. */
  15420. devicePosition?: Vector3;
  15421. /**
  15422. * The rotation quaternion of the device in babylon space.
  15423. */
  15424. deviceRotationQuaternion: Quaternion;
  15425. /**
  15426. * The raw pose coming from the device.
  15427. */
  15428. rawPose: Nullable<DevicePose>;
  15429. /**
  15430. * The scale of the device to be used when translating from device space to babylon space.
  15431. */
  15432. deviceScaleFactor: number;
  15433. /**
  15434. * Updates the poseControlled values based on the input device pose.
  15435. * @param poseData the pose data to update the object with
  15436. */
  15437. updateFromDevice(poseData: DevicePose): void;
  15438. }
  15439. /**
  15440. * Set of options to customize the webVRCamera
  15441. */
  15442. export interface WebVROptions {
  15443. /**
  15444. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15445. */
  15446. trackPosition?: boolean;
  15447. /**
  15448. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15449. */
  15450. positionScale?: number;
  15451. /**
  15452. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15453. */
  15454. displayName?: string;
  15455. /**
  15456. * Should the native controller meshes be initialized. (default: true)
  15457. */
  15458. controllerMeshes?: boolean;
  15459. /**
  15460. * Creating a default HemiLight only on controllers. (default: true)
  15461. */
  15462. defaultLightingOnControllers?: boolean;
  15463. /**
  15464. * If you don't want to use the default VR button of the helper. (default: false)
  15465. */
  15466. useCustomVRButton?: boolean;
  15467. /**
  15468. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15469. */
  15470. customVRButton?: HTMLButtonElement;
  15471. /**
  15472. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15473. */
  15474. rayLength?: number;
  15475. /**
  15476. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15477. */
  15478. defaultHeight?: number;
  15479. /**
  15480. * If multiview should be used if availible (default: false)
  15481. */
  15482. useMultiview?: boolean;
  15483. }
  15484. /**
  15485. * This represents a WebVR camera.
  15486. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15487. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15488. */
  15489. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15490. private webVROptions;
  15491. /**
  15492. * @hidden
  15493. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15494. */
  15495. _vrDevice: any;
  15496. /**
  15497. * The rawPose of the vrDevice.
  15498. */
  15499. rawPose: Nullable<DevicePose>;
  15500. private _onVREnabled;
  15501. private _specsVersion;
  15502. private _attached;
  15503. private _frameData;
  15504. protected _descendants: Array<Node>;
  15505. private _deviceRoomPosition;
  15506. /** @hidden */
  15507. _deviceRoomRotationQuaternion: Quaternion;
  15508. private _standingMatrix;
  15509. /**
  15510. * Represents device position in babylon space.
  15511. */
  15512. devicePosition: Vector3;
  15513. /**
  15514. * Represents device rotation in babylon space.
  15515. */
  15516. deviceRotationQuaternion: Quaternion;
  15517. /**
  15518. * The scale of the device to be used when translating from device space to babylon space.
  15519. */
  15520. deviceScaleFactor: number;
  15521. private _deviceToWorld;
  15522. private _worldToDevice;
  15523. /**
  15524. * References to the webVR controllers for the vrDevice.
  15525. */
  15526. controllers: Array<WebVRController>;
  15527. /**
  15528. * Emits an event when a controller is attached.
  15529. */
  15530. onControllersAttachedObservable: Observable<WebVRController[]>;
  15531. /**
  15532. * Emits an event when a controller's mesh has been loaded;
  15533. */
  15534. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15535. /**
  15536. * Emits an event when the HMD's pose has been updated.
  15537. */
  15538. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15539. private _poseSet;
  15540. /**
  15541. * If the rig cameras be used as parent instead of this camera.
  15542. */
  15543. rigParenting: boolean;
  15544. private _lightOnControllers;
  15545. private _defaultHeight?;
  15546. /**
  15547. * Instantiates a WebVRFreeCamera.
  15548. * @param name The name of the WebVRFreeCamera
  15549. * @param position The starting anchor position for the camera
  15550. * @param scene The scene the camera belongs to
  15551. * @param webVROptions a set of customizable options for the webVRCamera
  15552. */
  15553. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15554. /**
  15555. * Gets the device distance from the ground in meters.
  15556. * @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.
  15557. */
  15558. deviceDistanceToRoomGround(): number;
  15559. /**
  15560. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15561. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15562. */
  15563. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15564. /**
  15565. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15566. * @returns A promise with a boolean set to if the standing matrix is supported.
  15567. */
  15568. useStandingMatrixAsync(): Promise<boolean>;
  15569. /**
  15570. * Disposes the camera
  15571. */
  15572. dispose(): void;
  15573. /**
  15574. * Gets a vrController by name.
  15575. * @param name The name of the controller to retreive
  15576. * @returns the controller matching the name specified or null if not found
  15577. */
  15578. getControllerByName(name: string): Nullable<WebVRController>;
  15579. private _leftController;
  15580. /**
  15581. * The controller corresponding to the users left hand.
  15582. */
  15583. readonly leftController: Nullable<WebVRController>;
  15584. private _rightController;
  15585. /**
  15586. * The controller corresponding to the users right hand.
  15587. */
  15588. readonly rightController: Nullable<WebVRController>;
  15589. /**
  15590. * Casts a ray forward from the vrCamera's gaze.
  15591. * @param length Length of the ray (default: 100)
  15592. * @returns the ray corresponding to the gaze
  15593. */
  15594. getForwardRay(length?: number): Ray;
  15595. /**
  15596. * @hidden
  15597. * Updates the camera based on device's frame data
  15598. */
  15599. _checkInputs(): void;
  15600. /**
  15601. * Updates the poseControlled values based on the input device pose.
  15602. * @param poseData Pose coming from the device
  15603. */
  15604. updateFromDevice(poseData: DevicePose): void;
  15605. private _htmlElementAttached;
  15606. private _detachIfAttached;
  15607. /**
  15608. * WebVR's attach control will start broadcasting frames to the device.
  15609. * Note that in certain browsers (chrome for example) this function must be called
  15610. * within a user-interaction callback. Example:
  15611. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15612. *
  15613. * @param element html element to attach the vrDevice to
  15614. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15615. */
  15616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15617. /**
  15618. * Detaches the camera from the html element and disables VR
  15619. *
  15620. * @param element html element to detach from
  15621. */
  15622. detachControl(element: HTMLElement): void;
  15623. /**
  15624. * @returns the name of this class
  15625. */
  15626. getClassName(): string;
  15627. /**
  15628. * Calls resetPose on the vrDisplay
  15629. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15630. */
  15631. resetToCurrentRotation(): void;
  15632. /**
  15633. * @hidden
  15634. * Updates the rig cameras (left and right eye)
  15635. */
  15636. _updateRigCameras(): void;
  15637. private _workingVector;
  15638. private _oneVector;
  15639. private _workingMatrix;
  15640. private updateCacheCalled;
  15641. private _correctPositionIfNotTrackPosition;
  15642. /**
  15643. * @hidden
  15644. * Updates the cached values of the camera
  15645. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15646. */
  15647. _updateCache(ignoreParentClass?: boolean): void;
  15648. /**
  15649. * @hidden
  15650. * Get current device position in babylon world
  15651. */
  15652. _computeDevicePosition(): void;
  15653. /**
  15654. * Updates the current device position and rotation in the babylon world
  15655. */
  15656. update(): void;
  15657. /**
  15658. * @hidden
  15659. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15660. * @returns an identity matrix
  15661. */
  15662. _getViewMatrix(): Matrix;
  15663. private _tmpMatrix;
  15664. /**
  15665. * This function is called by the two RIG cameras.
  15666. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15667. * @hidden
  15668. */
  15669. _getWebVRViewMatrix(): Matrix;
  15670. /** @hidden */
  15671. _getWebVRProjectionMatrix(): Matrix;
  15672. private _onGamepadConnectedObserver;
  15673. private _onGamepadDisconnectedObserver;
  15674. private _updateCacheWhenTrackingDisabledObserver;
  15675. /**
  15676. * Initializes the controllers and their meshes
  15677. */
  15678. initControllers(): void;
  15679. }
  15680. }
  15681. declare module "babylonjs/PostProcesses/postProcess" {
  15682. import { Nullable } from "babylonjs/types";
  15683. import { SmartArray } from "babylonjs/Misc/smartArray";
  15684. import { Observable } from "babylonjs/Misc/observable";
  15685. import { Vector2 } from "babylonjs/Maths/math.vector";
  15686. import { Camera } from "babylonjs/Cameras/camera";
  15687. import { Effect } from "babylonjs/Materials/effect";
  15688. import "babylonjs/Shaders/postprocess.vertex";
  15689. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15690. import { Engine } from "babylonjs/Engines/engine";
  15691. import { Color4 } from "babylonjs/Maths/math.color";
  15692. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15693. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15694. /**
  15695. * Size options for a post process
  15696. */
  15697. export type PostProcessOptions = {
  15698. width: number;
  15699. height: number;
  15700. };
  15701. /**
  15702. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15703. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15704. */
  15705. export class PostProcess {
  15706. /** Name of the PostProcess. */
  15707. name: string;
  15708. /**
  15709. * Gets or sets the unique id of the post process
  15710. */
  15711. uniqueId: number;
  15712. /**
  15713. * Width of the texture to apply the post process on
  15714. */
  15715. width: number;
  15716. /**
  15717. * Height of the texture to apply the post process on
  15718. */
  15719. height: number;
  15720. /**
  15721. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15722. * @hidden
  15723. */
  15724. _outputTexture: Nullable<InternalTexture>;
  15725. /**
  15726. * Sampling mode used by the shader
  15727. * See https://doc.babylonjs.com/classes/3.1/texture
  15728. */
  15729. renderTargetSamplingMode: number;
  15730. /**
  15731. * Clear color to use when screen clearing
  15732. */
  15733. clearColor: Color4;
  15734. /**
  15735. * If the buffer needs to be cleared before applying the post process. (default: true)
  15736. * Should be set to false if shader will overwrite all previous pixels.
  15737. */
  15738. autoClear: boolean;
  15739. /**
  15740. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15741. */
  15742. alphaMode: number;
  15743. /**
  15744. * Sets the setAlphaBlendConstants of the babylon engine
  15745. */
  15746. alphaConstants: Color4;
  15747. /**
  15748. * Animations to be used for the post processing
  15749. */
  15750. animations: import("babylonjs/Animations/animation").Animation[];
  15751. /**
  15752. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15753. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15754. */
  15755. enablePixelPerfectMode: boolean;
  15756. /**
  15757. * Force the postprocess to be applied without taking in account viewport
  15758. */
  15759. forceFullscreenViewport: boolean;
  15760. /**
  15761. * List of inspectable custom properties (used by the Inspector)
  15762. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15763. */
  15764. inspectableCustomProperties: IInspectable[];
  15765. /**
  15766. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15767. *
  15768. * | Value | Type | Description |
  15769. * | ----- | ----------------------------------- | ----------- |
  15770. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15771. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15772. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15773. *
  15774. */
  15775. scaleMode: number;
  15776. /**
  15777. * Force textures to be a power of two (default: false)
  15778. */
  15779. alwaysForcePOT: boolean;
  15780. private _samples;
  15781. /**
  15782. * Number of sample textures (default: 1)
  15783. */
  15784. samples: number;
  15785. /**
  15786. * Modify the scale of the post process to be the same as the viewport (default: false)
  15787. */
  15788. adaptScaleToCurrentViewport: boolean;
  15789. private _camera;
  15790. private _scene;
  15791. private _engine;
  15792. private _options;
  15793. private _reusable;
  15794. private _textureType;
  15795. /**
  15796. * Smart array of input and output textures for the post process.
  15797. * @hidden
  15798. */
  15799. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15800. /**
  15801. * The index in _textures that corresponds to the output texture.
  15802. * @hidden
  15803. */
  15804. _currentRenderTextureInd: number;
  15805. private _effect;
  15806. private _samplers;
  15807. private _fragmentUrl;
  15808. private _vertexUrl;
  15809. private _parameters;
  15810. private _scaleRatio;
  15811. protected _indexParameters: any;
  15812. private _shareOutputWithPostProcess;
  15813. private _texelSize;
  15814. private _forcedOutputTexture;
  15815. /**
  15816. * Returns the fragment url or shader name used in the post process.
  15817. * @returns the fragment url or name in the shader store.
  15818. */
  15819. getEffectName(): string;
  15820. /**
  15821. * An event triggered when the postprocess is activated.
  15822. */
  15823. onActivateObservable: Observable<Camera>;
  15824. private _onActivateObserver;
  15825. /**
  15826. * A function that is added to the onActivateObservable
  15827. */
  15828. onActivate: Nullable<(camera: Camera) => void>;
  15829. /**
  15830. * An event triggered when the postprocess changes its size.
  15831. */
  15832. onSizeChangedObservable: Observable<PostProcess>;
  15833. private _onSizeChangedObserver;
  15834. /**
  15835. * A function that is added to the onSizeChangedObservable
  15836. */
  15837. onSizeChanged: (postProcess: PostProcess) => void;
  15838. /**
  15839. * An event triggered when the postprocess applies its effect.
  15840. */
  15841. onApplyObservable: Observable<Effect>;
  15842. private _onApplyObserver;
  15843. /**
  15844. * A function that is added to the onApplyObservable
  15845. */
  15846. onApply: (effect: Effect) => void;
  15847. /**
  15848. * An event triggered before rendering the postprocess
  15849. */
  15850. onBeforeRenderObservable: Observable<Effect>;
  15851. private _onBeforeRenderObserver;
  15852. /**
  15853. * A function that is added to the onBeforeRenderObservable
  15854. */
  15855. onBeforeRender: (effect: Effect) => void;
  15856. /**
  15857. * An event triggered after rendering the postprocess
  15858. */
  15859. onAfterRenderObservable: Observable<Effect>;
  15860. private _onAfterRenderObserver;
  15861. /**
  15862. * A function that is added to the onAfterRenderObservable
  15863. */
  15864. onAfterRender: (efect: Effect) => void;
  15865. /**
  15866. * 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
  15867. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15868. */
  15869. inputTexture: InternalTexture;
  15870. /**
  15871. * Gets the camera which post process is applied to.
  15872. * @returns The camera the post process is applied to.
  15873. */
  15874. getCamera(): Camera;
  15875. /**
  15876. * Gets the texel size of the postprocess.
  15877. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15878. */
  15879. readonly texelSize: Vector2;
  15880. /**
  15881. * Creates a new instance PostProcess
  15882. * @param name The name of the PostProcess.
  15883. * @param fragmentUrl The url of the fragment shader to be used.
  15884. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15885. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15886. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15887. * @param camera The camera to apply the render pass to.
  15888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15889. * @param engine The engine which the post process will be applied. (default: current engine)
  15890. * @param reusable If the post process can be reused on the same frame. (default: false)
  15891. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15892. * @param textureType Type of textures used when performing the post process. (default: 0)
  15893. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15894. * @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
  15895. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15896. */
  15897. constructor(
  15898. /** Name of the PostProcess. */
  15899. 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);
  15900. /**
  15901. * Gets a string idenfifying the name of the class
  15902. * @returns "PostProcess" string
  15903. */
  15904. getClassName(): string;
  15905. /**
  15906. * Gets the engine which this post process belongs to.
  15907. * @returns The engine the post process was enabled with.
  15908. */
  15909. getEngine(): Engine;
  15910. /**
  15911. * The effect that is created when initializing the post process.
  15912. * @returns The created effect corresponding the the postprocess.
  15913. */
  15914. getEffect(): Effect;
  15915. /**
  15916. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15917. * @param postProcess The post process to share the output with.
  15918. * @returns This post process.
  15919. */
  15920. shareOutputWith(postProcess: PostProcess): PostProcess;
  15921. /**
  15922. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15923. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15924. */
  15925. useOwnOutput(): void;
  15926. /**
  15927. * Updates the effect with the current post process compile time values and recompiles the shader.
  15928. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15929. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15930. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15931. * @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
  15932. * @param onCompiled Called when the shader has been compiled.
  15933. * @param onError Called if there is an error when compiling a shader.
  15934. */
  15935. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15936. /**
  15937. * The post process is reusable if it can be used multiple times within one frame.
  15938. * @returns If the post process is reusable
  15939. */
  15940. isReusable(): boolean;
  15941. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15942. markTextureDirty(): void;
  15943. /**
  15944. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15945. * 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.
  15946. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15947. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15948. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15949. * @returns The target texture that was bound to be written to.
  15950. */
  15951. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15952. /**
  15953. * If the post process is supported.
  15954. */
  15955. readonly isSupported: boolean;
  15956. /**
  15957. * The aspect ratio of the output texture.
  15958. */
  15959. readonly aspectRatio: number;
  15960. /**
  15961. * Get a value indicating if the post-process is ready to be used
  15962. * @returns true if the post-process is ready (shader is compiled)
  15963. */
  15964. isReady(): boolean;
  15965. /**
  15966. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15967. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15968. */
  15969. apply(): Nullable<Effect>;
  15970. private _disposeTextures;
  15971. /**
  15972. * Disposes the post process.
  15973. * @param camera The camera to dispose the post process on.
  15974. */
  15975. dispose(camera?: Camera): void;
  15976. }
  15977. }
  15978. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15979. /** @hidden */
  15980. export var kernelBlurVaryingDeclaration: {
  15981. name: string;
  15982. shader: string;
  15983. };
  15984. }
  15985. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15986. /** @hidden */
  15987. export var kernelBlurFragment: {
  15988. name: string;
  15989. shader: string;
  15990. };
  15991. }
  15992. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15993. /** @hidden */
  15994. export var kernelBlurFragment2: {
  15995. name: string;
  15996. shader: string;
  15997. };
  15998. }
  15999. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16000. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16001. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16002. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16003. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16004. /** @hidden */
  16005. export var kernelBlurPixelShader: {
  16006. name: string;
  16007. shader: string;
  16008. };
  16009. }
  16010. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16011. /** @hidden */
  16012. export var kernelBlurVertex: {
  16013. name: string;
  16014. shader: string;
  16015. };
  16016. }
  16017. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16018. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16019. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16020. /** @hidden */
  16021. export var kernelBlurVertexShader: {
  16022. name: string;
  16023. shader: string;
  16024. };
  16025. }
  16026. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16027. import { Vector2 } from "babylonjs/Maths/math.vector";
  16028. import { Nullable } from "babylonjs/types";
  16029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16030. import { Camera } from "babylonjs/Cameras/camera";
  16031. import { Effect } from "babylonjs/Materials/effect";
  16032. import { Engine } from "babylonjs/Engines/engine";
  16033. import "babylonjs/Shaders/kernelBlur.fragment";
  16034. import "babylonjs/Shaders/kernelBlur.vertex";
  16035. /**
  16036. * The Blur Post Process which blurs an image based on a kernel and direction.
  16037. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16038. */
  16039. export class BlurPostProcess extends PostProcess {
  16040. /** The direction in which to blur the image. */
  16041. direction: Vector2;
  16042. private blockCompilation;
  16043. protected _kernel: number;
  16044. protected _idealKernel: number;
  16045. protected _packedFloat: boolean;
  16046. private _staticDefines;
  16047. /**
  16048. * Sets the length in pixels of the blur sample region
  16049. */
  16050. /**
  16051. * Gets the length in pixels of the blur sample region
  16052. */
  16053. kernel: number;
  16054. /**
  16055. * Sets wether or not the blur needs to unpack/repack floats
  16056. */
  16057. /**
  16058. * Gets wether or not the blur is unpacking/repacking floats
  16059. */
  16060. packedFloat: boolean;
  16061. /**
  16062. * Creates a new instance BlurPostProcess
  16063. * @param name The name of the effect.
  16064. * @param direction The direction in which to blur the image.
  16065. * @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.
  16066. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16067. * @param camera The camera to apply the render pass to.
  16068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16069. * @param engine The engine which the post process will be applied. (default: current engine)
  16070. * @param reusable If the post process can be reused on the same frame. (default: false)
  16071. * @param textureType Type of textures used when performing the post process. (default: 0)
  16072. * @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)
  16073. */
  16074. constructor(name: string,
  16075. /** The direction in which to blur the image. */
  16076. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16077. /**
  16078. * Updates the effect with the current post process compile time values and recompiles the shader.
  16079. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16080. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16081. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16082. * @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
  16083. * @param onCompiled Called when the shader has been compiled.
  16084. * @param onError Called if there is an error when compiling a shader.
  16085. */
  16086. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16087. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16088. /**
  16089. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16090. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16091. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16092. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16093. * The gaps between physical kernels are compensated for in the weighting of the samples
  16094. * @param idealKernel Ideal blur kernel.
  16095. * @return Nearest best kernel.
  16096. */
  16097. protected _nearestBestKernel(idealKernel: number): number;
  16098. /**
  16099. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16100. * @param x The point on the Gaussian distribution to sample.
  16101. * @return the value of the Gaussian function at x.
  16102. */
  16103. protected _gaussianWeight(x: number): number;
  16104. /**
  16105. * Generates a string that can be used as a floating point number in GLSL.
  16106. * @param x Value to print.
  16107. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16108. * @return GLSL float string.
  16109. */
  16110. protected _glslFloat(x: number, decimalFigures?: number): string;
  16111. }
  16112. }
  16113. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16114. import { Scene } from "babylonjs/scene";
  16115. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16116. import { Plane } from "babylonjs/Maths/math.plane";
  16117. /**
  16118. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16119. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16120. * You can then easily use it as a reflectionTexture on a flat surface.
  16121. * In case the surface is not a plane, please consider relying on reflection probes.
  16122. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16123. */
  16124. export class MirrorTexture extends RenderTargetTexture {
  16125. private scene;
  16126. /**
  16127. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16128. * 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.
  16129. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16130. */
  16131. mirrorPlane: Plane;
  16132. /**
  16133. * Define the blur ratio used to blur the reflection if needed.
  16134. */
  16135. blurRatio: number;
  16136. /**
  16137. * Define the adaptive blur kernel used to blur the reflection if needed.
  16138. * This will autocompute the closest best match for the `blurKernel`
  16139. */
  16140. adaptiveBlurKernel: number;
  16141. /**
  16142. * Define the blur kernel used to blur the reflection if needed.
  16143. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16144. */
  16145. blurKernel: number;
  16146. /**
  16147. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16148. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16149. */
  16150. blurKernelX: number;
  16151. /**
  16152. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16153. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16154. */
  16155. blurKernelY: number;
  16156. private _autoComputeBlurKernel;
  16157. protected _onRatioRescale(): void;
  16158. private _updateGammaSpace;
  16159. private _imageProcessingConfigChangeObserver;
  16160. private _transformMatrix;
  16161. private _mirrorMatrix;
  16162. private _savedViewMatrix;
  16163. private _blurX;
  16164. private _blurY;
  16165. private _adaptiveBlurKernel;
  16166. private _blurKernelX;
  16167. private _blurKernelY;
  16168. private _blurRatio;
  16169. /**
  16170. * Instantiates a Mirror Texture.
  16171. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16172. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16173. * You can then easily use it as a reflectionTexture on a flat surface.
  16174. * In case the surface is not a plane, please consider relying on reflection probes.
  16175. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16176. * @param name
  16177. * @param size
  16178. * @param scene
  16179. * @param generateMipMaps
  16180. * @param type
  16181. * @param samplingMode
  16182. * @param generateDepthBuffer
  16183. */
  16184. constructor(name: string, size: number | {
  16185. width: number;
  16186. height: number;
  16187. } | {
  16188. ratio: number;
  16189. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16190. private _preparePostProcesses;
  16191. /**
  16192. * Clone the mirror texture.
  16193. * @returns the cloned texture
  16194. */
  16195. clone(): MirrorTexture;
  16196. /**
  16197. * Serialize the texture to a JSON representation you could use in Parse later on
  16198. * @returns the serialized JSON representation
  16199. */
  16200. serialize(): any;
  16201. /**
  16202. * Dispose the texture and release its associated resources.
  16203. */
  16204. dispose(): void;
  16205. }
  16206. }
  16207. declare module "babylonjs/Materials/Textures/texture" {
  16208. import { Observable } from "babylonjs/Misc/observable";
  16209. import { Nullable } from "babylonjs/types";
  16210. import { Matrix } from "babylonjs/Maths/math.vector";
  16211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16212. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16213. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16214. import { Scene } from "babylonjs/scene";
  16215. /**
  16216. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16217. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16218. */
  16219. export class Texture extends BaseTexture {
  16220. /**
  16221. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16222. */
  16223. static SerializeBuffers: boolean;
  16224. /** @hidden */
  16225. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16226. /** @hidden */
  16227. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16228. /** @hidden */
  16229. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16230. /** nearest is mag = nearest and min = nearest and mip = linear */
  16231. static readonly NEAREST_SAMPLINGMODE: number;
  16232. /** nearest is mag = nearest and min = nearest and mip = linear */
  16233. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16234. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16235. static readonly BILINEAR_SAMPLINGMODE: number;
  16236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16237. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16238. /** Trilinear is mag = linear and min = linear and mip = linear */
  16239. static readonly TRILINEAR_SAMPLINGMODE: number;
  16240. /** Trilinear is mag = linear and min = linear and mip = linear */
  16241. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16242. /** mag = nearest and min = nearest and mip = nearest */
  16243. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16244. /** mag = nearest and min = linear and mip = nearest */
  16245. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16246. /** mag = nearest and min = linear and mip = linear */
  16247. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16248. /** mag = nearest and min = linear and mip = none */
  16249. static readonly NEAREST_LINEAR: number;
  16250. /** mag = nearest and min = nearest and mip = none */
  16251. static readonly NEAREST_NEAREST: number;
  16252. /** mag = linear and min = nearest and mip = nearest */
  16253. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16254. /** mag = linear and min = nearest and mip = linear */
  16255. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16256. /** mag = linear and min = linear and mip = none */
  16257. static readonly LINEAR_LINEAR: number;
  16258. /** mag = linear and min = nearest and mip = none */
  16259. static readonly LINEAR_NEAREST: number;
  16260. /** Explicit coordinates mode */
  16261. static readonly EXPLICIT_MODE: number;
  16262. /** Spherical coordinates mode */
  16263. static readonly SPHERICAL_MODE: number;
  16264. /** Planar coordinates mode */
  16265. static readonly PLANAR_MODE: number;
  16266. /** Cubic coordinates mode */
  16267. static readonly CUBIC_MODE: number;
  16268. /** Projection coordinates mode */
  16269. static readonly PROJECTION_MODE: number;
  16270. /** Inverse Cubic coordinates mode */
  16271. static readonly SKYBOX_MODE: number;
  16272. /** Inverse Cubic coordinates mode */
  16273. static readonly INVCUBIC_MODE: number;
  16274. /** Equirectangular coordinates mode */
  16275. static readonly EQUIRECTANGULAR_MODE: number;
  16276. /** Equirectangular Fixed coordinates mode */
  16277. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16278. /** Equirectangular Fixed Mirrored coordinates mode */
  16279. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16280. /** Texture is not repeating outside of 0..1 UVs */
  16281. static readonly CLAMP_ADDRESSMODE: number;
  16282. /** Texture is repeating outside of 0..1 UVs */
  16283. static readonly WRAP_ADDRESSMODE: number;
  16284. /** Texture is repeating and mirrored */
  16285. static readonly MIRROR_ADDRESSMODE: number;
  16286. /**
  16287. * 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
  16288. */
  16289. static UseSerializedUrlIfAny: boolean;
  16290. /**
  16291. * Define the url of the texture.
  16292. */
  16293. url: Nullable<string>;
  16294. /**
  16295. * Define an offset on the texture to offset the u coordinates of the UVs
  16296. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16297. */
  16298. uOffset: number;
  16299. /**
  16300. * Define an offset on the texture to offset the v coordinates of the UVs
  16301. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16302. */
  16303. vOffset: number;
  16304. /**
  16305. * Define an offset on the texture to scale the u coordinates of the UVs
  16306. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16307. */
  16308. uScale: number;
  16309. /**
  16310. * Define an offset on the texture to scale the v coordinates of the UVs
  16311. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16312. */
  16313. vScale: number;
  16314. /**
  16315. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16316. * @see http://doc.babylonjs.com/how_to/more_materials
  16317. */
  16318. uAng: number;
  16319. /**
  16320. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16321. * @see http://doc.babylonjs.com/how_to/more_materials
  16322. */
  16323. vAng: number;
  16324. /**
  16325. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16326. * @see http://doc.babylonjs.com/how_to/more_materials
  16327. */
  16328. wAng: number;
  16329. /**
  16330. * Defines the center of rotation (U)
  16331. */
  16332. uRotationCenter: number;
  16333. /**
  16334. * Defines the center of rotation (V)
  16335. */
  16336. vRotationCenter: number;
  16337. /**
  16338. * Defines the center of rotation (W)
  16339. */
  16340. wRotationCenter: number;
  16341. /**
  16342. * Are mip maps generated for this texture or not.
  16343. */
  16344. readonly noMipmap: boolean;
  16345. /**
  16346. * List of inspectable custom properties (used by the Inspector)
  16347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16348. */
  16349. inspectableCustomProperties: Nullable<IInspectable[]>;
  16350. private _noMipmap;
  16351. /** @hidden */
  16352. _invertY: boolean;
  16353. private _rowGenerationMatrix;
  16354. private _cachedTextureMatrix;
  16355. private _projectionModeMatrix;
  16356. private _t0;
  16357. private _t1;
  16358. private _t2;
  16359. private _cachedUOffset;
  16360. private _cachedVOffset;
  16361. private _cachedUScale;
  16362. private _cachedVScale;
  16363. private _cachedUAng;
  16364. private _cachedVAng;
  16365. private _cachedWAng;
  16366. private _cachedProjectionMatrixId;
  16367. private _cachedCoordinatesMode;
  16368. /** @hidden */
  16369. protected _initialSamplingMode: number;
  16370. /** @hidden */
  16371. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16372. private _deleteBuffer;
  16373. protected _format: Nullable<number>;
  16374. private _delayedOnLoad;
  16375. private _delayedOnError;
  16376. private _mimeType?;
  16377. /**
  16378. * Observable triggered once the texture has been loaded.
  16379. */
  16380. onLoadObservable: Observable<Texture>;
  16381. protected _isBlocking: boolean;
  16382. /**
  16383. * Is the texture preventing material to render while loading.
  16384. * If false, a default texture will be used instead of the loading one during the preparation step.
  16385. */
  16386. isBlocking: boolean;
  16387. /**
  16388. * Get the current sampling mode associated with the texture.
  16389. */
  16390. readonly samplingMode: number;
  16391. /**
  16392. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16393. */
  16394. readonly invertY: boolean;
  16395. /**
  16396. * Instantiates a new texture.
  16397. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16398. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16399. * @param url defines the url of the picture to load as a texture
  16400. * @param scene defines the scene or engine the texture will belong to
  16401. * @param noMipmap defines if the texture will require mip maps or not
  16402. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16403. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16404. * @param onLoad defines a callback triggered when the texture has been loaded
  16405. * @param onError defines a callback triggered when an error occurred during the loading session
  16406. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16407. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16408. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16409. * @param mimeType defines an optional mime type information
  16410. */
  16411. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16412. /**
  16413. * Update the url (and optional buffer) of this texture if url was null during construction.
  16414. * @param url the url of the texture
  16415. * @param buffer the buffer of the texture (defaults to null)
  16416. * @param onLoad callback called when the texture is loaded (defaults to null)
  16417. */
  16418. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16419. /**
  16420. * Finish the loading sequence of a texture flagged as delayed load.
  16421. * @hidden
  16422. */
  16423. delayLoad(): void;
  16424. private _prepareRowForTextureGeneration;
  16425. /**
  16426. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16427. * @returns the transform matrix of the texture.
  16428. */
  16429. getTextureMatrix(uBase?: number): Matrix;
  16430. /**
  16431. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16432. * @returns The reflection texture transform
  16433. */
  16434. getReflectionTextureMatrix(): Matrix;
  16435. /**
  16436. * Clones the texture.
  16437. * @returns the cloned texture
  16438. */
  16439. clone(): Texture;
  16440. /**
  16441. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16442. * @returns The JSON representation of the texture
  16443. */
  16444. serialize(): any;
  16445. /**
  16446. * Get the current class name of the texture useful for serialization or dynamic coding.
  16447. * @returns "Texture"
  16448. */
  16449. getClassName(): string;
  16450. /**
  16451. * Dispose the texture and release its associated resources.
  16452. */
  16453. dispose(): void;
  16454. /**
  16455. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16456. * @param parsedTexture Define the JSON representation of the texture
  16457. * @param scene Define the scene the parsed texture should be instantiated in
  16458. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16459. * @returns The parsed texture if successful
  16460. */
  16461. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16462. /**
  16463. * Creates a texture from its base 64 representation.
  16464. * @param data Define the base64 payload without the data: prefix
  16465. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16466. * @param scene Define the scene the texture should belong to
  16467. * @param noMipmap Forces the texture to not create mip map information if true
  16468. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16469. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16470. * @param onLoad define a callback triggered when the texture has been loaded
  16471. * @param onError define a callback triggered when an error occurred during the loading session
  16472. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16473. * @returns the created texture
  16474. */
  16475. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16476. /**
  16477. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16478. * @param data Define the base64 payload without the data: prefix
  16479. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16480. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16481. * @param scene Define the scene the texture should belong to
  16482. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16483. * @param noMipmap Forces the texture to not create mip map information if true
  16484. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16485. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16486. * @param onLoad define a callback triggered when the texture has been loaded
  16487. * @param onError define a callback triggered when an error occurred during the loading session
  16488. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16489. * @returns the created texture
  16490. */
  16491. 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;
  16492. }
  16493. }
  16494. declare module "babylonjs/PostProcesses/postProcessManager" {
  16495. import { Nullable } from "babylonjs/types";
  16496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16497. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16498. import { Scene } from "babylonjs/scene";
  16499. /**
  16500. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16501. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16502. */
  16503. export class PostProcessManager {
  16504. private _scene;
  16505. private _indexBuffer;
  16506. private _vertexBuffers;
  16507. /**
  16508. * Creates a new instance PostProcess
  16509. * @param scene The scene that the post process is associated with.
  16510. */
  16511. constructor(scene: Scene);
  16512. private _prepareBuffers;
  16513. private _buildIndexBuffer;
  16514. /**
  16515. * Rebuilds the vertex buffers of the manager.
  16516. * @hidden
  16517. */
  16518. _rebuild(): void;
  16519. /**
  16520. * Prepares a frame to be run through a post process.
  16521. * @param sourceTexture The input texture to the post procesess. (default: null)
  16522. * @param postProcesses An array of post processes to be run. (default: null)
  16523. * @returns True if the post processes were able to be run.
  16524. * @hidden
  16525. */
  16526. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16527. /**
  16528. * Manually render a set of post processes to a texture.
  16529. * @param postProcesses An array of post processes to be run.
  16530. * @param targetTexture The target texture to render to.
  16531. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16532. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16533. * @param lodLevel defines which lod of the texture to render to
  16534. */
  16535. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16536. /**
  16537. * Finalize the result of the output of the postprocesses.
  16538. * @param doNotPresent If true the result will not be displayed to the screen.
  16539. * @param targetTexture The target texture to render to.
  16540. * @param faceIndex The index of the face to bind the target texture to.
  16541. * @param postProcesses The array of post processes to render.
  16542. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16543. * @hidden
  16544. */
  16545. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16546. /**
  16547. * Disposes of the post process manager.
  16548. */
  16549. dispose(): void;
  16550. }
  16551. }
  16552. declare module "babylonjs/Misc/gradients" {
  16553. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16554. /** Interface used by value gradients (color, factor, ...) */
  16555. export interface IValueGradient {
  16556. /**
  16557. * Gets or sets the gradient value (between 0 and 1)
  16558. */
  16559. gradient: number;
  16560. }
  16561. /** Class used to store color4 gradient */
  16562. export class ColorGradient implements IValueGradient {
  16563. /**
  16564. * Gets or sets the gradient value (between 0 and 1)
  16565. */
  16566. gradient: number;
  16567. /**
  16568. * Gets or sets first associated color
  16569. */
  16570. color1: Color4;
  16571. /**
  16572. * Gets or sets second associated color
  16573. */
  16574. color2?: Color4;
  16575. /**
  16576. * Will get a color picked randomly between color1 and color2.
  16577. * If color2 is undefined then color1 will be used
  16578. * @param result defines the target Color4 to store the result in
  16579. */
  16580. getColorToRef(result: Color4): void;
  16581. }
  16582. /** Class used to store color 3 gradient */
  16583. export class Color3Gradient implements IValueGradient {
  16584. /**
  16585. * Gets or sets the gradient value (between 0 and 1)
  16586. */
  16587. gradient: number;
  16588. /**
  16589. * Gets or sets the associated color
  16590. */
  16591. color: Color3;
  16592. }
  16593. /** Class used to store factor gradient */
  16594. export class FactorGradient implements IValueGradient {
  16595. /**
  16596. * Gets or sets the gradient value (between 0 and 1)
  16597. */
  16598. gradient: number;
  16599. /**
  16600. * Gets or sets first associated factor
  16601. */
  16602. factor1: number;
  16603. /**
  16604. * Gets or sets second associated factor
  16605. */
  16606. factor2?: number;
  16607. /**
  16608. * Will get a number picked randomly between factor1 and factor2.
  16609. * If factor2 is undefined then factor1 will be used
  16610. * @returns the picked number
  16611. */
  16612. getFactor(): number;
  16613. }
  16614. /**
  16615. * Helper used to simplify some generic gradient tasks
  16616. */
  16617. export class GradientHelper {
  16618. /**
  16619. * Gets the current gradient from an array of IValueGradient
  16620. * @param ratio defines the current ratio to get
  16621. * @param gradients defines the array of IValueGradient
  16622. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16623. */
  16624. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16625. }
  16626. }
  16627. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16628. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16629. import { Nullable } from "babylonjs/types";
  16630. module "babylonjs/Engines/thinEngine" {
  16631. interface ThinEngine {
  16632. /**
  16633. * Creates a dynamic texture
  16634. * @param width defines the width of the texture
  16635. * @param height defines the height of the texture
  16636. * @param generateMipMaps defines if the engine should generate the mip levels
  16637. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16638. * @returns the dynamic texture inside an InternalTexture
  16639. */
  16640. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16641. /**
  16642. * Update the content of a dynamic texture
  16643. * @param texture defines the texture to update
  16644. * @param canvas defines the canvas containing the source
  16645. * @param invertY defines if data must be stored with Y axis inverted
  16646. * @param premulAlpha defines if alpha is stored as premultiplied
  16647. * @param format defines the format of the data
  16648. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16649. */
  16650. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16651. }
  16652. }
  16653. }
  16654. declare module "babylonjs/Misc/canvasGenerator" {
  16655. /**
  16656. * Helper class used to generate a canvas to manipulate images
  16657. */
  16658. export class CanvasGenerator {
  16659. /**
  16660. * Create a new canvas (or offscreen canvas depending on the context)
  16661. * @param width defines the expected width
  16662. * @param height defines the expected height
  16663. * @return a new canvas or offscreen canvas
  16664. */
  16665. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16666. }
  16667. }
  16668. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16669. import { Scene } from "babylonjs/scene";
  16670. import { Texture } from "babylonjs/Materials/Textures/texture";
  16671. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16672. /**
  16673. * A class extending Texture allowing drawing on a texture
  16674. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16675. */
  16676. export class DynamicTexture extends Texture {
  16677. private _generateMipMaps;
  16678. private _canvas;
  16679. private _context;
  16680. private _engine;
  16681. /**
  16682. * Creates a DynamicTexture
  16683. * @param name defines the name of the texture
  16684. * @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
  16685. * @param scene defines the scene where you want the texture
  16686. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16687. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16688. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16689. */
  16690. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16691. /**
  16692. * Get the current class name of the texture useful for serialization or dynamic coding.
  16693. * @returns "DynamicTexture"
  16694. */
  16695. getClassName(): string;
  16696. /**
  16697. * Gets the current state of canRescale
  16698. */
  16699. readonly canRescale: boolean;
  16700. private _recreate;
  16701. /**
  16702. * Scales the texture
  16703. * @param ratio the scale factor to apply to both width and height
  16704. */
  16705. scale(ratio: number): void;
  16706. /**
  16707. * Resizes the texture
  16708. * @param width the new width
  16709. * @param height the new height
  16710. */
  16711. scaleTo(width: number, height: number): void;
  16712. /**
  16713. * Gets the context of the canvas used by the texture
  16714. * @returns the canvas context of the dynamic texture
  16715. */
  16716. getContext(): CanvasRenderingContext2D;
  16717. /**
  16718. * Clears the texture
  16719. */
  16720. clear(): void;
  16721. /**
  16722. * Updates the texture
  16723. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16724. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16725. */
  16726. update(invertY?: boolean, premulAlpha?: boolean): void;
  16727. /**
  16728. * Draws text onto the texture
  16729. * @param text defines the text to be drawn
  16730. * @param x defines the placement of the text from the left
  16731. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16732. * @param font defines the font to be used with font-style, font-size, font-name
  16733. * @param color defines the color used for the text
  16734. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16735. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16736. * @param update defines whether texture is immediately update (default is true)
  16737. */
  16738. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16739. /**
  16740. * Clones the texture
  16741. * @returns the clone of the texture.
  16742. */
  16743. clone(): DynamicTexture;
  16744. /**
  16745. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16746. * @returns a serialized dynamic texture object
  16747. */
  16748. serialize(): any;
  16749. /** @hidden */
  16750. _rebuild(): void;
  16751. }
  16752. }
  16753. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16754. import { Scene } from "babylonjs/scene";
  16755. import { ISceneComponent } from "babylonjs/sceneComponent";
  16756. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16757. module "babylonjs/abstractScene" {
  16758. interface AbstractScene {
  16759. /**
  16760. * The list of procedural textures added to the scene
  16761. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16762. */
  16763. proceduralTextures: Array<ProceduralTexture>;
  16764. }
  16765. }
  16766. /**
  16767. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16768. * in a given scene.
  16769. */
  16770. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16771. /**
  16772. * The component name helpfull to identify the component in the list of scene components.
  16773. */
  16774. readonly name: string;
  16775. /**
  16776. * The scene the component belongs to.
  16777. */
  16778. scene: Scene;
  16779. /**
  16780. * Creates a new instance of the component for the given scene
  16781. * @param scene Defines the scene to register the component in
  16782. */
  16783. constructor(scene: Scene);
  16784. /**
  16785. * Registers the component in a given scene
  16786. */
  16787. register(): void;
  16788. /**
  16789. * Rebuilds the elements related to this component in case of
  16790. * context lost for instance.
  16791. */
  16792. rebuild(): void;
  16793. /**
  16794. * Disposes the component and the associated ressources.
  16795. */
  16796. dispose(): void;
  16797. private _beforeClear;
  16798. }
  16799. }
  16800. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16802. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16803. module "babylonjs/Engines/thinEngine" {
  16804. interface ThinEngine {
  16805. /**
  16806. * Creates a new render target cube texture
  16807. * @param size defines the size of the texture
  16808. * @param options defines the options used to create the texture
  16809. * @returns a new render target cube texture stored in an InternalTexture
  16810. */
  16811. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16812. }
  16813. }
  16814. }
  16815. declare module "babylonjs/Shaders/procedural.vertex" {
  16816. /** @hidden */
  16817. export var proceduralVertexShader: {
  16818. name: string;
  16819. shader: string;
  16820. };
  16821. }
  16822. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16823. import { Observable } from "babylonjs/Misc/observable";
  16824. import { Nullable } from "babylonjs/types";
  16825. import { Scene } from "babylonjs/scene";
  16826. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16827. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16828. import { Effect } from "babylonjs/Materials/effect";
  16829. import { Texture } from "babylonjs/Materials/Textures/texture";
  16830. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16831. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16832. import "babylonjs/Shaders/procedural.vertex";
  16833. /**
  16834. * 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.
  16835. * This is the base class of any Procedural texture and contains most of the shareable code.
  16836. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16837. */
  16838. export class ProceduralTexture extends Texture {
  16839. isCube: boolean;
  16840. /**
  16841. * Define if the texture is enabled or not (disabled texture will not render)
  16842. */
  16843. isEnabled: boolean;
  16844. /**
  16845. * Define if the texture must be cleared before rendering (default is true)
  16846. */
  16847. autoClear: boolean;
  16848. /**
  16849. * Callback called when the texture is generated
  16850. */
  16851. onGenerated: () => void;
  16852. /**
  16853. * Event raised when the texture is generated
  16854. */
  16855. onGeneratedObservable: Observable<ProceduralTexture>;
  16856. /** @hidden */
  16857. _generateMipMaps: boolean;
  16858. /** @hidden **/
  16859. _effect: Effect;
  16860. /** @hidden */
  16861. _textures: {
  16862. [key: string]: Texture;
  16863. };
  16864. private _size;
  16865. private _currentRefreshId;
  16866. private _refreshRate;
  16867. private _vertexBuffers;
  16868. private _indexBuffer;
  16869. private _uniforms;
  16870. private _samplers;
  16871. private _fragment;
  16872. private _floats;
  16873. private _ints;
  16874. private _floatsArrays;
  16875. private _colors3;
  16876. private _colors4;
  16877. private _vectors2;
  16878. private _vectors3;
  16879. private _matrices;
  16880. private _fallbackTexture;
  16881. private _fallbackTextureUsed;
  16882. private _engine;
  16883. private _cachedDefines;
  16884. private _contentUpdateId;
  16885. private _contentData;
  16886. /**
  16887. * Instantiates a new procedural texture.
  16888. * 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.
  16889. * This is the base class of any Procedural texture and contains most of the shareable code.
  16890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16891. * @param name Define the name of the texture
  16892. * @param size Define the size of the texture to create
  16893. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16894. * @param scene Define the scene the texture belongs to
  16895. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16896. * @param generateMipMaps Define if the texture should creates mip maps or not
  16897. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16898. */
  16899. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16900. /**
  16901. * The effect that is created when initializing the post process.
  16902. * @returns The created effect corresponding the the postprocess.
  16903. */
  16904. getEffect(): Effect;
  16905. /**
  16906. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16907. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16908. */
  16909. getContent(): Nullable<ArrayBufferView>;
  16910. private _createIndexBuffer;
  16911. /** @hidden */
  16912. _rebuild(): void;
  16913. /**
  16914. * Resets the texture in order to recreate its associated resources.
  16915. * This can be called in case of context loss
  16916. */
  16917. reset(): void;
  16918. protected _getDefines(): string;
  16919. /**
  16920. * Is the texture ready to be used ? (rendered at least once)
  16921. * @returns true if ready, otherwise, false.
  16922. */
  16923. isReady(): boolean;
  16924. /**
  16925. * Resets the refresh counter of the texture and start bak from scratch.
  16926. * Could be useful to regenerate the texture if it is setup to render only once.
  16927. */
  16928. resetRefreshCounter(): void;
  16929. /**
  16930. * Set the fragment shader to use in order to render the texture.
  16931. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16932. */
  16933. setFragment(fragment: any): void;
  16934. /**
  16935. * Define the refresh rate of the texture or the rendering frequency.
  16936. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16937. */
  16938. refreshRate: number;
  16939. /** @hidden */
  16940. _shouldRender(): boolean;
  16941. /**
  16942. * Get the size the texture is rendering at.
  16943. * @returns the size (texture is always squared)
  16944. */
  16945. getRenderSize(): number;
  16946. /**
  16947. * Resize the texture to new value.
  16948. * @param size Define the new size the texture should have
  16949. * @param generateMipMaps Define whether the new texture should create mip maps
  16950. */
  16951. resize(size: number, generateMipMaps: boolean): void;
  16952. private _checkUniform;
  16953. /**
  16954. * Set a texture in the shader program used to render.
  16955. * @param name Define the name of the uniform samplers as defined in the shader
  16956. * @param texture Define the texture to bind to this sampler
  16957. * @return the texture itself allowing "fluent" like uniform updates
  16958. */
  16959. setTexture(name: string, texture: Texture): ProceduralTexture;
  16960. /**
  16961. * Set a float in the shader.
  16962. * @param name Define the name of the uniform as defined in the shader
  16963. * @param value Define the value to give to the uniform
  16964. * @return the texture itself allowing "fluent" like uniform updates
  16965. */
  16966. setFloat(name: string, value: number): ProceduralTexture;
  16967. /**
  16968. * Set a int in the shader.
  16969. * @param name Define the name of the uniform as defined in the shader
  16970. * @param value Define the value to give to the uniform
  16971. * @return the texture itself allowing "fluent" like uniform updates
  16972. */
  16973. setInt(name: string, value: number): ProceduralTexture;
  16974. /**
  16975. * Set an array of floats in the shader.
  16976. * @param name Define the name of the uniform as defined in the shader
  16977. * @param value Define the value to give to the uniform
  16978. * @return the texture itself allowing "fluent" like uniform updates
  16979. */
  16980. setFloats(name: string, value: number[]): ProceduralTexture;
  16981. /**
  16982. * Set a vec3 in the shader from a Color3.
  16983. * @param name Define the name of the uniform as defined in the shader
  16984. * @param value Define the value to give to the uniform
  16985. * @return the texture itself allowing "fluent" like uniform updates
  16986. */
  16987. setColor3(name: string, value: Color3): ProceduralTexture;
  16988. /**
  16989. * Set a vec4 in the shader from a Color4.
  16990. * @param name Define the name of the uniform as defined in the shader
  16991. * @param value Define the value to give to the uniform
  16992. * @return the texture itself allowing "fluent" like uniform updates
  16993. */
  16994. setColor4(name: string, value: Color4): ProceduralTexture;
  16995. /**
  16996. * Set a vec2 in the shader from a Vector2.
  16997. * @param name Define the name of the uniform as defined in the shader
  16998. * @param value Define the value to give to the uniform
  16999. * @return the texture itself allowing "fluent" like uniform updates
  17000. */
  17001. setVector2(name: string, value: Vector2): ProceduralTexture;
  17002. /**
  17003. * Set a vec3 in the shader from a Vector3.
  17004. * @param name Define the name of the uniform as defined in the shader
  17005. * @param value Define the value to give to the uniform
  17006. * @return the texture itself allowing "fluent" like uniform updates
  17007. */
  17008. setVector3(name: string, value: Vector3): ProceduralTexture;
  17009. /**
  17010. * Set a mat4 in the shader from a MAtrix.
  17011. * @param name Define the name of the uniform as defined in the shader
  17012. * @param value Define the value to give to the uniform
  17013. * @return the texture itself allowing "fluent" like uniform updates
  17014. */
  17015. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17016. /**
  17017. * Render the texture to its associated render target.
  17018. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17019. */
  17020. render(useCameraPostProcess?: boolean): void;
  17021. /**
  17022. * Clone the texture.
  17023. * @returns the cloned texture
  17024. */
  17025. clone(): ProceduralTexture;
  17026. /**
  17027. * Dispose the texture and release its asoociated resources.
  17028. */
  17029. dispose(): void;
  17030. }
  17031. }
  17032. declare module "babylonjs/Particles/baseParticleSystem" {
  17033. import { Nullable } from "babylonjs/types";
  17034. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17036. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17037. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17038. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17039. import { Scene } from "babylonjs/scene";
  17040. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17041. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17042. import { Texture } from "babylonjs/Materials/Textures/texture";
  17043. import { Color4 } from "babylonjs/Maths/math.color";
  17044. import { Animation } from "babylonjs/Animations/animation";
  17045. /**
  17046. * This represents the base class for particle system in Babylon.
  17047. * 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.
  17048. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17049. * @example https://doc.babylonjs.com/babylon101/particles
  17050. */
  17051. export class BaseParticleSystem {
  17052. /**
  17053. * Source color is added to the destination color without alpha affecting the result
  17054. */
  17055. static BLENDMODE_ONEONE: number;
  17056. /**
  17057. * Blend current color and particle color using particle’s alpha
  17058. */
  17059. static BLENDMODE_STANDARD: number;
  17060. /**
  17061. * Add current color and particle color multiplied by particle’s alpha
  17062. */
  17063. static BLENDMODE_ADD: number;
  17064. /**
  17065. * Multiply current color with particle color
  17066. */
  17067. static BLENDMODE_MULTIPLY: number;
  17068. /**
  17069. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17070. */
  17071. static BLENDMODE_MULTIPLYADD: number;
  17072. /**
  17073. * List of animations used by the particle system.
  17074. */
  17075. animations: Animation[];
  17076. /**
  17077. * The id of the Particle system.
  17078. */
  17079. id: string;
  17080. /**
  17081. * The friendly name of the Particle system.
  17082. */
  17083. name: string;
  17084. /**
  17085. * The rendering group used by the Particle system to chose when to render.
  17086. */
  17087. renderingGroupId: number;
  17088. /**
  17089. * The emitter represents the Mesh or position we are attaching the particle system to.
  17090. */
  17091. emitter: Nullable<AbstractMesh | Vector3>;
  17092. /**
  17093. * The maximum number of particles to emit per frame
  17094. */
  17095. emitRate: number;
  17096. /**
  17097. * If you want to launch only a few particles at once, that can be done, as well.
  17098. */
  17099. manualEmitCount: number;
  17100. /**
  17101. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17102. */
  17103. updateSpeed: number;
  17104. /**
  17105. * The amount of time the particle system is running (depends of the overall update speed).
  17106. */
  17107. targetStopDuration: number;
  17108. /**
  17109. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17110. */
  17111. disposeOnStop: boolean;
  17112. /**
  17113. * Minimum power of emitting particles.
  17114. */
  17115. minEmitPower: number;
  17116. /**
  17117. * Maximum power of emitting particles.
  17118. */
  17119. maxEmitPower: number;
  17120. /**
  17121. * Minimum life time of emitting particles.
  17122. */
  17123. minLifeTime: number;
  17124. /**
  17125. * Maximum life time of emitting particles.
  17126. */
  17127. maxLifeTime: number;
  17128. /**
  17129. * Minimum Size of emitting particles.
  17130. */
  17131. minSize: number;
  17132. /**
  17133. * Maximum Size of emitting particles.
  17134. */
  17135. maxSize: number;
  17136. /**
  17137. * Minimum scale of emitting particles on X axis.
  17138. */
  17139. minScaleX: number;
  17140. /**
  17141. * Maximum scale of emitting particles on X axis.
  17142. */
  17143. maxScaleX: number;
  17144. /**
  17145. * Minimum scale of emitting particles on Y axis.
  17146. */
  17147. minScaleY: number;
  17148. /**
  17149. * Maximum scale of emitting particles on Y axis.
  17150. */
  17151. maxScaleY: number;
  17152. /**
  17153. * Gets or sets the minimal initial rotation in radians.
  17154. */
  17155. minInitialRotation: number;
  17156. /**
  17157. * Gets or sets the maximal initial rotation in radians.
  17158. */
  17159. maxInitialRotation: number;
  17160. /**
  17161. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17162. */
  17163. minAngularSpeed: number;
  17164. /**
  17165. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17166. */
  17167. maxAngularSpeed: number;
  17168. /**
  17169. * The texture used to render each particle. (this can be a spritesheet)
  17170. */
  17171. particleTexture: Nullable<Texture>;
  17172. /**
  17173. * The layer mask we are rendering the particles through.
  17174. */
  17175. layerMask: number;
  17176. /**
  17177. * This can help using your own shader to render the particle system.
  17178. * The according effect will be created
  17179. */
  17180. customShader: any;
  17181. /**
  17182. * By default particle system starts as soon as they are created. This prevents the
  17183. * automatic start to happen and let you decide when to start emitting particles.
  17184. */
  17185. preventAutoStart: boolean;
  17186. private _noiseTexture;
  17187. /**
  17188. * Gets or sets a texture used to add random noise to particle positions
  17189. */
  17190. noiseTexture: Nullable<ProceduralTexture>;
  17191. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17192. noiseStrength: Vector3;
  17193. /**
  17194. * Callback triggered when the particle animation is ending.
  17195. */
  17196. onAnimationEnd: Nullable<() => void>;
  17197. /**
  17198. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17199. */
  17200. blendMode: number;
  17201. /**
  17202. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17203. * to override the particles.
  17204. */
  17205. forceDepthWrite: boolean;
  17206. /** 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 */
  17207. preWarmCycles: number;
  17208. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17209. preWarmStepOffset: number;
  17210. /**
  17211. * 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)
  17212. */
  17213. spriteCellChangeSpeed: number;
  17214. /**
  17215. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17216. */
  17217. startSpriteCellID: number;
  17218. /**
  17219. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17220. */
  17221. endSpriteCellID: number;
  17222. /**
  17223. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17224. */
  17225. spriteCellWidth: number;
  17226. /**
  17227. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17228. */
  17229. spriteCellHeight: number;
  17230. /**
  17231. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17232. */
  17233. spriteRandomStartCell: boolean;
  17234. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17235. translationPivot: Vector2;
  17236. /** @hidden */
  17237. protected _isAnimationSheetEnabled: boolean;
  17238. /**
  17239. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17240. */
  17241. beginAnimationOnStart: boolean;
  17242. /**
  17243. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17244. */
  17245. beginAnimationFrom: number;
  17246. /**
  17247. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17248. */
  17249. beginAnimationTo: number;
  17250. /**
  17251. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17252. */
  17253. beginAnimationLoop: boolean;
  17254. /**
  17255. * Gets or sets a world offset applied to all particles
  17256. */
  17257. worldOffset: Vector3;
  17258. /**
  17259. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17260. */
  17261. isAnimationSheetEnabled: boolean;
  17262. /**
  17263. * Get hosting scene
  17264. * @returns the scene
  17265. */
  17266. getScene(): Scene;
  17267. /**
  17268. * You can use gravity if you want to give an orientation to your particles.
  17269. */
  17270. gravity: Vector3;
  17271. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17272. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17273. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17274. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17275. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17276. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17277. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17278. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17279. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17280. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17281. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17282. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17283. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17284. /**
  17285. * Defines the delay in milliseconds before starting the system (0 by default)
  17286. */
  17287. startDelay: number;
  17288. /**
  17289. * Gets the current list of drag gradients.
  17290. * You must use addDragGradient and removeDragGradient to udpate this list
  17291. * @returns the list of drag gradients
  17292. */
  17293. getDragGradients(): Nullable<Array<FactorGradient>>;
  17294. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17295. limitVelocityDamping: number;
  17296. /**
  17297. * Gets the current list of limit velocity gradients.
  17298. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17299. * @returns the list of limit velocity gradients
  17300. */
  17301. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17302. /**
  17303. * Gets the current list of color gradients.
  17304. * You must use addColorGradient and removeColorGradient to udpate this list
  17305. * @returns the list of color gradients
  17306. */
  17307. getColorGradients(): Nullable<Array<ColorGradient>>;
  17308. /**
  17309. * Gets the current list of size gradients.
  17310. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17311. * @returns the list of size gradients
  17312. */
  17313. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17314. /**
  17315. * Gets the current list of color remap gradients.
  17316. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17317. * @returns the list of color remap gradients
  17318. */
  17319. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17320. /**
  17321. * Gets the current list of alpha remap gradients.
  17322. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17323. * @returns the list of alpha remap gradients
  17324. */
  17325. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17326. /**
  17327. * Gets the current list of life time gradients.
  17328. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17329. * @returns the list of life time gradients
  17330. */
  17331. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17332. /**
  17333. * Gets the current list of angular speed gradients.
  17334. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17335. * @returns the list of angular speed gradients
  17336. */
  17337. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17338. /**
  17339. * Gets the current list of velocity gradients.
  17340. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17341. * @returns the list of velocity gradients
  17342. */
  17343. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17344. /**
  17345. * Gets the current list of start size gradients.
  17346. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17347. * @returns the list of start size gradients
  17348. */
  17349. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17350. /**
  17351. * Gets the current list of emit rate gradients.
  17352. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17353. * @returns the list of emit rate gradients
  17354. */
  17355. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17356. /**
  17357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17358. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17359. */
  17360. direction1: Vector3;
  17361. /**
  17362. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17363. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17364. */
  17365. direction2: Vector3;
  17366. /**
  17367. * 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.
  17368. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17369. */
  17370. minEmitBox: Vector3;
  17371. /**
  17372. * 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.
  17373. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17374. */
  17375. maxEmitBox: Vector3;
  17376. /**
  17377. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17378. */
  17379. color1: Color4;
  17380. /**
  17381. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17382. */
  17383. color2: Color4;
  17384. /**
  17385. * Color the particle will have at the end of its lifetime
  17386. */
  17387. colorDead: Color4;
  17388. /**
  17389. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17390. */
  17391. textureMask: Color4;
  17392. /**
  17393. * The particle emitter type defines the emitter used by the particle system.
  17394. * It can be for example box, sphere, or cone...
  17395. */
  17396. particleEmitterType: IParticleEmitterType;
  17397. /** @hidden */
  17398. _isSubEmitter: boolean;
  17399. /**
  17400. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17401. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17402. */
  17403. billboardMode: number;
  17404. protected _isBillboardBased: boolean;
  17405. /**
  17406. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17407. */
  17408. isBillboardBased: boolean;
  17409. /**
  17410. * The scene the particle system belongs to.
  17411. */
  17412. protected _scene: Scene;
  17413. /**
  17414. * Local cache of defines for image processing.
  17415. */
  17416. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17417. /**
  17418. * Default configuration related to image processing available in the standard Material.
  17419. */
  17420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17421. /**
  17422. * Gets the image processing configuration used either in this material.
  17423. */
  17424. /**
  17425. * Sets the Default image processing configuration used either in the this material.
  17426. *
  17427. * If sets to null, the scene one is in use.
  17428. */
  17429. imageProcessingConfiguration: ImageProcessingConfiguration;
  17430. /**
  17431. * Attaches a new image processing configuration to the Standard Material.
  17432. * @param configuration
  17433. */
  17434. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17435. /** @hidden */
  17436. protected _reset(): void;
  17437. /** @hidden */
  17438. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17439. /**
  17440. * Instantiates a particle system.
  17441. * 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.
  17442. * @param name The name of the particle system
  17443. */
  17444. constructor(name: string);
  17445. /**
  17446. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17449. * @returns the emitter
  17450. */
  17451. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17452. /**
  17453. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17454. * @param radius The radius of the hemisphere to emit from
  17455. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17456. * @returns the emitter
  17457. */
  17458. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17459. /**
  17460. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17461. * @param radius The radius of the sphere to emit from
  17462. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17463. * @returns the emitter
  17464. */
  17465. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17466. /**
  17467. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17468. * @param radius The radius of the sphere to emit from
  17469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17471. * @returns the emitter
  17472. */
  17473. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17474. /**
  17475. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17476. * @param radius The radius of the emission cylinder
  17477. * @param height The height of the emission cylinder
  17478. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17479. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17480. * @returns the emitter
  17481. */
  17482. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17483. /**
  17484. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17485. * @param radius The radius of the cylinder to emit from
  17486. * @param height The height of the emission cylinder
  17487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17490. * @returns the emitter
  17491. */
  17492. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17493. /**
  17494. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17495. * @param radius The radius of the cone to emit from
  17496. * @param angle The base angle of the cone
  17497. * @returns the emitter
  17498. */
  17499. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17500. /**
  17501. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17504. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17505. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17506. * @returns the emitter
  17507. */
  17508. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17509. }
  17510. }
  17511. declare module "babylonjs/Particles/subEmitter" {
  17512. import { Scene } from "babylonjs/scene";
  17513. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17514. /**
  17515. * Type of sub emitter
  17516. */
  17517. export enum SubEmitterType {
  17518. /**
  17519. * Attached to the particle over it's lifetime
  17520. */
  17521. ATTACHED = 0,
  17522. /**
  17523. * Created when the particle dies
  17524. */
  17525. END = 1
  17526. }
  17527. /**
  17528. * Sub emitter class used to emit particles from an existing particle
  17529. */
  17530. export class SubEmitter {
  17531. /**
  17532. * the particle system to be used by the sub emitter
  17533. */
  17534. particleSystem: ParticleSystem;
  17535. /**
  17536. * Type of the submitter (Default: END)
  17537. */
  17538. type: SubEmitterType;
  17539. /**
  17540. * 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)
  17541. * Note: This only is supported when using an emitter of type Mesh
  17542. */
  17543. inheritDirection: boolean;
  17544. /**
  17545. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17546. */
  17547. inheritedVelocityAmount: number;
  17548. /**
  17549. * Creates a sub emitter
  17550. * @param particleSystem the particle system to be used by the sub emitter
  17551. */
  17552. constructor(
  17553. /**
  17554. * the particle system to be used by the sub emitter
  17555. */
  17556. particleSystem: ParticleSystem);
  17557. /**
  17558. * Clones the sub emitter
  17559. * @returns the cloned sub emitter
  17560. */
  17561. clone(): SubEmitter;
  17562. /**
  17563. * Serialize current object to a JSON object
  17564. * @returns the serialized object
  17565. */
  17566. serialize(): any;
  17567. /** @hidden */
  17568. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17569. /**
  17570. * Creates a new SubEmitter from a serialized JSON version
  17571. * @param serializationObject defines the JSON object to read from
  17572. * @param scene defines the hosting scene
  17573. * @param rootUrl defines the rootUrl for data loading
  17574. * @returns a new SubEmitter
  17575. */
  17576. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17577. /** Release associated resources */
  17578. dispose(): void;
  17579. }
  17580. }
  17581. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17582. /** @hidden */
  17583. export var clipPlaneFragmentDeclaration: {
  17584. name: string;
  17585. shader: string;
  17586. };
  17587. }
  17588. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17589. /** @hidden */
  17590. export var imageProcessingDeclaration: {
  17591. name: string;
  17592. shader: string;
  17593. };
  17594. }
  17595. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17596. /** @hidden */
  17597. export var imageProcessingFunctions: {
  17598. name: string;
  17599. shader: string;
  17600. };
  17601. }
  17602. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17603. /** @hidden */
  17604. export var clipPlaneFragment: {
  17605. name: string;
  17606. shader: string;
  17607. };
  17608. }
  17609. declare module "babylonjs/Shaders/particles.fragment" {
  17610. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17611. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17612. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17613. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17614. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17615. /** @hidden */
  17616. export var particlesPixelShader: {
  17617. name: string;
  17618. shader: string;
  17619. };
  17620. }
  17621. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17622. /** @hidden */
  17623. export var clipPlaneVertexDeclaration: {
  17624. name: string;
  17625. shader: string;
  17626. };
  17627. }
  17628. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17629. /** @hidden */
  17630. export var clipPlaneVertex: {
  17631. name: string;
  17632. shader: string;
  17633. };
  17634. }
  17635. declare module "babylonjs/Shaders/particles.vertex" {
  17636. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17638. /** @hidden */
  17639. export var particlesVertexShader: {
  17640. name: string;
  17641. shader: string;
  17642. };
  17643. }
  17644. declare module "babylonjs/Particles/particleSystem" {
  17645. import { Nullable } from "babylonjs/types";
  17646. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17647. import { Observable } from "babylonjs/Misc/observable";
  17648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17649. import { Effect } from "babylonjs/Materials/effect";
  17650. import { Scene, IDisposable } from "babylonjs/scene";
  17651. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17652. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17653. import { Particle } from "babylonjs/Particles/particle";
  17654. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17655. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17656. import "babylonjs/Shaders/particles.fragment";
  17657. import "babylonjs/Shaders/particles.vertex";
  17658. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17659. /**
  17660. * This represents a particle system in Babylon.
  17661. * 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.
  17662. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17663. * @example https://doc.babylonjs.com/babylon101/particles
  17664. */
  17665. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17666. /**
  17667. * Billboard mode will only apply to Y axis
  17668. */
  17669. static readonly BILLBOARDMODE_Y: number;
  17670. /**
  17671. * Billboard mode will apply to all axes
  17672. */
  17673. static readonly BILLBOARDMODE_ALL: number;
  17674. /**
  17675. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17676. */
  17677. static readonly BILLBOARDMODE_STRETCHED: number;
  17678. /**
  17679. * This function can be defined to provide custom update for active particles.
  17680. * This function will be called instead of regular update (age, position, color, etc.).
  17681. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17682. */
  17683. updateFunction: (particles: Particle[]) => void;
  17684. private _emitterWorldMatrix;
  17685. /**
  17686. * This function can be defined to specify initial direction for every new particle.
  17687. * It by default use the emitterType defined function
  17688. */
  17689. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17690. /**
  17691. * This function can be defined to specify initial position for every new particle.
  17692. * It by default use the emitterType defined function
  17693. */
  17694. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17695. /**
  17696. * @hidden
  17697. */
  17698. _inheritedVelocityOffset: Vector3;
  17699. /**
  17700. * An event triggered when the system is disposed
  17701. */
  17702. onDisposeObservable: Observable<ParticleSystem>;
  17703. private _onDisposeObserver;
  17704. /**
  17705. * Sets a callback that will be triggered when the system is disposed
  17706. */
  17707. onDispose: () => void;
  17708. private _particles;
  17709. private _epsilon;
  17710. private _capacity;
  17711. private _stockParticles;
  17712. private _newPartsExcess;
  17713. private _vertexData;
  17714. private _vertexBuffer;
  17715. private _vertexBuffers;
  17716. private _spriteBuffer;
  17717. private _indexBuffer;
  17718. private _effect;
  17719. private _customEffect;
  17720. private _cachedDefines;
  17721. private _scaledColorStep;
  17722. private _colorDiff;
  17723. private _scaledDirection;
  17724. private _scaledGravity;
  17725. private _currentRenderId;
  17726. private _alive;
  17727. private _useInstancing;
  17728. private _started;
  17729. private _stopped;
  17730. private _actualFrame;
  17731. private _scaledUpdateSpeed;
  17732. private _vertexBufferSize;
  17733. /** @hidden */
  17734. _currentEmitRateGradient: Nullable<FactorGradient>;
  17735. /** @hidden */
  17736. _currentEmitRate1: number;
  17737. /** @hidden */
  17738. _currentEmitRate2: number;
  17739. /** @hidden */
  17740. _currentStartSizeGradient: Nullable<FactorGradient>;
  17741. /** @hidden */
  17742. _currentStartSize1: number;
  17743. /** @hidden */
  17744. _currentStartSize2: number;
  17745. private readonly _rawTextureWidth;
  17746. private _rampGradientsTexture;
  17747. private _useRampGradients;
  17748. /** Gets or sets a boolean indicating that ramp gradients must be used
  17749. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17750. */
  17751. useRampGradients: boolean;
  17752. /**
  17753. * 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.
  17754. * 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: [])
  17755. */
  17756. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17757. private _subEmitters;
  17758. /**
  17759. * @hidden
  17760. * If the particle systems emitter should be disposed when the particle system is disposed
  17761. */
  17762. _disposeEmitterOnDispose: boolean;
  17763. /**
  17764. * The current active Sub-systems, this property is used by the root particle system only.
  17765. */
  17766. activeSubSystems: Array<ParticleSystem>;
  17767. private _rootParticleSystem;
  17768. /**
  17769. * Gets the current list of active particles
  17770. */
  17771. readonly particles: Particle[];
  17772. /**
  17773. * Returns the string "ParticleSystem"
  17774. * @returns a string containing the class name
  17775. */
  17776. getClassName(): string;
  17777. /**
  17778. * Instantiates a particle system.
  17779. * 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.
  17780. * @param name The name of the particle system
  17781. * @param capacity The max number of particles alive at the same time
  17782. * @param scene The scene the particle system belongs to
  17783. * @param customEffect a custom effect used to change the way particles are rendered by default
  17784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17785. * @param epsilon Offset used to render the particles
  17786. */
  17787. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17788. private _addFactorGradient;
  17789. private _removeFactorGradient;
  17790. /**
  17791. * Adds a new life time gradient
  17792. * @param gradient defines the gradient to use (between 0 and 1)
  17793. * @param factor defines the life time factor to affect to the specified gradient
  17794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17795. * @returns the current particle system
  17796. */
  17797. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17798. /**
  17799. * Remove a specific life time gradient
  17800. * @param gradient defines the gradient to remove
  17801. * @returns the current particle system
  17802. */
  17803. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17804. /**
  17805. * Adds a new size gradient
  17806. * @param gradient defines the gradient to use (between 0 and 1)
  17807. * @param factor defines the size factor to affect to the specified gradient
  17808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17809. * @returns the current particle system
  17810. */
  17811. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17812. /**
  17813. * Remove a specific size gradient
  17814. * @param gradient defines the gradient to remove
  17815. * @returns the current particle system
  17816. */
  17817. removeSizeGradient(gradient: number): IParticleSystem;
  17818. /**
  17819. * Adds a new color remap gradient
  17820. * @param gradient defines the gradient to use (between 0 and 1)
  17821. * @param min defines the color remap minimal range
  17822. * @param max defines the color remap maximal range
  17823. * @returns the current particle system
  17824. */
  17825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17826. /**
  17827. * Remove a specific color remap gradient
  17828. * @param gradient defines the gradient to remove
  17829. * @returns the current particle system
  17830. */
  17831. removeColorRemapGradient(gradient: number): IParticleSystem;
  17832. /**
  17833. * Adds a new alpha remap gradient
  17834. * @param gradient defines the gradient to use (between 0 and 1)
  17835. * @param min defines the alpha remap minimal range
  17836. * @param max defines the alpha remap maximal range
  17837. * @returns the current particle system
  17838. */
  17839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17840. /**
  17841. * Remove a specific alpha remap gradient
  17842. * @param gradient defines the gradient to remove
  17843. * @returns the current particle system
  17844. */
  17845. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17846. /**
  17847. * Adds a new angular speed gradient
  17848. * @param gradient defines the gradient to use (between 0 and 1)
  17849. * @param factor defines the angular speed to affect to the specified gradient
  17850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17851. * @returns the current particle system
  17852. */
  17853. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17854. /**
  17855. * Remove a specific angular speed gradient
  17856. * @param gradient defines the gradient to remove
  17857. * @returns the current particle system
  17858. */
  17859. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17860. /**
  17861. * Adds a new velocity gradient
  17862. * @param gradient defines the gradient to use (between 0 and 1)
  17863. * @param factor defines the velocity to affect to the specified gradient
  17864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17865. * @returns the current particle system
  17866. */
  17867. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17868. /**
  17869. * Remove a specific velocity gradient
  17870. * @param gradient defines the gradient to remove
  17871. * @returns the current particle system
  17872. */
  17873. removeVelocityGradient(gradient: number): IParticleSystem;
  17874. /**
  17875. * Adds a new limit velocity gradient
  17876. * @param gradient defines the gradient to use (between 0 and 1)
  17877. * @param factor defines the limit velocity value to affect to the specified gradient
  17878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17879. * @returns the current particle system
  17880. */
  17881. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17882. /**
  17883. * Remove a specific limit velocity gradient
  17884. * @param gradient defines the gradient to remove
  17885. * @returns the current particle system
  17886. */
  17887. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17888. /**
  17889. * Adds a new drag gradient
  17890. * @param gradient defines the gradient to use (between 0 and 1)
  17891. * @param factor defines the drag value to affect to the specified gradient
  17892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17893. * @returns the current particle system
  17894. */
  17895. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17896. /**
  17897. * Remove a specific drag gradient
  17898. * @param gradient defines the gradient to remove
  17899. * @returns the current particle system
  17900. */
  17901. removeDragGradient(gradient: number): IParticleSystem;
  17902. /**
  17903. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17904. * @param gradient defines the gradient to use (between 0 and 1)
  17905. * @param factor defines the emit rate value to affect to the specified gradient
  17906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17907. * @returns the current particle system
  17908. */
  17909. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17910. /**
  17911. * Remove a specific emit rate gradient
  17912. * @param gradient defines the gradient to remove
  17913. * @returns the current particle system
  17914. */
  17915. removeEmitRateGradient(gradient: number): IParticleSystem;
  17916. /**
  17917. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17918. * @param gradient defines the gradient to use (between 0 and 1)
  17919. * @param factor defines the start size value to affect to the specified gradient
  17920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17921. * @returns the current particle system
  17922. */
  17923. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17924. /**
  17925. * Remove a specific start size gradient
  17926. * @param gradient defines the gradient to remove
  17927. * @returns the current particle system
  17928. */
  17929. removeStartSizeGradient(gradient: number): IParticleSystem;
  17930. private _createRampGradientTexture;
  17931. /**
  17932. * Gets the current list of ramp gradients.
  17933. * You must use addRampGradient and removeRampGradient to udpate this list
  17934. * @returns the list of ramp gradients
  17935. */
  17936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17937. /**
  17938. * Adds a new ramp gradient used to remap particle colors
  17939. * @param gradient defines the gradient to use (between 0 and 1)
  17940. * @param color defines the color to affect to the specified gradient
  17941. * @returns the current particle system
  17942. */
  17943. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17944. /**
  17945. * Remove a specific ramp gradient
  17946. * @param gradient defines the gradient to remove
  17947. * @returns the current particle system
  17948. */
  17949. removeRampGradient(gradient: number): ParticleSystem;
  17950. /**
  17951. * Adds a new color gradient
  17952. * @param gradient defines the gradient to use (between 0 and 1)
  17953. * @param color1 defines the color to affect to the specified gradient
  17954. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17955. * @returns this particle system
  17956. */
  17957. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17958. /**
  17959. * Remove a specific color gradient
  17960. * @param gradient defines the gradient to remove
  17961. * @returns this particle system
  17962. */
  17963. removeColorGradient(gradient: number): IParticleSystem;
  17964. private _fetchR;
  17965. protected _reset(): void;
  17966. private _resetEffect;
  17967. private _createVertexBuffers;
  17968. private _createIndexBuffer;
  17969. /**
  17970. * Gets the maximum number of particles active at the same time.
  17971. * @returns The max number of active particles.
  17972. */
  17973. getCapacity(): number;
  17974. /**
  17975. * Gets whether there are still active particles in the system.
  17976. * @returns True if it is alive, otherwise false.
  17977. */
  17978. isAlive(): boolean;
  17979. /**
  17980. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17981. * @returns True if it has been started, otherwise false.
  17982. */
  17983. isStarted(): boolean;
  17984. private _prepareSubEmitterInternalArray;
  17985. /**
  17986. * Starts the particle system and begins to emit
  17987. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17988. */
  17989. start(delay?: number): void;
  17990. /**
  17991. * Stops the particle system.
  17992. * @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.
  17993. */
  17994. stop(stopSubEmitters?: boolean): void;
  17995. /**
  17996. * Remove all active particles
  17997. */
  17998. reset(): void;
  17999. /**
  18000. * @hidden (for internal use only)
  18001. */
  18002. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18003. /**
  18004. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18005. * Its lifetime will start back at 0.
  18006. */
  18007. recycleParticle: (particle: Particle) => void;
  18008. private _stopSubEmitters;
  18009. private _createParticle;
  18010. private _removeFromRoot;
  18011. private _emitFromParticle;
  18012. private _update;
  18013. /** @hidden */
  18014. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18015. /** @hidden */
  18016. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18017. /** @hidden */
  18018. private _getEffect;
  18019. /**
  18020. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18021. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18022. */
  18023. animate(preWarmOnly?: boolean): void;
  18024. private _appendParticleVertices;
  18025. /**
  18026. * Rebuilds the particle system.
  18027. */
  18028. rebuild(): void;
  18029. /**
  18030. * Is this system ready to be used/rendered
  18031. * @return true if the system is ready
  18032. */
  18033. isReady(): boolean;
  18034. private _render;
  18035. /**
  18036. * Renders the particle system in its current state.
  18037. * @returns the current number of particles
  18038. */
  18039. render(): number;
  18040. /**
  18041. * Disposes the particle system and free the associated resources
  18042. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18043. */
  18044. dispose(disposeTexture?: boolean): void;
  18045. /**
  18046. * Clones the particle system.
  18047. * @param name The name of the cloned object
  18048. * @param newEmitter The new emitter to use
  18049. * @returns the cloned particle system
  18050. */
  18051. clone(name: string, newEmitter: any): ParticleSystem;
  18052. /**
  18053. * Serializes the particle system to a JSON object.
  18054. * @returns the JSON object
  18055. */
  18056. serialize(): any;
  18057. /** @hidden */
  18058. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18059. /** @hidden */
  18060. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18061. /**
  18062. * Parses a JSON object to create a particle system.
  18063. * @param parsedParticleSystem The JSON object to parse
  18064. * @param scene The scene to create the particle system in
  18065. * @param rootUrl The root url to use to load external dependencies like texture
  18066. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18067. * @returns the Parsed particle system
  18068. */
  18069. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18070. }
  18071. }
  18072. declare module "babylonjs/Particles/particle" {
  18073. import { Nullable } from "babylonjs/types";
  18074. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18075. import { Color4 } from "babylonjs/Maths/math.color";
  18076. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18077. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18078. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18079. /**
  18080. * A particle represents one of the element emitted by a particle system.
  18081. * This is mainly define by its coordinates, direction, velocity and age.
  18082. */
  18083. export class Particle {
  18084. /**
  18085. * The particle system the particle belongs to.
  18086. */
  18087. particleSystem: ParticleSystem;
  18088. private static _Count;
  18089. /**
  18090. * Unique ID of the particle
  18091. */
  18092. id: number;
  18093. /**
  18094. * The world position of the particle in the scene.
  18095. */
  18096. position: Vector3;
  18097. /**
  18098. * The world direction of the particle in the scene.
  18099. */
  18100. direction: Vector3;
  18101. /**
  18102. * The color of the particle.
  18103. */
  18104. color: Color4;
  18105. /**
  18106. * The color change of the particle per step.
  18107. */
  18108. colorStep: Color4;
  18109. /**
  18110. * Defines how long will the life of the particle be.
  18111. */
  18112. lifeTime: number;
  18113. /**
  18114. * The current age of the particle.
  18115. */
  18116. age: number;
  18117. /**
  18118. * The current size of the particle.
  18119. */
  18120. size: number;
  18121. /**
  18122. * The current scale of the particle.
  18123. */
  18124. scale: Vector2;
  18125. /**
  18126. * The current angle of the particle.
  18127. */
  18128. angle: number;
  18129. /**
  18130. * Defines how fast is the angle changing.
  18131. */
  18132. angularSpeed: number;
  18133. /**
  18134. * Defines the cell index used by the particle to be rendered from a sprite.
  18135. */
  18136. cellIndex: number;
  18137. /**
  18138. * The information required to support color remapping
  18139. */
  18140. remapData: Vector4;
  18141. /** @hidden */
  18142. _randomCellOffset?: number;
  18143. /** @hidden */
  18144. _initialDirection: Nullable<Vector3>;
  18145. /** @hidden */
  18146. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18147. /** @hidden */
  18148. _initialStartSpriteCellID: number;
  18149. /** @hidden */
  18150. _initialEndSpriteCellID: number;
  18151. /** @hidden */
  18152. _currentColorGradient: Nullable<ColorGradient>;
  18153. /** @hidden */
  18154. _currentColor1: Color4;
  18155. /** @hidden */
  18156. _currentColor2: Color4;
  18157. /** @hidden */
  18158. _currentSizeGradient: Nullable<FactorGradient>;
  18159. /** @hidden */
  18160. _currentSize1: number;
  18161. /** @hidden */
  18162. _currentSize2: number;
  18163. /** @hidden */
  18164. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18165. /** @hidden */
  18166. _currentAngularSpeed1: number;
  18167. /** @hidden */
  18168. _currentAngularSpeed2: number;
  18169. /** @hidden */
  18170. _currentVelocityGradient: Nullable<FactorGradient>;
  18171. /** @hidden */
  18172. _currentVelocity1: number;
  18173. /** @hidden */
  18174. _currentVelocity2: number;
  18175. /** @hidden */
  18176. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18177. /** @hidden */
  18178. _currentLimitVelocity1: number;
  18179. /** @hidden */
  18180. _currentLimitVelocity2: number;
  18181. /** @hidden */
  18182. _currentDragGradient: Nullable<FactorGradient>;
  18183. /** @hidden */
  18184. _currentDrag1: number;
  18185. /** @hidden */
  18186. _currentDrag2: number;
  18187. /** @hidden */
  18188. _randomNoiseCoordinates1: Vector3;
  18189. /** @hidden */
  18190. _randomNoiseCoordinates2: Vector3;
  18191. /**
  18192. * Creates a new instance Particle
  18193. * @param particleSystem the particle system the particle belongs to
  18194. */
  18195. constructor(
  18196. /**
  18197. * The particle system the particle belongs to.
  18198. */
  18199. particleSystem: ParticleSystem);
  18200. private updateCellInfoFromSystem;
  18201. /**
  18202. * Defines how the sprite cell index is updated for the particle
  18203. */
  18204. updateCellIndex(): void;
  18205. /** @hidden */
  18206. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18207. /** @hidden */
  18208. _inheritParticleInfoToSubEmitters(): void;
  18209. /** @hidden */
  18210. _reset(): void;
  18211. /**
  18212. * Copy the properties of particle to another one.
  18213. * @param other the particle to copy the information to.
  18214. */
  18215. copyTo(other: Particle): void;
  18216. }
  18217. }
  18218. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18219. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18220. import { Effect } from "babylonjs/Materials/effect";
  18221. import { Particle } from "babylonjs/Particles/particle";
  18222. /**
  18223. * Particle emitter represents a volume emitting particles.
  18224. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18225. */
  18226. export interface IParticleEmitterType {
  18227. /**
  18228. * Called by the particle System when the direction is computed for the created particle.
  18229. * @param worldMatrix is the world matrix of the particle system
  18230. * @param directionToUpdate is the direction vector to update with the result
  18231. * @param particle is the particle we are computed the direction for
  18232. */
  18233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18234. /**
  18235. * Called by the particle System when the position is computed for the created particle.
  18236. * @param worldMatrix is the world matrix of the particle system
  18237. * @param positionToUpdate is the position vector to update with the result
  18238. * @param particle is the particle we are computed the position for
  18239. */
  18240. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18241. /**
  18242. * Clones the current emitter and returns a copy of it
  18243. * @returns the new emitter
  18244. */
  18245. clone(): IParticleEmitterType;
  18246. /**
  18247. * Called by the GPUParticleSystem to setup the update shader
  18248. * @param effect defines the update shader
  18249. */
  18250. applyToShader(effect: Effect): void;
  18251. /**
  18252. * Returns a string to use to update the GPU particles update shader
  18253. * @returns the effect defines string
  18254. */
  18255. getEffectDefines(): string;
  18256. /**
  18257. * Returns a string representing the class name
  18258. * @returns a string containing the class name
  18259. */
  18260. getClassName(): string;
  18261. /**
  18262. * Serializes the particle system to a JSON object.
  18263. * @returns the JSON object
  18264. */
  18265. serialize(): any;
  18266. /**
  18267. * Parse properties from a JSON object
  18268. * @param serializationObject defines the JSON object
  18269. */
  18270. parse(serializationObject: any): void;
  18271. }
  18272. }
  18273. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18274. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18275. import { Effect } from "babylonjs/Materials/effect";
  18276. import { Particle } from "babylonjs/Particles/particle";
  18277. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18278. /**
  18279. * Particle emitter emitting particles from the inside of a box.
  18280. * It emits the particles randomly between 2 given directions.
  18281. */
  18282. export class BoxParticleEmitter implements IParticleEmitterType {
  18283. /**
  18284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18285. */
  18286. direction1: Vector3;
  18287. /**
  18288. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18289. */
  18290. direction2: Vector3;
  18291. /**
  18292. * 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.
  18293. */
  18294. minEmitBox: Vector3;
  18295. /**
  18296. * 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.
  18297. */
  18298. maxEmitBox: Vector3;
  18299. /**
  18300. * Creates a new instance BoxParticleEmitter
  18301. */
  18302. constructor();
  18303. /**
  18304. * Called by the particle System when the direction is computed for the created particle.
  18305. * @param worldMatrix is the world matrix of the particle system
  18306. * @param directionToUpdate is the direction vector to update with the result
  18307. * @param particle is the particle we are computed the direction for
  18308. */
  18309. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18310. /**
  18311. * Called by the particle System when the position is computed for the created particle.
  18312. * @param worldMatrix is the world matrix of the particle system
  18313. * @param positionToUpdate is the position vector to update with the result
  18314. * @param particle is the particle we are computed the position for
  18315. */
  18316. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18317. /**
  18318. * Clones the current emitter and returns a copy of it
  18319. * @returns the new emitter
  18320. */
  18321. clone(): BoxParticleEmitter;
  18322. /**
  18323. * Called by the GPUParticleSystem to setup the update shader
  18324. * @param effect defines the update shader
  18325. */
  18326. applyToShader(effect: Effect): void;
  18327. /**
  18328. * Returns a string to use to update the GPU particles update shader
  18329. * @returns a string containng the defines string
  18330. */
  18331. getEffectDefines(): string;
  18332. /**
  18333. * Returns the string "BoxParticleEmitter"
  18334. * @returns a string containing the class name
  18335. */
  18336. getClassName(): string;
  18337. /**
  18338. * Serializes the particle system to a JSON object.
  18339. * @returns the JSON object
  18340. */
  18341. serialize(): any;
  18342. /**
  18343. * Parse properties from a JSON object
  18344. * @param serializationObject defines the JSON object
  18345. */
  18346. parse(serializationObject: any): void;
  18347. }
  18348. }
  18349. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18350. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18351. import { Effect } from "babylonjs/Materials/effect";
  18352. import { Particle } from "babylonjs/Particles/particle";
  18353. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18354. /**
  18355. * Particle emitter emitting particles from the inside of a cone.
  18356. * It emits the particles alongside the cone volume from the base to the particle.
  18357. * The emission direction might be randomized.
  18358. */
  18359. export class ConeParticleEmitter implements IParticleEmitterType {
  18360. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18361. directionRandomizer: number;
  18362. private _radius;
  18363. private _angle;
  18364. private _height;
  18365. /**
  18366. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18367. */
  18368. radiusRange: number;
  18369. /**
  18370. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18371. */
  18372. heightRange: number;
  18373. /**
  18374. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18375. */
  18376. emitFromSpawnPointOnly: boolean;
  18377. /**
  18378. * Gets or sets the radius of the emission cone
  18379. */
  18380. radius: number;
  18381. /**
  18382. * Gets or sets the angle of the emission cone
  18383. */
  18384. angle: number;
  18385. private _buildHeight;
  18386. /**
  18387. * Creates a new instance ConeParticleEmitter
  18388. * @param radius the radius of the emission cone (1 by default)
  18389. * @param angle the cone base angle (PI by default)
  18390. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18391. */
  18392. constructor(radius?: number, angle?: number,
  18393. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18394. directionRandomizer?: number);
  18395. /**
  18396. * Called by the particle System when the direction is computed for the created particle.
  18397. * @param worldMatrix is the world matrix of the particle system
  18398. * @param directionToUpdate is the direction vector to update with the result
  18399. * @param particle is the particle we are computed the direction for
  18400. */
  18401. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18402. /**
  18403. * Called by the particle System when the position is computed for the created particle.
  18404. * @param worldMatrix is the world matrix of the particle system
  18405. * @param positionToUpdate is the position vector to update with the result
  18406. * @param particle is the particle we are computed the position for
  18407. */
  18408. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18409. /**
  18410. * Clones the current emitter and returns a copy of it
  18411. * @returns the new emitter
  18412. */
  18413. clone(): ConeParticleEmitter;
  18414. /**
  18415. * Called by the GPUParticleSystem to setup the update shader
  18416. * @param effect defines the update shader
  18417. */
  18418. applyToShader(effect: Effect): void;
  18419. /**
  18420. * Returns a string to use to update the GPU particles update shader
  18421. * @returns a string containng the defines string
  18422. */
  18423. getEffectDefines(): string;
  18424. /**
  18425. * Returns the string "ConeParticleEmitter"
  18426. * @returns a string containing the class name
  18427. */
  18428. getClassName(): string;
  18429. /**
  18430. * Serializes the particle system to a JSON object.
  18431. * @returns the JSON object
  18432. */
  18433. serialize(): any;
  18434. /**
  18435. * Parse properties from a JSON object
  18436. * @param serializationObject defines the JSON object
  18437. */
  18438. parse(serializationObject: any): void;
  18439. }
  18440. }
  18441. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18442. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18443. import { Effect } from "babylonjs/Materials/effect";
  18444. import { Particle } from "babylonjs/Particles/particle";
  18445. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18446. /**
  18447. * Particle emitter emitting particles from the inside of a cylinder.
  18448. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18449. */
  18450. export class CylinderParticleEmitter implements IParticleEmitterType {
  18451. /**
  18452. * The radius of the emission cylinder.
  18453. */
  18454. radius: number;
  18455. /**
  18456. * The height of the emission cylinder.
  18457. */
  18458. height: number;
  18459. /**
  18460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18461. */
  18462. radiusRange: number;
  18463. /**
  18464. * How much to randomize the particle direction [0-1].
  18465. */
  18466. directionRandomizer: number;
  18467. /**
  18468. * Creates a new instance CylinderParticleEmitter
  18469. * @param radius the radius of the emission cylinder (1 by default)
  18470. * @param height the height of the emission cylinder (1 by default)
  18471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18472. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18473. */
  18474. constructor(
  18475. /**
  18476. * The radius of the emission cylinder.
  18477. */
  18478. radius?: number,
  18479. /**
  18480. * The height of the emission cylinder.
  18481. */
  18482. height?: number,
  18483. /**
  18484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18485. */
  18486. radiusRange?: number,
  18487. /**
  18488. * How much to randomize the particle direction [0-1].
  18489. */
  18490. directionRandomizer?: number);
  18491. /**
  18492. * Called by the particle System when the direction is computed for the created particle.
  18493. * @param worldMatrix is the world matrix of the particle system
  18494. * @param directionToUpdate is the direction vector to update with the result
  18495. * @param particle is the particle we are computed the direction for
  18496. */
  18497. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18498. /**
  18499. * Called by the particle System when the position is computed for the created particle.
  18500. * @param worldMatrix is the world matrix of the particle system
  18501. * @param positionToUpdate is the position vector to update with the result
  18502. * @param particle is the particle we are computed the position for
  18503. */
  18504. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18505. /**
  18506. * Clones the current emitter and returns a copy of it
  18507. * @returns the new emitter
  18508. */
  18509. clone(): CylinderParticleEmitter;
  18510. /**
  18511. * Called by the GPUParticleSystem to setup the update shader
  18512. * @param effect defines the update shader
  18513. */
  18514. applyToShader(effect: Effect): void;
  18515. /**
  18516. * Returns a string to use to update the GPU particles update shader
  18517. * @returns a string containng the defines string
  18518. */
  18519. getEffectDefines(): string;
  18520. /**
  18521. * Returns the string "CylinderParticleEmitter"
  18522. * @returns a string containing the class name
  18523. */
  18524. getClassName(): string;
  18525. /**
  18526. * Serializes the particle system to a JSON object.
  18527. * @returns the JSON object
  18528. */
  18529. serialize(): any;
  18530. /**
  18531. * Parse properties from a JSON object
  18532. * @param serializationObject defines the JSON object
  18533. */
  18534. parse(serializationObject: any): void;
  18535. }
  18536. /**
  18537. * Particle emitter emitting particles from the inside of a cylinder.
  18538. * It emits the particles randomly between two vectors.
  18539. */
  18540. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18541. /**
  18542. * The min limit of the emission direction.
  18543. */
  18544. direction1: Vector3;
  18545. /**
  18546. * The max limit of the emission direction.
  18547. */
  18548. direction2: Vector3;
  18549. /**
  18550. * Creates a new instance CylinderDirectedParticleEmitter
  18551. * @param radius the radius of the emission cylinder (1 by default)
  18552. * @param height the height of the emission cylinder (1 by default)
  18553. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18554. * @param direction1 the min limit of the emission direction (up vector by default)
  18555. * @param direction2 the max limit of the emission direction (up vector by default)
  18556. */
  18557. constructor(radius?: number, height?: number, radiusRange?: number,
  18558. /**
  18559. * The min limit of the emission direction.
  18560. */
  18561. direction1?: Vector3,
  18562. /**
  18563. * The max limit of the emission direction.
  18564. */
  18565. direction2?: Vector3);
  18566. /**
  18567. * Called by the particle System when the direction is computed for the created particle.
  18568. * @param worldMatrix is the world matrix of the particle system
  18569. * @param directionToUpdate is the direction vector to update with the result
  18570. * @param particle is the particle we are computed the direction for
  18571. */
  18572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18573. /**
  18574. * Clones the current emitter and returns a copy of it
  18575. * @returns the new emitter
  18576. */
  18577. clone(): CylinderDirectedParticleEmitter;
  18578. /**
  18579. * Called by the GPUParticleSystem to setup the update shader
  18580. * @param effect defines the update shader
  18581. */
  18582. applyToShader(effect: Effect): void;
  18583. /**
  18584. * Returns a string to use to update the GPU particles update shader
  18585. * @returns a string containng the defines string
  18586. */
  18587. getEffectDefines(): string;
  18588. /**
  18589. * Returns the string "CylinderDirectedParticleEmitter"
  18590. * @returns a string containing the class name
  18591. */
  18592. getClassName(): string;
  18593. /**
  18594. * Serializes the particle system to a JSON object.
  18595. * @returns the JSON object
  18596. */
  18597. serialize(): any;
  18598. /**
  18599. * Parse properties from a JSON object
  18600. * @param serializationObject defines the JSON object
  18601. */
  18602. parse(serializationObject: any): void;
  18603. }
  18604. }
  18605. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18606. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18607. import { Effect } from "babylonjs/Materials/effect";
  18608. import { Particle } from "babylonjs/Particles/particle";
  18609. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18610. /**
  18611. * Particle emitter emitting particles from the inside of a hemisphere.
  18612. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18613. */
  18614. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18615. /**
  18616. * The radius of the emission hemisphere.
  18617. */
  18618. radius: number;
  18619. /**
  18620. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18621. */
  18622. radiusRange: number;
  18623. /**
  18624. * How much to randomize the particle direction [0-1].
  18625. */
  18626. directionRandomizer: number;
  18627. /**
  18628. * Creates a new instance HemisphericParticleEmitter
  18629. * @param radius the radius of the emission hemisphere (1 by default)
  18630. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18631. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18632. */
  18633. constructor(
  18634. /**
  18635. * The radius of the emission hemisphere.
  18636. */
  18637. radius?: number,
  18638. /**
  18639. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18640. */
  18641. radiusRange?: number,
  18642. /**
  18643. * How much to randomize the particle direction [0-1].
  18644. */
  18645. directionRandomizer?: number);
  18646. /**
  18647. * Called by the particle System when the direction is computed for the created particle.
  18648. * @param worldMatrix is the world matrix of the particle system
  18649. * @param directionToUpdate is the direction vector to update with the result
  18650. * @param particle is the particle we are computed the direction for
  18651. */
  18652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18653. /**
  18654. * Called by the particle System when the position is computed for the created particle.
  18655. * @param worldMatrix is the world matrix of the particle system
  18656. * @param positionToUpdate is the position vector to update with the result
  18657. * @param particle is the particle we are computed the position for
  18658. */
  18659. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18660. /**
  18661. * Clones the current emitter and returns a copy of it
  18662. * @returns the new emitter
  18663. */
  18664. clone(): HemisphericParticleEmitter;
  18665. /**
  18666. * Called by the GPUParticleSystem to setup the update shader
  18667. * @param effect defines the update shader
  18668. */
  18669. applyToShader(effect: Effect): void;
  18670. /**
  18671. * Returns a string to use to update the GPU particles update shader
  18672. * @returns a string containng the defines string
  18673. */
  18674. getEffectDefines(): string;
  18675. /**
  18676. * Returns the string "HemisphericParticleEmitter"
  18677. * @returns a string containing the class name
  18678. */
  18679. getClassName(): string;
  18680. /**
  18681. * Serializes the particle system to a JSON object.
  18682. * @returns the JSON object
  18683. */
  18684. serialize(): any;
  18685. /**
  18686. * Parse properties from a JSON object
  18687. * @param serializationObject defines the JSON object
  18688. */
  18689. parse(serializationObject: any): void;
  18690. }
  18691. }
  18692. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18693. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18694. import { Effect } from "babylonjs/Materials/effect";
  18695. import { Particle } from "babylonjs/Particles/particle";
  18696. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18697. /**
  18698. * Particle emitter emitting particles from a point.
  18699. * It emits the particles randomly between 2 given directions.
  18700. */
  18701. export class PointParticleEmitter implements IParticleEmitterType {
  18702. /**
  18703. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18704. */
  18705. direction1: Vector3;
  18706. /**
  18707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18708. */
  18709. direction2: Vector3;
  18710. /**
  18711. * Creates a new instance PointParticleEmitter
  18712. */
  18713. constructor();
  18714. /**
  18715. * Called by the particle System when the direction is computed for the created particle.
  18716. * @param worldMatrix is the world matrix of the particle system
  18717. * @param directionToUpdate is the direction vector to update with the result
  18718. * @param particle is the particle we are computed the direction for
  18719. */
  18720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18721. /**
  18722. * Called by the particle System when the position is computed for the created particle.
  18723. * @param worldMatrix is the world matrix of the particle system
  18724. * @param positionToUpdate is the position vector to update with the result
  18725. * @param particle is the particle we are computed the position for
  18726. */
  18727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18728. /**
  18729. * Clones the current emitter and returns a copy of it
  18730. * @returns the new emitter
  18731. */
  18732. clone(): PointParticleEmitter;
  18733. /**
  18734. * Called by the GPUParticleSystem to setup the update shader
  18735. * @param effect defines the update shader
  18736. */
  18737. applyToShader(effect: Effect): void;
  18738. /**
  18739. * Returns a string to use to update the GPU particles update shader
  18740. * @returns a string containng the defines string
  18741. */
  18742. getEffectDefines(): string;
  18743. /**
  18744. * Returns the string "PointParticleEmitter"
  18745. * @returns a string containing the class name
  18746. */
  18747. getClassName(): string;
  18748. /**
  18749. * Serializes the particle system to a JSON object.
  18750. * @returns the JSON object
  18751. */
  18752. serialize(): any;
  18753. /**
  18754. * Parse properties from a JSON object
  18755. * @param serializationObject defines the JSON object
  18756. */
  18757. parse(serializationObject: any): void;
  18758. }
  18759. }
  18760. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18761. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18762. import { Effect } from "babylonjs/Materials/effect";
  18763. import { Particle } from "babylonjs/Particles/particle";
  18764. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18765. /**
  18766. * Particle emitter emitting particles from the inside of a sphere.
  18767. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18768. */
  18769. export class SphereParticleEmitter implements IParticleEmitterType {
  18770. /**
  18771. * The radius of the emission sphere.
  18772. */
  18773. radius: number;
  18774. /**
  18775. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18776. */
  18777. radiusRange: number;
  18778. /**
  18779. * How much to randomize the particle direction [0-1].
  18780. */
  18781. directionRandomizer: number;
  18782. /**
  18783. * Creates a new instance SphereParticleEmitter
  18784. * @param radius the radius of the emission sphere (1 by default)
  18785. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18786. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18787. */
  18788. constructor(
  18789. /**
  18790. * The radius of the emission sphere.
  18791. */
  18792. radius?: number,
  18793. /**
  18794. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18795. */
  18796. radiusRange?: number,
  18797. /**
  18798. * How much to randomize the particle direction [0-1].
  18799. */
  18800. directionRandomizer?: number);
  18801. /**
  18802. * Called by the particle System when the direction is computed for the created particle.
  18803. * @param worldMatrix is the world matrix of the particle system
  18804. * @param directionToUpdate is the direction vector to update with the result
  18805. * @param particle is the particle we are computed the direction for
  18806. */
  18807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18808. /**
  18809. * Called by the particle System when the position is computed for the created particle.
  18810. * @param worldMatrix is the world matrix of the particle system
  18811. * @param positionToUpdate is the position vector to update with the result
  18812. * @param particle is the particle we are computed the position for
  18813. */
  18814. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18815. /**
  18816. * Clones the current emitter and returns a copy of it
  18817. * @returns the new emitter
  18818. */
  18819. clone(): SphereParticleEmitter;
  18820. /**
  18821. * Called by the GPUParticleSystem to setup the update shader
  18822. * @param effect defines the update shader
  18823. */
  18824. applyToShader(effect: Effect): void;
  18825. /**
  18826. * Returns a string to use to update the GPU particles update shader
  18827. * @returns a string containng the defines string
  18828. */
  18829. getEffectDefines(): string;
  18830. /**
  18831. * Returns the string "SphereParticleEmitter"
  18832. * @returns a string containing the class name
  18833. */
  18834. getClassName(): string;
  18835. /**
  18836. * Serializes the particle system to a JSON object.
  18837. * @returns the JSON object
  18838. */
  18839. serialize(): any;
  18840. /**
  18841. * Parse properties from a JSON object
  18842. * @param serializationObject defines the JSON object
  18843. */
  18844. parse(serializationObject: any): void;
  18845. }
  18846. /**
  18847. * Particle emitter emitting particles from the inside of a sphere.
  18848. * It emits the particles randomly between two vectors.
  18849. */
  18850. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18851. /**
  18852. * The min limit of the emission direction.
  18853. */
  18854. direction1: Vector3;
  18855. /**
  18856. * The max limit of the emission direction.
  18857. */
  18858. direction2: Vector3;
  18859. /**
  18860. * Creates a new instance SphereDirectedParticleEmitter
  18861. * @param radius the radius of the emission sphere (1 by default)
  18862. * @param direction1 the min limit of the emission direction (up vector by default)
  18863. * @param direction2 the max limit of the emission direction (up vector by default)
  18864. */
  18865. constructor(radius?: number,
  18866. /**
  18867. * The min limit of the emission direction.
  18868. */
  18869. direction1?: Vector3,
  18870. /**
  18871. * The max limit of the emission direction.
  18872. */
  18873. direction2?: Vector3);
  18874. /**
  18875. * Called by the particle System when the direction is computed for the created particle.
  18876. * @param worldMatrix is the world matrix of the particle system
  18877. * @param directionToUpdate is the direction vector to update with the result
  18878. * @param particle is the particle we are computed the direction for
  18879. */
  18880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18881. /**
  18882. * Clones the current emitter and returns a copy of it
  18883. * @returns the new emitter
  18884. */
  18885. clone(): SphereDirectedParticleEmitter;
  18886. /**
  18887. * Called by the GPUParticleSystem to setup the update shader
  18888. * @param effect defines the update shader
  18889. */
  18890. applyToShader(effect: Effect): void;
  18891. /**
  18892. * Returns a string to use to update the GPU particles update shader
  18893. * @returns a string containng the defines string
  18894. */
  18895. getEffectDefines(): string;
  18896. /**
  18897. * Returns the string "SphereDirectedParticleEmitter"
  18898. * @returns a string containing the class name
  18899. */
  18900. getClassName(): string;
  18901. /**
  18902. * Serializes the particle system to a JSON object.
  18903. * @returns the JSON object
  18904. */
  18905. serialize(): any;
  18906. /**
  18907. * Parse properties from a JSON object
  18908. * @param serializationObject defines the JSON object
  18909. */
  18910. parse(serializationObject: any): void;
  18911. }
  18912. }
  18913. declare module "babylonjs/Particles/EmitterTypes/index" {
  18914. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18915. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18916. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18917. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18918. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18919. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18920. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18921. }
  18922. declare module "babylonjs/Particles/IParticleSystem" {
  18923. import { Nullable } from "babylonjs/types";
  18924. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18925. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18928. import { Texture } from "babylonjs/Materials/Textures/texture";
  18929. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18930. import { Scene } from "babylonjs/scene";
  18931. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18932. import { Animation } from "babylonjs/Animations/animation";
  18933. /**
  18934. * Interface representing a particle system in Babylon.js.
  18935. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18936. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18937. */
  18938. export interface IParticleSystem {
  18939. /**
  18940. * List of animations used by the particle system.
  18941. */
  18942. animations: Animation[];
  18943. /**
  18944. * The id of the Particle system.
  18945. */
  18946. id: string;
  18947. /**
  18948. * The name of the Particle system.
  18949. */
  18950. name: string;
  18951. /**
  18952. * The emitter represents the Mesh or position we are attaching the particle system to.
  18953. */
  18954. emitter: Nullable<AbstractMesh | Vector3>;
  18955. /**
  18956. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18957. */
  18958. isBillboardBased: boolean;
  18959. /**
  18960. * The rendering group used by the Particle system to chose when to render.
  18961. */
  18962. renderingGroupId: number;
  18963. /**
  18964. * The layer mask we are rendering the particles through.
  18965. */
  18966. layerMask: number;
  18967. /**
  18968. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18969. */
  18970. updateSpeed: number;
  18971. /**
  18972. * The amount of time the particle system is running (depends of the overall update speed).
  18973. */
  18974. targetStopDuration: number;
  18975. /**
  18976. * The texture used to render each particle. (this can be a spritesheet)
  18977. */
  18978. particleTexture: Nullable<Texture>;
  18979. /**
  18980. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18981. */
  18982. blendMode: number;
  18983. /**
  18984. * Minimum life time of emitting particles.
  18985. */
  18986. minLifeTime: number;
  18987. /**
  18988. * Maximum life time of emitting particles.
  18989. */
  18990. maxLifeTime: number;
  18991. /**
  18992. * Minimum Size of emitting particles.
  18993. */
  18994. minSize: number;
  18995. /**
  18996. * Maximum Size of emitting particles.
  18997. */
  18998. maxSize: number;
  18999. /**
  19000. * Minimum scale of emitting particles on X axis.
  19001. */
  19002. minScaleX: number;
  19003. /**
  19004. * Maximum scale of emitting particles on X axis.
  19005. */
  19006. maxScaleX: number;
  19007. /**
  19008. * Minimum scale of emitting particles on Y axis.
  19009. */
  19010. minScaleY: number;
  19011. /**
  19012. * Maximum scale of emitting particles on Y axis.
  19013. */
  19014. maxScaleY: number;
  19015. /**
  19016. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19017. */
  19018. color1: Color4;
  19019. /**
  19020. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19021. */
  19022. color2: Color4;
  19023. /**
  19024. * Color the particle will have at the end of its lifetime.
  19025. */
  19026. colorDead: Color4;
  19027. /**
  19028. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19029. */
  19030. emitRate: number;
  19031. /**
  19032. * You can use gravity if you want to give an orientation to your particles.
  19033. */
  19034. gravity: Vector3;
  19035. /**
  19036. * Minimum power of emitting particles.
  19037. */
  19038. minEmitPower: number;
  19039. /**
  19040. * Maximum power of emitting particles.
  19041. */
  19042. maxEmitPower: number;
  19043. /**
  19044. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19045. */
  19046. minAngularSpeed: number;
  19047. /**
  19048. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19049. */
  19050. maxAngularSpeed: number;
  19051. /**
  19052. * Gets or sets the minimal initial rotation in radians.
  19053. */
  19054. minInitialRotation: number;
  19055. /**
  19056. * Gets or sets the maximal initial rotation in radians.
  19057. */
  19058. maxInitialRotation: number;
  19059. /**
  19060. * The particle emitter type defines the emitter used by the particle system.
  19061. * It can be for example box, sphere, or cone...
  19062. */
  19063. particleEmitterType: Nullable<IParticleEmitterType>;
  19064. /**
  19065. * Defines the delay in milliseconds before starting the system (0 by default)
  19066. */
  19067. startDelay: number;
  19068. /**
  19069. * 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
  19070. */
  19071. preWarmCycles: number;
  19072. /**
  19073. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19074. */
  19075. preWarmStepOffset: number;
  19076. /**
  19077. * 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)
  19078. */
  19079. spriteCellChangeSpeed: number;
  19080. /**
  19081. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19082. */
  19083. startSpriteCellID: number;
  19084. /**
  19085. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19086. */
  19087. endSpriteCellID: number;
  19088. /**
  19089. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19090. */
  19091. spriteCellWidth: number;
  19092. /**
  19093. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19094. */
  19095. spriteCellHeight: number;
  19096. /**
  19097. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19098. */
  19099. spriteRandomStartCell: boolean;
  19100. /**
  19101. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19102. */
  19103. isAnimationSheetEnabled: boolean;
  19104. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19105. translationPivot: Vector2;
  19106. /**
  19107. * Gets or sets a texture used to add random noise to particle positions
  19108. */
  19109. noiseTexture: Nullable<BaseTexture>;
  19110. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19111. noiseStrength: Vector3;
  19112. /**
  19113. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19114. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19115. */
  19116. billboardMode: number;
  19117. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19118. limitVelocityDamping: number;
  19119. /**
  19120. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19121. */
  19122. beginAnimationOnStart: boolean;
  19123. /**
  19124. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19125. */
  19126. beginAnimationFrom: number;
  19127. /**
  19128. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19129. */
  19130. beginAnimationTo: number;
  19131. /**
  19132. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19133. */
  19134. beginAnimationLoop: boolean;
  19135. /**
  19136. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19137. */
  19138. disposeOnStop: boolean;
  19139. /**
  19140. * Gets the maximum number of particles active at the same time.
  19141. * @returns The max number of active particles.
  19142. */
  19143. getCapacity(): number;
  19144. /**
  19145. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19146. * @returns True if it has been started, otherwise false.
  19147. */
  19148. isStarted(): boolean;
  19149. /**
  19150. * Animates the particle system for this frame.
  19151. */
  19152. animate(): void;
  19153. /**
  19154. * Renders the particle system in its current state.
  19155. * @returns the current number of particles
  19156. */
  19157. render(): number;
  19158. /**
  19159. * Dispose the particle system and frees its associated resources.
  19160. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19161. */
  19162. dispose(disposeTexture?: boolean): void;
  19163. /**
  19164. * Clones the particle system.
  19165. * @param name The name of the cloned object
  19166. * @param newEmitter The new emitter to use
  19167. * @returns the cloned particle system
  19168. */
  19169. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19170. /**
  19171. * Serializes the particle system to a JSON object.
  19172. * @returns the JSON object
  19173. */
  19174. serialize(): any;
  19175. /**
  19176. * Rebuild the particle system
  19177. */
  19178. rebuild(): void;
  19179. /**
  19180. * Starts the particle system and begins to emit
  19181. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19182. */
  19183. start(delay?: number): void;
  19184. /**
  19185. * Stops the particle system.
  19186. */
  19187. stop(): void;
  19188. /**
  19189. * Remove all active particles
  19190. */
  19191. reset(): void;
  19192. /**
  19193. * Is this system ready to be used/rendered
  19194. * @return true if the system is ready
  19195. */
  19196. isReady(): boolean;
  19197. /**
  19198. * Adds a new color gradient
  19199. * @param gradient defines the gradient to use (between 0 and 1)
  19200. * @param color1 defines the color to affect to the specified gradient
  19201. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19202. * @returns the current particle system
  19203. */
  19204. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19205. /**
  19206. * Remove a specific color gradient
  19207. * @param gradient defines the gradient to remove
  19208. * @returns the current particle system
  19209. */
  19210. removeColorGradient(gradient: number): IParticleSystem;
  19211. /**
  19212. * Adds a new size gradient
  19213. * @param gradient defines the gradient to use (between 0 and 1)
  19214. * @param factor defines the size factor to affect to the specified gradient
  19215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19216. * @returns the current particle system
  19217. */
  19218. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19219. /**
  19220. * Remove a specific size gradient
  19221. * @param gradient defines the gradient to remove
  19222. * @returns the current particle system
  19223. */
  19224. removeSizeGradient(gradient: number): IParticleSystem;
  19225. /**
  19226. * Gets the current list of color gradients.
  19227. * You must use addColorGradient and removeColorGradient to udpate this list
  19228. * @returns the list of color gradients
  19229. */
  19230. getColorGradients(): Nullable<Array<ColorGradient>>;
  19231. /**
  19232. * Gets the current list of size gradients.
  19233. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19234. * @returns the list of size gradients
  19235. */
  19236. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19237. /**
  19238. * Gets the current list of angular speed gradients.
  19239. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19240. * @returns the list of angular speed gradients
  19241. */
  19242. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19243. /**
  19244. * Adds a new angular speed gradient
  19245. * @param gradient defines the gradient to use (between 0 and 1)
  19246. * @param factor defines the angular speed to affect to the specified gradient
  19247. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19248. * @returns the current particle system
  19249. */
  19250. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19251. /**
  19252. * Remove a specific angular speed gradient
  19253. * @param gradient defines the gradient to remove
  19254. * @returns the current particle system
  19255. */
  19256. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19257. /**
  19258. * Gets the current list of velocity gradients.
  19259. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19260. * @returns the list of velocity gradients
  19261. */
  19262. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19263. /**
  19264. * Adds a new velocity gradient
  19265. * @param gradient defines the gradient to use (between 0 and 1)
  19266. * @param factor defines the velocity to affect to the specified gradient
  19267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19268. * @returns the current particle system
  19269. */
  19270. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19271. /**
  19272. * Remove a specific velocity gradient
  19273. * @param gradient defines the gradient to remove
  19274. * @returns the current particle system
  19275. */
  19276. removeVelocityGradient(gradient: number): IParticleSystem;
  19277. /**
  19278. * Gets the current list of limit velocity gradients.
  19279. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19280. * @returns the list of limit velocity gradients
  19281. */
  19282. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19283. /**
  19284. * Adds a new limit velocity gradient
  19285. * @param gradient defines the gradient to use (between 0 and 1)
  19286. * @param factor defines the limit velocity to affect to the specified gradient
  19287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19288. * @returns the current particle system
  19289. */
  19290. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19291. /**
  19292. * Remove a specific limit velocity gradient
  19293. * @param gradient defines the gradient to remove
  19294. * @returns the current particle system
  19295. */
  19296. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19297. /**
  19298. * Adds a new drag gradient
  19299. * @param gradient defines the gradient to use (between 0 and 1)
  19300. * @param factor defines the drag to affect to the specified gradient
  19301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19302. * @returns the current particle system
  19303. */
  19304. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19305. /**
  19306. * Remove a specific drag gradient
  19307. * @param gradient defines the gradient to remove
  19308. * @returns the current particle system
  19309. */
  19310. removeDragGradient(gradient: number): IParticleSystem;
  19311. /**
  19312. * Gets the current list of drag gradients.
  19313. * You must use addDragGradient and removeDragGradient to udpate this list
  19314. * @returns the list of drag gradients
  19315. */
  19316. getDragGradients(): Nullable<Array<FactorGradient>>;
  19317. /**
  19318. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19319. * @param gradient defines the gradient to use (between 0 and 1)
  19320. * @param factor defines the emit rate to affect to the specified gradient
  19321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19322. * @returns the current particle system
  19323. */
  19324. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19325. /**
  19326. * Remove a specific emit rate gradient
  19327. * @param gradient defines the gradient to remove
  19328. * @returns the current particle system
  19329. */
  19330. removeEmitRateGradient(gradient: number): IParticleSystem;
  19331. /**
  19332. * Gets the current list of emit rate gradients.
  19333. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19334. * @returns the list of emit rate gradients
  19335. */
  19336. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19337. /**
  19338. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19339. * @param gradient defines the gradient to use (between 0 and 1)
  19340. * @param factor defines the start size to affect to the specified gradient
  19341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19342. * @returns the current particle system
  19343. */
  19344. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19345. /**
  19346. * Remove a specific start size gradient
  19347. * @param gradient defines the gradient to remove
  19348. * @returns the current particle system
  19349. */
  19350. removeStartSizeGradient(gradient: number): IParticleSystem;
  19351. /**
  19352. * Gets the current list of start size gradients.
  19353. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19354. * @returns the list of start size gradients
  19355. */
  19356. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19357. /**
  19358. * Adds a new life time gradient
  19359. * @param gradient defines the gradient to use (between 0 and 1)
  19360. * @param factor defines the life time factor to affect to the specified gradient
  19361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19362. * @returns the current particle system
  19363. */
  19364. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19365. /**
  19366. * Remove a specific life time gradient
  19367. * @param gradient defines the gradient to remove
  19368. * @returns the current particle system
  19369. */
  19370. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19371. /**
  19372. * Gets the current list of life time gradients.
  19373. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19374. * @returns the list of life time gradients
  19375. */
  19376. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19377. /**
  19378. * Gets the current list of color gradients.
  19379. * You must use addColorGradient and removeColorGradient to udpate this list
  19380. * @returns the list of color gradients
  19381. */
  19382. getColorGradients(): Nullable<Array<ColorGradient>>;
  19383. /**
  19384. * Adds a new ramp gradient used to remap particle colors
  19385. * @param gradient defines the gradient to use (between 0 and 1)
  19386. * @param color defines the color to affect to the specified gradient
  19387. * @returns the current particle system
  19388. */
  19389. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19390. /**
  19391. * Gets the current list of ramp gradients.
  19392. * You must use addRampGradient and removeRampGradient to udpate this list
  19393. * @returns the list of ramp gradients
  19394. */
  19395. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19396. /** Gets or sets a boolean indicating that ramp gradients must be used
  19397. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19398. */
  19399. useRampGradients: boolean;
  19400. /**
  19401. * Adds a new color remap gradient
  19402. * @param gradient defines the gradient to use (between 0 and 1)
  19403. * @param min defines the color remap minimal range
  19404. * @param max defines the color remap maximal range
  19405. * @returns the current particle system
  19406. */
  19407. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19408. /**
  19409. * Gets the current list of color remap gradients.
  19410. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19411. * @returns the list of color remap gradients
  19412. */
  19413. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19414. /**
  19415. * Adds a new alpha remap gradient
  19416. * @param gradient defines the gradient to use (between 0 and 1)
  19417. * @param min defines the alpha remap minimal range
  19418. * @param max defines the alpha remap maximal range
  19419. * @returns the current particle system
  19420. */
  19421. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19422. /**
  19423. * Gets the current list of alpha remap gradients.
  19424. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19425. * @returns the list of alpha remap gradients
  19426. */
  19427. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19428. /**
  19429. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19432. * @returns the emitter
  19433. */
  19434. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19435. /**
  19436. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19437. * @param radius The radius of the hemisphere to emit from
  19438. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19439. * @returns the emitter
  19440. */
  19441. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19442. /**
  19443. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19444. * @param radius The radius of the sphere to emit from
  19445. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19446. * @returns the emitter
  19447. */
  19448. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19449. /**
  19450. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19451. * @param radius The radius of the sphere to emit from
  19452. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19453. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19454. * @returns the emitter
  19455. */
  19456. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19457. /**
  19458. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19459. * @param radius The radius of the emission cylinder
  19460. * @param height The height of the emission cylinder
  19461. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19462. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19463. * @returns the emitter
  19464. */
  19465. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19466. /**
  19467. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19468. * @param radius The radius of the cylinder to emit from
  19469. * @param height The height of the emission cylinder
  19470. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19473. * @returns the emitter
  19474. */
  19475. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19476. /**
  19477. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19478. * @param radius The radius of the cone to emit from
  19479. * @param angle The base angle of the cone
  19480. * @returns the emitter
  19481. */
  19482. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19483. /**
  19484. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19487. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19488. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19489. * @returns the emitter
  19490. */
  19491. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19492. /**
  19493. * Get hosting scene
  19494. * @returns the scene
  19495. */
  19496. getScene(): Scene;
  19497. }
  19498. }
  19499. declare module "babylonjs/Meshes/instancedMesh" {
  19500. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19501. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19502. import { Camera } from "babylonjs/Cameras/camera";
  19503. import { Node } from "babylonjs/node";
  19504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19505. import { Mesh } from "babylonjs/Meshes/mesh";
  19506. import { Material } from "babylonjs/Materials/material";
  19507. import { Skeleton } from "babylonjs/Bones/skeleton";
  19508. import { Light } from "babylonjs/Lights/light";
  19509. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19510. /**
  19511. * Creates an instance based on a source mesh.
  19512. */
  19513. export class InstancedMesh extends AbstractMesh {
  19514. private _sourceMesh;
  19515. private _currentLOD;
  19516. /** @hidden */
  19517. _indexInSourceMeshInstanceArray: number;
  19518. constructor(name: string, source: Mesh);
  19519. /**
  19520. * Returns the string "InstancedMesh".
  19521. */
  19522. getClassName(): string;
  19523. /** Gets the list of lights affecting that mesh */
  19524. readonly lightSources: Light[];
  19525. _resyncLightSources(): void;
  19526. _resyncLightSource(light: Light): void;
  19527. _removeLightSource(light: Light, dispose: boolean): void;
  19528. /**
  19529. * If the source mesh receives shadows
  19530. */
  19531. readonly receiveShadows: boolean;
  19532. /**
  19533. * The material of the source mesh
  19534. */
  19535. readonly material: Nullable<Material>;
  19536. /**
  19537. * Visibility of the source mesh
  19538. */
  19539. readonly visibility: number;
  19540. /**
  19541. * Skeleton of the source mesh
  19542. */
  19543. readonly skeleton: Nullable<Skeleton>;
  19544. /**
  19545. * Rendering ground id of the source mesh
  19546. */
  19547. renderingGroupId: number;
  19548. /**
  19549. * Returns the total number of vertices (integer).
  19550. */
  19551. getTotalVertices(): number;
  19552. /**
  19553. * Returns a positive integer : the total number of indices in this mesh geometry.
  19554. * @returns the numner of indices or zero if the mesh has no geometry.
  19555. */
  19556. getTotalIndices(): number;
  19557. /**
  19558. * The source mesh of the instance
  19559. */
  19560. readonly sourceMesh: Mesh;
  19561. /**
  19562. * Is this node ready to be used/rendered
  19563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19564. * @return {boolean} is it ready
  19565. */
  19566. isReady(completeCheck?: boolean): boolean;
  19567. /**
  19568. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19569. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19570. * @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.
  19571. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19572. */
  19573. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19574. /**
  19575. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19576. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19577. * The `data` are either a numeric array either a Float32Array.
  19578. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19579. * 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).
  19580. * Note that a new underlying VertexBuffer object is created each call.
  19581. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19582. *
  19583. * Possible `kind` values :
  19584. * - VertexBuffer.PositionKind
  19585. * - VertexBuffer.UVKind
  19586. * - VertexBuffer.UV2Kind
  19587. * - VertexBuffer.UV3Kind
  19588. * - VertexBuffer.UV4Kind
  19589. * - VertexBuffer.UV5Kind
  19590. * - VertexBuffer.UV6Kind
  19591. * - VertexBuffer.ColorKind
  19592. * - VertexBuffer.MatricesIndicesKind
  19593. * - VertexBuffer.MatricesIndicesExtraKind
  19594. * - VertexBuffer.MatricesWeightsKind
  19595. * - VertexBuffer.MatricesWeightsExtraKind
  19596. *
  19597. * Returns the Mesh.
  19598. */
  19599. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19600. /**
  19601. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19602. * If the mesh has no geometry, it is simply returned as it is.
  19603. * The `data` are either a numeric array either a Float32Array.
  19604. * No new underlying VertexBuffer object is created.
  19605. * 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.
  19606. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19607. *
  19608. * Possible `kind` values :
  19609. * - VertexBuffer.PositionKind
  19610. * - VertexBuffer.UVKind
  19611. * - VertexBuffer.UV2Kind
  19612. * - VertexBuffer.UV3Kind
  19613. * - VertexBuffer.UV4Kind
  19614. * - VertexBuffer.UV5Kind
  19615. * - VertexBuffer.UV6Kind
  19616. * - VertexBuffer.ColorKind
  19617. * - VertexBuffer.MatricesIndicesKind
  19618. * - VertexBuffer.MatricesIndicesExtraKind
  19619. * - VertexBuffer.MatricesWeightsKind
  19620. * - VertexBuffer.MatricesWeightsExtraKind
  19621. *
  19622. * Returns the Mesh.
  19623. */
  19624. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19625. /**
  19626. * Sets the mesh indices.
  19627. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19628. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19629. * This method creates a new index buffer each call.
  19630. * Returns the Mesh.
  19631. */
  19632. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19633. /**
  19634. * Boolean : True if the mesh owns the requested kind of data.
  19635. */
  19636. isVerticesDataPresent(kind: string): boolean;
  19637. /**
  19638. * Returns an array of indices (IndicesArray).
  19639. */
  19640. getIndices(): Nullable<IndicesArray>;
  19641. readonly _positions: Nullable<Vector3[]>;
  19642. /**
  19643. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19644. * This means the mesh underlying bounding box and sphere are recomputed.
  19645. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19646. * @returns the current mesh
  19647. */
  19648. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19649. /** @hidden */
  19650. _preActivate(): InstancedMesh;
  19651. /** @hidden */
  19652. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19653. /** @hidden */
  19654. _postActivate(): void;
  19655. getWorldMatrix(): Matrix;
  19656. readonly isAnInstance: boolean;
  19657. /**
  19658. * Returns the current associated LOD AbstractMesh.
  19659. */
  19660. getLOD(camera: Camera): AbstractMesh;
  19661. /** @hidden */
  19662. _syncSubMeshes(): InstancedMesh;
  19663. /** @hidden */
  19664. _generatePointsArray(): boolean;
  19665. /**
  19666. * Creates a new InstancedMesh from the current mesh.
  19667. * - name (string) : the cloned mesh name
  19668. * - newParent (optional Node) : the optional Node to parent the clone to.
  19669. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19670. *
  19671. * Returns the clone.
  19672. */
  19673. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19674. /**
  19675. * Disposes the InstancedMesh.
  19676. * Returns nothing.
  19677. */
  19678. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19679. }
  19680. module "babylonjs/Meshes/mesh" {
  19681. interface Mesh {
  19682. /**
  19683. * Register a custom buffer that will be instanced
  19684. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19685. * @param kind defines the buffer kind
  19686. * @param stride defines the stride in floats
  19687. */
  19688. registerInstancedBuffer(kind: string, stride: number): void;
  19689. /** @hidden */
  19690. _userInstancedBuffersStorage: {
  19691. data: {
  19692. [key: string]: Float32Array;
  19693. };
  19694. sizes: {
  19695. [key: string]: number;
  19696. };
  19697. vertexBuffers: {
  19698. [key: string]: Nullable<VertexBuffer>;
  19699. };
  19700. strides: {
  19701. [key: string]: number;
  19702. };
  19703. };
  19704. }
  19705. }
  19706. module "babylonjs/Meshes/abstractMesh" {
  19707. interface AbstractMesh {
  19708. /**
  19709. * Object used to store instanced buffers defined by user
  19710. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19711. */
  19712. instancedBuffers: {
  19713. [key: string]: any;
  19714. };
  19715. }
  19716. }
  19717. }
  19718. declare module "babylonjs/Materials/shaderMaterial" {
  19719. import { Scene } from "babylonjs/scene";
  19720. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19722. import { Mesh } from "babylonjs/Meshes/mesh";
  19723. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19725. import { Texture } from "babylonjs/Materials/Textures/texture";
  19726. import { Material } from "babylonjs/Materials/material";
  19727. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19728. /**
  19729. * Defines the options associated with the creation of a shader material.
  19730. */
  19731. export interface IShaderMaterialOptions {
  19732. /**
  19733. * Does the material work in alpha blend mode
  19734. */
  19735. needAlphaBlending: boolean;
  19736. /**
  19737. * Does the material work in alpha test mode
  19738. */
  19739. needAlphaTesting: boolean;
  19740. /**
  19741. * The list of attribute names used in the shader
  19742. */
  19743. attributes: string[];
  19744. /**
  19745. * The list of unifrom names used in the shader
  19746. */
  19747. uniforms: string[];
  19748. /**
  19749. * The list of UBO names used in the shader
  19750. */
  19751. uniformBuffers: string[];
  19752. /**
  19753. * The list of sampler names used in the shader
  19754. */
  19755. samplers: string[];
  19756. /**
  19757. * The list of defines used in the shader
  19758. */
  19759. defines: string[];
  19760. }
  19761. /**
  19762. * 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.
  19763. *
  19764. * This returned material effects how the mesh will look based on the code in the shaders.
  19765. *
  19766. * @see http://doc.babylonjs.com/how_to/shader_material
  19767. */
  19768. export class ShaderMaterial extends Material {
  19769. private _shaderPath;
  19770. private _options;
  19771. private _textures;
  19772. private _textureArrays;
  19773. private _floats;
  19774. private _ints;
  19775. private _floatsArrays;
  19776. private _colors3;
  19777. private _colors3Arrays;
  19778. private _colors4;
  19779. private _colors4Arrays;
  19780. private _vectors2;
  19781. private _vectors3;
  19782. private _vectors4;
  19783. private _matrices;
  19784. private _matrixArrays;
  19785. private _matrices3x3;
  19786. private _matrices2x2;
  19787. private _vectors2Arrays;
  19788. private _vectors3Arrays;
  19789. private _vectors4Arrays;
  19790. private _cachedWorldViewMatrix;
  19791. private _cachedWorldViewProjectionMatrix;
  19792. private _renderId;
  19793. private _multiview;
  19794. /**
  19795. * Instantiate a new shader material.
  19796. * 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.
  19797. * This returned material effects how the mesh will look based on the code in the shaders.
  19798. * @see http://doc.babylonjs.com/how_to/shader_material
  19799. * @param name Define the name of the material in the scene
  19800. * @param scene Define the scene the material belongs to
  19801. * @param shaderPath Defines the route to the shader code in one of three ways:
  19802. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19803. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19804. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19805. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19806. * @param options Define the options used to create the shader
  19807. */
  19808. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19809. /**
  19810. * Gets the shader path used to define the shader code
  19811. * It can be modified to trigger a new compilation
  19812. */
  19813. /**
  19814. * Sets the shader path used to define the shader code
  19815. * It can be modified to trigger a new compilation
  19816. */
  19817. shaderPath: any;
  19818. /**
  19819. * Gets the options used to compile the shader.
  19820. * They can be modified to trigger a new compilation
  19821. */
  19822. readonly options: IShaderMaterialOptions;
  19823. /**
  19824. * Gets the current class name of the material e.g. "ShaderMaterial"
  19825. * Mainly use in serialization.
  19826. * @returns the class name
  19827. */
  19828. getClassName(): string;
  19829. /**
  19830. * Specifies if the material will require alpha blending
  19831. * @returns a boolean specifying if alpha blending is needed
  19832. */
  19833. needAlphaBlending(): boolean;
  19834. /**
  19835. * Specifies if this material should be rendered in alpha test mode
  19836. * @returns a boolean specifying if an alpha test is needed.
  19837. */
  19838. needAlphaTesting(): boolean;
  19839. private _checkUniform;
  19840. /**
  19841. * Set a texture in the shader.
  19842. * @param name Define the name of the uniform samplers as defined in the shader
  19843. * @param texture Define the texture to bind to this sampler
  19844. * @return the material itself allowing "fluent" like uniform updates
  19845. */
  19846. setTexture(name: string, texture: Texture): ShaderMaterial;
  19847. /**
  19848. * Set a texture array in the shader.
  19849. * @param name Define the name of the uniform sampler array as defined in the shader
  19850. * @param textures Define the list of textures to bind to this sampler
  19851. * @return the material itself allowing "fluent" like uniform updates
  19852. */
  19853. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19854. /**
  19855. * Set a float in the shader.
  19856. * @param name Define the name of the uniform as defined in the shader
  19857. * @param value Define the value to give to the uniform
  19858. * @return the material itself allowing "fluent" like uniform updates
  19859. */
  19860. setFloat(name: string, value: number): ShaderMaterial;
  19861. /**
  19862. * Set a int in the shader.
  19863. * @param name Define the name of the uniform as defined in the shader
  19864. * @param value Define the value to give to the uniform
  19865. * @return the material itself allowing "fluent" like uniform updates
  19866. */
  19867. setInt(name: string, value: number): ShaderMaterial;
  19868. /**
  19869. * Set an array of floats in the shader.
  19870. * @param name Define the name of the uniform as defined in the shader
  19871. * @param value Define the value to give to the uniform
  19872. * @return the material itself allowing "fluent" like uniform updates
  19873. */
  19874. setFloats(name: string, value: number[]): ShaderMaterial;
  19875. /**
  19876. * Set a vec3 in the shader from a Color3.
  19877. * @param name Define the name of the uniform as defined in the shader
  19878. * @param value Define the value to give to the uniform
  19879. * @return the material itself allowing "fluent" like uniform updates
  19880. */
  19881. setColor3(name: string, value: Color3): ShaderMaterial;
  19882. /**
  19883. * Set a vec3 array in the shader from a Color3 array.
  19884. * @param name Define the name of the uniform as defined in the shader
  19885. * @param value Define the value to give to the uniform
  19886. * @return the material itself allowing "fluent" like uniform updates
  19887. */
  19888. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19889. /**
  19890. * Set a vec4 in the shader from a Color4.
  19891. * @param name Define the name of the uniform as defined in the shader
  19892. * @param value Define the value to give to the uniform
  19893. * @return the material itself allowing "fluent" like uniform updates
  19894. */
  19895. setColor4(name: string, value: Color4): ShaderMaterial;
  19896. /**
  19897. * Set a vec4 array in the shader from a Color4 array.
  19898. * @param name Define the name of the uniform as defined in the shader
  19899. * @param value Define the value to give to the uniform
  19900. * @return the material itself allowing "fluent" like uniform updates
  19901. */
  19902. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19903. /**
  19904. * Set a vec2 in the shader from a Vector2.
  19905. * @param name Define the name of the uniform as defined in the shader
  19906. * @param value Define the value to give to the uniform
  19907. * @return the material itself allowing "fluent" like uniform updates
  19908. */
  19909. setVector2(name: string, value: Vector2): ShaderMaterial;
  19910. /**
  19911. * Set a vec3 in the shader from a Vector3.
  19912. * @param name Define the name of the uniform as defined in the shader
  19913. * @param value Define the value to give to the uniform
  19914. * @return the material itself allowing "fluent" like uniform updates
  19915. */
  19916. setVector3(name: string, value: Vector3): ShaderMaterial;
  19917. /**
  19918. * Set a vec4 in the shader from a Vector4.
  19919. * @param name Define the name of the uniform as defined in the shader
  19920. * @param value Define the value to give to the uniform
  19921. * @return the material itself allowing "fluent" like uniform updates
  19922. */
  19923. setVector4(name: string, value: Vector4): ShaderMaterial;
  19924. /**
  19925. * Set a mat4 in the shader from a Matrix.
  19926. * @param name Define the name of the uniform as defined in the shader
  19927. * @param value Define the value to give to the uniform
  19928. * @return the material itself allowing "fluent" like uniform updates
  19929. */
  19930. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19931. /**
  19932. * Set a float32Array in the shader from a matrix array.
  19933. * @param name Define the name of the uniform as defined in the shader
  19934. * @param value Define the value to give to the uniform
  19935. * @return the material itself allowing "fluent" like uniform updates
  19936. */
  19937. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19938. /**
  19939. * Set a mat3 in the shader from a Float32Array.
  19940. * @param name Define the name of the uniform as defined in the shader
  19941. * @param value Define the value to give to the uniform
  19942. * @return the material itself allowing "fluent" like uniform updates
  19943. */
  19944. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19945. /**
  19946. * Set a mat2 in the shader from a Float32Array.
  19947. * @param name Define the name of the uniform as defined in the shader
  19948. * @param value Define the value to give to the uniform
  19949. * @return the material itself allowing "fluent" like uniform updates
  19950. */
  19951. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19952. /**
  19953. * Set a vec2 array in the shader from a number array.
  19954. * @param name Define the name of the uniform as defined in the shader
  19955. * @param value Define the value to give to the uniform
  19956. * @return the material itself allowing "fluent" like uniform updates
  19957. */
  19958. setArray2(name: string, value: number[]): ShaderMaterial;
  19959. /**
  19960. * Set a vec3 array in the shader from a number array.
  19961. * @param name Define the name of the uniform as defined in the shader
  19962. * @param value Define the value to give to the uniform
  19963. * @return the material itself allowing "fluent" like uniform updates
  19964. */
  19965. setArray3(name: string, value: number[]): ShaderMaterial;
  19966. /**
  19967. * Set a vec4 array in the shader from a number array.
  19968. * @param name Define the name of the uniform as defined in the shader
  19969. * @param value Define the value to give to the uniform
  19970. * @return the material itself allowing "fluent" like uniform updates
  19971. */
  19972. setArray4(name: string, value: number[]): ShaderMaterial;
  19973. private _checkCache;
  19974. /**
  19975. * Specifies that the submesh is ready to be used
  19976. * @param mesh defines the mesh to check
  19977. * @param subMesh defines which submesh to check
  19978. * @param useInstances specifies that instances should be used
  19979. * @returns a boolean indicating that the submesh is ready or not
  19980. */
  19981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19982. /**
  19983. * Checks if the material is ready to render the requested mesh
  19984. * @param mesh Define the mesh to render
  19985. * @param useInstances Define whether or not the material is used with instances
  19986. * @returns true if ready, otherwise false
  19987. */
  19988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19989. /**
  19990. * Binds the world matrix to the material
  19991. * @param world defines the world transformation matrix
  19992. */
  19993. bindOnlyWorldMatrix(world: Matrix): void;
  19994. /**
  19995. * Binds the material to the mesh
  19996. * @param world defines the world transformation matrix
  19997. * @param mesh defines the mesh to bind the material to
  19998. */
  19999. bind(world: Matrix, mesh?: Mesh): void;
  20000. /**
  20001. * Gets the active textures from the material
  20002. * @returns an array of textures
  20003. */
  20004. getActiveTextures(): BaseTexture[];
  20005. /**
  20006. * Specifies if the material uses a texture
  20007. * @param texture defines the texture to check against the material
  20008. * @returns a boolean specifying if the material uses the texture
  20009. */
  20010. hasTexture(texture: BaseTexture): boolean;
  20011. /**
  20012. * Makes a duplicate of the material, and gives it a new name
  20013. * @param name defines the new name for the duplicated material
  20014. * @returns the cloned material
  20015. */
  20016. clone(name: string): ShaderMaterial;
  20017. /**
  20018. * Disposes the material
  20019. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20020. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20021. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20022. */
  20023. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20024. /**
  20025. * Serializes this material in a JSON representation
  20026. * @returns the serialized material object
  20027. */
  20028. serialize(): any;
  20029. /**
  20030. * Creates a shader material from parsed shader material data
  20031. * @param source defines the JSON represnetation of the material
  20032. * @param scene defines the hosting scene
  20033. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20034. * @returns a new material
  20035. */
  20036. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20037. }
  20038. }
  20039. declare module "babylonjs/Shaders/color.fragment" {
  20040. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20041. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20042. /** @hidden */
  20043. export var colorPixelShader: {
  20044. name: string;
  20045. shader: string;
  20046. };
  20047. }
  20048. declare module "babylonjs/Shaders/color.vertex" {
  20049. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20050. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20051. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20052. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20053. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20054. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20055. /** @hidden */
  20056. export var colorVertexShader: {
  20057. name: string;
  20058. shader: string;
  20059. };
  20060. }
  20061. declare module "babylonjs/Meshes/linesMesh" {
  20062. import { Nullable } from "babylonjs/types";
  20063. import { Scene } from "babylonjs/scene";
  20064. import { Color3 } from "babylonjs/Maths/math.color";
  20065. import { Node } from "babylonjs/node";
  20066. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20067. import { Mesh } from "babylonjs/Meshes/mesh";
  20068. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20069. import { Effect } from "babylonjs/Materials/effect";
  20070. import { Material } from "babylonjs/Materials/material";
  20071. import "babylonjs/Shaders/color.fragment";
  20072. import "babylonjs/Shaders/color.vertex";
  20073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20074. /**
  20075. * Line mesh
  20076. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20077. */
  20078. export class LinesMesh extends Mesh {
  20079. /**
  20080. * If vertex color should be applied to the mesh
  20081. */
  20082. readonly useVertexColor?: boolean | undefined;
  20083. /**
  20084. * If vertex alpha should be applied to the mesh
  20085. */
  20086. readonly useVertexAlpha?: boolean | undefined;
  20087. /**
  20088. * Color of the line (Default: White)
  20089. */
  20090. color: Color3;
  20091. /**
  20092. * Alpha of the line (Default: 1)
  20093. */
  20094. alpha: number;
  20095. /**
  20096. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20097. * This margin is expressed in world space coordinates, so its value may vary.
  20098. * Default value is 0.1
  20099. */
  20100. intersectionThreshold: number;
  20101. private _colorShader;
  20102. private color4;
  20103. /**
  20104. * Creates a new LinesMesh
  20105. * @param name defines the name
  20106. * @param scene defines the hosting scene
  20107. * @param parent defines the parent mesh if any
  20108. * @param source defines the optional source LinesMesh used to clone data from
  20109. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20110. * When false, achieved by calling a clone(), also passing False.
  20111. * This will make creation of children, recursive.
  20112. * @param useVertexColor defines if this LinesMesh supports vertex color
  20113. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20114. */
  20115. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20116. /**
  20117. * If vertex color should be applied to the mesh
  20118. */
  20119. useVertexColor?: boolean | undefined,
  20120. /**
  20121. * If vertex alpha should be applied to the mesh
  20122. */
  20123. useVertexAlpha?: boolean | undefined);
  20124. private _addClipPlaneDefine;
  20125. private _removeClipPlaneDefine;
  20126. isReady(): boolean;
  20127. /**
  20128. * Returns the string "LineMesh"
  20129. */
  20130. getClassName(): string;
  20131. /**
  20132. * @hidden
  20133. */
  20134. /**
  20135. * @hidden
  20136. */
  20137. material: Material;
  20138. /**
  20139. * @hidden
  20140. */
  20141. readonly checkCollisions: boolean;
  20142. /** @hidden */
  20143. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20144. /** @hidden */
  20145. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20146. /**
  20147. * Disposes of the line mesh
  20148. * @param doNotRecurse If children should be disposed
  20149. */
  20150. dispose(doNotRecurse?: boolean): void;
  20151. /**
  20152. * Returns a new LineMesh object cloned from the current one.
  20153. */
  20154. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20155. /**
  20156. * Creates a new InstancedLinesMesh object from the mesh model.
  20157. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20158. * @param name defines the name of the new instance
  20159. * @returns a new InstancedLinesMesh
  20160. */
  20161. createInstance(name: string): InstancedLinesMesh;
  20162. }
  20163. /**
  20164. * Creates an instance based on a source LinesMesh
  20165. */
  20166. export class InstancedLinesMesh extends InstancedMesh {
  20167. /**
  20168. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20169. * This margin is expressed in world space coordinates, so its value may vary.
  20170. * Initilized with the intersectionThreshold value of the source LinesMesh
  20171. */
  20172. intersectionThreshold: number;
  20173. constructor(name: string, source: LinesMesh);
  20174. /**
  20175. * Returns the string "InstancedLinesMesh".
  20176. */
  20177. getClassName(): string;
  20178. }
  20179. }
  20180. declare module "babylonjs/Shaders/line.fragment" {
  20181. /** @hidden */
  20182. export var linePixelShader: {
  20183. name: string;
  20184. shader: string;
  20185. };
  20186. }
  20187. declare module "babylonjs/Shaders/line.vertex" {
  20188. /** @hidden */
  20189. export var lineVertexShader: {
  20190. name: string;
  20191. shader: string;
  20192. };
  20193. }
  20194. declare module "babylonjs/Rendering/edgesRenderer" {
  20195. import { Nullable } from "babylonjs/types";
  20196. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20198. import { Vector3 } from "babylonjs/Maths/math.vector";
  20199. import { IDisposable } from "babylonjs/scene";
  20200. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20201. import "babylonjs/Shaders/line.fragment";
  20202. import "babylonjs/Shaders/line.vertex";
  20203. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20204. module "babylonjs/Meshes/abstractMesh" {
  20205. interface AbstractMesh {
  20206. /**
  20207. * Gets the edgesRenderer associated with the mesh
  20208. */
  20209. edgesRenderer: Nullable<EdgesRenderer>;
  20210. }
  20211. }
  20212. module "babylonjs/Meshes/linesMesh" {
  20213. interface LinesMesh {
  20214. /**
  20215. * Enables the edge rendering mode on the mesh.
  20216. * This mode makes the mesh edges visible
  20217. * @param epsilon defines the maximal distance between two angles to detect a face
  20218. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20219. * @returns the currentAbstractMesh
  20220. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20221. */
  20222. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20223. }
  20224. }
  20225. module "babylonjs/Meshes/linesMesh" {
  20226. interface InstancedLinesMesh {
  20227. /**
  20228. * Enables the edge rendering mode on the mesh.
  20229. * This mode makes the mesh edges visible
  20230. * @param epsilon defines the maximal distance between two angles to detect a face
  20231. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20232. * @returns the current InstancedLinesMesh
  20233. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20234. */
  20235. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20236. }
  20237. }
  20238. /**
  20239. * Defines the minimum contract an Edges renderer should follow.
  20240. */
  20241. export interface IEdgesRenderer extends IDisposable {
  20242. /**
  20243. * Gets or sets a boolean indicating if the edgesRenderer is active
  20244. */
  20245. isEnabled: boolean;
  20246. /**
  20247. * Renders the edges of the attached mesh,
  20248. */
  20249. render(): void;
  20250. /**
  20251. * Checks wether or not the edges renderer is ready to render.
  20252. * @return true if ready, otherwise false.
  20253. */
  20254. isReady(): boolean;
  20255. }
  20256. /**
  20257. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20258. */
  20259. export class EdgesRenderer implements IEdgesRenderer {
  20260. /**
  20261. * Define the size of the edges with an orthographic camera
  20262. */
  20263. edgesWidthScalerForOrthographic: number;
  20264. /**
  20265. * Define the size of the edges with a perspective camera
  20266. */
  20267. edgesWidthScalerForPerspective: number;
  20268. protected _source: AbstractMesh;
  20269. protected _linesPositions: number[];
  20270. protected _linesNormals: number[];
  20271. protected _linesIndices: number[];
  20272. protected _epsilon: number;
  20273. protected _indicesCount: number;
  20274. protected _lineShader: ShaderMaterial;
  20275. protected _ib: DataBuffer;
  20276. protected _buffers: {
  20277. [key: string]: Nullable<VertexBuffer>;
  20278. };
  20279. protected _checkVerticesInsteadOfIndices: boolean;
  20280. private _meshRebuildObserver;
  20281. private _meshDisposeObserver;
  20282. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20283. isEnabled: boolean;
  20284. /**
  20285. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20286. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20287. * @param source Mesh used to create edges
  20288. * @param epsilon sum of angles in adjacency to check for edge
  20289. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20290. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20291. */
  20292. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20293. protected _prepareRessources(): void;
  20294. /** @hidden */
  20295. _rebuild(): void;
  20296. /**
  20297. * Releases the required resources for the edges renderer
  20298. */
  20299. dispose(): void;
  20300. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20301. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20302. /**
  20303. * Checks if the pair of p0 and p1 is en edge
  20304. * @param faceIndex
  20305. * @param edge
  20306. * @param faceNormals
  20307. * @param p0
  20308. * @param p1
  20309. * @private
  20310. */
  20311. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20312. /**
  20313. * push line into the position, normal and index buffer
  20314. * @protected
  20315. */
  20316. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20317. /**
  20318. * Generates lines edges from adjacencjes
  20319. * @private
  20320. */
  20321. _generateEdgesLines(): void;
  20322. /**
  20323. * Checks wether or not the edges renderer is ready to render.
  20324. * @return true if ready, otherwise false.
  20325. */
  20326. isReady(): boolean;
  20327. /**
  20328. * Renders the edges of the attached mesh,
  20329. */
  20330. render(): void;
  20331. }
  20332. /**
  20333. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20334. */
  20335. export class LineEdgesRenderer extends EdgesRenderer {
  20336. /**
  20337. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20338. * @param source LineMesh used to generate edges
  20339. * @param epsilon not important (specified angle for edge detection)
  20340. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20341. */
  20342. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20343. /**
  20344. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20345. */
  20346. _generateEdgesLines(): void;
  20347. }
  20348. }
  20349. declare module "babylonjs/Rendering/renderingGroup" {
  20350. import { SmartArray } from "babylonjs/Misc/smartArray";
  20351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20353. import { Nullable } from "babylonjs/types";
  20354. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20355. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20356. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20357. import { Material } from "babylonjs/Materials/material";
  20358. import { Scene } from "babylonjs/scene";
  20359. /**
  20360. * This represents the object necessary to create a rendering group.
  20361. * This is exclusively used and created by the rendering manager.
  20362. * To modify the behavior, you use the available helpers in your scene or meshes.
  20363. * @hidden
  20364. */
  20365. export class RenderingGroup {
  20366. index: number;
  20367. private static _zeroVector;
  20368. private _scene;
  20369. private _opaqueSubMeshes;
  20370. private _transparentSubMeshes;
  20371. private _alphaTestSubMeshes;
  20372. private _depthOnlySubMeshes;
  20373. private _particleSystems;
  20374. private _spriteManagers;
  20375. private _opaqueSortCompareFn;
  20376. private _alphaTestSortCompareFn;
  20377. private _transparentSortCompareFn;
  20378. private _renderOpaque;
  20379. private _renderAlphaTest;
  20380. private _renderTransparent;
  20381. /** @hidden */
  20382. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20383. onBeforeTransparentRendering: () => void;
  20384. /**
  20385. * Set the opaque sort comparison function.
  20386. * If null the sub meshes will be render in the order they were created
  20387. */
  20388. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20389. /**
  20390. * Set the alpha test sort comparison function.
  20391. * If null the sub meshes will be render in the order they were created
  20392. */
  20393. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20394. /**
  20395. * Set the transparent sort comparison function.
  20396. * If null the sub meshes will be render in the order they were created
  20397. */
  20398. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20399. /**
  20400. * Creates a new rendering group.
  20401. * @param index The rendering group index
  20402. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20403. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20404. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20405. */
  20406. 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>);
  20407. /**
  20408. * Render all the sub meshes contained in the group.
  20409. * @param customRenderFunction Used to override the default render behaviour of the group.
  20410. * @returns true if rendered some submeshes.
  20411. */
  20412. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20413. /**
  20414. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20415. * @param subMeshes The submeshes to render
  20416. */
  20417. private renderOpaqueSorted;
  20418. /**
  20419. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20420. * @param subMeshes The submeshes to render
  20421. */
  20422. private renderAlphaTestSorted;
  20423. /**
  20424. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20425. * @param subMeshes The submeshes to render
  20426. */
  20427. private renderTransparentSorted;
  20428. /**
  20429. * Renders the submeshes in a specified order.
  20430. * @param subMeshes The submeshes to sort before render
  20431. * @param sortCompareFn The comparison function use to sort
  20432. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20433. * @param transparent Specifies to activate blending if true
  20434. */
  20435. private static renderSorted;
  20436. /**
  20437. * Renders the submeshes in the order they were dispatched (no sort applied).
  20438. * @param subMeshes The submeshes to render
  20439. */
  20440. private static renderUnsorted;
  20441. /**
  20442. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20443. * are rendered back to front if in the same alpha index.
  20444. *
  20445. * @param a The first submesh
  20446. * @param b The second submesh
  20447. * @returns The result of the comparison
  20448. */
  20449. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20450. /**
  20451. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20452. * are rendered back to front.
  20453. *
  20454. * @param a The first submesh
  20455. * @param b The second submesh
  20456. * @returns The result of the comparison
  20457. */
  20458. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20459. /**
  20460. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20461. * are rendered front to back (prevent overdraw).
  20462. *
  20463. * @param a The first submesh
  20464. * @param b The second submesh
  20465. * @returns The result of the comparison
  20466. */
  20467. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20468. /**
  20469. * Resets the different lists of submeshes to prepare a new frame.
  20470. */
  20471. prepare(): void;
  20472. dispose(): void;
  20473. /**
  20474. * Inserts the submesh in its correct queue depending on its material.
  20475. * @param subMesh The submesh to dispatch
  20476. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20477. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20478. */
  20479. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20480. dispatchSprites(spriteManager: ISpriteManager): void;
  20481. dispatchParticles(particleSystem: IParticleSystem): void;
  20482. private _renderParticles;
  20483. private _renderSprites;
  20484. }
  20485. }
  20486. declare module "babylonjs/Rendering/renderingManager" {
  20487. import { Nullable } from "babylonjs/types";
  20488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20489. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20490. import { SmartArray } from "babylonjs/Misc/smartArray";
  20491. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20492. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20493. import { Material } from "babylonjs/Materials/material";
  20494. import { Scene } from "babylonjs/scene";
  20495. import { Camera } from "babylonjs/Cameras/camera";
  20496. /**
  20497. * Interface describing the different options available in the rendering manager
  20498. * regarding Auto Clear between groups.
  20499. */
  20500. export interface IRenderingManagerAutoClearSetup {
  20501. /**
  20502. * Defines whether or not autoclear is enable.
  20503. */
  20504. autoClear: boolean;
  20505. /**
  20506. * Defines whether or not to autoclear the depth buffer.
  20507. */
  20508. depth: boolean;
  20509. /**
  20510. * Defines whether or not to autoclear the stencil buffer.
  20511. */
  20512. stencil: boolean;
  20513. }
  20514. /**
  20515. * This class is used by the onRenderingGroupObservable
  20516. */
  20517. export class RenderingGroupInfo {
  20518. /**
  20519. * The Scene that being rendered
  20520. */
  20521. scene: Scene;
  20522. /**
  20523. * The camera currently used for the rendering pass
  20524. */
  20525. camera: Nullable<Camera>;
  20526. /**
  20527. * The ID of the renderingGroup being processed
  20528. */
  20529. renderingGroupId: number;
  20530. }
  20531. /**
  20532. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20533. * It is enable to manage the different groups as well as the different necessary sort functions.
  20534. * This should not be used directly aside of the few static configurations
  20535. */
  20536. export class RenderingManager {
  20537. /**
  20538. * The max id used for rendering groups (not included)
  20539. */
  20540. static MAX_RENDERINGGROUPS: number;
  20541. /**
  20542. * The min id used for rendering groups (included)
  20543. */
  20544. static MIN_RENDERINGGROUPS: number;
  20545. /**
  20546. * Used to globally prevent autoclearing scenes.
  20547. */
  20548. static AUTOCLEAR: boolean;
  20549. /**
  20550. * @hidden
  20551. */
  20552. _useSceneAutoClearSetup: boolean;
  20553. private _scene;
  20554. private _renderingGroups;
  20555. private _depthStencilBufferAlreadyCleaned;
  20556. private _autoClearDepthStencil;
  20557. private _customOpaqueSortCompareFn;
  20558. private _customAlphaTestSortCompareFn;
  20559. private _customTransparentSortCompareFn;
  20560. private _renderingGroupInfo;
  20561. /**
  20562. * Instantiates a new rendering group for a particular scene
  20563. * @param scene Defines the scene the groups belongs to
  20564. */
  20565. constructor(scene: Scene);
  20566. private _clearDepthStencilBuffer;
  20567. /**
  20568. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20569. * @hidden
  20570. */
  20571. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20572. /**
  20573. * Resets the different information of the group to prepare a new frame
  20574. * @hidden
  20575. */
  20576. reset(): void;
  20577. /**
  20578. * Dispose and release the group and its associated resources.
  20579. * @hidden
  20580. */
  20581. dispose(): void;
  20582. /**
  20583. * Clear the info related to rendering groups preventing retention points during dispose.
  20584. */
  20585. freeRenderingGroups(): void;
  20586. private _prepareRenderingGroup;
  20587. /**
  20588. * Add a sprite manager to the rendering manager in order to render it this frame.
  20589. * @param spriteManager Define the sprite manager to render
  20590. */
  20591. dispatchSprites(spriteManager: ISpriteManager): void;
  20592. /**
  20593. * Add a particle system to the rendering manager in order to render it this frame.
  20594. * @param particleSystem Define the particle system to render
  20595. */
  20596. dispatchParticles(particleSystem: IParticleSystem): void;
  20597. /**
  20598. * Add a submesh to the manager in order to render it this frame
  20599. * @param subMesh The submesh to dispatch
  20600. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20601. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20602. */
  20603. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20604. /**
  20605. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20606. * This allowed control for front to back rendering or reversly depending of the special needs.
  20607. *
  20608. * @param renderingGroupId The rendering group id corresponding to its index
  20609. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20610. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20611. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20612. */
  20613. 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;
  20614. /**
  20615. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20616. *
  20617. * @param renderingGroupId The rendering group id corresponding to its index
  20618. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20619. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20620. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20621. */
  20622. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20623. /**
  20624. * Gets the current auto clear configuration for one rendering group of the rendering
  20625. * manager.
  20626. * @param index the rendering group index to get the information for
  20627. * @returns The auto clear setup for the requested rendering group
  20628. */
  20629. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20630. }
  20631. }
  20632. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20633. import { Observable } from "babylonjs/Misc/observable";
  20634. import { SmartArray } from "babylonjs/Misc/smartArray";
  20635. import { Nullable } from "babylonjs/types";
  20636. import { Camera } from "babylonjs/Cameras/camera";
  20637. import { Scene } from "babylonjs/scene";
  20638. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20639. import { Color4 } from "babylonjs/Maths/math.color";
  20640. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20643. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20644. import { Texture } from "babylonjs/Materials/Textures/texture";
  20645. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20646. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20647. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20648. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20649. import { Engine } from "babylonjs/Engines/engine";
  20650. /**
  20651. * This Helps creating a texture that will be created from a camera in your scene.
  20652. * It is basically a dynamic texture that could be used to create special effects for instance.
  20653. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20654. */
  20655. export class RenderTargetTexture extends Texture {
  20656. isCube: boolean;
  20657. /**
  20658. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20659. */
  20660. static readonly REFRESHRATE_RENDER_ONCE: number;
  20661. /**
  20662. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20663. */
  20664. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20665. /**
  20666. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20667. * the central point of your effect and can save a lot of performances.
  20668. */
  20669. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20670. /**
  20671. * Use this predicate to dynamically define the list of mesh you want to render.
  20672. * If set, the renderList property will be overwritten.
  20673. */
  20674. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20675. private _renderList;
  20676. /**
  20677. * Use this list to define the list of mesh you want to render.
  20678. */
  20679. renderList: Nullable<Array<AbstractMesh>>;
  20680. private _hookArray;
  20681. /**
  20682. * Define if particles should be rendered in your texture.
  20683. */
  20684. renderParticles: boolean;
  20685. /**
  20686. * Define if sprites should be rendered in your texture.
  20687. */
  20688. renderSprites: boolean;
  20689. /**
  20690. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20691. */
  20692. coordinatesMode: number;
  20693. /**
  20694. * Define the camera used to render the texture.
  20695. */
  20696. activeCamera: Nullable<Camera>;
  20697. /**
  20698. * Override the render function of the texture with your own one.
  20699. */
  20700. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20701. /**
  20702. * Define if camera post processes should be use while rendering the texture.
  20703. */
  20704. useCameraPostProcesses: boolean;
  20705. /**
  20706. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20707. */
  20708. ignoreCameraViewport: boolean;
  20709. private _postProcessManager;
  20710. private _postProcesses;
  20711. private _resizeObserver;
  20712. /**
  20713. * An event triggered when the texture is unbind.
  20714. */
  20715. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20716. /**
  20717. * An event triggered when the texture is unbind.
  20718. */
  20719. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20720. private _onAfterUnbindObserver;
  20721. /**
  20722. * Set a after unbind callback in the texture.
  20723. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20724. */
  20725. onAfterUnbind: () => void;
  20726. /**
  20727. * An event triggered before rendering the texture
  20728. */
  20729. onBeforeRenderObservable: Observable<number>;
  20730. private _onBeforeRenderObserver;
  20731. /**
  20732. * Set a before render callback in the texture.
  20733. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20734. */
  20735. onBeforeRender: (faceIndex: number) => void;
  20736. /**
  20737. * An event triggered after rendering the texture
  20738. */
  20739. onAfterRenderObservable: Observable<number>;
  20740. private _onAfterRenderObserver;
  20741. /**
  20742. * Set a after render callback in the texture.
  20743. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20744. */
  20745. onAfterRender: (faceIndex: number) => void;
  20746. /**
  20747. * An event triggered after the texture clear
  20748. */
  20749. onClearObservable: Observable<Engine>;
  20750. private _onClearObserver;
  20751. /**
  20752. * Set a clear callback in the texture.
  20753. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20754. */
  20755. onClear: (Engine: Engine) => void;
  20756. /**
  20757. * An event triggered when the texture is resized.
  20758. */
  20759. onResizeObservable: Observable<RenderTargetTexture>;
  20760. /**
  20761. * Define the clear color of the Render Target if it should be different from the scene.
  20762. */
  20763. clearColor: Color4;
  20764. protected _size: number | {
  20765. width: number;
  20766. height: number;
  20767. };
  20768. protected _initialSizeParameter: number | {
  20769. width: number;
  20770. height: number;
  20771. } | {
  20772. ratio: number;
  20773. };
  20774. protected _sizeRatio: Nullable<number>;
  20775. /** @hidden */
  20776. _generateMipMaps: boolean;
  20777. protected _renderingManager: RenderingManager;
  20778. /** @hidden */
  20779. _waitingRenderList: string[];
  20780. protected _doNotChangeAspectRatio: boolean;
  20781. protected _currentRefreshId: number;
  20782. protected _refreshRate: number;
  20783. protected _textureMatrix: Matrix;
  20784. protected _samples: number;
  20785. protected _renderTargetOptions: RenderTargetCreationOptions;
  20786. /**
  20787. * Gets render target creation options that were used.
  20788. */
  20789. readonly renderTargetOptions: RenderTargetCreationOptions;
  20790. protected _engine: Engine;
  20791. protected _onRatioRescale(): void;
  20792. /**
  20793. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20794. * It must define where the camera used to render the texture is set
  20795. */
  20796. boundingBoxPosition: Vector3;
  20797. private _boundingBoxSize;
  20798. /**
  20799. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20800. * When defined, the cubemap will switch to local mode
  20801. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20802. * @example https://www.babylonjs-playground.com/#RNASML
  20803. */
  20804. boundingBoxSize: Vector3;
  20805. /**
  20806. * In case the RTT has been created with a depth texture, get the associated
  20807. * depth texture.
  20808. * Otherwise, return null.
  20809. */
  20810. depthStencilTexture: Nullable<InternalTexture>;
  20811. /**
  20812. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20813. * or used a shadow, depth texture...
  20814. * @param name The friendly name of the texture
  20815. * @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)
  20816. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20817. * @param generateMipMaps True if mip maps need to be generated after render.
  20818. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20819. * @param type The type of the buffer in the RTT (int, half float, float...)
  20820. * @param isCube True if a cube texture needs to be created
  20821. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20822. * @param generateDepthBuffer True to generate a depth buffer
  20823. * @param generateStencilBuffer True to generate a stencil buffer
  20824. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20825. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20826. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20827. */
  20828. constructor(name: string, size: number | {
  20829. width: number;
  20830. height: number;
  20831. } | {
  20832. ratio: number;
  20833. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20834. /**
  20835. * Creates a depth stencil texture.
  20836. * This is only available in WebGL 2 or with the depth texture extension available.
  20837. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20838. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20839. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20840. */
  20841. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20842. private _processSizeParameter;
  20843. /**
  20844. * Define the number of samples to use in case of MSAA.
  20845. * It defaults to one meaning no MSAA has been enabled.
  20846. */
  20847. samples: number;
  20848. /**
  20849. * Resets the refresh counter of the texture and start bak from scratch.
  20850. * Could be useful to regenerate the texture if it is setup to render only once.
  20851. */
  20852. resetRefreshCounter(): void;
  20853. /**
  20854. * Define the refresh rate of the texture or the rendering frequency.
  20855. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20856. */
  20857. refreshRate: number;
  20858. /**
  20859. * Adds a post process to the render target rendering passes.
  20860. * @param postProcess define the post process to add
  20861. */
  20862. addPostProcess(postProcess: PostProcess): void;
  20863. /**
  20864. * Clear all the post processes attached to the render target
  20865. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20866. */
  20867. clearPostProcesses(dispose?: boolean): void;
  20868. /**
  20869. * Remove one of the post process from the list of attached post processes to the texture
  20870. * @param postProcess define the post process to remove from the list
  20871. */
  20872. removePostProcess(postProcess: PostProcess): void;
  20873. /** @hidden */
  20874. _shouldRender(): boolean;
  20875. /**
  20876. * Gets the actual render size of the texture.
  20877. * @returns the width of the render size
  20878. */
  20879. getRenderSize(): number;
  20880. /**
  20881. * Gets the actual render width of the texture.
  20882. * @returns the width of the render size
  20883. */
  20884. getRenderWidth(): number;
  20885. /**
  20886. * Gets the actual render height of the texture.
  20887. * @returns the height of the render size
  20888. */
  20889. getRenderHeight(): number;
  20890. /**
  20891. * Get if the texture can be rescaled or not.
  20892. */
  20893. readonly canRescale: boolean;
  20894. /**
  20895. * Resize the texture using a ratio.
  20896. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20897. */
  20898. scale(ratio: number): void;
  20899. /**
  20900. * Get the texture reflection matrix used to rotate/transform the reflection.
  20901. * @returns the reflection matrix
  20902. */
  20903. getReflectionTextureMatrix(): Matrix;
  20904. /**
  20905. * Resize the texture to a new desired size.
  20906. * Be carrefull as it will recreate all the data in the new texture.
  20907. * @param size Define the new size. It can be:
  20908. * - a number for squared texture,
  20909. * - an object containing { width: number, height: number }
  20910. * - or an object containing a ratio { ratio: number }
  20911. */
  20912. resize(size: number | {
  20913. width: number;
  20914. height: number;
  20915. } | {
  20916. ratio: number;
  20917. }): void;
  20918. /**
  20919. * Renders all the objects from the render list into the texture.
  20920. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20921. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20922. */
  20923. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20924. private _bestReflectionRenderTargetDimension;
  20925. /**
  20926. * @hidden
  20927. * @param faceIndex face index to bind to if this is a cubetexture
  20928. */
  20929. _bindFrameBuffer(faceIndex?: number): void;
  20930. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20931. private renderToTarget;
  20932. /**
  20933. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20934. * This allowed control for front to back rendering or reversly depending of the special needs.
  20935. *
  20936. * @param renderingGroupId The rendering group id corresponding to its index
  20937. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20938. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20939. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20940. */
  20941. 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;
  20942. /**
  20943. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20944. *
  20945. * @param renderingGroupId The rendering group id corresponding to its index
  20946. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20947. */
  20948. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20949. /**
  20950. * Clones the texture.
  20951. * @returns the cloned texture
  20952. */
  20953. clone(): RenderTargetTexture;
  20954. /**
  20955. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20956. * @returns The JSON representation of the texture
  20957. */
  20958. serialize(): any;
  20959. /**
  20960. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20961. */
  20962. disposeFramebufferObjects(): void;
  20963. /**
  20964. * Dispose the texture and release its associated resources.
  20965. */
  20966. dispose(): void;
  20967. /** @hidden */
  20968. _rebuild(): void;
  20969. /**
  20970. * Clear the info related to rendering groups preventing retention point in material dispose.
  20971. */
  20972. freeRenderingGroups(): void;
  20973. /**
  20974. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20975. * @returns the view count
  20976. */
  20977. getViewCount(): number;
  20978. }
  20979. }
  20980. declare module "babylonjs/Materials/material" {
  20981. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20982. import { SmartArray } from "babylonjs/Misc/smartArray";
  20983. import { Observable } from "babylonjs/Misc/observable";
  20984. import { Nullable } from "babylonjs/types";
  20985. import { Scene } from "babylonjs/scene";
  20986. import { Matrix } from "babylonjs/Maths/math.vector";
  20987. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20989. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20990. import { Effect } from "babylonjs/Materials/effect";
  20991. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20992. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20994. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20995. import { Mesh } from "babylonjs/Meshes/mesh";
  20996. import { Animation } from "babylonjs/Animations/animation";
  20997. /**
  20998. * Options for compiling materials.
  20999. */
  21000. export interface IMaterialCompilationOptions {
  21001. /**
  21002. * Defines whether clip planes are enabled.
  21003. */
  21004. clipPlane: boolean;
  21005. /**
  21006. * Defines whether instances are enabled.
  21007. */
  21008. useInstances: boolean;
  21009. }
  21010. /**
  21011. * Base class for the main features of a material in Babylon.js
  21012. */
  21013. export class Material implements IAnimatable {
  21014. /**
  21015. * Returns the triangle fill mode
  21016. */
  21017. static readonly TriangleFillMode: number;
  21018. /**
  21019. * Returns the wireframe mode
  21020. */
  21021. static readonly WireFrameFillMode: number;
  21022. /**
  21023. * Returns the point fill mode
  21024. */
  21025. static readonly PointFillMode: number;
  21026. /**
  21027. * Returns the point list draw mode
  21028. */
  21029. static readonly PointListDrawMode: number;
  21030. /**
  21031. * Returns the line list draw mode
  21032. */
  21033. static readonly LineListDrawMode: number;
  21034. /**
  21035. * Returns the line loop draw mode
  21036. */
  21037. static readonly LineLoopDrawMode: number;
  21038. /**
  21039. * Returns the line strip draw mode
  21040. */
  21041. static readonly LineStripDrawMode: number;
  21042. /**
  21043. * Returns the triangle strip draw mode
  21044. */
  21045. static readonly TriangleStripDrawMode: number;
  21046. /**
  21047. * Returns the triangle fan draw mode
  21048. */
  21049. static readonly TriangleFanDrawMode: number;
  21050. /**
  21051. * Stores the clock-wise side orientation
  21052. */
  21053. static readonly ClockWiseSideOrientation: number;
  21054. /**
  21055. * Stores the counter clock-wise side orientation
  21056. */
  21057. static readonly CounterClockWiseSideOrientation: number;
  21058. /**
  21059. * The dirty texture flag value
  21060. */
  21061. static readonly TextureDirtyFlag: number;
  21062. /**
  21063. * The dirty light flag value
  21064. */
  21065. static readonly LightDirtyFlag: number;
  21066. /**
  21067. * The dirty fresnel flag value
  21068. */
  21069. static readonly FresnelDirtyFlag: number;
  21070. /**
  21071. * The dirty attribute flag value
  21072. */
  21073. static readonly AttributesDirtyFlag: number;
  21074. /**
  21075. * The dirty misc flag value
  21076. */
  21077. static readonly MiscDirtyFlag: number;
  21078. /**
  21079. * The all dirty flag value
  21080. */
  21081. static readonly AllDirtyFlag: number;
  21082. /**
  21083. * The ID of the material
  21084. */
  21085. id: string;
  21086. /**
  21087. * Gets or sets the unique id of the material
  21088. */
  21089. uniqueId: number;
  21090. /**
  21091. * The name of the material
  21092. */
  21093. name: string;
  21094. /**
  21095. * Gets or sets user defined metadata
  21096. */
  21097. metadata: any;
  21098. /**
  21099. * For internal use only. Please do not use.
  21100. */
  21101. reservedDataStore: any;
  21102. /**
  21103. * Specifies if the ready state should be checked on each call
  21104. */
  21105. checkReadyOnEveryCall: boolean;
  21106. /**
  21107. * Specifies if the ready state should be checked once
  21108. */
  21109. checkReadyOnlyOnce: boolean;
  21110. /**
  21111. * The state of the material
  21112. */
  21113. state: string;
  21114. /**
  21115. * The alpha value of the material
  21116. */
  21117. protected _alpha: number;
  21118. /**
  21119. * List of inspectable custom properties (used by the Inspector)
  21120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21121. */
  21122. inspectableCustomProperties: IInspectable[];
  21123. /**
  21124. * Sets the alpha value of the material
  21125. */
  21126. /**
  21127. * Gets the alpha value of the material
  21128. */
  21129. alpha: number;
  21130. /**
  21131. * Specifies if back face culling is enabled
  21132. */
  21133. protected _backFaceCulling: boolean;
  21134. /**
  21135. * Sets the back-face culling state
  21136. */
  21137. /**
  21138. * Gets the back-face culling state
  21139. */
  21140. backFaceCulling: boolean;
  21141. /**
  21142. * Stores the value for side orientation
  21143. */
  21144. sideOrientation: number;
  21145. /**
  21146. * Callback triggered when the material is compiled
  21147. */
  21148. onCompiled: Nullable<(effect: Effect) => void>;
  21149. /**
  21150. * Callback triggered when an error occurs
  21151. */
  21152. onError: Nullable<(effect: Effect, errors: string) => void>;
  21153. /**
  21154. * Callback triggered to get the render target textures
  21155. */
  21156. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21157. /**
  21158. * Gets a boolean indicating that current material needs to register RTT
  21159. */
  21160. readonly hasRenderTargetTextures: boolean;
  21161. /**
  21162. * Specifies if the material should be serialized
  21163. */
  21164. doNotSerialize: boolean;
  21165. /**
  21166. * @hidden
  21167. */
  21168. _storeEffectOnSubMeshes: boolean;
  21169. /**
  21170. * Stores the animations for the material
  21171. */
  21172. animations: Nullable<Array<Animation>>;
  21173. /**
  21174. * An event triggered when the material is disposed
  21175. */
  21176. onDisposeObservable: Observable<Material>;
  21177. /**
  21178. * An observer which watches for dispose events
  21179. */
  21180. private _onDisposeObserver;
  21181. private _onUnBindObservable;
  21182. /**
  21183. * Called during a dispose event
  21184. */
  21185. onDispose: () => void;
  21186. private _onBindObservable;
  21187. /**
  21188. * An event triggered when the material is bound
  21189. */
  21190. readonly onBindObservable: Observable<AbstractMesh>;
  21191. /**
  21192. * An observer which watches for bind events
  21193. */
  21194. private _onBindObserver;
  21195. /**
  21196. * Called during a bind event
  21197. */
  21198. onBind: (Mesh: AbstractMesh) => void;
  21199. /**
  21200. * An event triggered when the material is unbound
  21201. */
  21202. readonly onUnBindObservable: Observable<Material>;
  21203. /**
  21204. * Stores the value of the alpha mode
  21205. */
  21206. private _alphaMode;
  21207. /**
  21208. * Sets the value of the alpha mode.
  21209. *
  21210. * | Value | Type | Description |
  21211. * | --- | --- | --- |
  21212. * | 0 | ALPHA_DISABLE | |
  21213. * | 1 | ALPHA_ADD | |
  21214. * | 2 | ALPHA_COMBINE | |
  21215. * | 3 | ALPHA_SUBTRACT | |
  21216. * | 4 | ALPHA_MULTIPLY | |
  21217. * | 5 | ALPHA_MAXIMIZED | |
  21218. * | 6 | ALPHA_ONEONE | |
  21219. * | 7 | ALPHA_PREMULTIPLIED | |
  21220. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21221. * | 9 | ALPHA_INTERPOLATE | |
  21222. * | 10 | ALPHA_SCREENMODE | |
  21223. *
  21224. */
  21225. /**
  21226. * Gets the value of the alpha mode
  21227. */
  21228. alphaMode: number;
  21229. /**
  21230. * Stores the state of the need depth pre-pass value
  21231. */
  21232. private _needDepthPrePass;
  21233. /**
  21234. * Sets the need depth pre-pass value
  21235. */
  21236. /**
  21237. * Gets the depth pre-pass value
  21238. */
  21239. needDepthPrePass: boolean;
  21240. /**
  21241. * Specifies if depth writing should be disabled
  21242. */
  21243. disableDepthWrite: boolean;
  21244. /**
  21245. * Specifies if depth writing should be forced
  21246. */
  21247. forceDepthWrite: boolean;
  21248. /**
  21249. * Specifies the depth function that should be used. 0 means the default engine function
  21250. */
  21251. depthFunction: number;
  21252. /**
  21253. * Specifies if there should be a separate pass for culling
  21254. */
  21255. separateCullingPass: boolean;
  21256. /**
  21257. * Stores the state specifing if fog should be enabled
  21258. */
  21259. private _fogEnabled;
  21260. /**
  21261. * Sets the state for enabling fog
  21262. */
  21263. /**
  21264. * Gets the value of the fog enabled state
  21265. */
  21266. fogEnabled: boolean;
  21267. /**
  21268. * Stores the size of points
  21269. */
  21270. pointSize: number;
  21271. /**
  21272. * Stores the z offset value
  21273. */
  21274. zOffset: number;
  21275. /**
  21276. * Gets a value specifying if wireframe mode is enabled
  21277. */
  21278. /**
  21279. * Sets the state of wireframe mode
  21280. */
  21281. wireframe: boolean;
  21282. /**
  21283. * Gets the value specifying if point clouds are enabled
  21284. */
  21285. /**
  21286. * Sets the state of point cloud mode
  21287. */
  21288. pointsCloud: boolean;
  21289. /**
  21290. * Gets the material fill mode
  21291. */
  21292. /**
  21293. * Sets the material fill mode
  21294. */
  21295. fillMode: number;
  21296. /**
  21297. * @hidden
  21298. * Stores the effects for the material
  21299. */
  21300. _effect: Nullable<Effect>;
  21301. /**
  21302. * @hidden
  21303. * Specifies if the material was previously ready
  21304. */
  21305. _wasPreviouslyReady: boolean;
  21306. /**
  21307. * Specifies if uniform buffers should be used
  21308. */
  21309. private _useUBO;
  21310. /**
  21311. * Stores a reference to the scene
  21312. */
  21313. private _scene;
  21314. /**
  21315. * Stores the fill mode state
  21316. */
  21317. private _fillMode;
  21318. /**
  21319. * Specifies if the depth write state should be cached
  21320. */
  21321. private _cachedDepthWriteState;
  21322. /**
  21323. * Specifies if the depth function state should be cached
  21324. */
  21325. private _cachedDepthFunctionState;
  21326. /**
  21327. * Stores the uniform buffer
  21328. */
  21329. protected _uniformBuffer: UniformBuffer;
  21330. /** @hidden */
  21331. _indexInSceneMaterialArray: number;
  21332. /** @hidden */
  21333. meshMap: Nullable<{
  21334. [id: string]: AbstractMesh | undefined;
  21335. }>;
  21336. /**
  21337. * Creates a material instance
  21338. * @param name defines the name of the material
  21339. * @param scene defines the scene to reference
  21340. * @param doNotAdd specifies if the material should be added to the scene
  21341. */
  21342. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21343. /**
  21344. * Returns a string representation of the current material
  21345. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21346. * @returns a string with material information
  21347. */
  21348. toString(fullDetails?: boolean): string;
  21349. /**
  21350. * Gets the class name of the material
  21351. * @returns a string with the class name of the material
  21352. */
  21353. getClassName(): string;
  21354. /**
  21355. * Specifies if updates for the material been locked
  21356. */
  21357. readonly isFrozen: boolean;
  21358. /**
  21359. * Locks updates for the material
  21360. */
  21361. freeze(): void;
  21362. /**
  21363. * Unlocks updates for the material
  21364. */
  21365. unfreeze(): void;
  21366. /**
  21367. * Specifies if the material is ready to be used
  21368. * @param mesh defines the mesh to check
  21369. * @param useInstances specifies if instances should be used
  21370. * @returns a boolean indicating if the material is ready to be used
  21371. */
  21372. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21373. /**
  21374. * Specifies that the submesh is ready to be used
  21375. * @param mesh defines the mesh to check
  21376. * @param subMesh defines which submesh to check
  21377. * @param useInstances specifies that instances should be used
  21378. * @returns a boolean indicating that the submesh is ready or not
  21379. */
  21380. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21381. /**
  21382. * Returns the material effect
  21383. * @returns the effect associated with the material
  21384. */
  21385. getEffect(): Nullable<Effect>;
  21386. /**
  21387. * Returns the current scene
  21388. * @returns a Scene
  21389. */
  21390. getScene(): Scene;
  21391. /**
  21392. * Specifies if the material will require alpha blending
  21393. * @returns a boolean specifying if alpha blending is needed
  21394. */
  21395. needAlphaBlending(): boolean;
  21396. /**
  21397. * Specifies if the mesh will require alpha blending
  21398. * @param mesh defines the mesh to check
  21399. * @returns a boolean specifying if alpha blending is needed for the mesh
  21400. */
  21401. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21402. /**
  21403. * Specifies if this material should be rendered in alpha test mode
  21404. * @returns a boolean specifying if an alpha test is needed.
  21405. */
  21406. needAlphaTesting(): boolean;
  21407. /**
  21408. * Gets the texture used for the alpha test
  21409. * @returns the texture to use for alpha testing
  21410. */
  21411. getAlphaTestTexture(): Nullable<BaseTexture>;
  21412. /**
  21413. * Marks the material to indicate that it needs to be re-calculated
  21414. */
  21415. markDirty(): void;
  21416. /** @hidden */
  21417. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21418. /**
  21419. * Binds the material to the mesh
  21420. * @param world defines the world transformation matrix
  21421. * @param mesh defines the mesh to bind the material to
  21422. */
  21423. bind(world: Matrix, mesh?: Mesh): void;
  21424. /**
  21425. * Binds the submesh to the material
  21426. * @param world defines the world transformation matrix
  21427. * @param mesh defines the mesh containing the submesh
  21428. * @param subMesh defines the submesh to bind the material to
  21429. */
  21430. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21431. /**
  21432. * Binds the world matrix to the material
  21433. * @param world defines the world transformation matrix
  21434. */
  21435. bindOnlyWorldMatrix(world: Matrix): void;
  21436. /**
  21437. * Binds the scene's uniform buffer to the effect.
  21438. * @param effect defines the effect to bind to the scene uniform buffer
  21439. * @param sceneUbo defines the uniform buffer storing scene data
  21440. */
  21441. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21442. /**
  21443. * Binds the view matrix to the effect
  21444. * @param effect defines the effect to bind the view matrix to
  21445. */
  21446. bindView(effect: Effect): void;
  21447. /**
  21448. * Binds the view projection matrix to the effect
  21449. * @param effect defines the effect to bind the view projection matrix to
  21450. */
  21451. bindViewProjection(effect: Effect): void;
  21452. /**
  21453. * Specifies if material alpha testing should be turned on for the mesh
  21454. * @param mesh defines the mesh to check
  21455. */
  21456. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21457. /**
  21458. * Processes to execute after binding the material to a mesh
  21459. * @param mesh defines the rendered mesh
  21460. */
  21461. protected _afterBind(mesh?: Mesh): void;
  21462. /**
  21463. * Unbinds the material from the mesh
  21464. */
  21465. unbind(): void;
  21466. /**
  21467. * Gets the active textures from the material
  21468. * @returns an array of textures
  21469. */
  21470. getActiveTextures(): BaseTexture[];
  21471. /**
  21472. * Specifies if the material uses a texture
  21473. * @param texture defines the texture to check against the material
  21474. * @returns a boolean specifying if the material uses the texture
  21475. */
  21476. hasTexture(texture: BaseTexture): boolean;
  21477. /**
  21478. * Makes a duplicate of the material, and gives it a new name
  21479. * @param name defines the new name for the duplicated material
  21480. * @returns the cloned material
  21481. */
  21482. clone(name: string): Nullable<Material>;
  21483. /**
  21484. * Gets the meshes bound to the material
  21485. * @returns an array of meshes bound to the material
  21486. */
  21487. getBindedMeshes(): AbstractMesh[];
  21488. /**
  21489. * Force shader compilation
  21490. * @param mesh defines the mesh associated with this material
  21491. * @param onCompiled defines a function to execute once the material is compiled
  21492. * @param options defines the options to configure the compilation
  21493. * @param onError defines a function to execute if the material fails compiling
  21494. */
  21495. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21496. /**
  21497. * Force shader compilation
  21498. * @param mesh defines the mesh that will use this material
  21499. * @param options defines additional options for compiling the shaders
  21500. * @returns a promise that resolves when the compilation completes
  21501. */
  21502. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21503. private static readonly _AllDirtyCallBack;
  21504. private static readonly _ImageProcessingDirtyCallBack;
  21505. private static readonly _TextureDirtyCallBack;
  21506. private static readonly _FresnelDirtyCallBack;
  21507. private static readonly _MiscDirtyCallBack;
  21508. private static readonly _LightsDirtyCallBack;
  21509. private static readonly _AttributeDirtyCallBack;
  21510. private static _FresnelAndMiscDirtyCallBack;
  21511. private static _TextureAndMiscDirtyCallBack;
  21512. private static readonly _DirtyCallbackArray;
  21513. private static readonly _RunDirtyCallBacks;
  21514. /**
  21515. * Marks a define in the material to indicate that it needs to be re-computed
  21516. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21517. */
  21518. markAsDirty(flag: number): void;
  21519. /**
  21520. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21521. * @param func defines a function which checks material defines against the submeshes
  21522. */
  21523. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21524. /**
  21525. * Indicates that we need to re-calculated for all submeshes
  21526. */
  21527. protected _markAllSubMeshesAsAllDirty(): void;
  21528. /**
  21529. * Indicates that image processing needs to be re-calculated for all submeshes
  21530. */
  21531. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21532. /**
  21533. * Indicates that textures need to be re-calculated for all submeshes
  21534. */
  21535. protected _markAllSubMeshesAsTexturesDirty(): void;
  21536. /**
  21537. * Indicates that fresnel needs to be re-calculated for all submeshes
  21538. */
  21539. protected _markAllSubMeshesAsFresnelDirty(): void;
  21540. /**
  21541. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21542. */
  21543. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21544. /**
  21545. * Indicates that lights need to be re-calculated for all submeshes
  21546. */
  21547. protected _markAllSubMeshesAsLightsDirty(): void;
  21548. /**
  21549. * Indicates that attributes need to be re-calculated for all submeshes
  21550. */
  21551. protected _markAllSubMeshesAsAttributesDirty(): void;
  21552. /**
  21553. * Indicates that misc needs to be re-calculated for all submeshes
  21554. */
  21555. protected _markAllSubMeshesAsMiscDirty(): void;
  21556. /**
  21557. * Indicates that textures and misc need to be re-calculated for all submeshes
  21558. */
  21559. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21560. /**
  21561. * Disposes the material
  21562. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21563. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21564. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21565. */
  21566. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21567. /** @hidden */
  21568. private releaseVertexArrayObject;
  21569. /**
  21570. * Serializes this material
  21571. * @returns the serialized material object
  21572. */
  21573. serialize(): any;
  21574. /**
  21575. * Creates a material from parsed material data
  21576. * @param parsedMaterial defines parsed material data
  21577. * @param scene defines the hosting scene
  21578. * @param rootUrl defines the root URL to use to load textures
  21579. * @returns a new material
  21580. */
  21581. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21582. }
  21583. }
  21584. declare module "babylonjs/Materials/multiMaterial" {
  21585. import { Nullable } from "babylonjs/types";
  21586. import { Scene } from "babylonjs/scene";
  21587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21588. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21590. import { Material } from "babylonjs/Materials/material";
  21591. /**
  21592. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21593. * separate meshes. This can be use to improve performances.
  21594. * @see http://doc.babylonjs.com/how_to/multi_materials
  21595. */
  21596. export class MultiMaterial extends Material {
  21597. private _subMaterials;
  21598. /**
  21599. * Gets or Sets the list of Materials used within the multi material.
  21600. * They need to be ordered according to the submeshes order in the associated mesh
  21601. */
  21602. subMaterials: Nullable<Material>[];
  21603. /**
  21604. * Function used to align with Node.getChildren()
  21605. * @returns the list of Materials used within the multi material
  21606. */
  21607. getChildren(): Nullable<Material>[];
  21608. /**
  21609. * Instantiates a new Multi Material
  21610. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21611. * separate meshes. This can be use to improve performances.
  21612. * @see http://doc.babylonjs.com/how_to/multi_materials
  21613. * @param name Define the name in the scene
  21614. * @param scene Define the scene the material belongs to
  21615. */
  21616. constructor(name: string, scene: Scene);
  21617. private _hookArray;
  21618. /**
  21619. * Get one of the submaterial by its index in the submaterials array
  21620. * @param index The index to look the sub material at
  21621. * @returns The Material if the index has been defined
  21622. */
  21623. getSubMaterial(index: number): Nullable<Material>;
  21624. /**
  21625. * Get the list of active textures for the whole sub materials list.
  21626. * @returns All the textures that will be used during the rendering
  21627. */
  21628. getActiveTextures(): BaseTexture[];
  21629. /**
  21630. * Gets the current class name of the material e.g. "MultiMaterial"
  21631. * Mainly use in serialization.
  21632. * @returns the class name
  21633. */
  21634. getClassName(): string;
  21635. /**
  21636. * Checks if the material is ready to render the requested sub mesh
  21637. * @param mesh Define the mesh the submesh belongs to
  21638. * @param subMesh Define the sub mesh to look readyness for
  21639. * @param useInstances Define whether or not the material is used with instances
  21640. * @returns true if ready, otherwise false
  21641. */
  21642. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21643. /**
  21644. * Clones the current material and its related sub materials
  21645. * @param name Define the name of the newly cloned material
  21646. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21647. * @returns the cloned material
  21648. */
  21649. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21650. /**
  21651. * Serializes the materials into a JSON representation.
  21652. * @returns the JSON representation
  21653. */
  21654. serialize(): any;
  21655. /**
  21656. * Dispose the material and release its associated resources
  21657. * @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)
  21658. * @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)
  21659. * @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)
  21660. */
  21661. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21662. /**
  21663. * Creates a MultiMaterial from parsed MultiMaterial data.
  21664. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21665. * @param scene defines the hosting scene
  21666. * @returns a new MultiMaterial
  21667. */
  21668. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21669. }
  21670. }
  21671. declare module "babylonjs/Meshes/subMesh" {
  21672. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21673. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21674. import { Engine } from "babylonjs/Engines/engine";
  21675. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21676. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21677. import { Effect } from "babylonjs/Materials/effect";
  21678. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21679. import { Plane } from "babylonjs/Maths/math.plane";
  21680. import { Collider } from "babylonjs/Collisions/collider";
  21681. import { Material } from "babylonjs/Materials/material";
  21682. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21684. import { Mesh } from "babylonjs/Meshes/mesh";
  21685. import { Ray } from "babylonjs/Culling/ray";
  21686. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21687. /**
  21688. * Base class for submeshes
  21689. */
  21690. export class BaseSubMesh {
  21691. /** @hidden */
  21692. _materialDefines: Nullable<MaterialDefines>;
  21693. /** @hidden */
  21694. _materialEffect: Nullable<Effect>;
  21695. /**
  21696. * Gets material defines used by the effect associated to the sub mesh
  21697. */
  21698. /**
  21699. * Sets material defines used by the effect associated to the sub mesh
  21700. */
  21701. materialDefines: Nullable<MaterialDefines>;
  21702. /**
  21703. * Gets associated effect
  21704. */
  21705. readonly effect: Nullable<Effect>;
  21706. /**
  21707. * Sets associated effect (effect used to render this submesh)
  21708. * @param effect defines the effect to associate with
  21709. * @param defines defines the set of defines used to compile this effect
  21710. */
  21711. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21712. }
  21713. /**
  21714. * Defines a subdivision inside a mesh
  21715. */
  21716. export class SubMesh extends BaseSubMesh implements ICullable {
  21717. /** the material index to use */
  21718. materialIndex: number;
  21719. /** vertex index start */
  21720. verticesStart: number;
  21721. /** vertices count */
  21722. verticesCount: number;
  21723. /** index start */
  21724. indexStart: number;
  21725. /** indices count */
  21726. indexCount: number;
  21727. /** @hidden */
  21728. _linesIndexCount: number;
  21729. private _mesh;
  21730. private _renderingMesh;
  21731. private _boundingInfo;
  21732. private _linesIndexBuffer;
  21733. /** @hidden */
  21734. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21735. /** @hidden */
  21736. _trianglePlanes: Plane[];
  21737. /** @hidden */
  21738. _lastColliderTransformMatrix: Nullable<Matrix>;
  21739. /** @hidden */
  21740. _renderId: number;
  21741. /** @hidden */
  21742. _alphaIndex: number;
  21743. /** @hidden */
  21744. _distanceToCamera: number;
  21745. /** @hidden */
  21746. _id: number;
  21747. private _currentMaterial;
  21748. /**
  21749. * Add a new submesh to a mesh
  21750. * @param materialIndex defines the material index to use
  21751. * @param verticesStart defines vertex index start
  21752. * @param verticesCount defines vertices count
  21753. * @param indexStart defines index start
  21754. * @param indexCount defines indices count
  21755. * @param mesh defines the parent mesh
  21756. * @param renderingMesh defines an optional rendering mesh
  21757. * @param createBoundingBox defines if bounding box should be created for this submesh
  21758. * @returns the new submesh
  21759. */
  21760. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21761. /**
  21762. * Creates a new submesh
  21763. * @param materialIndex defines the material index to use
  21764. * @param verticesStart defines vertex index start
  21765. * @param verticesCount defines vertices count
  21766. * @param indexStart defines index start
  21767. * @param indexCount defines indices count
  21768. * @param mesh defines the parent mesh
  21769. * @param renderingMesh defines an optional rendering mesh
  21770. * @param createBoundingBox defines if bounding box should be created for this submesh
  21771. */
  21772. constructor(
  21773. /** the material index to use */
  21774. materialIndex: number,
  21775. /** vertex index start */
  21776. verticesStart: number,
  21777. /** vertices count */
  21778. verticesCount: number,
  21779. /** index start */
  21780. indexStart: number,
  21781. /** indices count */
  21782. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21783. /**
  21784. * Returns true if this submesh covers the entire parent mesh
  21785. * @ignorenaming
  21786. */
  21787. readonly IsGlobal: boolean;
  21788. /**
  21789. * Returns the submesh BoudingInfo object
  21790. * @returns current bounding info (or mesh's one if the submesh is global)
  21791. */
  21792. getBoundingInfo(): BoundingInfo;
  21793. /**
  21794. * Sets the submesh BoundingInfo
  21795. * @param boundingInfo defines the new bounding info to use
  21796. * @returns the SubMesh
  21797. */
  21798. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21799. /**
  21800. * Returns the mesh of the current submesh
  21801. * @return the parent mesh
  21802. */
  21803. getMesh(): AbstractMesh;
  21804. /**
  21805. * Returns the rendering mesh of the submesh
  21806. * @returns the rendering mesh (could be different from parent mesh)
  21807. */
  21808. getRenderingMesh(): Mesh;
  21809. /**
  21810. * Returns the submesh material
  21811. * @returns null or the current material
  21812. */
  21813. getMaterial(): Nullable<Material>;
  21814. /**
  21815. * Sets a new updated BoundingInfo object to the submesh
  21816. * @param data defines an optional position array to use to determine the bounding info
  21817. * @returns the SubMesh
  21818. */
  21819. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21820. /** @hidden */
  21821. _checkCollision(collider: Collider): boolean;
  21822. /**
  21823. * Updates the submesh BoundingInfo
  21824. * @param world defines the world matrix to use to update the bounding info
  21825. * @returns the submesh
  21826. */
  21827. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21828. /**
  21829. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21830. * @param frustumPlanes defines the frustum planes
  21831. * @returns true if the submesh is intersecting with the frustum
  21832. */
  21833. isInFrustum(frustumPlanes: Plane[]): boolean;
  21834. /**
  21835. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21836. * @param frustumPlanes defines the frustum planes
  21837. * @returns true if the submesh is inside the frustum
  21838. */
  21839. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21840. /**
  21841. * Renders the submesh
  21842. * @param enableAlphaMode defines if alpha needs to be used
  21843. * @returns the submesh
  21844. */
  21845. render(enableAlphaMode: boolean): SubMesh;
  21846. /**
  21847. * @hidden
  21848. */
  21849. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21850. /**
  21851. * Checks if the submesh intersects with a ray
  21852. * @param ray defines the ray to test
  21853. * @returns true is the passed ray intersects the submesh bounding box
  21854. */
  21855. canIntersects(ray: Ray): boolean;
  21856. /**
  21857. * Intersects current submesh with a ray
  21858. * @param ray defines the ray to test
  21859. * @param positions defines mesh's positions array
  21860. * @param indices defines mesh's indices array
  21861. * @param fastCheck defines if only bounding info should be used
  21862. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21863. * @returns intersection info or null if no intersection
  21864. */
  21865. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21866. /** @hidden */
  21867. private _intersectLines;
  21868. /** @hidden */
  21869. private _intersectUnIndexedLines;
  21870. /** @hidden */
  21871. private _intersectTriangles;
  21872. /** @hidden */
  21873. private _intersectUnIndexedTriangles;
  21874. /** @hidden */
  21875. _rebuild(): void;
  21876. /**
  21877. * Creates a new submesh from the passed mesh
  21878. * @param newMesh defines the new hosting mesh
  21879. * @param newRenderingMesh defines an optional rendering mesh
  21880. * @returns the new submesh
  21881. */
  21882. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21883. /**
  21884. * Release associated resources
  21885. */
  21886. dispose(): void;
  21887. /**
  21888. * Gets the class name
  21889. * @returns the string "SubMesh".
  21890. */
  21891. getClassName(): string;
  21892. /**
  21893. * Creates a new submesh from indices data
  21894. * @param materialIndex the index of the main mesh material
  21895. * @param startIndex the index where to start the copy in the mesh indices array
  21896. * @param indexCount the number of indices to copy then from the startIndex
  21897. * @param mesh the main mesh to create the submesh from
  21898. * @param renderingMesh the optional rendering mesh
  21899. * @returns a new submesh
  21900. */
  21901. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21902. }
  21903. }
  21904. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21905. /**
  21906. * Class used to represent data loading progression
  21907. */
  21908. export class SceneLoaderFlags {
  21909. private static _ForceFullSceneLoadingForIncremental;
  21910. private static _ShowLoadingScreen;
  21911. private static _CleanBoneMatrixWeights;
  21912. private static _loggingLevel;
  21913. /**
  21914. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21915. */
  21916. static ForceFullSceneLoadingForIncremental: boolean;
  21917. /**
  21918. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21919. */
  21920. static ShowLoadingScreen: boolean;
  21921. /**
  21922. * Defines the current logging level (while loading the scene)
  21923. * @ignorenaming
  21924. */
  21925. static loggingLevel: number;
  21926. /**
  21927. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21928. */
  21929. static CleanBoneMatrixWeights: boolean;
  21930. }
  21931. }
  21932. declare module "babylonjs/Meshes/geometry" {
  21933. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21934. import { Scene } from "babylonjs/scene";
  21935. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21936. import { Engine } from "babylonjs/Engines/engine";
  21937. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21938. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21939. import { Effect } from "babylonjs/Materials/effect";
  21940. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21941. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21942. import { Mesh } from "babylonjs/Meshes/mesh";
  21943. /**
  21944. * Class used to store geometry data (vertex buffers + index buffer)
  21945. */
  21946. export class Geometry implements IGetSetVerticesData {
  21947. /**
  21948. * Gets or sets the ID of the geometry
  21949. */
  21950. id: string;
  21951. /**
  21952. * Gets or sets the unique ID of the geometry
  21953. */
  21954. uniqueId: number;
  21955. /**
  21956. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21957. */
  21958. delayLoadState: number;
  21959. /**
  21960. * Gets the file containing the data to load when running in delay load state
  21961. */
  21962. delayLoadingFile: Nullable<string>;
  21963. /**
  21964. * Callback called when the geometry is updated
  21965. */
  21966. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21967. private _scene;
  21968. private _engine;
  21969. private _meshes;
  21970. private _totalVertices;
  21971. /** @hidden */
  21972. _indices: IndicesArray;
  21973. /** @hidden */
  21974. _vertexBuffers: {
  21975. [key: string]: VertexBuffer;
  21976. };
  21977. private _isDisposed;
  21978. private _extend;
  21979. private _boundingBias;
  21980. /** @hidden */
  21981. _delayInfo: Array<string>;
  21982. private _indexBuffer;
  21983. private _indexBufferIsUpdatable;
  21984. /** @hidden */
  21985. _boundingInfo: Nullable<BoundingInfo>;
  21986. /** @hidden */
  21987. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21988. /** @hidden */
  21989. _softwareSkinningFrameId: number;
  21990. private _vertexArrayObjects;
  21991. private _updatable;
  21992. /** @hidden */
  21993. _positions: Nullable<Vector3[]>;
  21994. /**
  21995. * 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
  21996. */
  21997. /**
  21998. * 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
  21999. */
  22000. boundingBias: Vector2;
  22001. /**
  22002. * Static function used to attach a new empty geometry to a mesh
  22003. * @param mesh defines the mesh to attach the geometry to
  22004. * @returns the new Geometry
  22005. */
  22006. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22007. /**
  22008. * Creates a new geometry
  22009. * @param id defines the unique ID
  22010. * @param scene defines the hosting scene
  22011. * @param vertexData defines the VertexData used to get geometry data
  22012. * @param updatable defines if geometry must be updatable (false by default)
  22013. * @param mesh defines the mesh that will be associated with the geometry
  22014. */
  22015. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22016. /**
  22017. * Gets the current extend of the geometry
  22018. */
  22019. readonly extend: {
  22020. minimum: Vector3;
  22021. maximum: Vector3;
  22022. };
  22023. /**
  22024. * Gets the hosting scene
  22025. * @returns the hosting Scene
  22026. */
  22027. getScene(): Scene;
  22028. /**
  22029. * Gets the hosting engine
  22030. * @returns the hosting Engine
  22031. */
  22032. getEngine(): Engine;
  22033. /**
  22034. * Defines if the geometry is ready to use
  22035. * @returns true if the geometry is ready to be used
  22036. */
  22037. isReady(): boolean;
  22038. /**
  22039. * Gets a value indicating that the geometry should not be serialized
  22040. */
  22041. readonly doNotSerialize: boolean;
  22042. /** @hidden */
  22043. _rebuild(): void;
  22044. /**
  22045. * Affects all geometry data in one call
  22046. * @param vertexData defines the geometry data
  22047. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22048. */
  22049. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22050. /**
  22051. * Set specific vertex data
  22052. * @param kind defines the data kind (Position, normal, etc...)
  22053. * @param data defines the vertex data to use
  22054. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22055. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22056. */
  22057. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22058. /**
  22059. * Removes a specific vertex data
  22060. * @param kind defines the data kind (Position, normal, etc...)
  22061. */
  22062. removeVerticesData(kind: string): void;
  22063. /**
  22064. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22065. * @param buffer defines the vertex buffer to use
  22066. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22067. */
  22068. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22069. /**
  22070. * Update a specific vertex buffer
  22071. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22072. * It will do nothing if the buffer is not updatable
  22073. * @param kind defines the data kind (Position, normal, etc...)
  22074. * @param data defines the data to use
  22075. * @param offset defines the offset in the target buffer where to store the data
  22076. * @param useBytes set to true if the offset is in bytes
  22077. */
  22078. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22079. /**
  22080. * Update a specific vertex buffer
  22081. * This function will create a new buffer if the current one is not updatable
  22082. * @param kind defines the data kind (Position, normal, etc...)
  22083. * @param data defines the data to use
  22084. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22085. */
  22086. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22087. private _updateBoundingInfo;
  22088. /** @hidden */
  22089. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22090. /**
  22091. * Gets total number of vertices
  22092. * @returns the total number of vertices
  22093. */
  22094. getTotalVertices(): number;
  22095. /**
  22096. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22097. * @param kind defines the data kind (Position, normal, etc...)
  22098. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22099. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22100. * @returns a float array containing vertex data
  22101. */
  22102. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22103. /**
  22104. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22105. * @param kind defines the data kind (Position, normal, etc...)
  22106. * @returns true if the vertex buffer with the specified kind is updatable
  22107. */
  22108. isVertexBufferUpdatable(kind: string): boolean;
  22109. /**
  22110. * Gets a specific vertex buffer
  22111. * @param kind defines the data kind (Position, normal, etc...)
  22112. * @returns a VertexBuffer
  22113. */
  22114. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22115. /**
  22116. * Returns all vertex buffers
  22117. * @return an object holding all vertex buffers indexed by kind
  22118. */
  22119. getVertexBuffers(): Nullable<{
  22120. [key: string]: VertexBuffer;
  22121. }>;
  22122. /**
  22123. * Gets a boolean indicating if specific vertex buffer is present
  22124. * @param kind defines the data kind (Position, normal, etc...)
  22125. * @returns true if data is present
  22126. */
  22127. isVerticesDataPresent(kind: string): boolean;
  22128. /**
  22129. * Gets a list of all attached data kinds (Position, normal, etc...)
  22130. * @returns a list of string containing all kinds
  22131. */
  22132. getVerticesDataKinds(): string[];
  22133. /**
  22134. * Update index buffer
  22135. * @param indices defines the indices to store in the index buffer
  22136. * @param offset defines the offset in the target buffer where to store the data
  22137. * @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)
  22138. */
  22139. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22140. /**
  22141. * Creates a new index buffer
  22142. * @param indices defines the indices to store in the index buffer
  22143. * @param totalVertices defines the total number of vertices (could be null)
  22144. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22145. */
  22146. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22147. /**
  22148. * Return the total number of indices
  22149. * @returns the total number of indices
  22150. */
  22151. getTotalIndices(): number;
  22152. /**
  22153. * Gets the index buffer array
  22154. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22155. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22156. * @returns the index buffer array
  22157. */
  22158. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22159. /**
  22160. * Gets the index buffer
  22161. * @return the index buffer
  22162. */
  22163. getIndexBuffer(): Nullable<DataBuffer>;
  22164. /** @hidden */
  22165. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22166. /**
  22167. * Release the associated resources for a specific mesh
  22168. * @param mesh defines the source mesh
  22169. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22170. */
  22171. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22172. /**
  22173. * Apply current geometry to a given mesh
  22174. * @param mesh defines the mesh to apply geometry to
  22175. */
  22176. applyToMesh(mesh: Mesh): void;
  22177. private _updateExtend;
  22178. private _applyToMesh;
  22179. private notifyUpdate;
  22180. /**
  22181. * Load the geometry if it was flagged as delay loaded
  22182. * @param scene defines the hosting scene
  22183. * @param onLoaded defines a callback called when the geometry is loaded
  22184. */
  22185. load(scene: Scene, onLoaded?: () => void): void;
  22186. private _queueLoad;
  22187. /**
  22188. * Invert the geometry to move from a right handed system to a left handed one.
  22189. */
  22190. toLeftHanded(): void;
  22191. /** @hidden */
  22192. _resetPointsArrayCache(): void;
  22193. /** @hidden */
  22194. _generatePointsArray(): boolean;
  22195. /**
  22196. * Gets a value indicating if the geometry is disposed
  22197. * @returns true if the geometry was disposed
  22198. */
  22199. isDisposed(): boolean;
  22200. private _disposeVertexArrayObjects;
  22201. /**
  22202. * Free all associated resources
  22203. */
  22204. dispose(): void;
  22205. /**
  22206. * Clone the current geometry into a new geometry
  22207. * @param id defines the unique ID of the new geometry
  22208. * @returns a new geometry object
  22209. */
  22210. copy(id: string): Geometry;
  22211. /**
  22212. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22213. * @return a JSON representation of the current geometry data (without the vertices data)
  22214. */
  22215. serialize(): any;
  22216. private toNumberArray;
  22217. /**
  22218. * Serialize all vertices data into a JSON oject
  22219. * @returns a JSON representation of the current geometry data
  22220. */
  22221. serializeVerticeData(): any;
  22222. /**
  22223. * Extracts a clone of a mesh geometry
  22224. * @param mesh defines the source mesh
  22225. * @param id defines the unique ID of the new geometry object
  22226. * @returns the new geometry object
  22227. */
  22228. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22229. /**
  22230. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22231. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22232. * Be aware Math.random() could cause collisions, but:
  22233. * "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"
  22234. * @returns a string containing a new GUID
  22235. */
  22236. static RandomId(): string;
  22237. /** @hidden */
  22238. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22239. private static _CleanMatricesWeights;
  22240. /**
  22241. * Create a new geometry from persisted data (Using .babylon file format)
  22242. * @param parsedVertexData defines the persisted data
  22243. * @param scene defines the hosting scene
  22244. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22245. * @returns the new geometry object
  22246. */
  22247. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22248. }
  22249. }
  22250. declare module "babylonjs/Meshes/mesh.vertexData" {
  22251. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22252. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22253. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22254. import { Geometry } from "babylonjs/Meshes/geometry";
  22255. import { Mesh } from "babylonjs/Meshes/mesh";
  22256. /**
  22257. * Define an interface for all classes that will get and set the data on vertices
  22258. */
  22259. export interface IGetSetVerticesData {
  22260. /**
  22261. * Gets a boolean indicating if specific vertex data is present
  22262. * @param kind defines the vertex data kind to use
  22263. * @returns true is data kind is present
  22264. */
  22265. isVerticesDataPresent(kind: string): boolean;
  22266. /**
  22267. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22268. * @param kind defines the data kind (Position, normal, etc...)
  22269. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22270. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22271. * @returns a float array containing vertex data
  22272. */
  22273. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22274. /**
  22275. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22276. * @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.
  22277. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22278. * @returns the indices array or an empty array if the mesh has no geometry
  22279. */
  22280. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22281. /**
  22282. * Set specific vertex data
  22283. * @param kind defines the data kind (Position, normal, etc...)
  22284. * @param data defines the vertex data to use
  22285. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22286. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22287. */
  22288. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22289. /**
  22290. * Update a specific associated vertex buffer
  22291. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22292. * - VertexBuffer.PositionKind
  22293. * - VertexBuffer.UVKind
  22294. * - VertexBuffer.UV2Kind
  22295. * - VertexBuffer.UV3Kind
  22296. * - VertexBuffer.UV4Kind
  22297. * - VertexBuffer.UV5Kind
  22298. * - VertexBuffer.UV6Kind
  22299. * - VertexBuffer.ColorKind
  22300. * - VertexBuffer.MatricesIndicesKind
  22301. * - VertexBuffer.MatricesIndicesExtraKind
  22302. * - VertexBuffer.MatricesWeightsKind
  22303. * - VertexBuffer.MatricesWeightsExtraKind
  22304. * @param data defines the data source
  22305. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22306. * @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)
  22307. */
  22308. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22309. /**
  22310. * Creates a new index buffer
  22311. * @param indices defines the indices to store in the index buffer
  22312. * @param totalVertices defines the total number of vertices (could be null)
  22313. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22314. */
  22315. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22316. }
  22317. /**
  22318. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22319. */
  22320. export class VertexData {
  22321. /**
  22322. * Mesh side orientation : usually the external or front surface
  22323. */
  22324. static readonly FRONTSIDE: number;
  22325. /**
  22326. * Mesh side orientation : usually the internal or back surface
  22327. */
  22328. static readonly BACKSIDE: number;
  22329. /**
  22330. * Mesh side orientation : both internal and external or front and back surfaces
  22331. */
  22332. static readonly DOUBLESIDE: number;
  22333. /**
  22334. * Mesh side orientation : by default, `FRONTSIDE`
  22335. */
  22336. static readonly DEFAULTSIDE: number;
  22337. /**
  22338. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22339. */
  22340. positions: Nullable<FloatArray>;
  22341. /**
  22342. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22343. */
  22344. normals: Nullable<FloatArray>;
  22345. /**
  22346. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22347. */
  22348. tangents: Nullable<FloatArray>;
  22349. /**
  22350. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22351. */
  22352. uvs: Nullable<FloatArray>;
  22353. /**
  22354. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22355. */
  22356. uvs2: Nullable<FloatArray>;
  22357. /**
  22358. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22359. */
  22360. uvs3: Nullable<FloatArray>;
  22361. /**
  22362. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22363. */
  22364. uvs4: Nullable<FloatArray>;
  22365. /**
  22366. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22367. */
  22368. uvs5: Nullable<FloatArray>;
  22369. /**
  22370. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22371. */
  22372. uvs6: Nullable<FloatArray>;
  22373. /**
  22374. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22375. */
  22376. colors: Nullable<FloatArray>;
  22377. /**
  22378. * 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).
  22379. */
  22380. matricesIndices: Nullable<FloatArray>;
  22381. /**
  22382. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22383. */
  22384. matricesWeights: Nullable<FloatArray>;
  22385. /**
  22386. * An array extending the number of possible indices
  22387. */
  22388. matricesIndicesExtra: Nullable<FloatArray>;
  22389. /**
  22390. * An array extending the number of possible weights when the number of indices is extended
  22391. */
  22392. matricesWeightsExtra: Nullable<FloatArray>;
  22393. /**
  22394. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22395. */
  22396. indices: Nullable<IndicesArray>;
  22397. /**
  22398. * Uses the passed data array to set the set the values for the specified kind of data
  22399. * @param data a linear array of floating numbers
  22400. * @param kind the type of data that is being set, eg positions, colors etc
  22401. */
  22402. set(data: FloatArray, kind: string): void;
  22403. /**
  22404. * Associates the vertexData to the passed Mesh.
  22405. * Sets it as updatable or not (default `false`)
  22406. * @param mesh the mesh the vertexData is applied to
  22407. * @param updatable when used and having the value true allows new data to update the vertexData
  22408. * @returns the VertexData
  22409. */
  22410. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22411. /**
  22412. * Associates the vertexData to the passed Geometry.
  22413. * Sets it as updatable or not (default `false`)
  22414. * @param geometry the geometry the vertexData is applied to
  22415. * @param updatable when used and having the value true allows new data to update the vertexData
  22416. * @returns VertexData
  22417. */
  22418. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22419. /**
  22420. * Updates the associated mesh
  22421. * @param mesh the mesh to be updated
  22422. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22423. * @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
  22424. * @returns VertexData
  22425. */
  22426. updateMesh(mesh: Mesh): VertexData;
  22427. /**
  22428. * Updates the associated geometry
  22429. * @param geometry the geometry to be updated
  22430. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22431. * @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
  22432. * @returns VertexData.
  22433. */
  22434. updateGeometry(geometry: Geometry): VertexData;
  22435. private _applyTo;
  22436. private _update;
  22437. /**
  22438. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22439. * @param matrix the transforming matrix
  22440. * @returns the VertexData
  22441. */
  22442. transform(matrix: Matrix): VertexData;
  22443. /**
  22444. * Merges the passed VertexData into the current one
  22445. * @param other the VertexData to be merged into the current one
  22446. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22447. * @returns the modified VertexData
  22448. */
  22449. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22450. private _mergeElement;
  22451. private _validate;
  22452. /**
  22453. * Serializes the VertexData
  22454. * @returns a serialized object
  22455. */
  22456. serialize(): any;
  22457. /**
  22458. * Extracts the vertexData from a mesh
  22459. * @param mesh the mesh from which to extract the VertexData
  22460. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22461. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22462. * @returns the object VertexData associated to the passed mesh
  22463. */
  22464. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22465. /**
  22466. * Extracts the vertexData from the geometry
  22467. * @param geometry the geometry from which to extract the VertexData
  22468. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22469. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22470. * @returns the object VertexData associated to the passed mesh
  22471. */
  22472. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22473. private static _ExtractFrom;
  22474. /**
  22475. * Creates the VertexData for a Ribbon
  22476. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22477. * * pathArray array of paths, each of which an array of successive Vector3
  22478. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22479. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22480. * * 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
  22481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22482. * * 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)
  22483. * * 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)
  22484. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22485. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22486. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22487. * @returns the VertexData of the ribbon
  22488. */
  22489. static CreateRibbon(options: {
  22490. pathArray: Vector3[][];
  22491. closeArray?: boolean;
  22492. closePath?: boolean;
  22493. offset?: number;
  22494. sideOrientation?: number;
  22495. frontUVs?: Vector4;
  22496. backUVs?: Vector4;
  22497. invertUV?: boolean;
  22498. uvs?: Vector2[];
  22499. colors?: Color4[];
  22500. }): VertexData;
  22501. /**
  22502. * Creates the VertexData for a box
  22503. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22504. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22505. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22506. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22507. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22508. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22509. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22510. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22511. * * 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)
  22512. * * 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)
  22513. * @returns the VertexData of the box
  22514. */
  22515. static CreateBox(options: {
  22516. size?: number;
  22517. width?: number;
  22518. height?: number;
  22519. depth?: number;
  22520. faceUV?: Vector4[];
  22521. faceColors?: Color4[];
  22522. sideOrientation?: number;
  22523. frontUVs?: Vector4;
  22524. backUVs?: Vector4;
  22525. }): VertexData;
  22526. /**
  22527. * Creates the VertexData for a tiled box
  22528. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22529. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22530. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22531. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22532. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22533. * @returns the VertexData of the box
  22534. */
  22535. static CreateTiledBox(options: {
  22536. pattern?: number;
  22537. width?: number;
  22538. height?: number;
  22539. depth?: number;
  22540. tileSize?: number;
  22541. tileWidth?: number;
  22542. tileHeight?: number;
  22543. alignHorizontal?: number;
  22544. alignVertical?: number;
  22545. faceUV?: Vector4[];
  22546. faceColors?: Color4[];
  22547. sideOrientation?: number;
  22548. }): VertexData;
  22549. /**
  22550. * Creates the VertexData for a tiled plane
  22551. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22552. * * pattern a limited pattern arrangement depending on the number
  22553. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22554. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22555. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22557. * * 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)
  22558. * * 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)
  22559. * @returns the VertexData of the tiled plane
  22560. */
  22561. static CreateTiledPlane(options: {
  22562. pattern?: number;
  22563. tileSize?: number;
  22564. tileWidth?: number;
  22565. tileHeight?: number;
  22566. size?: number;
  22567. width?: number;
  22568. height?: number;
  22569. alignHorizontal?: number;
  22570. alignVertical?: number;
  22571. sideOrientation?: number;
  22572. frontUVs?: Vector4;
  22573. backUVs?: Vector4;
  22574. }): VertexData;
  22575. /**
  22576. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22577. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22578. * * segments sets the number of horizontal strips optional, default 32
  22579. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22580. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22581. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22582. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22583. * * 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
  22584. * * 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
  22585. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22586. * * 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)
  22587. * * 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)
  22588. * @returns the VertexData of the ellipsoid
  22589. */
  22590. static CreateSphere(options: {
  22591. segments?: number;
  22592. diameter?: number;
  22593. diameterX?: number;
  22594. diameterY?: number;
  22595. diameterZ?: number;
  22596. arc?: number;
  22597. slice?: number;
  22598. sideOrientation?: number;
  22599. frontUVs?: Vector4;
  22600. backUVs?: Vector4;
  22601. }): VertexData;
  22602. /**
  22603. * Creates the VertexData for a cylinder, cone or prism
  22604. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22605. * * height sets the height (y direction) of the cylinder, optional, default 2
  22606. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22607. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22608. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22609. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22610. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22611. * * 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
  22612. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22613. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22614. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22615. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22616. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22617. * * 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)
  22618. * * 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)
  22619. * @returns the VertexData of the cylinder, cone or prism
  22620. */
  22621. static CreateCylinder(options: {
  22622. height?: number;
  22623. diameterTop?: number;
  22624. diameterBottom?: number;
  22625. diameter?: number;
  22626. tessellation?: number;
  22627. subdivisions?: number;
  22628. arc?: number;
  22629. faceColors?: Color4[];
  22630. faceUV?: Vector4[];
  22631. hasRings?: boolean;
  22632. enclose?: boolean;
  22633. sideOrientation?: number;
  22634. frontUVs?: Vector4;
  22635. backUVs?: Vector4;
  22636. }): VertexData;
  22637. /**
  22638. * Creates the VertexData for a torus
  22639. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22640. * * diameter the diameter of the torus, optional default 1
  22641. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22642. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22643. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22644. * * 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)
  22645. * * 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)
  22646. * @returns the VertexData of the torus
  22647. */
  22648. static CreateTorus(options: {
  22649. diameter?: number;
  22650. thickness?: number;
  22651. tessellation?: number;
  22652. sideOrientation?: number;
  22653. frontUVs?: Vector4;
  22654. backUVs?: Vector4;
  22655. }): VertexData;
  22656. /**
  22657. * Creates the VertexData of the LineSystem
  22658. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22659. * - lines an array of lines, each line being an array of successive Vector3
  22660. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22661. * @returns the VertexData of the LineSystem
  22662. */
  22663. static CreateLineSystem(options: {
  22664. lines: Vector3[][];
  22665. colors?: Nullable<Color4[][]>;
  22666. }): VertexData;
  22667. /**
  22668. * Create the VertexData for a DashedLines
  22669. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22670. * - points an array successive Vector3
  22671. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22672. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22673. * - dashNb the intended total number of dashes, optional, default 200
  22674. * @returns the VertexData for the DashedLines
  22675. */
  22676. static CreateDashedLines(options: {
  22677. points: Vector3[];
  22678. dashSize?: number;
  22679. gapSize?: number;
  22680. dashNb?: number;
  22681. }): VertexData;
  22682. /**
  22683. * Creates the VertexData for a Ground
  22684. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22685. * - width the width (x direction) of the ground, optional, default 1
  22686. * - height the height (z direction) of the ground, optional, default 1
  22687. * - subdivisions the number of subdivisions per side, optional, default 1
  22688. * @returns the VertexData of the Ground
  22689. */
  22690. static CreateGround(options: {
  22691. width?: number;
  22692. height?: number;
  22693. subdivisions?: number;
  22694. subdivisionsX?: number;
  22695. subdivisionsY?: number;
  22696. }): VertexData;
  22697. /**
  22698. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22699. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22700. * * xmin the ground minimum X coordinate, optional, default -1
  22701. * * zmin the ground minimum Z coordinate, optional, default -1
  22702. * * xmax the ground maximum X coordinate, optional, default 1
  22703. * * zmax the ground maximum Z coordinate, optional, default 1
  22704. * * 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}
  22705. * * 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}
  22706. * @returns the VertexData of the TiledGround
  22707. */
  22708. static CreateTiledGround(options: {
  22709. xmin: number;
  22710. zmin: number;
  22711. xmax: number;
  22712. zmax: number;
  22713. subdivisions?: {
  22714. w: number;
  22715. h: number;
  22716. };
  22717. precision?: {
  22718. w: number;
  22719. h: number;
  22720. };
  22721. }): VertexData;
  22722. /**
  22723. * Creates the VertexData of the Ground designed from a heightmap
  22724. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22725. * * width the width (x direction) of the ground
  22726. * * height the height (z direction) of the ground
  22727. * * subdivisions the number of subdivisions per side
  22728. * * minHeight the minimum altitude on the ground, optional, default 0
  22729. * * maxHeight the maximum altitude on the ground, optional default 1
  22730. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22731. * * buffer the array holding the image color data
  22732. * * bufferWidth the width of image
  22733. * * bufferHeight the height of image
  22734. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22735. * @returns the VertexData of the Ground designed from a heightmap
  22736. */
  22737. static CreateGroundFromHeightMap(options: {
  22738. width: number;
  22739. height: number;
  22740. subdivisions: number;
  22741. minHeight: number;
  22742. maxHeight: number;
  22743. colorFilter: Color3;
  22744. buffer: Uint8Array;
  22745. bufferWidth: number;
  22746. bufferHeight: number;
  22747. alphaFilter: number;
  22748. }): VertexData;
  22749. /**
  22750. * Creates the VertexData for a Plane
  22751. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22752. * * size sets the width and height of the plane to the value of size, optional default 1
  22753. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22754. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22755. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22756. * * 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)
  22757. * * 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)
  22758. * @returns the VertexData of the box
  22759. */
  22760. static CreatePlane(options: {
  22761. size?: number;
  22762. width?: number;
  22763. height?: number;
  22764. sideOrientation?: number;
  22765. frontUVs?: Vector4;
  22766. backUVs?: Vector4;
  22767. }): VertexData;
  22768. /**
  22769. * Creates the VertexData of the Disc or regular Polygon
  22770. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22771. * * radius the radius of the disc, optional default 0.5
  22772. * * tessellation the number of polygon sides, optional, default 64
  22773. * * 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
  22774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22775. * * 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)
  22776. * * 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)
  22777. * @returns the VertexData of the box
  22778. */
  22779. static CreateDisc(options: {
  22780. radius?: number;
  22781. tessellation?: number;
  22782. arc?: number;
  22783. sideOrientation?: number;
  22784. frontUVs?: Vector4;
  22785. backUVs?: Vector4;
  22786. }): VertexData;
  22787. /**
  22788. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22789. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22790. * @param polygon a mesh built from polygonTriangulation.build()
  22791. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22792. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22793. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22794. * @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)
  22795. * @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)
  22796. * @returns the VertexData of the Polygon
  22797. */
  22798. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22799. /**
  22800. * Creates the VertexData of the IcoSphere
  22801. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22802. * * radius the radius of the IcoSphere, optional default 1
  22803. * * radiusX allows stretching in the x direction, optional, default radius
  22804. * * radiusY allows stretching in the y direction, optional, default radius
  22805. * * radiusZ allows stretching in the z direction, optional, default radius
  22806. * * flat when true creates a flat shaded mesh, optional, default true
  22807. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22808. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22809. * * 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)
  22810. * * 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)
  22811. * @returns the VertexData of the IcoSphere
  22812. */
  22813. static CreateIcoSphere(options: {
  22814. radius?: number;
  22815. radiusX?: number;
  22816. radiusY?: number;
  22817. radiusZ?: number;
  22818. flat?: boolean;
  22819. subdivisions?: number;
  22820. sideOrientation?: number;
  22821. frontUVs?: Vector4;
  22822. backUVs?: Vector4;
  22823. }): VertexData;
  22824. /**
  22825. * Creates the VertexData for a Polyhedron
  22826. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22827. * * type provided types are:
  22828. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22829. * * 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)
  22830. * * size the size of the IcoSphere, optional default 1
  22831. * * sizeX allows stretching in the x direction, optional, default size
  22832. * * sizeY allows stretching in the y direction, optional, default size
  22833. * * sizeZ allows stretching in the z direction, optional, default size
  22834. * * 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
  22835. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22836. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22837. * * flat when true creates a flat shaded mesh, optional, default true
  22838. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22839. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22840. * * 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)
  22841. * * 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)
  22842. * @returns the VertexData of the Polyhedron
  22843. */
  22844. static CreatePolyhedron(options: {
  22845. type?: number;
  22846. size?: number;
  22847. sizeX?: number;
  22848. sizeY?: number;
  22849. sizeZ?: number;
  22850. custom?: any;
  22851. faceUV?: Vector4[];
  22852. faceColors?: Color4[];
  22853. flat?: boolean;
  22854. sideOrientation?: number;
  22855. frontUVs?: Vector4;
  22856. backUVs?: Vector4;
  22857. }): VertexData;
  22858. /**
  22859. * Creates the VertexData for a TorusKnot
  22860. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22861. * * radius the radius of the torus knot, optional, default 2
  22862. * * tube the thickness of the tube, optional, default 0.5
  22863. * * radialSegments the number of sides on each tube segments, optional, default 32
  22864. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22865. * * p the number of windings around the z axis, optional, default 2
  22866. * * q the number of windings around the x axis, optional, default 3
  22867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22868. * * 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)
  22869. * * 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)
  22870. * @returns the VertexData of the Torus Knot
  22871. */
  22872. static CreateTorusKnot(options: {
  22873. radius?: number;
  22874. tube?: number;
  22875. radialSegments?: number;
  22876. tubularSegments?: number;
  22877. p?: number;
  22878. q?: number;
  22879. sideOrientation?: number;
  22880. frontUVs?: Vector4;
  22881. backUVs?: Vector4;
  22882. }): VertexData;
  22883. /**
  22884. * Compute normals for given positions and indices
  22885. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22886. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22887. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22888. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22889. * * facetNormals : optional array of facet normals (vector3)
  22890. * * facetPositions : optional array of facet positions (vector3)
  22891. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22892. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22893. * * bInfo : optional bounding info, required for facetPartitioning computation
  22894. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22895. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22896. * * useRightHandedSystem: optional boolean to for right handed system computation
  22897. * * depthSort : optional boolean to enable the facet depth sort computation
  22898. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22899. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22900. */
  22901. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22902. facetNormals?: any;
  22903. facetPositions?: any;
  22904. facetPartitioning?: any;
  22905. ratio?: number;
  22906. bInfo?: any;
  22907. bbSize?: Vector3;
  22908. subDiv?: any;
  22909. useRightHandedSystem?: boolean;
  22910. depthSort?: boolean;
  22911. distanceTo?: Vector3;
  22912. depthSortedFacets?: any;
  22913. }): void;
  22914. /** @hidden */
  22915. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22916. /**
  22917. * Applies VertexData created from the imported parameters to the geometry
  22918. * @param parsedVertexData the parsed data from an imported file
  22919. * @param geometry the geometry to apply the VertexData to
  22920. */
  22921. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22922. }
  22923. }
  22924. declare module "babylonjs/Morph/morphTarget" {
  22925. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22926. import { Observable } from "babylonjs/Misc/observable";
  22927. import { Nullable, FloatArray } from "babylonjs/types";
  22928. import { Scene } from "babylonjs/scene";
  22929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22930. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22931. /**
  22932. * Defines a target to use with MorphTargetManager
  22933. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22934. */
  22935. export class MorphTarget implements IAnimatable {
  22936. /** defines the name of the target */
  22937. name: string;
  22938. /**
  22939. * Gets or sets the list of animations
  22940. */
  22941. animations: import("babylonjs/Animations/animation").Animation[];
  22942. private _scene;
  22943. private _positions;
  22944. private _normals;
  22945. private _tangents;
  22946. private _uvs;
  22947. private _influence;
  22948. private _uniqueId;
  22949. /**
  22950. * Observable raised when the influence changes
  22951. */
  22952. onInfluenceChanged: Observable<boolean>;
  22953. /** @hidden */
  22954. _onDataLayoutChanged: Observable<void>;
  22955. /**
  22956. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22957. */
  22958. influence: number;
  22959. /**
  22960. * Gets or sets the id of the morph Target
  22961. */
  22962. id: string;
  22963. private _animationPropertiesOverride;
  22964. /**
  22965. * Gets or sets the animation properties override
  22966. */
  22967. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22968. /**
  22969. * Creates a new MorphTarget
  22970. * @param name defines the name of the target
  22971. * @param influence defines the influence to use
  22972. * @param scene defines the scene the morphtarget belongs to
  22973. */
  22974. constructor(
  22975. /** defines the name of the target */
  22976. name: string, influence?: number, scene?: Nullable<Scene>);
  22977. /**
  22978. * Gets the unique ID of this manager
  22979. */
  22980. readonly uniqueId: number;
  22981. /**
  22982. * Gets a boolean defining if the target contains position data
  22983. */
  22984. readonly hasPositions: boolean;
  22985. /**
  22986. * Gets a boolean defining if the target contains normal data
  22987. */
  22988. readonly hasNormals: boolean;
  22989. /**
  22990. * Gets a boolean defining if the target contains tangent data
  22991. */
  22992. readonly hasTangents: boolean;
  22993. /**
  22994. * Gets a boolean defining if the target contains texture coordinates data
  22995. */
  22996. readonly hasUVs: boolean;
  22997. /**
  22998. * Affects position data to this target
  22999. * @param data defines the position data to use
  23000. */
  23001. setPositions(data: Nullable<FloatArray>): void;
  23002. /**
  23003. * Gets the position data stored in this target
  23004. * @returns a FloatArray containing the position data (or null if not present)
  23005. */
  23006. getPositions(): Nullable<FloatArray>;
  23007. /**
  23008. * Affects normal data to this target
  23009. * @param data defines the normal data to use
  23010. */
  23011. setNormals(data: Nullable<FloatArray>): void;
  23012. /**
  23013. * Gets the normal data stored in this target
  23014. * @returns a FloatArray containing the normal data (or null if not present)
  23015. */
  23016. getNormals(): Nullable<FloatArray>;
  23017. /**
  23018. * Affects tangent data to this target
  23019. * @param data defines the tangent data to use
  23020. */
  23021. setTangents(data: Nullable<FloatArray>): void;
  23022. /**
  23023. * Gets the tangent data stored in this target
  23024. * @returns a FloatArray containing the tangent data (or null if not present)
  23025. */
  23026. getTangents(): Nullable<FloatArray>;
  23027. /**
  23028. * Affects texture coordinates data to this target
  23029. * @param data defines the texture coordinates data to use
  23030. */
  23031. setUVs(data: Nullable<FloatArray>): void;
  23032. /**
  23033. * Gets the texture coordinates data stored in this target
  23034. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23035. */
  23036. getUVs(): Nullable<FloatArray>;
  23037. /**
  23038. * Clone the current target
  23039. * @returns a new MorphTarget
  23040. */
  23041. clone(): MorphTarget;
  23042. /**
  23043. * Serializes the current target into a Serialization object
  23044. * @returns the serialized object
  23045. */
  23046. serialize(): any;
  23047. /**
  23048. * Returns the string "MorphTarget"
  23049. * @returns "MorphTarget"
  23050. */
  23051. getClassName(): string;
  23052. /**
  23053. * Creates a new target from serialized data
  23054. * @param serializationObject defines the serialized data to use
  23055. * @returns a new MorphTarget
  23056. */
  23057. static Parse(serializationObject: any): MorphTarget;
  23058. /**
  23059. * Creates a MorphTarget from mesh data
  23060. * @param mesh defines the source mesh
  23061. * @param name defines the name to use for the new target
  23062. * @param influence defines the influence to attach to the target
  23063. * @returns a new MorphTarget
  23064. */
  23065. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23066. }
  23067. }
  23068. declare module "babylonjs/Morph/morphTargetManager" {
  23069. import { Nullable } from "babylonjs/types";
  23070. import { Scene } from "babylonjs/scene";
  23071. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23072. /**
  23073. * This class is used to deform meshes using morphing between different targets
  23074. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23075. */
  23076. export class MorphTargetManager {
  23077. private _targets;
  23078. private _targetInfluenceChangedObservers;
  23079. private _targetDataLayoutChangedObservers;
  23080. private _activeTargets;
  23081. private _scene;
  23082. private _influences;
  23083. private _supportsNormals;
  23084. private _supportsTangents;
  23085. private _supportsUVs;
  23086. private _vertexCount;
  23087. private _uniqueId;
  23088. private _tempInfluences;
  23089. /**
  23090. * Gets or sets a boolean indicating if normals must be morphed
  23091. */
  23092. enableNormalMorphing: boolean;
  23093. /**
  23094. * Gets or sets a boolean indicating if tangents must be morphed
  23095. */
  23096. enableTangentMorphing: boolean;
  23097. /**
  23098. * Gets or sets a boolean indicating if UV must be morphed
  23099. */
  23100. enableUVMorphing: boolean;
  23101. /**
  23102. * Creates a new MorphTargetManager
  23103. * @param scene defines the current scene
  23104. */
  23105. constructor(scene?: Nullable<Scene>);
  23106. /**
  23107. * Gets the unique ID of this manager
  23108. */
  23109. readonly uniqueId: number;
  23110. /**
  23111. * Gets the number of vertices handled by this manager
  23112. */
  23113. readonly vertexCount: number;
  23114. /**
  23115. * Gets a boolean indicating if this manager supports morphing of normals
  23116. */
  23117. readonly supportsNormals: boolean;
  23118. /**
  23119. * Gets a boolean indicating if this manager supports morphing of tangents
  23120. */
  23121. readonly supportsTangents: boolean;
  23122. /**
  23123. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23124. */
  23125. readonly supportsUVs: boolean;
  23126. /**
  23127. * Gets the number of targets stored in this manager
  23128. */
  23129. readonly numTargets: number;
  23130. /**
  23131. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23132. */
  23133. readonly numInfluencers: number;
  23134. /**
  23135. * Gets the list of influences (one per target)
  23136. */
  23137. readonly influences: Float32Array;
  23138. /**
  23139. * Gets the active target at specified index. An active target is a target with an influence > 0
  23140. * @param index defines the index to check
  23141. * @returns the requested target
  23142. */
  23143. getActiveTarget(index: number): MorphTarget;
  23144. /**
  23145. * Gets the target at specified index
  23146. * @param index defines the index to check
  23147. * @returns the requested target
  23148. */
  23149. getTarget(index: number): MorphTarget;
  23150. /**
  23151. * Add a new target to this manager
  23152. * @param target defines the target to add
  23153. */
  23154. addTarget(target: MorphTarget): void;
  23155. /**
  23156. * Removes a target from the manager
  23157. * @param target defines the target to remove
  23158. */
  23159. removeTarget(target: MorphTarget): void;
  23160. /**
  23161. * Clone the current manager
  23162. * @returns a new MorphTargetManager
  23163. */
  23164. clone(): MorphTargetManager;
  23165. /**
  23166. * Serializes the current manager into a Serialization object
  23167. * @returns the serialized object
  23168. */
  23169. serialize(): any;
  23170. private _syncActiveTargets;
  23171. /**
  23172. * Syncrhonize the targets with all the meshes using this morph target manager
  23173. */
  23174. synchronize(): void;
  23175. /**
  23176. * Creates a new MorphTargetManager from serialized data
  23177. * @param serializationObject defines the serialized data
  23178. * @param scene defines the hosting scene
  23179. * @returns the new MorphTargetManager
  23180. */
  23181. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23182. }
  23183. }
  23184. declare module "babylonjs/Meshes/meshLODLevel" {
  23185. import { Mesh } from "babylonjs/Meshes/mesh";
  23186. import { Nullable } from "babylonjs/types";
  23187. /**
  23188. * Class used to represent a specific level of detail of a mesh
  23189. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23190. */
  23191. export class MeshLODLevel {
  23192. /** Defines the distance where this level should start being displayed */
  23193. distance: number;
  23194. /** Defines the mesh to use to render this level */
  23195. mesh: Nullable<Mesh>;
  23196. /**
  23197. * Creates a new LOD level
  23198. * @param distance defines the distance where this level should star being displayed
  23199. * @param mesh defines the mesh to use to render this level
  23200. */
  23201. constructor(
  23202. /** Defines the distance where this level should start being displayed */
  23203. distance: number,
  23204. /** Defines the mesh to use to render this level */
  23205. mesh: Nullable<Mesh>);
  23206. }
  23207. }
  23208. declare module "babylonjs/Meshes/groundMesh" {
  23209. import { Scene } from "babylonjs/scene";
  23210. import { Vector3 } from "babylonjs/Maths/math.vector";
  23211. import { Mesh } from "babylonjs/Meshes/mesh";
  23212. /**
  23213. * Mesh representing the gorund
  23214. */
  23215. export class GroundMesh extends Mesh {
  23216. /** If octree should be generated */
  23217. generateOctree: boolean;
  23218. private _heightQuads;
  23219. /** @hidden */
  23220. _subdivisionsX: number;
  23221. /** @hidden */
  23222. _subdivisionsY: number;
  23223. /** @hidden */
  23224. _width: number;
  23225. /** @hidden */
  23226. _height: number;
  23227. /** @hidden */
  23228. _minX: number;
  23229. /** @hidden */
  23230. _maxX: number;
  23231. /** @hidden */
  23232. _minZ: number;
  23233. /** @hidden */
  23234. _maxZ: number;
  23235. constructor(name: string, scene: Scene);
  23236. /**
  23237. * "GroundMesh"
  23238. * @returns "GroundMesh"
  23239. */
  23240. getClassName(): string;
  23241. /**
  23242. * The minimum of x and y subdivisions
  23243. */
  23244. readonly subdivisions: number;
  23245. /**
  23246. * X subdivisions
  23247. */
  23248. readonly subdivisionsX: number;
  23249. /**
  23250. * Y subdivisions
  23251. */
  23252. readonly subdivisionsY: number;
  23253. /**
  23254. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23255. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23256. * @param chunksCount the number of subdivisions for x and y
  23257. * @param octreeBlocksSize (Default: 32)
  23258. */
  23259. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23260. /**
  23261. * Returns a height (y) value in the Worl system :
  23262. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23263. * @param x x coordinate
  23264. * @param z z coordinate
  23265. * @returns the ground y position if (x, z) are outside the ground surface.
  23266. */
  23267. getHeightAtCoordinates(x: number, z: number): number;
  23268. /**
  23269. * Returns a normalized vector (Vector3) orthogonal to the ground
  23270. * at the ground coordinates (x, z) expressed in the World system.
  23271. * @param x x coordinate
  23272. * @param z z coordinate
  23273. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23274. */
  23275. getNormalAtCoordinates(x: number, z: number): Vector3;
  23276. /**
  23277. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23278. * at the ground coordinates (x, z) expressed in the World system.
  23279. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23280. * @param x x coordinate
  23281. * @param z z coordinate
  23282. * @param ref vector to store the result
  23283. * @returns the GroundMesh.
  23284. */
  23285. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23286. /**
  23287. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23288. * if the ground has been updated.
  23289. * This can be used in the render loop.
  23290. * @returns the GroundMesh.
  23291. */
  23292. updateCoordinateHeights(): GroundMesh;
  23293. private _getFacetAt;
  23294. private _initHeightQuads;
  23295. private _computeHeightQuads;
  23296. /**
  23297. * Serializes this ground mesh
  23298. * @param serializationObject object to write serialization to
  23299. */
  23300. serialize(serializationObject: any): void;
  23301. /**
  23302. * Parses a serialized ground mesh
  23303. * @param parsedMesh the serialized mesh
  23304. * @param scene the scene to create the ground mesh in
  23305. * @returns the created ground mesh
  23306. */
  23307. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23308. }
  23309. }
  23310. declare module "babylonjs/Physics/physicsJoint" {
  23311. import { Vector3 } from "babylonjs/Maths/math.vector";
  23312. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23313. /**
  23314. * Interface for Physics-Joint data
  23315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23316. */
  23317. export interface PhysicsJointData {
  23318. /**
  23319. * The main pivot of the joint
  23320. */
  23321. mainPivot?: Vector3;
  23322. /**
  23323. * The connected pivot of the joint
  23324. */
  23325. connectedPivot?: Vector3;
  23326. /**
  23327. * The main axis of the joint
  23328. */
  23329. mainAxis?: Vector3;
  23330. /**
  23331. * The connected axis of the joint
  23332. */
  23333. connectedAxis?: Vector3;
  23334. /**
  23335. * The collision of the joint
  23336. */
  23337. collision?: boolean;
  23338. /**
  23339. * Native Oimo/Cannon/Energy data
  23340. */
  23341. nativeParams?: any;
  23342. }
  23343. /**
  23344. * This is a holder class for the physics joint created by the physics plugin
  23345. * It holds a set of functions to control the underlying joint
  23346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23347. */
  23348. export class PhysicsJoint {
  23349. /**
  23350. * The type of the physics joint
  23351. */
  23352. type: number;
  23353. /**
  23354. * The data for the physics joint
  23355. */
  23356. jointData: PhysicsJointData;
  23357. private _physicsJoint;
  23358. protected _physicsPlugin: IPhysicsEnginePlugin;
  23359. /**
  23360. * Initializes the physics joint
  23361. * @param type The type of the physics joint
  23362. * @param jointData The data for the physics joint
  23363. */
  23364. constructor(
  23365. /**
  23366. * The type of the physics joint
  23367. */
  23368. type: number,
  23369. /**
  23370. * The data for the physics joint
  23371. */
  23372. jointData: PhysicsJointData);
  23373. /**
  23374. * Gets the physics joint
  23375. */
  23376. /**
  23377. * Sets the physics joint
  23378. */
  23379. physicsJoint: any;
  23380. /**
  23381. * Sets the physics plugin
  23382. */
  23383. physicsPlugin: IPhysicsEnginePlugin;
  23384. /**
  23385. * Execute a function that is physics-plugin specific.
  23386. * @param {Function} func the function that will be executed.
  23387. * It accepts two parameters: the physics world and the physics joint
  23388. */
  23389. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23390. /**
  23391. * Distance-Joint type
  23392. */
  23393. static DistanceJoint: number;
  23394. /**
  23395. * Hinge-Joint type
  23396. */
  23397. static HingeJoint: number;
  23398. /**
  23399. * Ball-and-Socket joint type
  23400. */
  23401. static BallAndSocketJoint: number;
  23402. /**
  23403. * Wheel-Joint type
  23404. */
  23405. static WheelJoint: number;
  23406. /**
  23407. * Slider-Joint type
  23408. */
  23409. static SliderJoint: number;
  23410. /**
  23411. * Prismatic-Joint type
  23412. */
  23413. static PrismaticJoint: number;
  23414. /**
  23415. * Universal-Joint type
  23416. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23417. */
  23418. static UniversalJoint: number;
  23419. /**
  23420. * Hinge-Joint 2 type
  23421. */
  23422. static Hinge2Joint: number;
  23423. /**
  23424. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23425. */
  23426. static PointToPointJoint: number;
  23427. /**
  23428. * Spring-Joint type
  23429. */
  23430. static SpringJoint: number;
  23431. /**
  23432. * Lock-Joint type
  23433. */
  23434. static LockJoint: number;
  23435. }
  23436. /**
  23437. * A class representing a physics distance joint
  23438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23439. */
  23440. export class DistanceJoint extends PhysicsJoint {
  23441. /**
  23442. *
  23443. * @param jointData The data for the Distance-Joint
  23444. */
  23445. constructor(jointData: DistanceJointData);
  23446. /**
  23447. * Update the predefined distance.
  23448. * @param maxDistance The maximum preferred distance
  23449. * @param minDistance The minimum preferred distance
  23450. */
  23451. updateDistance(maxDistance: number, minDistance?: number): void;
  23452. }
  23453. /**
  23454. * Represents a Motor-Enabled Joint
  23455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23456. */
  23457. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23458. /**
  23459. * Initializes the Motor-Enabled Joint
  23460. * @param type The type of the joint
  23461. * @param jointData The physica joint data for the joint
  23462. */
  23463. constructor(type: number, jointData: PhysicsJointData);
  23464. /**
  23465. * Set the motor values.
  23466. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23467. * @param force the force to apply
  23468. * @param maxForce max force for this motor.
  23469. */
  23470. setMotor(force?: number, maxForce?: number): void;
  23471. /**
  23472. * Set the motor's limits.
  23473. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23474. * @param upperLimit The upper limit of the motor
  23475. * @param lowerLimit The lower limit of the motor
  23476. */
  23477. setLimit(upperLimit: number, lowerLimit?: number): void;
  23478. }
  23479. /**
  23480. * This class represents a single physics Hinge-Joint
  23481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23482. */
  23483. export class HingeJoint extends MotorEnabledJoint {
  23484. /**
  23485. * Initializes the Hinge-Joint
  23486. * @param jointData The joint data for the Hinge-Joint
  23487. */
  23488. constructor(jointData: PhysicsJointData);
  23489. /**
  23490. * Set the motor values.
  23491. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23492. * @param {number} force the force to apply
  23493. * @param {number} maxForce max force for this motor.
  23494. */
  23495. setMotor(force?: number, maxForce?: number): void;
  23496. /**
  23497. * Set the motor's limits.
  23498. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23499. * @param upperLimit The upper limit of the motor
  23500. * @param lowerLimit The lower limit of the motor
  23501. */
  23502. setLimit(upperLimit: number, lowerLimit?: number): void;
  23503. }
  23504. /**
  23505. * This class represents a dual hinge physics joint (same as wheel joint)
  23506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23507. */
  23508. export class Hinge2Joint extends MotorEnabledJoint {
  23509. /**
  23510. * Initializes the Hinge2-Joint
  23511. * @param jointData The joint data for the Hinge2-Joint
  23512. */
  23513. constructor(jointData: PhysicsJointData);
  23514. /**
  23515. * Set the motor values.
  23516. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23517. * @param {number} targetSpeed the speed the motor is to reach
  23518. * @param {number} maxForce max force for this motor.
  23519. * @param {motorIndex} the motor's index, 0 or 1.
  23520. */
  23521. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23522. /**
  23523. * Set the motor limits.
  23524. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23525. * @param {number} upperLimit the upper limit
  23526. * @param {number} lowerLimit lower limit
  23527. * @param {motorIndex} the motor's index, 0 or 1.
  23528. */
  23529. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23530. }
  23531. /**
  23532. * Interface for a motor enabled joint
  23533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23534. */
  23535. export interface IMotorEnabledJoint {
  23536. /**
  23537. * Physics joint
  23538. */
  23539. physicsJoint: any;
  23540. /**
  23541. * Sets the motor of the motor-enabled joint
  23542. * @param force The force of the motor
  23543. * @param maxForce The maximum force of the motor
  23544. * @param motorIndex The index of the motor
  23545. */
  23546. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23547. /**
  23548. * Sets the limit of the motor
  23549. * @param upperLimit The upper limit of the motor
  23550. * @param lowerLimit The lower limit of the motor
  23551. * @param motorIndex The index of the motor
  23552. */
  23553. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23554. }
  23555. /**
  23556. * Joint data for a Distance-Joint
  23557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23558. */
  23559. export interface DistanceJointData extends PhysicsJointData {
  23560. /**
  23561. * Max distance the 2 joint objects can be apart
  23562. */
  23563. maxDistance: number;
  23564. }
  23565. /**
  23566. * Joint data from a spring joint
  23567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23568. */
  23569. export interface SpringJointData extends PhysicsJointData {
  23570. /**
  23571. * Length of the spring
  23572. */
  23573. length: number;
  23574. /**
  23575. * Stiffness of the spring
  23576. */
  23577. stiffness: number;
  23578. /**
  23579. * Damping of the spring
  23580. */
  23581. damping: number;
  23582. /** this callback will be called when applying the force to the impostors. */
  23583. forceApplicationCallback: () => void;
  23584. }
  23585. }
  23586. declare module "babylonjs/Physics/physicsRaycastResult" {
  23587. import { Vector3 } from "babylonjs/Maths/math.vector";
  23588. /**
  23589. * Holds the data for the raycast result
  23590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23591. */
  23592. export class PhysicsRaycastResult {
  23593. private _hasHit;
  23594. private _hitDistance;
  23595. private _hitNormalWorld;
  23596. private _hitPointWorld;
  23597. private _rayFromWorld;
  23598. private _rayToWorld;
  23599. /**
  23600. * Gets if there was a hit
  23601. */
  23602. readonly hasHit: boolean;
  23603. /**
  23604. * Gets the distance from the hit
  23605. */
  23606. readonly hitDistance: number;
  23607. /**
  23608. * Gets the hit normal/direction in the world
  23609. */
  23610. readonly hitNormalWorld: Vector3;
  23611. /**
  23612. * Gets the hit point in the world
  23613. */
  23614. readonly hitPointWorld: Vector3;
  23615. /**
  23616. * Gets the ray "start point" of the ray in the world
  23617. */
  23618. readonly rayFromWorld: Vector3;
  23619. /**
  23620. * Gets the ray "end point" of the ray in the world
  23621. */
  23622. readonly rayToWorld: Vector3;
  23623. /**
  23624. * Sets the hit data (normal & point in world space)
  23625. * @param hitNormalWorld defines the normal in world space
  23626. * @param hitPointWorld defines the point in world space
  23627. */
  23628. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23629. /**
  23630. * Sets the distance from the start point to the hit point
  23631. * @param distance
  23632. */
  23633. setHitDistance(distance: number): void;
  23634. /**
  23635. * Calculates the distance manually
  23636. */
  23637. calculateHitDistance(): void;
  23638. /**
  23639. * Resets all the values to default
  23640. * @param from The from point on world space
  23641. * @param to The to point on world space
  23642. */
  23643. reset(from?: Vector3, to?: Vector3): void;
  23644. }
  23645. /**
  23646. * Interface for the size containing width and height
  23647. */
  23648. interface IXYZ {
  23649. /**
  23650. * X
  23651. */
  23652. x: number;
  23653. /**
  23654. * Y
  23655. */
  23656. y: number;
  23657. /**
  23658. * Z
  23659. */
  23660. z: number;
  23661. }
  23662. }
  23663. declare module "babylonjs/Physics/IPhysicsEngine" {
  23664. import { Nullable } from "babylonjs/types";
  23665. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23667. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23668. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23669. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23670. /**
  23671. * Interface used to describe a physics joint
  23672. */
  23673. export interface PhysicsImpostorJoint {
  23674. /** Defines the main impostor to which the joint is linked */
  23675. mainImpostor: PhysicsImpostor;
  23676. /** Defines the impostor that is connected to the main impostor using this joint */
  23677. connectedImpostor: PhysicsImpostor;
  23678. /** Defines the joint itself */
  23679. joint: PhysicsJoint;
  23680. }
  23681. /** @hidden */
  23682. export interface IPhysicsEnginePlugin {
  23683. world: any;
  23684. name: string;
  23685. setGravity(gravity: Vector3): void;
  23686. setTimeStep(timeStep: number): void;
  23687. getTimeStep(): number;
  23688. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23689. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23690. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23691. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23692. removePhysicsBody(impostor: PhysicsImpostor): void;
  23693. generateJoint(joint: PhysicsImpostorJoint): void;
  23694. removeJoint(joint: PhysicsImpostorJoint): void;
  23695. isSupported(): boolean;
  23696. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23697. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23698. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23699. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23700. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23701. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23702. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23703. getBodyMass(impostor: PhysicsImpostor): number;
  23704. getBodyFriction(impostor: PhysicsImpostor): number;
  23705. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23706. getBodyRestitution(impostor: PhysicsImpostor): number;
  23707. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23708. getBodyPressure?(impostor: PhysicsImpostor): number;
  23709. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23710. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23711. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23712. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23713. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23714. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23715. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23716. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23717. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23718. sleepBody(impostor: PhysicsImpostor): void;
  23719. wakeUpBody(impostor: PhysicsImpostor): void;
  23720. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23721. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23722. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23723. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23724. getRadius(impostor: PhysicsImpostor): number;
  23725. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23726. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23727. dispose(): void;
  23728. }
  23729. /**
  23730. * Interface used to define a physics engine
  23731. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23732. */
  23733. export interface IPhysicsEngine {
  23734. /**
  23735. * Gets the gravity vector used by the simulation
  23736. */
  23737. gravity: Vector3;
  23738. /**
  23739. * Sets the gravity vector used by the simulation
  23740. * @param gravity defines the gravity vector to use
  23741. */
  23742. setGravity(gravity: Vector3): void;
  23743. /**
  23744. * Set the time step of the physics engine.
  23745. * Default is 1/60.
  23746. * To slow it down, enter 1/600 for example.
  23747. * To speed it up, 1/30
  23748. * @param newTimeStep the new timestep to apply to this world.
  23749. */
  23750. setTimeStep(newTimeStep: number): void;
  23751. /**
  23752. * Get the time step of the physics engine.
  23753. * @returns the current time step
  23754. */
  23755. getTimeStep(): number;
  23756. /**
  23757. * Set the sub time step of the physics engine.
  23758. * Default is 0 meaning there is no sub steps
  23759. * To increase physics resolution precision, set a small value (like 1 ms)
  23760. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23761. */
  23762. setSubTimeStep(subTimeStep: number): void;
  23763. /**
  23764. * Get the sub time step of the physics engine.
  23765. * @returns the current sub time step
  23766. */
  23767. getSubTimeStep(): number;
  23768. /**
  23769. * Release all resources
  23770. */
  23771. dispose(): void;
  23772. /**
  23773. * Gets the name of the current physics plugin
  23774. * @returns the name of the plugin
  23775. */
  23776. getPhysicsPluginName(): string;
  23777. /**
  23778. * Adding a new impostor for the impostor tracking.
  23779. * This will be done by the impostor itself.
  23780. * @param impostor the impostor to add
  23781. */
  23782. addImpostor(impostor: PhysicsImpostor): void;
  23783. /**
  23784. * Remove an impostor from the engine.
  23785. * This impostor and its mesh will not longer be updated by the physics engine.
  23786. * @param impostor the impostor to remove
  23787. */
  23788. removeImpostor(impostor: PhysicsImpostor): void;
  23789. /**
  23790. * Add a joint to the physics engine
  23791. * @param mainImpostor defines the main impostor to which the joint is added.
  23792. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23793. * @param joint defines the joint that will connect both impostors.
  23794. */
  23795. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23796. /**
  23797. * Removes a joint from the simulation
  23798. * @param mainImpostor defines the impostor used with the joint
  23799. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23800. * @param joint defines the joint to remove
  23801. */
  23802. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23803. /**
  23804. * Gets the current plugin used to run the simulation
  23805. * @returns current plugin
  23806. */
  23807. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23808. /**
  23809. * Gets the list of physic impostors
  23810. * @returns an array of PhysicsImpostor
  23811. */
  23812. getImpostors(): Array<PhysicsImpostor>;
  23813. /**
  23814. * Gets the impostor for a physics enabled object
  23815. * @param object defines the object impersonated by the impostor
  23816. * @returns the PhysicsImpostor or null if not found
  23817. */
  23818. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23819. /**
  23820. * Gets the impostor for a physics body object
  23821. * @param body defines physics body used by the impostor
  23822. * @returns the PhysicsImpostor or null if not found
  23823. */
  23824. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23825. /**
  23826. * Does a raycast in the physics world
  23827. * @param from when should the ray start?
  23828. * @param to when should the ray end?
  23829. * @returns PhysicsRaycastResult
  23830. */
  23831. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23832. /**
  23833. * Called by the scene. No need to call it.
  23834. * @param delta defines the timespam between frames
  23835. */
  23836. _step(delta: number): void;
  23837. }
  23838. }
  23839. declare module "babylonjs/Physics/physicsImpostor" {
  23840. import { Nullable, IndicesArray } from "babylonjs/types";
  23841. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23842. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23844. import { Scene } from "babylonjs/scene";
  23845. import { Bone } from "babylonjs/Bones/bone";
  23846. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23847. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23848. import { Space } from "babylonjs/Maths/math.axis";
  23849. /**
  23850. * The interface for the physics imposter parameters
  23851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23852. */
  23853. export interface PhysicsImpostorParameters {
  23854. /**
  23855. * The mass of the physics imposter
  23856. */
  23857. mass: number;
  23858. /**
  23859. * The friction of the physics imposter
  23860. */
  23861. friction?: number;
  23862. /**
  23863. * The coefficient of restitution of the physics imposter
  23864. */
  23865. restitution?: number;
  23866. /**
  23867. * The native options of the physics imposter
  23868. */
  23869. nativeOptions?: any;
  23870. /**
  23871. * Specifies if the parent should be ignored
  23872. */
  23873. ignoreParent?: boolean;
  23874. /**
  23875. * Specifies if bi-directional transformations should be disabled
  23876. */
  23877. disableBidirectionalTransformation?: boolean;
  23878. /**
  23879. * The pressure inside the physics imposter, soft object only
  23880. */
  23881. pressure?: number;
  23882. /**
  23883. * The stiffness the physics imposter, soft object only
  23884. */
  23885. stiffness?: number;
  23886. /**
  23887. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23888. */
  23889. velocityIterations?: number;
  23890. /**
  23891. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23892. */
  23893. positionIterations?: number;
  23894. /**
  23895. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23896. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23897. * Add to fix multiple points
  23898. */
  23899. fixedPoints?: number;
  23900. /**
  23901. * The collision margin around a soft object
  23902. */
  23903. margin?: number;
  23904. /**
  23905. * The collision margin around a soft object
  23906. */
  23907. damping?: number;
  23908. /**
  23909. * The path for a rope based on an extrusion
  23910. */
  23911. path?: any;
  23912. /**
  23913. * The shape of an extrusion used for a rope based on an extrusion
  23914. */
  23915. shape?: any;
  23916. }
  23917. /**
  23918. * Interface for a physics-enabled object
  23919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23920. */
  23921. export interface IPhysicsEnabledObject {
  23922. /**
  23923. * The position of the physics-enabled object
  23924. */
  23925. position: Vector3;
  23926. /**
  23927. * The rotation of the physics-enabled object
  23928. */
  23929. rotationQuaternion: Nullable<Quaternion>;
  23930. /**
  23931. * The scale of the physics-enabled object
  23932. */
  23933. scaling: Vector3;
  23934. /**
  23935. * The rotation of the physics-enabled object
  23936. */
  23937. rotation?: Vector3;
  23938. /**
  23939. * The parent of the physics-enabled object
  23940. */
  23941. parent?: any;
  23942. /**
  23943. * The bounding info of the physics-enabled object
  23944. * @returns The bounding info of the physics-enabled object
  23945. */
  23946. getBoundingInfo(): BoundingInfo;
  23947. /**
  23948. * Computes the world matrix
  23949. * @param force Specifies if the world matrix should be computed by force
  23950. * @returns A world matrix
  23951. */
  23952. computeWorldMatrix(force: boolean): Matrix;
  23953. /**
  23954. * Gets the world matrix
  23955. * @returns A world matrix
  23956. */
  23957. getWorldMatrix?(): Matrix;
  23958. /**
  23959. * Gets the child meshes
  23960. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23961. * @returns An array of abstract meshes
  23962. */
  23963. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23964. /**
  23965. * Gets the vertex data
  23966. * @param kind The type of vertex data
  23967. * @returns A nullable array of numbers, or a float32 array
  23968. */
  23969. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23970. /**
  23971. * Gets the indices from the mesh
  23972. * @returns A nullable array of index arrays
  23973. */
  23974. getIndices?(): Nullable<IndicesArray>;
  23975. /**
  23976. * Gets the scene from the mesh
  23977. * @returns the indices array or null
  23978. */
  23979. getScene?(): Scene;
  23980. /**
  23981. * Gets the absolute position from the mesh
  23982. * @returns the absolute position
  23983. */
  23984. getAbsolutePosition(): Vector3;
  23985. /**
  23986. * Gets the absolute pivot point from the mesh
  23987. * @returns the absolute pivot point
  23988. */
  23989. getAbsolutePivotPoint(): Vector3;
  23990. /**
  23991. * Rotates the mesh
  23992. * @param axis The axis of rotation
  23993. * @param amount The amount of rotation
  23994. * @param space The space of the rotation
  23995. * @returns The rotation transform node
  23996. */
  23997. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23998. /**
  23999. * Translates the mesh
  24000. * @param axis The axis of translation
  24001. * @param distance The distance of translation
  24002. * @param space The space of the translation
  24003. * @returns The transform node
  24004. */
  24005. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24006. /**
  24007. * Sets the absolute position of the mesh
  24008. * @param absolutePosition The absolute position of the mesh
  24009. * @returns The transform node
  24010. */
  24011. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24012. /**
  24013. * Gets the class name of the mesh
  24014. * @returns The class name
  24015. */
  24016. getClassName(): string;
  24017. }
  24018. /**
  24019. * Represents a physics imposter
  24020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24021. */
  24022. export class PhysicsImpostor {
  24023. /**
  24024. * The physics-enabled object used as the physics imposter
  24025. */
  24026. object: IPhysicsEnabledObject;
  24027. /**
  24028. * The type of the physics imposter
  24029. */
  24030. type: number;
  24031. private _options;
  24032. private _scene?;
  24033. /**
  24034. * The default object size of the imposter
  24035. */
  24036. static DEFAULT_OBJECT_SIZE: Vector3;
  24037. /**
  24038. * The identity quaternion of the imposter
  24039. */
  24040. static IDENTITY_QUATERNION: Quaternion;
  24041. /** @hidden */
  24042. _pluginData: any;
  24043. private _physicsEngine;
  24044. private _physicsBody;
  24045. private _bodyUpdateRequired;
  24046. private _onBeforePhysicsStepCallbacks;
  24047. private _onAfterPhysicsStepCallbacks;
  24048. /** @hidden */
  24049. _onPhysicsCollideCallbacks: Array<{
  24050. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24051. otherImpostors: Array<PhysicsImpostor>;
  24052. }>;
  24053. private _deltaPosition;
  24054. private _deltaRotation;
  24055. private _deltaRotationConjugated;
  24056. /** @hidden */
  24057. _isFromLine: boolean;
  24058. private _parent;
  24059. private _isDisposed;
  24060. private static _tmpVecs;
  24061. private static _tmpQuat;
  24062. /**
  24063. * Specifies if the physics imposter is disposed
  24064. */
  24065. readonly isDisposed: boolean;
  24066. /**
  24067. * Gets the mass of the physics imposter
  24068. */
  24069. mass: number;
  24070. /**
  24071. * Gets the coefficient of friction
  24072. */
  24073. /**
  24074. * Sets the coefficient of friction
  24075. */
  24076. friction: number;
  24077. /**
  24078. * Gets the coefficient of restitution
  24079. */
  24080. /**
  24081. * Sets the coefficient of restitution
  24082. */
  24083. restitution: number;
  24084. /**
  24085. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24086. */
  24087. /**
  24088. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24089. */
  24090. pressure: number;
  24091. /**
  24092. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24093. */
  24094. /**
  24095. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24096. */
  24097. stiffness: number;
  24098. /**
  24099. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24100. */
  24101. /**
  24102. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24103. */
  24104. velocityIterations: number;
  24105. /**
  24106. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24107. */
  24108. /**
  24109. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24110. */
  24111. positionIterations: number;
  24112. /**
  24113. * The unique id of the physics imposter
  24114. * set by the physics engine when adding this impostor to the array
  24115. */
  24116. uniqueId: number;
  24117. /**
  24118. * @hidden
  24119. */
  24120. soft: boolean;
  24121. /**
  24122. * @hidden
  24123. */
  24124. segments: number;
  24125. private _joints;
  24126. /**
  24127. * Initializes the physics imposter
  24128. * @param object The physics-enabled object used as the physics imposter
  24129. * @param type The type of the physics imposter
  24130. * @param _options The options for the physics imposter
  24131. * @param _scene The Babylon scene
  24132. */
  24133. constructor(
  24134. /**
  24135. * The physics-enabled object used as the physics imposter
  24136. */
  24137. object: IPhysicsEnabledObject,
  24138. /**
  24139. * The type of the physics imposter
  24140. */
  24141. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24142. /**
  24143. * This function will completly initialize this impostor.
  24144. * It will create a new body - but only if this mesh has no parent.
  24145. * If it has, this impostor will not be used other than to define the impostor
  24146. * of the child mesh.
  24147. * @hidden
  24148. */
  24149. _init(): void;
  24150. private _getPhysicsParent;
  24151. /**
  24152. * Should a new body be generated.
  24153. * @returns boolean specifying if body initialization is required
  24154. */
  24155. isBodyInitRequired(): boolean;
  24156. /**
  24157. * Sets the updated scaling
  24158. * @param updated Specifies if the scaling is updated
  24159. */
  24160. setScalingUpdated(): void;
  24161. /**
  24162. * Force a regeneration of this or the parent's impostor's body.
  24163. * Use under cautious - This will remove all joints already implemented.
  24164. */
  24165. forceUpdate(): void;
  24166. /**
  24167. * Gets the body that holds this impostor. Either its own, or its parent.
  24168. */
  24169. /**
  24170. * Set the physics body. Used mainly by the physics engine/plugin
  24171. */
  24172. physicsBody: any;
  24173. /**
  24174. * Get the parent of the physics imposter
  24175. * @returns Physics imposter or null
  24176. */
  24177. /**
  24178. * Sets the parent of the physics imposter
  24179. */
  24180. parent: Nullable<PhysicsImpostor>;
  24181. /**
  24182. * Resets the update flags
  24183. */
  24184. resetUpdateFlags(): void;
  24185. /**
  24186. * Gets the object extend size
  24187. * @returns the object extend size
  24188. */
  24189. getObjectExtendSize(): Vector3;
  24190. /**
  24191. * Gets the object center
  24192. * @returns The object center
  24193. */
  24194. getObjectCenter(): Vector3;
  24195. /**
  24196. * Get a specific parametes from the options parameter
  24197. * @param paramName The object parameter name
  24198. * @returns The object parameter
  24199. */
  24200. getParam(paramName: string): any;
  24201. /**
  24202. * Sets a specific parameter in the options given to the physics plugin
  24203. * @param paramName The parameter name
  24204. * @param value The value of the parameter
  24205. */
  24206. setParam(paramName: string, value: number): void;
  24207. /**
  24208. * Specifically change the body's mass option. Won't recreate the physics body object
  24209. * @param mass The mass of the physics imposter
  24210. */
  24211. setMass(mass: number): void;
  24212. /**
  24213. * Gets the linear velocity
  24214. * @returns linear velocity or null
  24215. */
  24216. getLinearVelocity(): Nullable<Vector3>;
  24217. /**
  24218. * Sets the linear velocity
  24219. * @param velocity linear velocity or null
  24220. */
  24221. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24222. /**
  24223. * Gets the angular velocity
  24224. * @returns angular velocity or null
  24225. */
  24226. getAngularVelocity(): Nullable<Vector3>;
  24227. /**
  24228. * Sets the angular velocity
  24229. * @param velocity The velocity or null
  24230. */
  24231. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24232. /**
  24233. * Execute a function with the physics plugin native code
  24234. * Provide a function the will have two variables - the world object and the physics body object
  24235. * @param func The function to execute with the physics plugin native code
  24236. */
  24237. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24238. /**
  24239. * Register a function that will be executed before the physics world is stepping forward
  24240. * @param func The function to execute before the physics world is stepped forward
  24241. */
  24242. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24243. /**
  24244. * Unregister a function that will be executed before the physics world is stepping forward
  24245. * @param func The function to execute before the physics world is stepped forward
  24246. */
  24247. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24248. /**
  24249. * Register a function that will be executed after the physics step
  24250. * @param func The function to execute after physics step
  24251. */
  24252. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24253. /**
  24254. * Unregisters a function that will be executed after the physics step
  24255. * @param func The function to execute after physics step
  24256. */
  24257. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24258. /**
  24259. * register a function that will be executed when this impostor collides against a different body
  24260. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24261. * @param func Callback that is executed on collision
  24262. */
  24263. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24264. /**
  24265. * Unregisters the physics imposter on contact
  24266. * @param collideAgainst The physics object to collide against
  24267. * @param func Callback to execute on collision
  24268. */
  24269. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24270. private _tmpQuat;
  24271. private _tmpQuat2;
  24272. /**
  24273. * Get the parent rotation
  24274. * @returns The parent rotation
  24275. */
  24276. getParentsRotation(): Quaternion;
  24277. /**
  24278. * this function is executed by the physics engine.
  24279. */
  24280. beforeStep: () => void;
  24281. /**
  24282. * this function is executed by the physics engine
  24283. */
  24284. afterStep: () => void;
  24285. /**
  24286. * Legacy collision detection event support
  24287. */
  24288. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24289. /**
  24290. * event and body object due to cannon's event-based architecture.
  24291. */
  24292. onCollide: (e: {
  24293. body: any;
  24294. }) => void;
  24295. /**
  24296. * Apply a force
  24297. * @param force The force to apply
  24298. * @param contactPoint The contact point for the force
  24299. * @returns The physics imposter
  24300. */
  24301. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24302. /**
  24303. * Apply an impulse
  24304. * @param force The impulse force
  24305. * @param contactPoint The contact point for the impulse force
  24306. * @returns The physics imposter
  24307. */
  24308. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24309. /**
  24310. * A help function to create a joint
  24311. * @param otherImpostor A physics imposter used to create a joint
  24312. * @param jointType The type of joint
  24313. * @param jointData The data for the joint
  24314. * @returns The physics imposter
  24315. */
  24316. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24317. /**
  24318. * Add a joint to this impostor with a different impostor
  24319. * @param otherImpostor A physics imposter used to add a joint
  24320. * @param joint The joint to add
  24321. * @returns The physics imposter
  24322. */
  24323. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24324. /**
  24325. * Add an anchor to a cloth impostor
  24326. * @param otherImpostor rigid impostor to anchor to
  24327. * @param width ratio across width from 0 to 1
  24328. * @param height ratio up height from 0 to 1
  24329. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24330. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24331. * @returns impostor the soft imposter
  24332. */
  24333. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24334. /**
  24335. * Add a hook to a rope impostor
  24336. * @param otherImpostor rigid impostor to anchor to
  24337. * @param length ratio across rope from 0 to 1
  24338. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24339. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24340. * @returns impostor the rope imposter
  24341. */
  24342. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24343. /**
  24344. * Will keep this body still, in a sleep mode.
  24345. * @returns the physics imposter
  24346. */
  24347. sleep(): PhysicsImpostor;
  24348. /**
  24349. * Wake the body up.
  24350. * @returns The physics imposter
  24351. */
  24352. wakeUp(): PhysicsImpostor;
  24353. /**
  24354. * Clones the physics imposter
  24355. * @param newObject The physics imposter clones to this physics-enabled object
  24356. * @returns A nullable physics imposter
  24357. */
  24358. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24359. /**
  24360. * Disposes the physics imposter
  24361. */
  24362. dispose(): void;
  24363. /**
  24364. * Sets the delta position
  24365. * @param position The delta position amount
  24366. */
  24367. setDeltaPosition(position: Vector3): void;
  24368. /**
  24369. * Sets the delta rotation
  24370. * @param rotation The delta rotation amount
  24371. */
  24372. setDeltaRotation(rotation: Quaternion): void;
  24373. /**
  24374. * Gets the box size of the physics imposter and stores the result in the input parameter
  24375. * @param result Stores the box size
  24376. * @returns The physics imposter
  24377. */
  24378. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24379. /**
  24380. * Gets the radius of the physics imposter
  24381. * @returns Radius of the physics imposter
  24382. */
  24383. getRadius(): number;
  24384. /**
  24385. * Sync a bone with this impostor
  24386. * @param bone The bone to sync to the impostor.
  24387. * @param boneMesh The mesh that the bone is influencing.
  24388. * @param jointPivot The pivot of the joint / bone in local space.
  24389. * @param distToJoint Optional distance from the impostor to the joint.
  24390. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24391. */
  24392. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24393. /**
  24394. * Sync impostor to a bone
  24395. * @param bone The bone that the impostor will be synced to.
  24396. * @param boneMesh The mesh that the bone is influencing.
  24397. * @param jointPivot The pivot of the joint / bone in local space.
  24398. * @param distToJoint Optional distance from the impostor to the joint.
  24399. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24400. * @param boneAxis Optional vector3 axis the bone is aligned with
  24401. */
  24402. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24403. /**
  24404. * No-Imposter type
  24405. */
  24406. static NoImpostor: number;
  24407. /**
  24408. * Sphere-Imposter type
  24409. */
  24410. static SphereImpostor: number;
  24411. /**
  24412. * Box-Imposter type
  24413. */
  24414. static BoxImpostor: number;
  24415. /**
  24416. * Plane-Imposter type
  24417. */
  24418. static PlaneImpostor: number;
  24419. /**
  24420. * Mesh-imposter type
  24421. */
  24422. static MeshImpostor: number;
  24423. /**
  24424. * Capsule-Impostor type (Ammo.js plugin only)
  24425. */
  24426. static CapsuleImpostor: number;
  24427. /**
  24428. * Cylinder-Imposter type
  24429. */
  24430. static CylinderImpostor: number;
  24431. /**
  24432. * Particle-Imposter type
  24433. */
  24434. static ParticleImpostor: number;
  24435. /**
  24436. * Heightmap-Imposter type
  24437. */
  24438. static HeightmapImpostor: number;
  24439. /**
  24440. * ConvexHull-Impostor type (Ammo.js plugin only)
  24441. */
  24442. static ConvexHullImpostor: number;
  24443. /**
  24444. * Custom-Imposter type (Ammo.js plugin only)
  24445. */
  24446. static CustomImpostor: number;
  24447. /**
  24448. * Rope-Imposter type
  24449. */
  24450. static RopeImpostor: number;
  24451. /**
  24452. * Cloth-Imposter type
  24453. */
  24454. static ClothImpostor: number;
  24455. /**
  24456. * Softbody-Imposter type
  24457. */
  24458. static SoftbodyImpostor: number;
  24459. }
  24460. }
  24461. declare module "babylonjs/Meshes/mesh" {
  24462. import { Observable } from "babylonjs/Misc/observable";
  24463. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24464. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24465. import { Camera } from "babylonjs/Cameras/camera";
  24466. import { Scene } from "babylonjs/scene";
  24467. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24468. import { Color4 } from "babylonjs/Maths/math.color";
  24469. import { Engine } from "babylonjs/Engines/engine";
  24470. import { Node } from "babylonjs/node";
  24471. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24472. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24473. import { Buffer } from "babylonjs/Meshes/buffer";
  24474. import { Geometry } from "babylonjs/Meshes/geometry";
  24475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24477. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24478. import { Effect } from "babylonjs/Materials/effect";
  24479. import { Material } from "babylonjs/Materials/material";
  24480. import { Skeleton } from "babylonjs/Bones/skeleton";
  24481. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24482. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24483. import { Path3D } from "babylonjs/Maths/math.path";
  24484. import { Plane } from "babylonjs/Maths/math.plane";
  24485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24486. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24487. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24488. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24489. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24490. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24491. /**
  24492. * @hidden
  24493. **/
  24494. export class _CreationDataStorage {
  24495. closePath?: boolean;
  24496. closeArray?: boolean;
  24497. idx: number[];
  24498. dashSize: number;
  24499. gapSize: number;
  24500. path3D: Path3D;
  24501. pathArray: Vector3[][];
  24502. arc: number;
  24503. radius: number;
  24504. cap: number;
  24505. tessellation: number;
  24506. }
  24507. /**
  24508. * @hidden
  24509. **/
  24510. class _InstanceDataStorage {
  24511. visibleInstances: any;
  24512. batchCache: _InstancesBatch;
  24513. instancesBufferSize: number;
  24514. instancesBuffer: Nullable<Buffer>;
  24515. instancesData: Float32Array;
  24516. overridenInstanceCount: number;
  24517. isFrozen: boolean;
  24518. previousBatch: Nullable<_InstancesBatch>;
  24519. hardwareInstancedRendering: boolean;
  24520. sideOrientation: number;
  24521. manualUpdate: boolean;
  24522. }
  24523. /**
  24524. * @hidden
  24525. **/
  24526. export class _InstancesBatch {
  24527. mustReturn: boolean;
  24528. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24529. renderSelf: boolean[];
  24530. hardwareInstancedRendering: boolean[];
  24531. }
  24532. /**
  24533. * Class used to represent renderable models
  24534. */
  24535. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24536. /**
  24537. * Mesh side orientation : usually the external or front surface
  24538. */
  24539. static readonly FRONTSIDE: number;
  24540. /**
  24541. * Mesh side orientation : usually the internal or back surface
  24542. */
  24543. static readonly BACKSIDE: number;
  24544. /**
  24545. * Mesh side orientation : both internal and external or front and back surfaces
  24546. */
  24547. static readonly DOUBLESIDE: number;
  24548. /**
  24549. * Mesh side orientation : by default, `FRONTSIDE`
  24550. */
  24551. static readonly DEFAULTSIDE: number;
  24552. /**
  24553. * Mesh cap setting : no cap
  24554. */
  24555. static readonly NO_CAP: number;
  24556. /**
  24557. * Mesh cap setting : one cap at the beginning of the mesh
  24558. */
  24559. static readonly CAP_START: number;
  24560. /**
  24561. * Mesh cap setting : one cap at the end of the mesh
  24562. */
  24563. static readonly CAP_END: number;
  24564. /**
  24565. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24566. */
  24567. static readonly CAP_ALL: number;
  24568. /**
  24569. * Mesh pattern setting : no flip or rotate
  24570. */
  24571. static readonly NO_FLIP: number;
  24572. /**
  24573. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24574. */
  24575. static readonly FLIP_TILE: number;
  24576. /**
  24577. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24578. */
  24579. static readonly ROTATE_TILE: number;
  24580. /**
  24581. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24582. */
  24583. static readonly FLIP_ROW: number;
  24584. /**
  24585. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24586. */
  24587. static readonly ROTATE_ROW: number;
  24588. /**
  24589. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24590. */
  24591. static readonly FLIP_N_ROTATE_TILE: number;
  24592. /**
  24593. * Mesh pattern setting : rotate pattern and rotate
  24594. */
  24595. static readonly FLIP_N_ROTATE_ROW: number;
  24596. /**
  24597. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24598. */
  24599. static readonly CENTER: number;
  24600. /**
  24601. * Mesh tile positioning : part tiles on left
  24602. */
  24603. static readonly LEFT: number;
  24604. /**
  24605. * Mesh tile positioning : part tiles on right
  24606. */
  24607. static readonly RIGHT: number;
  24608. /**
  24609. * Mesh tile positioning : part tiles on top
  24610. */
  24611. static readonly TOP: number;
  24612. /**
  24613. * Mesh tile positioning : part tiles on bottom
  24614. */
  24615. static readonly BOTTOM: number;
  24616. /**
  24617. * Gets the default side orientation.
  24618. * @param orientation the orientation to value to attempt to get
  24619. * @returns the default orientation
  24620. * @hidden
  24621. */
  24622. static _GetDefaultSideOrientation(orientation?: number): number;
  24623. private _internalMeshDataInfo;
  24624. /**
  24625. * An event triggered before rendering the mesh
  24626. */
  24627. readonly onBeforeRenderObservable: Observable<Mesh>;
  24628. /**
  24629. * An event triggered before binding the mesh
  24630. */
  24631. readonly onBeforeBindObservable: Observable<Mesh>;
  24632. /**
  24633. * An event triggered after rendering the mesh
  24634. */
  24635. readonly onAfterRenderObservable: Observable<Mesh>;
  24636. /**
  24637. * An event triggered before drawing the mesh
  24638. */
  24639. readonly onBeforeDrawObservable: Observable<Mesh>;
  24640. private _onBeforeDrawObserver;
  24641. /**
  24642. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24643. */
  24644. onBeforeDraw: () => void;
  24645. readonly hasInstances: boolean;
  24646. /**
  24647. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24648. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24649. */
  24650. delayLoadState: number;
  24651. /**
  24652. * Gets the list of instances created from this mesh
  24653. * it is not supposed to be modified manually.
  24654. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24655. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24656. */
  24657. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24658. /**
  24659. * Gets the file containing delay loading data for this mesh
  24660. */
  24661. delayLoadingFile: string;
  24662. /** @hidden */
  24663. _binaryInfo: any;
  24664. /**
  24665. * User defined function used to change how LOD level selection is done
  24666. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24667. */
  24668. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24669. /**
  24670. * Gets or sets the morph target manager
  24671. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24672. */
  24673. morphTargetManager: Nullable<MorphTargetManager>;
  24674. /** @hidden */
  24675. _creationDataStorage: Nullable<_CreationDataStorage>;
  24676. /** @hidden */
  24677. _geometry: Nullable<Geometry>;
  24678. /** @hidden */
  24679. _delayInfo: Array<string>;
  24680. /** @hidden */
  24681. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24682. /** @hidden */
  24683. _instanceDataStorage: _InstanceDataStorage;
  24684. private _effectiveMaterial;
  24685. /** @hidden */
  24686. _shouldGenerateFlatShading: boolean;
  24687. /** @hidden */
  24688. _originalBuilderSideOrientation: number;
  24689. /**
  24690. * Use this property to change the original side orientation defined at construction time
  24691. */
  24692. overrideMaterialSideOrientation: Nullable<number>;
  24693. /**
  24694. * Gets the source mesh (the one used to clone this one from)
  24695. */
  24696. readonly source: Nullable<Mesh>;
  24697. /**
  24698. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24699. */
  24700. isUnIndexed: boolean;
  24701. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24702. readonly worldMatrixInstancedBuffer: Float32Array;
  24703. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24704. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24705. /**
  24706. * @constructor
  24707. * @param name The value used by scene.getMeshByName() to do a lookup.
  24708. * @param scene The scene to add this mesh to.
  24709. * @param parent The parent of this mesh, if it has one
  24710. * @param source An optional Mesh from which geometry is shared, cloned.
  24711. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24712. * When false, achieved by calling a clone(), also passing False.
  24713. * This will make creation of children, recursive.
  24714. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24715. */
  24716. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24717. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24718. doNotInstantiate: boolean;
  24719. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24720. /**
  24721. * Gets the class name
  24722. * @returns the string "Mesh".
  24723. */
  24724. getClassName(): string;
  24725. /** @hidden */
  24726. readonly _isMesh: boolean;
  24727. /**
  24728. * Returns a description of this mesh
  24729. * @param fullDetails define if full details about this mesh must be used
  24730. * @returns a descriptive string representing this mesh
  24731. */
  24732. toString(fullDetails?: boolean): string;
  24733. /** @hidden */
  24734. _unBindEffect(): void;
  24735. /**
  24736. * Gets a boolean indicating if this mesh has LOD
  24737. */
  24738. readonly hasLODLevels: boolean;
  24739. /**
  24740. * Gets the list of MeshLODLevel associated with the current mesh
  24741. * @returns an array of MeshLODLevel
  24742. */
  24743. getLODLevels(): MeshLODLevel[];
  24744. private _sortLODLevels;
  24745. /**
  24746. * Add a mesh as LOD level triggered at the given distance.
  24747. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24748. * @param distance The distance from the center of the object to show this level
  24749. * @param mesh The mesh to be added as LOD level (can be null)
  24750. * @return This mesh (for chaining)
  24751. */
  24752. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24753. /**
  24754. * Returns the LOD level mesh at the passed distance or null if not found.
  24755. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24756. * @param distance The distance from the center of the object to show this level
  24757. * @returns a Mesh or `null`
  24758. */
  24759. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24760. /**
  24761. * Remove a mesh from the LOD array
  24762. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24763. * @param mesh defines the mesh to be removed
  24764. * @return This mesh (for chaining)
  24765. */
  24766. removeLODLevel(mesh: Mesh): Mesh;
  24767. /**
  24768. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24769. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24770. * @param camera defines the camera to use to compute distance
  24771. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24772. * @return This mesh (for chaining)
  24773. */
  24774. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24775. /**
  24776. * Gets the mesh internal Geometry object
  24777. */
  24778. readonly geometry: Nullable<Geometry>;
  24779. /**
  24780. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24781. * @returns the total number of vertices
  24782. */
  24783. getTotalVertices(): number;
  24784. /**
  24785. * Returns the content of an associated vertex buffer
  24786. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24787. * - VertexBuffer.PositionKind
  24788. * - VertexBuffer.UVKind
  24789. * - VertexBuffer.UV2Kind
  24790. * - VertexBuffer.UV3Kind
  24791. * - VertexBuffer.UV4Kind
  24792. * - VertexBuffer.UV5Kind
  24793. * - VertexBuffer.UV6Kind
  24794. * - VertexBuffer.ColorKind
  24795. * - VertexBuffer.MatricesIndicesKind
  24796. * - VertexBuffer.MatricesIndicesExtraKind
  24797. * - VertexBuffer.MatricesWeightsKind
  24798. * - VertexBuffer.MatricesWeightsExtraKind
  24799. * @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
  24800. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24801. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24802. */
  24803. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24804. /**
  24805. * Returns the mesh VertexBuffer object from the requested `kind`
  24806. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24807. * - VertexBuffer.PositionKind
  24808. * - VertexBuffer.NormalKind
  24809. * - VertexBuffer.UVKind
  24810. * - VertexBuffer.UV2Kind
  24811. * - VertexBuffer.UV3Kind
  24812. * - VertexBuffer.UV4Kind
  24813. * - VertexBuffer.UV5Kind
  24814. * - VertexBuffer.UV6Kind
  24815. * - VertexBuffer.ColorKind
  24816. * - VertexBuffer.MatricesIndicesKind
  24817. * - VertexBuffer.MatricesIndicesExtraKind
  24818. * - VertexBuffer.MatricesWeightsKind
  24819. * - VertexBuffer.MatricesWeightsExtraKind
  24820. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24821. */
  24822. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24823. /**
  24824. * Tests if a specific vertex buffer is associated with this mesh
  24825. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24826. * - VertexBuffer.PositionKind
  24827. * - VertexBuffer.NormalKind
  24828. * - VertexBuffer.UVKind
  24829. * - VertexBuffer.UV2Kind
  24830. * - VertexBuffer.UV3Kind
  24831. * - VertexBuffer.UV4Kind
  24832. * - VertexBuffer.UV5Kind
  24833. * - VertexBuffer.UV6Kind
  24834. * - VertexBuffer.ColorKind
  24835. * - VertexBuffer.MatricesIndicesKind
  24836. * - VertexBuffer.MatricesIndicesExtraKind
  24837. * - VertexBuffer.MatricesWeightsKind
  24838. * - VertexBuffer.MatricesWeightsExtraKind
  24839. * @returns a boolean
  24840. */
  24841. isVerticesDataPresent(kind: string): boolean;
  24842. /**
  24843. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24844. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24845. * - VertexBuffer.PositionKind
  24846. * - VertexBuffer.UVKind
  24847. * - VertexBuffer.UV2Kind
  24848. * - VertexBuffer.UV3Kind
  24849. * - VertexBuffer.UV4Kind
  24850. * - VertexBuffer.UV5Kind
  24851. * - VertexBuffer.UV6Kind
  24852. * - VertexBuffer.ColorKind
  24853. * - VertexBuffer.MatricesIndicesKind
  24854. * - VertexBuffer.MatricesIndicesExtraKind
  24855. * - VertexBuffer.MatricesWeightsKind
  24856. * - VertexBuffer.MatricesWeightsExtraKind
  24857. * @returns a boolean
  24858. */
  24859. isVertexBufferUpdatable(kind: string): boolean;
  24860. /**
  24861. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24862. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24863. * - VertexBuffer.PositionKind
  24864. * - VertexBuffer.NormalKind
  24865. * - VertexBuffer.UVKind
  24866. * - VertexBuffer.UV2Kind
  24867. * - VertexBuffer.UV3Kind
  24868. * - VertexBuffer.UV4Kind
  24869. * - VertexBuffer.UV5Kind
  24870. * - VertexBuffer.UV6Kind
  24871. * - VertexBuffer.ColorKind
  24872. * - VertexBuffer.MatricesIndicesKind
  24873. * - VertexBuffer.MatricesIndicesExtraKind
  24874. * - VertexBuffer.MatricesWeightsKind
  24875. * - VertexBuffer.MatricesWeightsExtraKind
  24876. * @returns an array of strings
  24877. */
  24878. getVerticesDataKinds(): string[];
  24879. /**
  24880. * Returns a positive integer : the total number of indices in this mesh geometry.
  24881. * @returns the numner of indices or zero if the mesh has no geometry.
  24882. */
  24883. getTotalIndices(): number;
  24884. /**
  24885. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24886. * @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.
  24887. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24888. * @returns the indices array or an empty array if the mesh has no geometry
  24889. */
  24890. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24891. readonly isBlocked: boolean;
  24892. /**
  24893. * Determine if the current mesh is ready to be rendered
  24894. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24895. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24896. * @returns true if all associated assets are ready (material, textures, shaders)
  24897. */
  24898. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24899. /**
  24900. * 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.
  24901. */
  24902. readonly areNormalsFrozen: boolean;
  24903. /**
  24904. * 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.
  24905. * @returns the current mesh
  24906. */
  24907. freezeNormals(): Mesh;
  24908. /**
  24909. * 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
  24910. * @returns the current mesh
  24911. */
  24912. unfreezeNormals(): Mesh;
  24913. /**
  24914. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24915. */
  24916. overridenInstanceCount: number;
  24917. /** @hidden */
  24918. _preActivate(): Mesh;
  24919. /** @hidden */
  24920. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24921. /** @hidden */
  24922. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24923. /**
  24924. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24925. * This means the mesh underlying bounding box and sphere are recomputed.
  24926. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24927. * @returns the current mesh
  24928. */
  24929. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24930. /** @hidden */
  24931. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24932. /**
  24933. * This function will subdivide the mesh into multiple submeshes
  24934. * @param count defines the expected number of submeshes
  24935. */
  24936. subdivide(count: number): void;
  24937. /**
  24938. * Copy a FloatArray into a specific associated vertex buffer
  24939. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24940. * - VertexBuffer.PositionKind
  24941. * - VertexBuffer.UVKind
  24942. * - VertexBuffer.UV2Kind
  24943. * - VertexBuffer.UV3Kind
  24944. * - VertexBuffer.UV4Kind
  24945. * - VertexBuffer.UV5Kind
  24946. * - VertexBuffer.UV6Kind
  24947. * - VertexBuffer.ColorKind
  24948. * - VertexBuffer.MatricesIndicesKind
  24949. * - VertexBuffer.MatricesIndicesExtraKind
  24950. * - VertexBuffer.MatricesWeightsKind
  24951. * - VertexBuffer.MatricesWeightsExtraKind
  24952. * @param data defines the data source
  24953. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24954. * @param stride defines the data stride size (can be null)
  24955. * @returns the current mesh
  24956. */
  24957. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24958. /**
  24959. * Delete a vertex buffer associated with this mesh
  24960. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24961. * - VertexBuffer.PositionKind
  24962. * - VertexBuffer.UVKind
  24963. * - VertexBuffer.UV2Kind
  24964. * - VertexBuffer.UV3Kind
  24965. * - VertexBuffer.UV4Kind
  24966. * - VertexBuffer.UV5Kind
  24967. * - VertexBuffer.UV6Kind
  24968. * - VertexBuffer.ColorKind
  24969. * - VertexBuffer.MatricesIndicesKind
  24970. * - VertexBuffer.MatricesIndicesExtraKind
  24971. * - VertexBuffer.MatricesWeightsKind
  24972. * - VertexBuffer.MatricesWeightsExtraKind
  24973. */
  24974. removeVerticesData(kind: string): void;
  24975. /**
  24976. * Flags an associated vertex buffer as updatable
  24977. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24978. * - VertexBuffer.PositionKind
  24979. * - VertexBuffer.UVKind
  24980. * - VertexBuffer.UV2Kind
  24981. * - VertexBuffer.UV3Kind
  24982. * - VertexBuffer.UV4Kind
  24983. * - VertexBuffer.UV5Kind
  24984. * - VertexBuffer.UV6Kind
  24985. * - VertexBuffer.ColorKind
  24986. * - VertexBuffer.MatricesIndicesKind
  24987. * - VertexBuffer.MatricesIndicesExtraKind
  24988. * - VertexBuffer.MatricesWeightsKind
  24989. * - VertexBuffer.MatricesWeightsExtraKind
  24990. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24991. */
  24992. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24993. /**
  24994. * Sets the mesh global Vertex Buffer
  24995. * @param buffer defines the buffer to use
  24996. * @returns the current mesh
  24997. */
  24998. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24999. /**
  25000. * Update a specific associated vertex buffer
  25001. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25002. * - VertexBuffer.PositionKind
  25003. * - VertexBuffer.UVKind
  25004. * - VertexBuffer.UV2Kind
  25005. * - VertexBuffer.UV3Kind
  25006. * - VertexBuffer.UV4Kind
  25007. * - VertexBuffer.UV5Kind
  25008. * - VertexBuffer.UV6Kind
  25009. * - VertexBuffer.ColorKind
  25010. * - VertexBuffer.MatricesIndicesKind
  25011. * - VertexBuffer.MatricesIndicesExtraKind
  25012. * - VertexBuffer.MatricesWeightsKind
  25013. * - VertexBuffer.MatricesWeightsExtraKind
  25014. * @param data defines the data source
  25015. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25016. * @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)
  25017. * @returns the current mesh
  25018. */
  25019. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25020. /**
  25021. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25022. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25023. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25024. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25025. * @returns the current mesh
  25026. */
  25027. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25028. /**
  25029. * Creates a un-shared specific occurence of the geometry for the mesh.
  25030. * @returns the current mesh
  25031. */
  25032. makeGeometryUnique(): Mesh;
  25033. /**
  25034. * Set the index buffer of this mesh
  25035. * @param indices defines the source data
  25036. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25037. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25038. * @returns the current mesh
  25039. */
  25040. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25041. /**
  25042. * Update the current index buffer
  25043. * @param indices defines the source data
  25044. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25045. * @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)
  25046. * @returns the current mesh
  25047. */
  25048. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25049. /**
  25050. * Invert the geometry to move from a right handed system to a left handed one.
  25051. * @returns the current mesh
  25052. */
  25053. toLeftHanded(): Mesh;
  25054. /** @hidden */
  25055. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25056. /** @hidden */
  25057. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25058. /**
  25059. * Registers for this mesh a javascript function called just before the rendering process
  25060. * @param func defines the function to call before rendering this mesh
  25061. * @returns the current mesh
  25062. */
  25063. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25064. /**
  25065. * Disposes a previously registered javascript function called before the rendering
  25066. * @param func defines the function to remove
  25067. * @returns the current mesh
  25068. */
  25069. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25070. /**
  25071. * Registers for this mesh a javascript function called just after the rendering is complete
  25072. * @param func defines the function to call after rendering this mesh
  25073. * @returns the current mesh
  25074. */
  25075. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25076. /**
  25077. * Disposes a previously registered javascript function called after the rendering.
  25078. * @param func defines the function to remove
  25079. * @returns the current mesh
  25080. */
  25081. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25082. /** @hidden */
  25083. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25084. /** @hidden */
  25085. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25086. /** @hidden */
  25087. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25088. /** @hidden */
  25089. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25090. /** @hidden */
  25091. _rebuild(): void;
  25092. /** @hidden */
  25093. _freeze(): void;
  25094. /** @hidden */
  25095. _unFreeze(): void;
  25096. /**
  25097. * 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
  25098. * @param subMesh defines the subMesh to render
  25099. * @param enableAlphaMode defines if alpha mode can be changed
  25100. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25101. * @returns the current mesh
  25102. */
  25103. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25104. private _onBeforeDraw;
  25105. /**
  25106. * Renormalize the mesh and patch it up if there are no weights
  25107. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25108. * However in the case of zero weights then we set just a single influence to 1.
  25109. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25110. */
  25111. cleanMatrixWeights(): void;
  25112. private normalizeSkinFourWeights;
  25113. private normalizeSkinWeightsAndExtra;
  25114. /**
  25115. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25116. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25117. * the user know there was an issue with importing the mesh
  25118. * @returns a validation object with skinned, valid and report string
  25119. */
  25120. validateSkinning(): {
  25121. skinned: boolean;
  25122. valid: boolean;
  25123. report: string;
  25124. };
  25125. /** @hidden */
  25126. _checkDelayState(): Mesh;
  25127. private _queueLoad;
  25128. /**
  25129. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25130. * A mesh is in the frustum if its bounding box intersects the frustum
  25131. * @param frustumPlanes defines the frustum to test
  25132. * @returns true if the mesh is in the frustum planes
  25133. */
  25134. isInFrustum(frustumPlanes: Plane[]): boolean;
  25135. /**
  25136. * Sets the mesh material by the material or multiMaterial `id` property
  25137. * @param id is a string identifying the material or the multiMaterial
  25138. * @returns the current mesh
  25139. */
  25140. setMaterialByID(id: string): Mesh;
  25141. /**
  25142. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25143. * @returns an array of IAnimatable
  25144. */
  25145. getAnimatables(): IAnimatable[];
  25146. /**
  25147. * Modifies the mesh geometry according to the passed transformation matrix.
  25148. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25149. * The mesh normals are modified using the same transformation.
  25150. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25151. * @param transform defines the transform matrix to use
  25152. * @see http://doc.babylonjs.com/resources/baking_transformations
  25153. * @returns the current mesh
  25154. */
  25155. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25156. /**
  25157. * Modifies the mesh geometry according to its own current World Matrix.
  25158. * The mesh World Matrix is then reset.
  25159. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25160. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25161. * @see http://doc.babylonjs.com/resources/baking_transformations
  25162. * @returns the current mesh
  25163. */
  25164. bakeCurrentTransformIntoVertices(): Mesh;
  25165. /** @hidden */
  25166. readonly _positions: Nullable<Vector3[]>;
  25167. /** @hidden */
  25168. _resetPointsArrayCache(): Mesh;
  25169. /** @hidden */
  25170. _generatePointsArray(): boolean;
  25171. /**
  25172. * Returns a new Mesh object generated from the current mesh properties.
  25173. * This method must not get confused with createInstance()
  25174. * @param name is a string, the name given to the new mesh
  25175. * @param newParent can be any Node object (default `null`)
  25176. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25177. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25178. * @returns a new mesh
  25179. */
  25180. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25181. /**
  25182. * Releases resources associated with this mesh.
  25183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25185. */
  25186. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25187. /** @hidden */
  25188. _disposeInstanceSpecificData(): void;
  25189. /**
  25190. * Modifies the mesh geometry according to a displacement map.
  25191. * 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.
  25192. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25193. * @param url is a string, the URL from the image file is to be downloaded.
  25194. * @param minHeight is the lower limit of the displacement.
  25195. * @param maxHeight is the upper limit of the displacement.
  25196. * @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.
  25197. * @param uvOffset is an optional vector2 used to offset UV.
  25198. * @param uvScale is an optional vector2 used to scale UV.
  25199. * @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.
  25200. * @returns the Mesh.
  25201. */
  25202. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25203. /**
  25204. * Modifies the mesh geometry according to a displacementMap buffer.
  25205. * 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.
  25206. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25207. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25208. * @param heightMapWidth is the width of the buffer image.
  25209. * @param heightMapHeight is the height of the buffer image.
  25210. * @param minHeight is the lower limit of the displacement.
  25211. * @param maxHeight is the upper limit of the displacement.
  25212. * @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.
  25213. * @param uvOffset is an optional vector2 used to offset UV.
  25214. * @param uvScale is an optional vector2 used to scale UV.
  25215. * @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.
  25216. * @returns the Mesh.
  25217. */
  25218. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25219. /**
  25220. * Modify the mesh to get a flat shading rendering.
  25221. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25222. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25223. * @returns current mesh
  25224. */
  25225. convertToFlatShadedMesh(): Mesh;
  25226. /**
  25227. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25228. * In other words, more vertices, no more indices and a single bigger VBO.
  25229. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25230. * @returns current mesh
  25231. */
  25232. convertToUnIndexedMesh(): Mesh;
  25233. /**
  25234. * Inverses facet orientations.
  25235. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25236. * @param flipNormals will also inverts the normals
  25237. * @returns current mesh
  25238. */
  25239. flipFaces(flipNormals?: boolean): Mesh;
  25240. /**
  25241. * Increase the number of facets and hence vertices in a mesh
  25242. * Vertex normals are interpolated from existing vertex normals
  25243. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25244. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25245. */
  25246. increaseVertices(numberPerEdge: number): void;
  25247. /**
  25248. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25249. * This will undo any application of covertToFlatShadedMesh
  25250. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25251. */
  25252. forceSharedVertices(): void;
  25253. /** @hidden */
  25254. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25255. /** @hidden */
  25256. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25257. /**
  25258. * Creates a new InstancedMesh object from the mesh model.
  25259. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25260. * @param name defines the name of the new instance
  25261. * @returns a new InstancedMesh
  25262. */
  25263. createInstance(name: string): InstancedMesh;
  25264. /**
  25265. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25266. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25267. * @returns the current mesh
  25268. */
  25269. synchronizeInstances(): Mesh;
  25270. /**
  25271. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25272. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25273. * This should be used together with the simplification to avoid disappearing triangles.
  25274. * @param successCallback an optional success callback to be called after the optimization finished.
  25275. * @returns the current mesh
  25276. */
  25277. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25278. /**
  25279. * Serialize current mesh
  25280. * @param serializationObject defines the object which will receive the serialization data
  25281. */
  25282. serialize(serializationObject: any): void;
  25283. /** @hidden */
  25284. _syncGeometryWithMorphTargetManager(): void;
  25285. /** @hidden */
  25286. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25287. /**
  25288. * Returns a new Mesh object parsed from the source provided.
  25289. * @param parsedMesh is the source
  25290. * @param scene defines the hosting scene
  25291. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25292. * @returns a new Mesh
  25293. */
  25294. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25295. /**
  25296. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25297. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25298. * @param name defines the name of the mesh to create
  25299. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25300. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25301. * @param closePath creates a seam between the first and the last points of each path of the path array
  25302. * @param offset is taken in account only if the `pathArray` is containing a single path
  25303. * @param scene defines the hosting scene
  25304. * @param updatable defines if the mesh must be flagged as updatable
  25305. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25306. * @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)
  25307. * @returns a new Mesh
  25308. */
  25309. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25310. /**
  25311. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25312. * @param name defines the name of the mesh to create
  25313. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25314. * @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
  25315. * @param scene defines the hosting scene
  25316. * @param updatable defines if the mesh must be flagged as updatable
  25317. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25318. * @returns a new Mesh
  25319. */
  25320. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25321. /**
  25322. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25323. * @param name defines the name of the mesh to create
  25324. * @param size sets the size (float) of each box side (default 1)
  25325. * @param scene defines the hosting scene
  25326. * @param updatable defines if the mesh must be flagged as updatable
  25327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25328. * @returns a new Mesh
  25329. */
  25330. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25331. /**
  25332. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25333. * @param name defines the name of the mesh to create
  25334. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25335. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25336. * @param scene defines the hosting scene
  25337. * @param updatable defines if the mesh must be flagged as updatable
  25338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25339. * @returns a new Mesh
  25340. */
  25341. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25342. /**
  25343. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25344. * @param name defines the name of the mesh to create
  25345. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25346. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25347. * @param scene defines the hosting scene
  25348. * @returns a new Mesh
  25349. */
  25350. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25351. /**
  25352. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25353. * @param name defines the name of the mesh to create
  25354. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25355. * @param diameterTop set the top cap diameter (floats, default 1)
  25356. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25357. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25358. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25359. * @param scene defines the hosting scene
  25360. * @param updatable defines if the mesh must be flagged as updatable
  25361. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25362. * @returns a new Mesh
  25363. */
  25364. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25365. /**
  25366. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25367. * @param name defines the name of the mesh to create
  25368. * @param diameter sets the diameter size (float) of the torus (default 1)
  25369. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25370. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25371. * @param scene defines the hosting scene
  25372. * @param updatable defines if the mesh must be flagged as updatable
  25373. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25374. * @returns a new Mesh
  25375. */
  25376. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25377. /**
  25378. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25379. * @param name defines the name of the mesh to create
  25380. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25381. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25382. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25383. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25384. * @param p the number of windings on X axis (positive integers, default 2)
  25385. * @param q the number of windings on Y axis (positive integers, default 3)
  25386. * @param scene defines the hosting scene
  25387. * @param updatable defines if the mesh must be flagged as updatable
  25388. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25389. * @returns a new Mesh
  25390. */
  25391. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25392. /**
  25393. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25394. * @param name defines the name of the mesh to create
  25395. * @param points is an array successive Vector3
  25396. * @param scene defines the hosting scene
  25397. * @param updatable defines if the mesh must be flagged as updatable
  25398. * @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).
  25399. * @returns a new Mesh
  25400. */
  25401. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25402. /**
  25403. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25404. * @param name defines the name of the mesh to create
  25405. * @param points is an array successive Vector3
  25406. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25407. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25408. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25409. * @param scene defines the hosting scene
  25410. * @param updatable defines if the mesh must be flagged as updatable
  25411. * @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)
  25412. * @returns a new Mesh
  25413. */
  25414. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25415. /**
  25416. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25417. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25418. * 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.
  25419. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25420. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25421. * Remember you can only change the shape positions, not their number when updating a polygon.
  25422. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25423. * @param name defines the name of the mesh to create
  25424. * @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
  25425. * @param scene defines the hosting scene
  25426. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25427. * @param updatable defines if the mesh must be flagged as updatable
  25428. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25429. * @param earcutInjection can be used to inject your own earcut reference
  25430. * @returns a new Mesh
  25431. */
  25432. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25433. /**
  25434. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25435. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25436. * @param name defines the name of the mesh to create
  25437. * @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
  25438. * @param depth defines the height of extrusion
  25439. * @param scene defines the hosting scene
  25440. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25441. * @param updatable defines if the mesh must be flagged as updatable
  25442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25443. * @param earcutInjection can be used to inject your own earcut reference
  25444. * @returns a new Mesh
  25445. */
  25446. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25447. /**
  25448. * Creates an extruded shape mesh.
  25449. * 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
  25450. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25451. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25452. * @param name defines the name of the mesh to create
  25453. * @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
  25454. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25455. * @param scale is the value to scale the shape
  25456. * @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
  25457. * @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
  25458. * @param scene defines the hosting scene
  25459. * @param updatable defines if the mesh must be flagged as updatable
  25460. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25461. * @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)
  25462. * @returns a new Mesh
  25463. */
  25464. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25465. /**
  25466. * Creates an custom extruded shape mesh.
  25467. * The custom extrusion is a parametric shape.
  25468. * It has no predefined shape. Its final shape will depend on the input parameters.
  25469. * Please consider using the same method from the MeshBuilder class instead
  25470. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25471. * @param name defines the name of the mesh to create
  25472. * @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
  25473. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25474. * @param scaleFunction is a custom Javascript function called on each path point
  25475. * @param rotationFunction is a custom Javascript function called on each path point
  25476. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25477. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25478. * @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
  25479. * @param scene defines the hosting scene
  25480. * @param updatable defines if the mesh must be flagged as updatable
  25481. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25482. * @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)
  25483. * @returns a new Mesh
  25484. */
  25485. 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;
  25486. /**
  25487. * Creates lathe mesh.
  25488. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25489. * Please consider using the same method from the MeshBuilder class instead
  25490. * @param name defines the name of the mesh to create
  25491. * @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
  25492. * @param radius is the radius value of the lathe
  25493. * @param tessellation is the side number of the lathe.
  25494. * @param scene defines the hosting scene
  25495. * @param updatable defines if the mesh must be flagged as updatable
  25496. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25497. * @returns a new Mesh
  25498. */
  25499. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25500. /**
  25501. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25502. * @param name defines the name of the mesh to create
  25503. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25504. * @param scene defines the hosting scene
  25505. * @param updatable defines if the mesh must be flagged as updatable
  25506. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25507. * @returns a new Mesh
  25508. */
  25509. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25510. /**
  25511. * Creates a ground mesh.
  25512. * Please consider using the same method from the MeshBuilder class instead
  25513. * @param name defines the name of the mesh to create
  25514. * @param width set the width of the ground
  25515. * @param height set the height of the ground
  25516. * @param subdivisions sets the number of subdivisions per side
  25517. * @param scene defines the hosting scene
  25518. * @param updatable defines if the mesh must be flagged as updatable
  25519. * @returns a new Mesh
  25520. */
  25521. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25522. /**
  25523. * Creates a tiled ground mesh.
  25524. * Please consider using the same method from the MeshBuilder class instead
  25525. * @param name defines the name of the mesh to create
  25526. * @param xmin set the ground minimum X coordinate
  25527. * @param zmin set the ground minimum Y coordinate
  25528. * @param xmax set the ground maximum X coordinate
  25529. * @param zmax set the ground maximum Z coordinate
  25530. * @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
  25531. * @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
  25532. * @param scene defines the hosting scene
  25533. * @param updatable defines if the mesh must be flagged as updatable
  25534. * @returns a new Mesh
  25535. */
  25536. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25537. w: number;
  25538. h: number;
  25539. }, precision: {
  25540. w: number;
  25541. h: number;
  25542. }, scene: Scene, updatable?: boolean): Mesh;
  25543. /**
  25544. * Creates a ground mesh from a height map.
  25545. * Please consider using the same method from the MeshBuilder class instead
  25546. * @see http://doc.babylonjs.com/babylon101/height_map
  25547. * @param name defines the name of the mesh to create
  25548. * @param url sets the URL of the height map image resource
  25549. * @param width set the ground width size
  25550. * @param height set the ground height size
  25551. * @param subdivisions sets the number of subdivision per side
  25552. * @param minHeight is the minimum altitude on the ground
  25553. * @param maxHeight is the maximum altitude on the ground
  25554. * @param scene defines the hosting scene
  25555. * @param updatable defines if the mesh must be flagged as updatable
  25556. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25557. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25558. * @returns a new Mesh
  25559. */
  25560. 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;
  25561. /**
  25562. * Creates a tube mesh.
  25563. * The tube is a parametric shape.
  25564. * It has no predefined shape. Its final shape will depend on the input parameters.
  25565. * Please consider using the same method from the MeshBuilder class instead
  25566. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25567. * @param name defines the name of the mesh to create
  25568. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25569. * @param radius sets the tube radius size
  25570. * @param tessellation is the number of sides on the tubular surface
  25571. * @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
  25572. * @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
  25573. * @param scene defines the hosting scene
  25574. * @param updatable defines if the mesh must be flagged as updatable
  25575. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25576. * @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)
  25577. * @returns a new Mesh
  25578. */
  25579. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25580. (i: number, distance: number): number;
  25581. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25582. /**
  25583. * Creates a polyhedron mesh.
  25584. * Please consider using the same method from the MeshBuilder class instead.
  25585. * * 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
  25586. * * The parameter `size` (positive float, default 1) sets the polygon size
  25587. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25588. * * 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`
  25589. * * 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
  25590. * * 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)`)
  25591. * * 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
  25592. * * 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
  25593. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25594. * * If you create a double-sided mesh, you can choose what parts of 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
  25595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25596. * @param name defines the name of the mesh to create
  25597. * @param options defines the options used to create the mesh
  25598. * @param scene defines the hosting scene
  25599. * @returns a new Mesh
  25600. */
  25601. static CreatePolyhedron(name: string, options: {
  25602. type?: number;
  25603. size?: number;
  25604. sizeX?: number;
  25605. sizeY?: number;
  25606. sizeZ?: number;
  25607. custom?: any;
  25608. faceUV?: Vector4[];
  25609. faceColors?: Color4[];
  25610. updatable?: boolean;
  25611. sideOrientation?: number;
  25612. }, scene: Scene): Mesh;
  25613. /**
  25614. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25615. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25616. * * 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`)
  25617. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25618. * * 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
  25619. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25620. * * If you create a double-sided mesh, you can choose what parts of 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
  25621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25622. * @param name defines the name of the mesh
  25623. * @param options defines the options used to create the mesh
  25624. * @param scene defines the hosting scene
  25625. * @returns a new Mesh
  25626. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25627. */
  25628. static CreateIcoSphere(name: string, options: {
  25629. radius?: number;
  25630. flat?: boolean;
  25631. subdivisions?: number;
  25632. sideOrientation?: number;
  25633. updatable?: boolean;
  25634. }, scene: Scene): Mesh;
  25635. /**
  25636. * Creates a decal mesh.
  25637. * Please consider using the same method from the MeshBuilder class instead.
  25638. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25639. * @param name defines the name of the mesh
  25640. * @param sourceMesh defines the mesh receiving the decal
  25641. * @param position sets the position of the decal in world coordinates
  25642. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25643. * @param size sets the decal scaling
  25644. * @param angle sets the angle to rotate the decal
  25645. * @returns a new Mesh
  25646. */
  25647. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25648. /**
  25649. * Prepare internal position array for software CPU skinning
  25650. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25651. */
  25652. setPositionsForCPUSkinning(): Float32Array;
  25653. /**
  25654. * Prepare internal normal array for software CPU skinning
  25655. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25656. */
  25657. setNormalsForCPUSkinning(): Float32Array;
  25658. /**
  25659. * Updates the vertex buffer by applying transformation from the bones
  25660. * @param skeleton defines the skeleton to apply to current mesh
  25661. * @returns the current mesh
  25662. */
  25663. applySkeleton(skeleton: Skeleton): Mesh;
  25664. /**
  25665. * 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
  25666. * @param meshes defines the list of meshes to scan
  25667. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25668. */
  25669. static MinMax(meshes: AbstractMesh[]): {
  25670. min: Vector3;
  25671. max: Vector3;
  25672. };
  25673. /**
  25674. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25675. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25676. * @returns a vector3
  25677. */
  25678. static Center(meshesOrMinMaxVector: {
  25679. min: Vector3;
  25680. max: Vector3;
  25681. } | AbstractMesh[]): Vector3;
  25682. /**
  25683. * Merge the array of meshes into a single mesh for performance reasons.
  25684. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25685. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25686. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25687. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25688. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25689. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25690. * @returns a new mesh
  25691. */
  25692. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25693. /** @hidden */
  25694. addInstance(instance: InstancedMesh): void;
  25695. /** @hidden */
  25696. removeInstance(instance: InstancedMesh): void;
  25697. }
  25698. }
  25699. declare module "babylonjs/Cameras/camera" {
  25700. import { SmartArray } from "babylonjs/Misc/smartArray";
  25701. import { Observable } from "babylonjs/Misc/observable";
  25702. import { Nullable } from "babylonjs/types";
  25703. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25704. import { Scene } from "babylonjs/scene";
  25705. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25706. import { Node } from "babylonjs/node";
  25707. import { Mesh } from "babylonjs/Meshes/mesh";
  25708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25709. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25710. import { Viewport } from "babylonjs/Maths/math.viewport";
  25711. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25712. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25713. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25714. import { Ray } from "babylonjs/Culling/ray";
  25715. /**
  25716. * This is the base class of all the camera used in the application.
  25717. * @see http://doc.babylonjs.com/features/cameras
  25718. */
  25719. export class Camera extends Node {
  25720. /** @hidden */
  25721. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25722. /**
  25723. * This is the default projection mode used by the cameras.
  25724. * It helps recreating a feeling of perspective and better appreciate depth.
  25725. * This is the best way to simulate real life cameras.
  25726. */
  25727. static readonly PERSPECTIVE_CAMERA: number;
  25728. /**
  25729. * This helps creating camera with an orthographic mode.
  25730. * 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.
  25731. */
  25732. static readonly ORTHOGRAPHIC_CAMERA: number;
  25733. /**
  25734. * This is the default FOV mode for perspective cameras.
  25735. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25736. */
  25737. static readonly FOVMODE_VERTICAL_FIXED: number;
  25738. /**
  25739. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25740. */
  25741. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25742. /**
  25743. * This specifies ther is no need for a camera rig.
  25744. * Basically only one eye is rendered corresponding to the camera.
  25745. */
  25746. static readonly RIG_MODE_NONE: number;
  25747. /**
  25748. * Simulates a camera Rig with one blue eye and one red eye.
  25749. * This can be use with 3d blue and red glasses.
  25750. */
  25751. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25752. /**
  25753. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25754. */
  25755. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25756. /**
  25757. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25758. */
  25759. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25760. /**
  25761. * Defines that both eyes of the camera will be rendered over under each other.
  25762. */
  25763. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25764. /**
  25765. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25766. */
  25767. static readonly RIG_MODE_VR: number;
  25768. /**
  25769. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25770. */
  25771. static readonly RIG_MODE_WEBVR: number;
  25772. /**
  25773. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25774. */
  25775. static readonly RIG_MODE_CUSTOM: number;
  25776. /**
  25777. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25778. */
  25779. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25780. /**
  25781. * Define the input manager associated with the camera.
  25782. */
  25783. inputs: CameraInputsManager<Camera>;
  25784. /** @hidden */
  25785. _position: Vector3;
  25786. /**
  25787. * Define the current local position of the camera in the scene
  25788. */
  25789. position: Vector3;
  25790. /**
  25791. * The vector the camera should consider as up.
  25792. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25793. */
  25794. upVector: Vector3;
  25795. /**
  25796. * Define the current limit on the left side for an orthographic camera
  25797. * In scene unit
  25798. */
  25799. orthoLeft: Nullable<number>;
  25800. /**
  25801. * Define the current limit on the right side for an orthographic camera
  25802. * In scene unit
  25803. */
  25804. orthoRight: Nullable<number>;
  25805. /**
  25806. * Define the current limit on the bottom side for an orthographic camera
  25807. * In scene unit
  25808. */
  25809. orthoBottom: Nullable<number>;
  25810. /**
  25811. * Define the current limit on the top side for an orthographic camera
  25812. * In scene unit
  25813. */
  25814. orthoTop: Nullable<number>;
  25815. /**
  25816. * Field Of View is set in Radians. (default is 0.8)
  25817. */
  25818. fov: number;
  25819. /**
  25820. * Define the minimum distance the camera can see from.
  25821. * This is important to note that the depth buffer are not infinite and the closer it starts
  25822. * the more your scene might encounter depth fighting issue.
  25823. */
  25824. minZ: number;
  25825. /**
  25826. * Define the maximum distance the camera can see to.
  25827. * This is important to note that the depth buffer are not infinite and the further it end
  25828. * the more your scene might encounter depth fighting issue.
  25829. */
  25830. maxZ: number;
  25831. /**
  25832. * Define the default inertia of the camera.
  25833. * This helps giving a smooth feeling to the camera movement.
  25834. */
  25835. inertia: number;
  25836. /**
  25837. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25838. */
  25839. mode: number;
  25840. /**
  25841. * Define wether the camera is intermediate.
  25842. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25843. */
  25844. isIntermediate: boolean;
  25845. /**
  25846. * Define the viewport of the camera.
  25847. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25848. */
  25849. viewport: Viewport;
  25850. /**
  25851. * Restricts the camera to viewing objects with the same layerMask.
  25852. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25853. */
  25854. layerMask: number;
  25855. /**
  25856. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25857. */
  25858. fovMode: number;
  25859. /**
  25860. * Rig mode of the camera.
  25861. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25862. * This is normally controlled byt the camera themselves as internal use.
  25863. */
  25864. cameraRigMode: number;
  25865. /**
  25866. * Defines the distance between both "eyes" in case of a RIG
  25867. */
  25868. interaxialDistance: number;
  25869. /**
  25870. * Defines if stereoscopic rendering is done side by side or over under.
  25871. */
  25872. isStereoscopicSideBySide: boolean;
  25873. /**
  25874. * 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
  25875. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25876. * else in the scene. (Eg. security camera)
  25877. *
  25878. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25879. */
  25880. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25881. /**
  25882. * When set, the camera will render to this render target instead of the default canvas
  25883. *
  25884. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25885. */
  25886. outputRenderTarget: Nullable<RenderTargetTexture>;
  25887. /**
  25888. * Observable triggered when the camera view matrix has changed.
  25889. */
  25890. onViewMatrixChangedObservable: Observable<Camera>;
  25891. /**
  25892. * Observable triggered when the camera Projection matrix has changed.
  25893. */
  25894. onProjectionMatrixChangedObservable: Observable<Camera>;
  25895. /**
  25896. * Observable triggered when the inputs have been processed.
  25897. */
  25898. onAfterCheckInputsObservable: Observable<Camera>;
  25899. /**
  25900. * Observable triggered when reset has been called and applied to the camera.
  25901. */
  25902. onRestoreStateObservable: Observable<Camera>;
  25903. /** @hidden */
  25904. _cameraRigParams: any;
  25905. /** @hidden */
  25906. _rigCameras: Camera[];
  25907. /** @hidden */
  25908. _rigPostProcess: Nullable<PostProcess>;
  25909. protected _webvrViewMatrix: Matrix;
  25910. /** @hidden */
  25911. _skipRendering: boolean;
  25912. /** @hidden */
  25913. _projectionMatrix: Matrix;
  25914. /** @hidden */
  25915. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25916. /** @hidden */
  25917. _activeMeshes: SmartArray<AbstractMesh>;
  25918. protected _globalPosition: Vector3;
  25919. /** @hidden */
  25920. _computedViewMatrix: Matrix;
  25921. private _doNotComputeProjectionMatrix;
  25922. private _transformMatrix;
  25923. private _frustumPlanes;
  25924. private _refreshFrustumPlanes;
  25925. private _storedFov;
  25926. private _stateStored;
  25927. /**
  25928. * Instantiates a new camera object.
  25929. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25930. * @see http://doc.babylonjs.com/features/cameras
  25931. * @param name Defines the name of the camera in the scene
  25932. * @param position Defines the position of the camera
  25933. * @param scene Defines the scene the camera belongs too
  25934. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25935. */
  25936. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25937. /**
  25938. * Store current camera state (fov, position, etc..)
  25939. * @returns the camera
  25940. */
  25941. storeState(): Camera;
  25942. /**
  25943. * Restores the camera state values if it has been stored. You must call storeState() first
  25944. */
  25945. protected _restoreStateValues(): boolean;
  25946. /**
  25947. * Restored camera state. You must call storeState() first.
  25948. * @returns true if restored and false otherwise
  25949. */
  25950. restoreState(): boolean;
  25951. /**
  25952. * Gets the class name of the camera.
  25953. * @returns the class name
  25954. */
  25955. getClassName(): string;
  25956. /** @hidden */
  25957. readonly _isCamera: boolean;
  25958. /**
  25959. * Gets a string representation of the camera useful for debug purpose.
  25960. * @param fullDetails Defines that a more verboe level of logging is required
  25961. * @returns the string representation
  25962. */
  25963. toString(fullDetails?: boolean): string;
  25964. /**
  25965. * Gets the current world space position of the camera.
  25966. */
  25967. readonly globalPosition: Vector3;
  25968. /**
  25969. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25970. * @returns the active meshe list
  25971. */
  25972. getActiveMeshes(): SmartArray<AbstractMesh>;
  25973. /**
  25974. * Check wether a mesh is part of the current active mesh list of the camera
  25975. * @param mesh Defines the mesh to check
  25976. * @returns true if active, false otherwise
  25977. */
  25978. isActiveMesh(mesh: Mesh): boolean;
  25979. /**
  25980. * Is this camera ready to be used/rendered
  25981. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25982. * @return true if the camera is ready
  25983. */
  25984. isReady(completeCheck?: boolean): boolean;
  25985. /** @hidden */
  25986. _initCache(): void;
  25987. /** @hidden */
  25988. _updateCache(ignoreParentClass?: boolean): void;
  25989. /** @hidden */
  25990. _isSynchronized(): boolean;
  25991. /** @hidden */
  25992. _isSynchronizedViewMatrix(): boolean;
  25993. /** @hidden */
  25994. _isSynchronizedProjectionMatrix(): boolean;
  25995. /**
  25996. * Attach the input controls to a specific dom element to get the input from.
  25997. * @param element Defines the element the controls should be listened from
  25998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25999. */
  26000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26001. /**
  26002. * Detach the current controls from the specified dom element.
  26003. * @param element Defines the element to stop listening the inputs from
  26004. */
  26005. detachControl(element: HTMLElement): void;
  26006. /**
  26007. * Update the camera state according to the different inputs gathered during the frame.
  26008. */
  26009. update(): void;
  26010. /** @hidden */
  26011. _checkInputs(): void;
  26012. /** @hidden */
  26013. readonly rigCameras: Camera[];
  26014. /**
  26015. * Gets the post process used by the rig cameras
  26016. */
  26017. readonly rigPostProcess: Nullable<PostProcess>;
  26018. /**
  26019. * Internal, gets the first post proces.
  26020. * @returns the first post process to be run on this camera.
  26021. */
  26022. _getFirstPostProcess(): Nullable<PostProcess>;
  26023. private _cascadePostProcessesToRigCams;
  26024. /**
  26025. * Attach a post process to the camera.
  26026. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26027. * @param postProcess The post process to attach to the camera
  26028. * @param insertAt The position of the post process in case several of them are in use in the scene
  26029. * @returns the position the post process has been inserted at
  26030. */
  26031. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26032. /**
  26033. * Detach a post process to the camera.
  26034. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26035. * @param postProcess The post process to detach from the camera
  26036. */
  26037. detachPostProcess(postProcess: PostProcess): void;
  26038. /**
  26039. * Gets the current world matrix of the camera
  26040. */
  26041. getWorldMatrix(): Matrix;
  26042. /** @hidden */
  26043. _getViewMatrix(): Matrix;
  26044. /**
  26045. * Gets the current view matrix of the camera.
  26046. * @param force forces the camera to recompute the matrix without looking at the cached state
  26047. * @returns the view matrix
  26048. */
  26049. getViewMatrix(force?: boolean): Matrix;
  26050. /**
  26051. * Freeze the projection matrix.
  26052. * It will prevent the cache check of the camera projection compute and can speed up perf
  26053. * if no parameter of the camera are meant to change
  26054. * @param projection Defines manually a projection if necessary
  26055. */
  26056. freezeProjectionMatrix(projection?: Matrix): void;
  26057. /**
  26058. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26059. */
  26060. unfreezeProjectionMatrix(): void;
  26061. /**
  26062. * Gets the current projection matrix of the camera.
  26063. * @param force forces the camera to recompute the matrix without looking at the cached state
  26064. * @returns the projection matrix
  26065. */
  26066. getProjectionMatrix(force?: boolean): Matrix;
  26067. /**
  26068. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26069. * @returns a Matrix
  26070. */
  26071. getTransformationMatrix(): Matrix;
  26072. private _updateFrustumPlanes;
  26073. /**
  26074. * Checks if a cullable object (mesh...) is in the camera frustum
  26075. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26076. * @param target The object to check
  26077. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26078. * @returns true if the object is in frustum otherwise false
  26079. */
  26080. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26081. /**
  26082. * Checks if a cullable object (mesh...) is in the camera frustum
  26083. * Unlike isInFrustum this cheks the full bounding box
  26084. * @param target The object to check
  26085. * @returns true if the object is in frustum otherwise false
  26086. */
  26087. isCompletelyInFrustum(target: ICullable): boolean;
  26088. /**
  26089. * Gets a ray in the forward direction from the camera.
  26090. * @param length Defines the length of the ray to create
  26091. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26092. * @param origin Defines the start point of the ray which defaults to the camera position
  26093. * @returns the forward ray
  26094. */
  26095. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26096. /**
  26097. * Releases resources associated with this node.
  26098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26100. */
  26101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26102. /** @hidden */
  26103. _isLeftCamera: boolean;
  26104. /**
  26105. * Gets the left camera of a rig setup in case of Rigged Camera
  26106. */
  26107. readonly isLeftCamera: boolean;
  26108. /** @hidden */
  26109. _isRightCamera: boolean;
  26110. /**
  26111. * Gets the right camera of a rig setup in case of Rigged Camera
  26112. */
  26113. readonly isRightCamera: boolean;
  26114. /**
  26115. * Gets the left camera of a rig setup in case of Rigged Camera
  26116. */
  26117. readonly leftCamera: Nullable<FreeCamera>;
  26118. /**
  26119. * Gets the right camera of a rig setup in case of Rigged Camera
  26120. */
  26121. readonly rightCamera: Nullable<FreeCamera>;
  26122. /**
  26123. * Gets the left camera target of a rig setup in case of Rigged Camera
  26124. * @returns the target position
  26125. */
  26126. getLeftTarget(): Nullable<Vector3>;
  26127. /**
  26128. * Gets the right camera target of a rig setup in case of Rigged Camera
  26129. * @returns the target position
  26130. */
  26131. getRightTarget(): Nullable<Vector3>;
  26132. /**
  26133. * @hidden
  26134. */
  26135. setCameraRigMode(mode: number, rigParams: any): void;
  26136. /** @hidden */
  26137. static _setStereoscopicRigMode(camera: Camera): void;
  26138. /** @hidden */
  26139. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26140. /** @hidden */
  26141. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26142. /** @hidden */
  26143. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26144. /** @hidden */
  26145. _getVRProjectionMatrix(): Matrix;
  26146. protected _updateCameraRotationMatrix(): void;
  26147. protected _updateWebVRCameraRotationMatrix(): void;
  26148. /**
  26149. * This function MUST be overwritten by the different WebVR cameras available.
  26150. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26151. * @hidden
  26152. */
  26153. _getWebVRProjectionMatrix(): Matrix;
  26154. /**
  26155. * This function MUST be overwritten by the different WebVR cameras available.
  26156. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26157. * @hidden
  26158. */
  26159. _getWebVRViewMatrix(): Matrix;
  26160. /** @hidden */
  26161. setCameraRigParameter(name: string, value: any): void;
  26162. /**
  26163. * needs to be overridden by children so sub has required properties to be copied
  26164. * @hidden
  26165. */
  26166. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26167. /**
  26168. * May need to be overridden by children
  26169. * @hidden
  26170. */
  26171. _updateRigCameras(): void;
  26172. /** @hidden */
  26173. _setupInputs(): void;
  26174. /**
  26175. * Serialiaze the camera setup to a json represention
  26176. * @returns the JSON representation
  26177. */
  26178. serialize(): any;
  26179. /**
  26180. * Clones the current camera.
  26181. * @param name The cloned camera name
  26182. * @returns the cloned camera
  26183. */
  26184. clone(name: string): Camera;
  26185. /**
  26186. * Gets the direction of the camera relative to a given local axis.
  26187. * @param localAxis Defines the reference axis to provide a relative direction.
  26188. * @return the direction
  26189. */
  26190. getDirection(localAxis: Vector3): Vector3;
  26191. /**
  26192. * Returns the current camera absolute rotation
  26193. */
  26194. readonly absoluteRotation: Quaternion;
  26195. /**
  26196. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26197. * @param localAxis Defines the reference axis to provide a relative direction.
  26198. * @param result Defines the vector to store the result in
  26199. */
  26200. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26201. /**
  26202. * Gets a camera constructor for a given camera type
  26203. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26204. * @param name The name of the camera the result will be able to instantiate
  26205. * @param scene The scene the result will construct the camera in
  26206. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26207. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26208. * @returns a factory method to construc the camera
  26209. */
  26210. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26211. /**
  26212. * Compute the world matrix of the camera.
  26213. * @returns the camera world matrix
  26214. */
  26215. computeWorldMatrix(): Matrix;
  26216. /**
  26217. * Parse a JSON and creates the camera from the parsed information
  26218. * @param parsedCamera The JSON to parse
  26219. * @param scene The scene to instantiate the camera in
  26220. * @returns the newly constructed camera
  26221. */
  26222. static Parse(parsedCamera: any, scene: Scene): Camera;
  26223. }
  26224. }
  26225. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26226. import { Nullable } from "babylonjs/types";
  26227. import { Scene } from "babylonjs/scene";
  26228. import { Vector4 } from "babylonjs/Maths/math.vector";
  26229. import { Mesh } from "babylonjs/Meshes/mesh";
  26230. /**
  26231. * Class containing static functions to help procedurally build meshes
  26232. */
  26233. export class DiscBuilder {
  26234. /**
  26235. * Creates a plane polygonal mesh. By default, this is a disc
  26236. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26237. * * 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
  26238. * * 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
  26239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26242. * @param name defines the name of the mesh
  26243. * @param options defines the options used to create the mesh
  26244. * @param scene defines the hosting scene
  26245. * @returns the plane polygonal mesh
  26246. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26247. */
  26248. static CreateDisc(name: string, options: {
  26249. radius?: number;
  26250. tessellation?: number;
  26251. arc?: number;
  26252. updatable?: boolean;
  26253. sideOrientation?: number;
  26254. frontUVs?: Vector4;
  26255. backUVs?: Vector4;
  26256. }, scene?: Nullable<Scene>): Mesh;
  26257. }
  26258. }
  26259. declare module "babylonjs/Materials/fresnelParameters" {
  26260. import { Color3 } from "babylonjs/Maths/math.color";
  26261. /**
  26262. * This represents all the required information to add a fresnel effect on a material:
  26263. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26264. */
  26265. export class FresnelParameters {
  26266. private _isEnabled;
  26267. /**
  26268. * Define if the fresnel effect is enable or not.
  26269. */
  26270. isEnabled: boolean;
  26271. /**
  26272. * Define the color used on edges (grazing angle)
  26273. */
  26274. leftColor: Color3;
  26275. /**
  26276. * Define the color used on center
  26277. */
  26278. rightColor: Color3;
  26279. /**
  26280. * Define bias applied to computed fresnel term
  26281. */
  26282. bias: number;
  26283. /**
  26284. * Defined the power exponent applied to fresnel term
  26285. */
  26286. power: number;
  26287. /**
  26288. * Clones the current fresnel and its valuues
  26289. * @returns a clone fresnel configuration
  26290. */
  26291. clone(): FresnelParameters;
  26292. /**
  26293. * Serializes the current fresnel parameters to a JSON representation.
  26294. * @return the JSON serialization
  26295. */
  26296. serialize(): any;
  26297. /**
  26298. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26299. * @param parsedFresnelParameters Define the JSON representation
  26300. * @returns the parsed parameters
  26301. */
  26302. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26303. }
  26304. }
  26305. declare module "babylonjs/Materials/pushMaterial" {
  26306. import { Nullable } from "babylonjs/types";
  26307. import { Scene } from "babylonjs/scene";
  26308. import { Matrix } from "babylonjs/Maths/math.vector";
  26309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26310. import { Mesh } from "babylonjs/Meshes/mesh";
  26311. import { Material } from "babylonjs/Materials/material";
  26312. import { Effect } from "babylonjs/Materials/effect";
  26313. /**
  26314. * Base class of materials working in push mode in babylon JS
  26315. * @hidden
  26316. */
  26317. export class PushMaterial extends Material {
  26318. protected _activeEffect: Effect;
  26319. protected _normalMatrix: Matrix;
  26320. /**
  26321. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26322. * This means that the material can keep using a previous shader while a new one is being compiled.
  26323. * This is mostly used when shader parallel compilation is supported (true by default)
  26324. */
  26325. allowShaderHotSwapping: boolean;
  26326. constructor(name: string, scene: Scene);
  26327. getEffect(): Effect;
  26328. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26329. /**
  26330. * Binds the given world matrix to the active effect
  26331. *
  26332. * @param world the matrix to bind
  26333. */
  26334. bindOnlyWorldMatrix(world: Matrix): void;
  26335. /**
  26336. * Binds the given normal matrix to the active effect
  26337. *
  26338. * @param normalMatrix the matrix to bind
  26339. */
  26340. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26341. bind(world: Matrix, mesh?: Mesh): void;
  26342. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26343. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26344. }
  26345. }
  26346. declare module "babylonjs/Materials/materialFlags" {
  26347. /**
  26348. * This groups all the flags used to control the materials channel.
  26349. */
  26350. export class MaterialFlags {
  26351. private static _DiffuseTextureEnabled;
  26352. /**
  26353. * Are diffuse textures enabled in the application.
  26354. */
  26355. static DiffuseTextureEnabled: boolean;
  26356. private static _AmbientTextureEnabled;
  26357. /**
  26358. * Are ambient textures enabled in the application.
  26359. */
  26360. static AmbientTextureEnabled: boolean;
  26361. private static _OpacityTextureEnabled;
  26362. /**
  26363. * Are opacity textures enabled in the application.
  26364. */
  26365. static OpacityTextureEnabled: boolean;
  26366. private static _ReflectionTextureEnabled;
  26367. /**
  26368. * Are reflection textures enabled in the application.
  26369. */
  26370. static ReflectionTextureEnabled: boolean;
  26371. private static _EmissiveTextureEnabled;
  26372. /**
  26373. * Are emissive textures enabled in the application.
  26374. */
  26375. static EmissiveTextureEnabled: boolean;
  26376. private static _SpecularTextureEnabled;
  26377. /**
  26378. * Are specular textures enabled in the application.
  26379. */
  26380. static SpecularTextureEnabled: boolean;
  26381. private static _BumpTextureEnabled;
  26382. /**
  26383. * Are bump textures enabled in the application.
  26384. */
  26385. static BumpTextureEnabled: boolean;
  26386. private static _LightmapTextureEnabled;
  26387. /**
  26388. * Are lightmap textures enabled in the application.
  26389. */
  26390. static LightmapTextureEnabled: boolean;
  26391. private static _RefractionTextureEnabled;
  26392. /**
  26393. * Are refraction textures enabled in the application.
  26394. */
  26395. static RefractionTextureEnabled: boolean;
  26396. private static _ColorGradingTextureEnabled;
  26397. /**
  26398. * Are color grading textures enabled in the application.
  26399. */
  26400. static ColorGradingTextureEnabled: boolean;
  26401. private static _FresnelEnabled;
  26402. /**
  26403. * Are fresnels enabled in the application.
  26404. */
  26405. static FresnelEnabled: boolean;
  26406. private static _ClearCoatTextureEnabled;
  26407. /**
  26408. * Are clear coat textures enabled in the application.
  26409. */
  26410. static ClearCoatTextureEnabled: boolean;
  26411. private static _ClearCoatBumpTextureEnabled;
  26412. /**
  26413. * Are clear coat bump textures enabled in the application.
  26414. */
  26415. static ClearCoatBumpTextureEnabled: boolean;
  26416. private static _ClearCoatTintTextureEnabled;
  26417. /**
  26418. * Are clear coat tint textures enabled in the application.
  26419. */
  26420. static ClearCoatTintTextureEnabled: boolean;
  26421. private static _SheenTextureEnabled;
  26422. /**
  26423. * Are sheen textures enabled in the application.
  26424. */
  26425. static SheenTextureEnabled: boolean;
  26426. private static _AnisotropicTextureEnabled;
  26427. /**
  26428. * Are anisotropic textures enabled in the application.
  26429. */
  26430. static AnisotropicTextureEnabled: boolean;
  26431. private static _ThicknessTextureEnabled;
  26432. /**
  26433. * Are thickness textures enabled in the application.
  26434. */
  26435. static ThicknessTextureEnabled: boolean;
  26436. }
  26437. }
  26438. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26439. /** @hidden */
  26440. export var defaultFragmentDeclaration: {
  26441. name: string;
  26442. shader: string;
  26443. };
  26444. }
  26445. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26446. /** @hidden */
  26447. export var defaultUboDeclaration: {
  26448. name: string;
  26449. shader: string;
  26450. };
  26451. }
  26452. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26453. /** @hidden */
  26454. export var lightFragmentDeclaration: {
  26455. name: string;
  26456. shader: string;
  26457. };
  26458. }
  26459. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26460. /** @hidden */
  26461. export var lightUboDeclaration: {
  26462. name: string;
  26463. shader: string;
  26464. };
  26465. }
  26466. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26467. /** @hidden */
  26468. export var lightsFragmentFunctions: {
  26469. name: string;
  26470. shader: string;
  26471. };
  26472. }
  26473. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26474. /** @hidden */
  26475. export var shadowsFragmentFunctions: {
  26476. name: string;
  26477. shader: string;
  26478. };
  26479. }
  26480. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26481. /** @hidden */
  26482. export var fresnelFunction: {
  26483. name: string;
  26484. shader: string;
  26485. };
  26486. }
  26487. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26488. /** @hidden */
  26489. export var reflectionFunction: {
  26490. name: string;
  26491. shader: string;
  26492. };
  26493. }
  26494. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26495. /** @hidden */
  26496. export var bumpFragmentFunctions: {
  26497. name: string;
  26498. shader: string;
  26499. };
  26500. }
  26501. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26502. /** @hidden */
  26503. export var logDepthDeclaration: {
  26504. name: string;
  26505. shader: string;
  26506. };
  26507. }
  26508. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26509. /** @hidden */
  26510. export var bumpFragment: {
  26511. name: string;
  26512. shader: string;
  26513. };
  26514. }
  26515. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26516. /** @hidden */
  26517. export var depthPrePass: {
  26518. name: string;
  26519. shader: string;
  26520. };
  26521. }
  26522. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26523. /** @hidden */
  26524. export var lightFragment: {
  26525. name: string;
  26526. shader: string;
  26527. };
  26528. }
  26529. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26530. /** @hidden */
  26531. export var logDepthFragment: {
  26532. name: string;
  26533. shader: string;
  26534. };
  26535. }
  26536. declare module "babylonjs/Shaders/default.fragment" {
  26537. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26538. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26539. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26540. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26541. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26542. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26543. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26544. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26545. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26546. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26547. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26548. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26549. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26550. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26551. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26552. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26553. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26554. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26555. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26556. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26557. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26558. /** @hidden */
  26559. export var defaultPixelShader: {
  26560. name: string;
  26561. shader: string;
  26562. };
  26563. }
  26564. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26565. /** @hidden */
  26566. export var defaultVertexDeclaration: {
  26567. name: string;
  26568. shader: string;
  26569. };
  26570. }
  26571. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26572. /** @hidden */
  26573. export var bumpVertexDeclaration: {
  26574. name: string;
  26575. shader: string;
  26576. };
  26577. }
  26578. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26579. /** @hidden */
  26580. export var bumpVertex: {
  26581. name: string;
  26582. shader: string;
  26583. };
  26584. }
  26585. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26586. /** @hidden */
  26587. export var fogVertex: {
  26588. name: string;
  26589. shader: string;
  26590. };
  26591. }
  26592. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26593. /** @hidden */
  26594. export var shadowsVertex: {
  26595. name: string;
  26596. shader: string;
  26597. };
  26598. }
  26599. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26600. /** @hidden */
  26601. export var pointCloudVertex: {
  26602. name: string;
  26603. shader: string;
  26604. };
  26605. }
  26606. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26607. /** @hidden */
  26608. export var logDepthVertex: {
  26609. name: string;
  26610. shader: string;
  26611. };
  26612. }
  26613. declare module "babylonjs/Shaders/default.vertex" {
  26614. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26615. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26616. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26617. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26618. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26619. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26620. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26621. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26622. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26623. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26624. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26625. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26626. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26627. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26628. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26629. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26630. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26631. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26632. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26633. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26634. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26635. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26636. /** @hidden */
  26637. export var defaultVertexShader: {
  26638. name: string;
  26639. shader: string;
  26640. };
  26641. }
  26642. declare module "babylonjs/Materials/standardMaterial" {
  26643. import { SmartArray } from "babylonjs/Misc/smartArray";
  26644. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26645. import { Nullable } from "babylonjs/types";
  26646. import { Scene } from "babylonjs/scene";
  26647. import { Matrix } from "babylonjs/Maths/math.vector";
  26648. import { Color3 } from "babylonjs/Maths/math.color";
  26649. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26651. import { Mesh } from "babylonjs/Meshes/mesh";
  26652. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26653. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26654. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26655. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26656. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26657. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26658. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26659. import "babylonjs/Shaders/default.fragment";
  26660. import "babylonjs/Shaders/default.vertex";
  26661. /** @hidden */
  26662. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26663. MAINUV1: boolean;
  26664. MAINUV2: boolean;
  26665. DIFFUSE: boolean;
  26666. DIFFUSEDIRECTUV: number;
  26667. AMBIENT: boolean;
  26668. AMBIENTDIRECTUV: number;
  26669. OPACITY: boolean;
  26670. OPACITYDIRECTUV: number;
  26671. OPACITYRGB: boolean;
  26672. REFLECTION: boolean;
  26673. EMISSIVE: boolean;
  26674. EMISSIVEDIRECTUV: number;
  26675. SPECULAR: boolean;
  26676. SPECULARDIRECTUV: number;
  26677. BUMP: boolean;
  26678. BUMPDIRECTUV: number;
  26679. PARALLAX: boolean;
  26680. PARALLAXOCCLUSION: boolean;
  26681. SPECULAROVERALPHA: boolean;
  26682. CLIPPLANE: boolean;
  26683. CLIPPLANE2: boolean;
  26684. CLIPPLANE3: boolean;
  26685. CLIPPLANE4: boolean;
  26686. ALPHATEST: boolean;
  26687. DEPTHPREPASS: boolean;
  26688. ALPHAFROMDIFFUSE: boolean;
  26689. POINTSIZE: boolean;
  26690. FOG: boolean;
  26691. SPECULARTERM: boolean;
  26692. DIFFUSEFRESNEL: boolean;
  26693. OPACITYFRESNEL: boolean;
  26694. REFLECTIONFRESNEL: boolean;
  26695. REFRACTIONFRESNEL: boolean;
  26696. EMISSIVEFRESNEL: boolean;
  26697. FRESNEL: boolean;
  26698. NORMAL: boolean;
  26699. UV1: boolean;
  26700. UV2: boolean;
  26701. VERTEXCOLOR: boolean;
  26702. VERTEXALPHA: boolean;
  26703. NUM_BONE_INFLUENCERS: number;
  26704. BonesPerMesh: number;
  26705. BONETEXTURE: boolean;
  26706. INSTANCES: boolean;
  26707. GLOSSINESS: boolean;
  26708. ROUGHNESS: boolean;
  26709. EMISSIVEASILLUMINATION: boolean;
  26710. LINKEMISSIVEWITHDIFFUSE: boolean;
  26711. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26712. LIGHTMAP: boolean;
  26713. LIGHTMAPDIRECTUV: number;
  26714. OBJECTSPACE_NORMALMAP: boolean;
  26715. USELIGHTMAPASSHADOWMAP: boolean;
  26716. REFLECTIONMAP_3D: boolean;
  26717. REFLECTIONMAP_SPHERICAL: boolean;
  26718. REFLECTIONMAP_PLANAR: boolean;
  26719. REFLECTIONMAP_CUBIC: boolean;
  26720. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26721. REFLECTIONMAP_PROJECTION: boolean;
  26722. REFLECTIONMAP_SKYBOX: boolean;
  26723. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26724. REFLECTIONMAP_EXPLICIT: boolean;
  26725. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26726. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26727. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26728. INVERTCUBICMAP: boolean;
  26729. LOGARITHMICDEPTH: boolean;
  26730. REFRACTION: boolean;
  26731. REFRACTIONMAP_3D: boolean;
  26732. REFLECTIONOVERALPHA: boolean;
  26733. TWOSIDEDLIGHTING: boolean;
  26734. SHADOWFLOAT: boolean;
  26735. MORPHTARGETS: boolean;
  26736. MORPHTARGETS_NORMAL: boolean;
  26737. MORPHTARGETS_TANGENT: boolean;
  26738. MORPHTARGETS_UV: boolean;
  26739. NUM_MORPH_INFLUENCERS: number;
  26740. NONUNIFORMSCALING: boolean;
  26741. PREMULTIPLYALPHA: boolean;
  26742. IMAGEPROCESSING: boolean;
  26743. VIGNETTE: boolean;
  26744. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26745. VIGNETTEBLENDMODEOPAQUE: boolean;
  26746. TONEMAPPING: boolean;
  26747. TONEMAPPING_ACES: boolean;
  26748. CONTRAST: boolean;
  26749. COLORCURVES: boolean;
  26750. COLORGRADING: boolean;
  26751. COLORGRADING3D: boolean;
  26752. SAMPLER3DGREENDEPTH: boolean;
  26753. SAMPLER3DBGRMAP: boolean;
  26754. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26755. MULTIVIEW: boolean;
  26756. /**
  26757. * If the reflection texture on this material is in linear color space
  26758. * @hidden
  26759. */
  26760. IS_REFLECTION_LINEAR: boolean;
  26761. /**
  26762. * If the refraction texture on this material is in linear color space
  26763. * @hidden
  26764. */
  26765. IS_REFRACTION_LINEAR: boolean;
  26766. EXPOSURE: boolean;
  26767. constructor();
  26768. setReflectionMode(modeToEnable: string): void;
  26769. }
  26770. /**
  26771. * This is the default material used in Babylon. It is the best trade off between quality
  26772. * and performances.
  26773. * @see http://doc.babylonjs.com/babylon101/materials
  26774. */
  26775. export class StandardMaterial extends PushMaterial {
  26776. private _diffuseTexture;
  26777. /**
  26778. * The basic texture of the material as viewed under a light.
  26779. */
  26780. diffuseTexture: Nullable<BaseTexture>;
  26781. private _ambientTexture;
  26782. /**
  26783. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26784. */
  26785. ambientTexture: Nullable<BaseTexture>;
  26786. private _opacityTexture;
  26787. /**
  26788. * Define the transparency of the material from a texture.
  26789. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26790. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26791. */
  26792. opacityTexture: Nullable<BaseTexture>;
  26793. private _reflectionTexture;
  26794. /**
  26795. * Define the texture used to display the reflection.
  26796. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26797. */
  26798. reflectionTexture: Nullable<BaseTexture>;
  26799. private _emissiveTexture;
  26800. /**
  26801. * Define texture of the material as if self lit.
  26802. * This will be mixed in the final result even in the absence of light.
  26803. */
  26804. emissiveTexture: Nullable<BaseTexture>;
  26805. private _specularTexture;
  26806. /**
  26807. * Define how the color and intensity of the highlight given by the light in the material.
  26808. */
  26809. specularTexture: Nullable<BaseTexture>;
  26810. private _bumpTexture;
  26811. /**
  26812. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26813. * 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.
  26814. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26815. */
  26816. bumpTexture: Nullable<BaseTexture>;
  26817. private _lightmapTexture;
  26818. /**
  26819. * Complex lighting can be computationally expensive to compute at runtime.
  26820. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26821. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26822. */
  26823. lightmapTexture: Nullable<BaseTexture>;
  26824. private _refractionTexture;
  26825. /**
  26826. * Define the texture used to display the refraction.
  26827. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26828. */
  26829. refractionTexture: Nullable<BaseTexture>;
  26830. /**
  26831. * The color of the material lit by the environmental background lighting.
  26832. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26833. */
  26834. ambientColor: Color3;
  26835. /**
  26836. * The basic color of the material as viewed under a light.
  26837. */
  26838. diffuseColor: Color3;
  26839. /**
  26840. * Define how the color and intensity of the highlight given by the light in the material.
  26841. */
  26842. specularColor: Color3;
  26843. /**
  26844. * Define the color of the material as if self lit.
  26845. * This will be mixed in the final result even in the absence of light.
  26846. */
  26847. emissiveColor: Color3;
  26848. /**
  26849. * Defines how sharp are the highlights in the material.
  26850. * The bigger the value the sharper giving a more glossy feeling to the result.
  26851. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26852. */
  26853. specularPower: number;
  26854. private _useAlphaFromDiffuseTexture;
  26855. /**
  26856. * Does the transparency come from the diffuse texture alpha channel.
  26857. */
  26858. useAlphaFromDiffuseTexture: boolean;
  26859. private _useEmissiveAsIllumination;
  26860. /**
  26861. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26862. */
  26863. useEmissiveAsIllumination: boolean;
  26864. private _linkEmissiveWithDiffuse;
  26865. /**
  26866. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26867. * the emissive level when the final color is close to one.
  26868. */
  26869. linkEmissiveWithDiffuse: boolean;
  26870. private _useSpecularOverAlpha;
  26871. /**
  26872. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26873. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26874. */
  26875. useSpecularOverAlpha: boolean;
  26876. private _useReflectionOverAlpha;
  26877. /**
  26878. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26879. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26880. */
  26881. useReflectionOverAlpha: boolean;
  26882. private _disableLighting;
  26883. /**
  26884. * Does lights from the scene impacts this material.
  26885. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26886. */
  26887. disableLighting: boolean;
  26888. private _useObjectSpaceNormalMap;
  26889. /**
  26890. * Allows using an object space normal map (instead of tangent space).
  26891. */
  26892. useObjectSpaceNormalMap: boolean;
  26893. private _useParallax;
  26894. /**
  26895. * Is parallax enabled or not.
  26896. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26897. */
  26898. useParallax: boolean;
  26899. private _useParallaxOcclusion;
  26900. /**
  26901. * Is parallax occlusion enabled or not.
  26902. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26903. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26904. */
  26905. useParallaxOcclusion: boolean;
  26906. /**
  26907. * 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.
  26908. */
  26909. parallaxScaleBias: number;
  26910. private _roughness;
  26911. /**
  26912. * Helps to define how blurry the reflections should appears in the material.
  26913. */
  26914. roughness: number;
  26915. /**
  26916. * In case of refraction, define the value of the index of refraction.
  26917. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26918. */
  26919. indexOfRefraction: number;
  26920. /**
  26921. * Invert the refraction texture alongside the y axis.
  26922. * It can be useful with procedural textures or probe for instance.
  26923. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26924. */
  26925. invertRefractionY: boolean;
  26926. /**
  26927. * Defines the alpha limits in alpha test mode.
  26928. */
  26929. alphaCutOff: number;
  26930. private _useLightmapAsShadowmap;
  26931. /**
  26932. * In case of light mapping, define whether the map contains light or shadow informations.
  26933. */
  26934. useLightmapAsShadowmap: boolean;
  26935. private _diffuseFresnelParameters;
  26936. /**
  26937. * Define the diffuse fresnel parameters of the material.
  26938. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26939. */
  26940. diffuseFresnelParameters: FresnelParameters;
  26941. private _opacityFresnelParameters;
  26942. /**
  26943. * Define the opacity fresnel parameters of the material.
  26944. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26945. */
  26946. opacityFresnelParameters: FresnelParameters;
  26947. private _reflectionFresnelParameters;
  26948. /**
  26949. * Define the reflection fresnel parameters of the material.
  26950. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26951. */
  26952. reflectionFresnelParameters: FresnelParameters;
  26953. private _refractionFresnelParameters;
  26954. /**
  26955. * Define the refraction fresnel parameters of the material.
  26956. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26957. */
  26958. refractionFresnelParameters: FresnelParameters;
  26959. private _emissiveFresnelParameters;
  26960. /**
  26961. * Define the emissive fresnel parameters of the material.
  26962. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26963. */
  26964. emissiveFresnelParameters: FresnelParameters;
  26965. private _useReflectionFresnelFromSpecular;
  26966. /**
  26967. * If true automatically deducts the fresnels values from the material specularity.
  26968. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26969. */
  26970. useReflectionFresnelFromSpecular: boolean;
  26971. private _useGlossinessFromSpecularMapAlpha;
  26972. /**
  26973. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26974. */
  26975. useGlossinessFromSpecularMapAlpha: boolean;
  26976. private _maxSimultaneousLights;
  26977. /**
  26978. * Defines the maximum number of lights that can be used in the material
  26979. */
  26980. maxSimultaneousLights: number;
  26981. private _invertNormalMapX;
  26982. /**
  26983. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26984. */
  26985. invertNormalMapX: boolean;
  26986. private _invertNormalMapY;
  26987. /**
  26988. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26989. */
  26990. invertNormalMapY: boolean;
  26991. private _twoSidedLighting;
  26992. /**
  26993. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26994. */
  26995. twoSidedLighting: boolean;
  26996. /**
  26997. * Default configuration related to image processing available in the standard Material.
  26998. */
  26999. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27000. /**
  27001. * Gets the image processing configuration used either in this material.
  27002. */
  27003. /**
  27004. * Sets the Default image processing configuration used either in the this material.
  27005. *
  27006. * If sets to null, the scene one is in use.
  27007. */
  27008. imageProcessingConfiguration: ImageProcessingConfiguration;
  27009. /**
  27010. * Keep track of the image processing observer to allow dispose and replace.
  27011. */
  27012. private _imageProcessingObserver;
  27013. /**
  27014. * Attaches a new image processing configuration to the Standard Material.
  27015. * @param configuration
  27016. */
  27017. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27018. /**
  27019. * Gets wether the color curves effect is enabled.
  27020. */
  27021. /**
  27022. * Sets wether the color curves effect is enabled.
  27023. */
  27024. cameraColorCurvesEnabled: boolean;
  27025. /**
  27026. * Gets wether the color grading effect is enabled.
  27027. */
  27028. /**
  27029. * Gets wether the color grading effect is enabled.
  27030. */
  27031. cameraColorGradingEnabled: boolean;
  27032. /**
  27033. * Gets wether tonemapping is enabled or not.
  27034. */
  27035. /**
  27036. * Sets wether tonemapping is enabled or not
  27037. */
  27038. cameraToneMappingEnabled: boolean;
  27039. /**
  27040. * The camera exposure used on this material.
  27041. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27042. * This corresponds to a photographic exposure.
  27043. */
  27044. /**
  27045. * The camera exposure used on this material.
  27046. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27047. * This corresponds to a photographic exposure.
  27048. */
  27049. cameraExposure: number;
  27050. /**
  27051. * Gets The camera contrast used on this material.
  27052. */
  27053. /**
  27054. * Sets The camera contrast used on this material.
  27055. */
  27056. cameraContrast: number;
  27057. /**
  27058. * Gets the Color Grading 2D Lookup Texture.
  27059. */
  27060. /**
  27061. * Sets the Color Grading 2D Lookup Texture.
  27062. */
  27063. cameraColorGradingTexture: Nullable<BaseTexture>;
  27064. /**
  27065. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27066. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27067. * 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;
  27068. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27069. */
  27070. /**
  27071. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27072. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27073. * 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;
  27074. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27075. */
  27076. cameraColorCurves: Nullable<ColorCurves>;
  27077. /**
  27078. * Custom callback helping to override the default shader used in the material.
  27079. */
  27080. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27081. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27082. protected _worldViewProjectionMatrix: Matrix;
  27083. protected _globalAmbientColor: Color3;
  27084. protected _useLogarithmicDepth: boolean;
  27085. protected _rebuildInParallel: boolean;
  27086. /**
  27087. * Instantiates a new standard material.
  27088. * This is the default material used in Babylon. It is the best trade off between quality
  27089. * and performances.
  27090. * @see http://doc.babylonjs.com/babylon101/materials
  27091. * @param name Define the name of the material in the scene
  27092. * @param scene Define the scene the material belong to
  27093. */
  27094. constructor(name: string, scene: Scene);
  27095. /**
  27096. * Gets a boolean indicating that current material needs to register RTT
  27097. */
  27098. readonly hasRenderTargetTextures: boolean;
  27099. /**
  27100. * Gets the current class name of the material e.g. "StandardMaterial"
  27101. * Mainly use in serialization.
  27102. * @returns the class name
  27103. */
  27104. getClassName(): string;
  27105. /**
  27106. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27107. * You can try switching to logarithmic depth.
  27108. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27109. */
  27110. useLogarithmicDepth: boolean;
  27111. /**
  27112. * Specifies if the material will require alpha blending
  27113. * @returns a boolean specifying if alpha blending is needed
  27114. */
  27115. needAlphaBlending(): boolean;
  27116. /**
  27117. * Specifies if this material should be rendered in alpha test mode
  27118. * @returns a boolean specifying if an alpha test is needed.
  27119. */
  27120. needAlphaTesting(): boolean;
  27121. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27122. /**
  27123. * Get the texture used for alpha test purpose.
  27124. * @returns the diffuse texture in case of the standard material.
  27125. */
  27126. getAlphaTestTexture(): Nullable<BaseTexture>;
  27127. /**
  27128. * Get if the submesh is ready to be used and all its information available.
  27129. * Child classes can use it to update shaders
  27130. * @param mesh defines the mesh to check
  27131. * @param subMesh defines which submesh to check
  27132. * @param useInstances specifies that instances should be used
  27133. * @returns a boolean indicating that the submesh is ready or not
  27134. */
  27135. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27136. /**
  27137. * Builds the material UBO layouts.
  27138. * Used internally during the effect preparation.
  27139. */
  27140. buildUniformLayout(): void;
  27141. /**
  27142. * Unbinds the material from the mesh
  27143. */
  27144. unbind(): void;
  27145. /**
  27146. * Binds the submesh to this material by preparing the effect and shader to draw
  27147. * @param world defines the world transformation matrix
  27148. * @param mesh defines the mesh containing the submesh
  27149. * @param subMesh defines the submesh to bind the material to
  27150. */
  27151. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27152. /**
  27153. * Get the list of animatables in the material.
  27154. * @returns the list of animatables object used in the material
  27155. */
  27156. getAnimatables(): IAnimatable[];
  27157. /**
  27158. * Gets the active textures from the material
  27159. * @returns an array of textures
  27160. */
  27161. getActiveTextures(): BaseTexture[];
  27162. /**
  27163. * Specifies if the material uses a texture
  27164. * @param texture defines the texture to check against the material
  27165. * @returns a boolean specifying if the material uses the texture
  27166. */
  27167. hasTexture(texture: BaseTexture): boolean;
  27168. /**
  27169. * Disposes the material
  27170. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27171. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27172. */
  27173. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27174. /**
  27175. * Makes a duplicate of the material, and gives it a new name
  27176. * @param name defines the new name for the duplicated material
  27177. * @returns the cloned material
  27178. */
  27179. clone(name: string): StandardMaterial;
  27180. /**
  27181. * Serializes this material in a JSON representation
  27182. * @returns the serialized material object
  27183. */
  27184. serialize(): any;
  27185. /**
  27186. * Creates a standard material from parsed material data
  27187. * @param source defines the JSON representation of the material
  27188. * @param scene defines the hosting scene
  27189. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27190. * @returns a new standard material
  27191. */
  27192. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27193. /**
  27194. * Are diffuse textures enabled in the application.
  27195. */
  27196. static DiffuseTextureEnabled: boolean;
  27197. /**
  27198. * Are ambient textures enabled in the application.
  27199. */
  27200. static AmbientTextureEnabled: boolean;
  27201. /**
  27202. * Are opacity textures enabled in the application.
  27203. */
  27204. static OpacityTextureEnabled: boolean;
  27205. /**
  27206. * Are reflection textures enabled in the application.
  27207. */
  27208. static ReflectionTextureEnabled: boolean;
  27209. /**
  27210. * Are emissive textures enabled in the application.
  27211. */
  27212. static EmissiveTextureEnabled: boolean;
  27213. /**
  27214. * Are specular textures enabled in the application.
  27215. */
  27216. static SpecularTextureEnabled: boolean;
  27217. /**
  27218. * Are bump textures enabled in the application.
  27219. */
  27220. static BumpTextureEnabled: boolean;
  27221. /**
  27222. * Are lightmap textures enabled in the application.
  27223. */
  27224. static LightmapTextureEnabled: boolean;
  27225. /**
  27226. * Are refraction textures enabled in the application.
  27227. */
  27228. static RefractionTextureEnabled: boolean;
  27229. /**
  27230. * Are color grading textures enabled in the application.
  27231. */
  27232. static ColorGradingTextureEnabled: boolean;
  27233. /**
  27234. * Are fresnels enabled in the application.
  27235. */
  27236. static FresnelEnabled: boolean;
  27237. }
  27238. }
  27239. declare module "babylonjs/Particles/solidParticleSystem" {
  27240. import { Nullable } from "babylonjs/types";
  27241. import { Vector3 } from "babylonjs/Maths/math.vector";
  27242. import { Mesh } from "babylonjs/Meshes/mesh";
  27243. import { Scene, IDisposable } from "babylonjs/scene";
  27244. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27245. import { Material } from "babylonjs/Materials/material";
  27246. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27247. /**
  27248. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27249. *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.
  27250. * The SPS is also a particle system. It provides some methods to manage the particles.
  27251. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27252. *
  27253. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27254. */
  27255. export class SolidParticleSystem implements IDisposable {
  27256. /**
  27257. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27258. * Example : var p = SPS.particles[i];
  27259. */
  27260. particles: SolidParticle[];
  27261. /**
  27262. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27263. */
  27264. nbParticles: number;
  27265. /**
  27266. * If the particles must ever face the camera (default false). Useful for planar particles.
  27267. */
  27268. billboard: boolean;
  27269. /**
  27270. * Recompute normals when adding a shape
  27271. */
  27272. recomputeNormals: boolean;
  27273. /**
  27274. * This a counter ofr your own usage. It's not set by any SPS functions.
  27275. */
  27276. counter: number;
  27277. /**
  27278. * The SPS name. This name is also given to the underlying mesh.
  27279. */
  27280. name: string;
  27281. /**
  27282. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27283. */
  27284. mesh: Mesh;
  27285. /**
  27286. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27287. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27288. */
  27289. vars: any;
  27290. /**
  27291. * This array is populated when the SPS is set as 'pickable'.
  27292. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27293. * Each element of this array is an object `{idx: int, faceId: int}`.
  27294. * `idx` is the picked particle index in the `SPS.particles` array
  27295. * `faceId` is the picked face index counted within this particle.
  27296. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27297. */
  27298. pickedParticles: {
  27299. idx: number;
  27300. faceId: number;
  27301. }[];
  27302. /**
  27303. * This array is populated when `enableDepthSort` is set to true.
  27304. * Each element of this array is an instance of the class DepthSortedParticle.
  27305. */
  27306. depthSortedParticles: DepthSortedParticle[];
  27307. /**
  27308. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27309. * @hidden
  27310. */
  27311. _bSphereOnly: boolean;
  27312. /**
  27313. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27314. * @hidden
  27315. */
  27316. _bSphereRadiusFactor: number;
  27317. private _scene;
  27318. private _positions;
  27319. private _indices;
  27320. private _normals;
  27321. private _colors;
  27322. private _uvs;
  27323. private _indices32;
  27324. private _positions32;
  27325. private _normals32;
  27326. private _fixedNormal32;
  27327. private _colors32;
  27328. private _uvs32;
  27329. private _index;
  27330. private _updatable;
  27331. private _pickable;
  27332. private _isVisibilityBoxLocked;
  27333. private _alwaysVisible;
  27334. private _depthSort;
  27335. private _expandable;
  27336. private _shapeCounter;
  27337. private _copy;
  27338. private _color;
  27339. private _computeParticleColor;
  27340. private _computeParticleTexture;
  27341. private _computeParticleRotation;
  27342. private _computeParticleVertex;
  27343. private _computeBoundingBox;
  27344. private _depthSortParticles;
  27345. private _camera;
  27346. private _mustUnrotateFixedNormals;
  27347. private _particlesIntersect;
  27348. private _needs32Bits;
  27349. private _isNotBuilt;
  27350. private _lastParticleId;
  27351. private _idxOfId;
  27352. private _multimaterialEnabled;
  27353. private _useModelMaterial;
  27354. private _indicesByMaterial;
  27355. private _materialIndexes;
  27356. private _depthSortFunction;
  27357. private _materialSortFunction;
  27358. private _materials;
  27359. private _multimaterial;
  27360. private _materialIndexesById;
  27361. private _defaultMaterial;
  27362. private _autoUpdateSubMeshes;
  27363. /**
  27364. * Creates a SPS (Solid Particle System) object.
  27365. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27366. * @param scene (Scene) is the scene in which the SPS is added.
  27367. * @param options defines the options of the sps e.g.
  27368. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27369. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27370. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27371. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27372. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27373. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27374. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27375. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27376. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27377. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27378. */
  27379. constructor(name: string, scene: Scene, options?: {
  27380. updatable?: boolean;
  27381. isPickable?: boolean;
  27382. enableDepthSort?: boolean;
  27383. particleIntersection?: boolean;
  27384. boundingSphereOnly?: boolean;
  27385. bSphereRadiusFactor?: number;
  27386. expandable?: boolean;
  27387. useModelMaterial?: boolean;
  27388. enableMultiMaterial?: boolean;
  27389. });
  27390. /**
  27391. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27392. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27393. * @returns the created mesh
  27394. */
  27395. buildMesh(): Mesh;
  27396. /**
  27397. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27398. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27399. * Thus the particles generated from `digest()` have their property `position` set yet.
  27400. * @param mesh ( Mesh ) is the mesh to be digested
  27401. * @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
  27402. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27403. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27404. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27405. * @returns the current SPS
  27406. */
  27407. digest(mesh: Mesh, options?: {
  27408. facetNb?: number;
  27409. number?: number;
  27410. delta?: number;
  27411. storage?: [];
  27412. }): SolidParticleSystem;
  27413. /**
  27414. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27415. * @hidden
  27416. */
  27417. private _unrotateFixedNormals;
  27418. /**
  27419. * Resets the temporary working copy particle
  27420. * @hidden
  27421. */
  27422. private _resetCopy;
  27423. /**
  27424. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27425. * @param p the current index in the positions array to be updated
  27426. * @param ind the current index in the indices array
  27427. * @param shape a Vector3 array, the shape geometry
  27428. * @param positions the positions array to be updated
  27429. * @param meshInd the shape indices array
  27430. * @param indices the indices array to be updated
  27431. * @param meshUV the shape uv array
  27432. * @param uvs the uv array to be updated
  27433. * @param meshCol the shape color array
  27434. * @param colors the color array to be updated
  27435. * @param meshNor the shape normals array
  27436. * @param normals the normals array to be updated
  27437. * @param idx the particle index
  27438. * @param idxInShape the particle index in its shape
  27439. * @param options the addShape() method passed options
  27440. * @model the particle model
  27441. * @hidden
  27442. */
  27443. private _meshBuilder;
  27444. /**
  27445. * Returns a shape Vector3 array from positions float array
  27446. * @param positions float array
  27447. * @returns a vector3 array
  27448. * @hidden
  27449. */
  27450. private _posToShape;
  27451. /**
  27452. * Returns a shapeUV array from a float uvs (array deep copy)
  27453. * @param uvs as a float array
  27454. * @returns a shapeUV array
  27455. * @hidden
  27456. */
  27457. private _uvsToShapeUV;
  27458. /**
  27459. * Adds a new particle object in the particles array
  27460. * @param idx particle index in particles array
  27461. * @param id particle id
  27462. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27463. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27464. * @param model particle ModelShape object
  27465. * @param shapeId model shape identifier
  27466. * @param idxInShape index of the particle in the current model
  27467. * @param bInfo model bounding info object
  27468. * @param storage target storage array, if any
  27469. * @hidden
  27470. */
  27471. private _addParticle;
  27472. /**
  27473. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27474. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27475. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27476. * @param nb (positive integer) the number of particles to be created from this model
  27477. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27478. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27479. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27480. * @returns the number of shapes in the system
  27481. */
  27482. addShape(mesh: Mesh, nb: number, options?: {
  27483. positionFunction?: any;
  27484. vertexFunction?: any;
  27485. storage?: [];
  27486. }): number;
  27487. /**
  27488. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27489. * @hidden
  27490. */
  27491. private _rebuildParticle;
  27492. /**
  27493. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27494. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27495. * @returns the SPS.
  27496. */
  27497. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27498. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27499. * Returns an array with the removed particles.
  27500. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27501. * The SPS can't be empty so at least one particle needs to remain in place.
  27502. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27503. * @param start index of the first particle to remove
  27504. * @param end index of the last particle to remove (included)
  27505. * @returns an array populated with the removed particles
  27506. */
  27507. removeParticles(start: number, end: number): SolidParticle[];
  27508. /**
  27509. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27510. * @param solidParticleArray an array populated with Solid Particles objects
  27511. * @returns the SPS
  27512. */
  27513. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27514. /**
  27515. * Creates a new particle and modifies the SPS mesh geometry :
  27516. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27517. * - calls _addParticle() to populate the particle array
  27518. * factorized code from addShape() and insertParticlesFromArray()
  27519. * @param idx particle index in the particles array
  27520. * @param i particle index in its shape
  27521. * @param modelShape particle ModelShape object
  27522. * @param shape shape vertex array
  27523. * @param meshInd shape indices array
  27524. * @param meshUV shape uv array
  27525. * @param meshCol shape color array
  27526. * @param meshNor shape normals array
  27527. * @param bbInfo shape bounding info
  27528. * @param storage target particle storage
  27529. * @options addShape() passed options
  27530. * @hidden
  27531. */
  27532. private _insertNewParticle;
  27533. /**
  27534. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27535. * This method calls `updateParticle()` for each particle of the SPS.
  27536. * For an animated SPS, it is usually called within the render loop.
  27537. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27538. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27539. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27540. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27541. * @returns the SPS.
  27542. */
  27543. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27544. /**
  27545. * Disposes the SPS.
  27546. */
  27547. dispose(): void;
  27548. /**
  27549. * Returns a SolidParticle object from its identifier : particle.id
  27550. * @param id (integer) the particle Id
  27551. * @returns the searched particle or null if not found in the SPS.
  27552. */
  27553. getParticleById(id: number): Nullable<SolidParticle>;
  27554. /**
  27555. * Returns a new array populated with the particles having the passed shapeId.
  27556. * @param shapeId (integer) the shape identifier
  27557. * @returns a new solid particle array
  27558. */
  27559. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27560. /**
  27561. * Populates the passed array "ref" with the particles having the passed shapeId.
  27562. * @param shapeId the shape identifier
  27563. * @returns the SPS
  27564. * @param ref
  27565. */
  27566. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27567. /**
  27568. * Computes the required SubMeshes according the materials assigned to the particles.
  27569. * @returns the solid particle system.
  27570. * Does nothing if called before the SPS mesh is built.
  27571. */
  27572. computeSubMeshes(): SolidParticleSystem;
  27573. /**
  27574. * Sorts the solid particles by material when MultiMaterial is enabled.
  27575. * Updates the indices32 array.
  27576. * Updates the indicesByMaterial array.
  27577. * Updates the mesh indices array.
  27578. * @returns the SPS
  27579. * @hidden
  27580. */
  27581. private _sortParticlesByMaterial;
  27582. /**
  27583. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27584. * @hidden
  27585. */
  27586. private _setMaterialIndexesById;
  27587. /**
  27588. * Returns an array with unique values of Materials from the passed array
  27589. * @param array the material array to be checked and filtered
  27590. * @hidden
  27591. */
  27592. private _filterUniqueMaterialId;
  27593. /**
  27594. * Sets a new Standard Material as _defaultMaterial if not already set.
  27595. * @hidden
  27596. */
  27597. private _setDefaultMaterial;
  27598. /**
  27599. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27600. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27601. * @returns the SPS.
  27602. */
  27603. refreshVisibleSize(): SolidParticleSystem;
  27604. /**
  27605. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27606. * @param size the size (float) of the visibility box
  27607. * note : this doesn't lock the SPS mesh bounding box.
  27608. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27609. */
  27610. setVisibilityBox(size: number): void;
  27611. /**
  27612. * Gets whether the SPS as always visible or not
  27613. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27614. */
  27615. /**
  27616. * Sets the SPS as always visible or not
  27617. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27618. */
  27619. isAlwaysVisible: boolean;
  27620. /**
  27621. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27622. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27623. */
  27624. /**
  27625. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27626. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27627. */
  27628. isVisibilityBoxLocked: boolean;
  27629. /**
  27630. * Tells to `setParticles()` to compute the particle rotations or not.
  27631. * Default value : true. The SPS is faster when it's set to false.
  27632. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27633. */
  27634. /**
  27635. * Gets if `setParticles()` computes the particle rotations or not.
  27636. * Default value : true. The SPS is faster when it's set to false.
  27637. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27638. */
  27639. computeParticleRotation: boolean;
  27640. /**
  27641. * Tells to `setParticles()` to compute the particle colors or not.
  27642. * Default value : true. The SPS is faster when it's set to false.
  27643. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27644. */
  27645. /**
  27646. * Gets if `setParticles()` computes the particle colors or not.
  27647. * Default value : true. The SPS is faster when it's set to false.
  27648. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27649. */
  27650. computeParticleColor: boolean;
  27651. /**
  27652. * Gets if `setParticles()` computes the particle textures or not.
  27653. * Default value : true. The SPS is faster when it's set to false.
  27654. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27655. */
  27656. computeParticleTexture: boolean;
  27657. /**
  27658. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27659. * Default value : false. The SPS is faster when it's set to false.
  27660. * Note : the particle custom vertex positions aren't stored values.
  27661. */
  27662. /**
  27663. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27664. * Default value : false. The SPS is faster when it's set to false.
  27665. * Note : the particle custom vertex positions aren't stored values.
  27666. */
  27667. computeParticleVertex: boolean;
  27668. /**
  27669. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27670. */
  27671. /**
  27672. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27673. */
  27674. computeBoundingBox: boolean;
  27675. /**
  27676. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27677. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27678. * Default : `true`
  27679. */
  27680. /**
  27681. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27682. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27683. * Default : `true`
  27684. */
  27685. depthSortParticles: boolean;
  27686. /**
  27687. * Gets if the SPS is created as expandable at construction time.
  27688. * Default : `false`
  27689. */
  27690. readonly expandable: boolean;
  27691. /**
  27692. * Gets if the SPS supports the Multi Materials
  27693. */
  27694. readonly multimaterialEnabled: boolean;
  27695. /**
  27696. * Gets if the SPS uses the model materials for its own multimaterial.
  27697. */
  27698. readonly useModelMaterial: boolean;
  27699. /**
  27700. * The SPS used material array.
  27701. */
  27702. readonly materials: Material[];
  27703. /**
  27704. * Sets the SPS MultiMaterial from the passed materials.
  27705. * Note : the passed array is internally copied and not used then by reference.
  27706. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27707. */
  27708. setMultiMaterial(materials: Material[]): void;
  27709. /**
  27710. * The SPS computed multimaterial object
  27711. */
  27712. multimaterial: MultiMaterial;
  27713. /**
  27714. * If the subMeshes must be updated on the next call to setParticles()
  27715. */
  27716. autoUpdateSubMeshes: boolean;
  27717. /**
  27718. * This function does nothing. It may be overwritten to set all the particle first values.
  27719. * The SPS doesn't call this function, you may have to call it by your own.
  27720. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27721. */
  27722. initParticles(): void;
  27723. /**
  27724. * This function does nothing. It may be overwritten to recycle a particle.
  27725. * The SPS doesn't call this function, you may have to call it by your own.
  27726. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27727. * @param particle The particle to recycle
  27728. * @returns the recycled particle
  27729. */
  27730. recycleParticle(particle: SolidParticle): SolidParticle;
  27731. /**
  27732. * Updates a particle : this function should be overwritten by the user.
  27733. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27734. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27735. * @example : just set a particle position or velocity and recycle conditions
  27736. * @param particle The particle to update
  27737. * @returns the updated particle
  27738. */
  27739. updateParticle(particle: SolidParticle): SolidParticle;
  27740. /**
  27741. * Updates a vertex of a particle : it can be overwritten by the user.
  27742. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27743. * @param particle the current particle
  27744. * @param vertex the current index of the current particle
  27745. * @param pt the index of the current vertex in the particle shape
  27746. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27747. * @example : just set a vertex particle position
  27748. * @returns the updated vertex
  27749. */
  27750. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27751. /**
  27752. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27753. * This does nothing and may be overwritten by the user.
  27754. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27755. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27756. * @param update the boolean update value actually passed to setParticles()
  27757. */
  27758. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27759. /**
  27760. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27761. * This will be passed three parameters.
  27762. * This does nothing and may be overwritten by the user.
  27763. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27764. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27765. * @param update the boolean update value actually passed to setParticles()
  27766. */
  27767. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27768. }
  27769. }
  27770. declare module "babylonjs/Particles/solidParticle" {
  27771. import { Nullable } from "babylonjs/types";
  27772. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  27773. import { Color4 } from "babylonjs/Maths/math.color";
  27774. import { Mesh } from "babylonjs/Meshes/mesh";
  27775. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27776. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  27777. import { Plane } from "babylonjs/Maths/math.plane";
  27778. import { Material } from "babylonjs/Materials/material";
  27779. /**
  27780. * Represents one particle of a solid particle system.
  27781. */
  27782. export class SolidParticle {
  27783. /**
  27784. * particle global index
  27785. */
  27786. idx: number;
  27787. /**
  27788. * particle identifier
  27789. */
  27790. id: number;
  27791. /**
  27792. * The color of the particle
  27793. */
  27794. color: Nullable<Color4>;
  27795. /**
  27796. * The world space position of the particle.
  27797. */
  27798. position: Vector3;
  27799. /**
  27800. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27801. */
  27802. rotation: Vector3;
  27803. /**
  27804. * The world space rotation quaternion of the particle.
  27805. */
  27806. rotationQuaternion: Nullable<Quaternion>;
  27807. /**
  27808. * The scaling of the particle.
  27809. */
  27810. scaling: Vector3;
  27811. /**
  27812. * The uvs of the particle.
  27813. */
  27814. uvs: Vector4;
  27815. /**
  27816. * The current speed of the particle.
  27817. */
  27818. velocity: Vector3;
  27819. /**
  27820. * The pivot point in the particle local space.
  27821. */
  27822. pivot: Vector3;
  27823. /**
  27824. * Must the particle be translated from its pivot point in its local space ?
  27825. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27826. * Default : false
  27827. */
  27828. translateFromPivot: boolean;
  27829. /**
  27830. * Is the particle active or not ?
  27831. */
  27832. alive: boolean;
  27833. /**
  27834. * Is the particle visible or not ?
  27835. */
  27836. isVisible: boolean;
  27837. /**
  27838. * Index of this particle in the global "positions" array (Internal use)
  27839. * @hidden
  27840. */
  27841. _pos: number;
  27842. /**
  27843. * @hidden Index of this particle in the global "indices" array (Internal use)
  27844. */
  27845. _ind: number;
  27846. /**
  27847. * @hidden ModelShape of this particle (Internal use)
  27848. */
  27849. _model: ModelShape;
  27850. /**
  27851. * ModelShape id of this particle
  27852. */
  27853. shapeId: number;
  27854. /**
  27855. * Index of the particle in its shape id
  27856. */
  27857. idxInShape: number;
  27858. /**
  27859. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27860. */
  27861. _modelBoundingInfo: BoundingInfo;
  27862. /**
  27863. * @hidden Particle BoundingInfo object (Internal use)
  27864. */
  27865. _boundingInfo: BoundingInfo;
  27866. /**
  27867. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27868. */
  27869. _sps: SolidParticleSystem;
  27870. /**
  27871. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27872. */
  27873. _stillInvisible: boolean;
  27874. /**
  27875. * @hidden Last computed particle rotation matrix
  27876. */
  27877. _rotationMatrix: number[];
  27878. /**
  27879. * Parent particle Id, if any.
  27880. * Default null.
  27881. */
  27882. parentId: Nullable<number>;
  27883. /**
  27884. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27885. */
  27886. materialIndex: Nullable<number>;
  27887. /**
  27888. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27889. * The possible values are :
  27890. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27891. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27892. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27893. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27894. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27895. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27896. * */
  27897. cullingStrategy: number;
  27898. /**
  27899. * @hidden Internal global position in the SPS.
  27900. */
  27901. _globalPosition: Vector3;
  27902. /**
  27903. * Creates a Solid Particle object.
  27904. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27905. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27906. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27907. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27908. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27909. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27910. * @param shapeId (integer) is the model shape identifier in the SPS.
  27911. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27912. * @param sps defines the sps it is associated to
  27913. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27914. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27915. */
  27916. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27917. /**
  27918. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27919. * @param target the particle target
  27920. * @returns the current particle
  27921. */
  27922. copyToRef(target: SolidParticle): SolidParticle;
  27923. /**
  27924. * Legacy support, changed scale to scaling
  27925. */
  27926. /**
  27927. * Legacy support, changed scale to scaling
  27928. */
  27929. scale: Vector3;
  27930. /**
  27931. * Legacy support, changed quaternion to rotationQuaternion
  27932. */
  27933. /**
  27934. * Legacy support, changed quaternion to rotationQuaternion
  27935. */
  27936. quaternion: Nullable<Quaternion>;
  27937. /**
  27938. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27939. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27940. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27941. * @returns true if it intersects
  27942. */
  27943. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27944. /**
  27945. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27946. * A particle is in the frustum if its bounding box intersects the frustum
  27947. * @param frustumPlanes defines the frustum to test
  27948. * @returns true if the particle is in the frustum planes
  27949. */
  27950. isInFrustum(frustumPlanes: Plane[]): boolean;
  27951. /**
  27952. * get the rotation matrix of the particle
  27953. * @hidden
  27954. */
  27955. getRotationMatrix(m: Matrix): void;
  27956. }
  27957. /**
  27958. * Represents the shape of the model used by one particle of a solid particle system.
  27959. * SPS internal tool, don't use it manually.
  27960. */
  27961. export class ModelShape {
  27962. /**
  27963. * The shape id
  27964. * @hidden
  27965. */
  27966. shapeID: number;
  27967. /**
  27968. * flat array of model positions (internal use)
  27969. * @hidden
  27970. */
  27971. _shape: Vector3[];
  27972. /**
  27973. * flat array of model UVs (internal use)
  27974. * @hidden
  27975. */
  27976. _shapeUV: number[];
  27977. /**
  27978. * color array of the model
  27979. * @hidden
  27980. */
  27981. _shapeColors: number[];
  27982. /**
  27983. * indices array of the model
  27984. * @hidden
  27985. */
  27986. _indices: number[];
  27987. /**
  27988. * normals array of the model
  27989. * @hidden
  27990. */
  27991. _normals: number[];
  27992. /**
  27993. * length of the shape in the model indices array (internal use)
  27994. * @hidden
  27995. */
  27996. _indicesLength: number;
  27997. /**
  27998. * Custom position function (internal use)
  27999. * @hidden
  28000. */
  28001. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28002. /**
  28003. * Custom vertex function (internal use)
  28004. * @hidden
  28005. */
  28006. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28007. /**
  28008. * Model material (internal use)
  28009. * @hidden
  28010. */
  28011. _material: Nullable<Material>;
  28012. /**
  28013. * 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.
  28014. * SPS internal tool, don't use it manually.
  28015. * @hidden
  28016. */
  28017. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28018. }
  28019. /**
  28020. * Represents a Depth Sorted Particle in the solid particle system.
  28021. * @hidden
  28022. */
  28023. export class DepthSortedParticle {
  28024. /**
  28025. * Index of the particle in the "indices" array
  28026. */
  28027. ind: number;
  28028. /**
  28029. * Length of the particle shape in the "indices" array
  28030. */
  28031. indicesLength: number;
  28032. /**
  28033. * Squared distance from the particle to the camera
  28034. */
  28035. sqDistance: number;
  28036. /**
  28037. * Material index when used with MultiMaterials
  28038. */
  28039. materialIndex: number;
  28040. /**
  28041. * Creates a new sorted particle
  28042. * @param materialIndex
  28043. */
  28044. constructor(ind: number, indLength: number, materialIndex: number);
  28045. }
  28046. }
  28047. declare module "babylonjs/Collisions/meshCollisionData" {
  28048. import { Collider } from "babylonjs/Collisions/collider";
  28049. import { Vector3 } from "babylonjs/Maths/math.vector";
  28050. import { Nullable } from "babylonjs/types";
  28051. import { Observer } from "babylonjs/Misc/observable";
  28052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28053. /**
  28054. * @hidden
  28055. */
  28056. export class _MeshCollisionData {
  28057. _checkCollisions: boolean;
  28058. _collisionMask: number;
  28059. _collisionGroup: number;
  28060. _collider: Nullable<Collider>;
  28061. _oldPositionForCollisions: Vector3;
  28062. _diffPositionForCollisions: Vector3;
  28063. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28064. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28065. }
  28066. }
  28067. declare module "babylonjs/Meshes/abstractMesh" {
  28068. import { Observable } from "babylonjs/Misc/observable";
  28069. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28070. import { Camera } from "babylonjs/Cameras/camera";
  28071. import { Scene, IDisposable } from "babylonjs/scene";
  28072. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28073. import { Node } from "babylonjs/node";
  28074. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28075. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28076. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28077. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28078. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28079. import { Material } from "babylonjs/Materials/material";
  28080. import { Light } from "babylonjs/Lights/light";
  28081. import { Skeleton } from "babylonjs/Bones/skeleton";
  28082. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28083. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28084. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28085. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28086. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28087. import { Plane } from "babylonjs/Maths/math.plane";
  28088. import { Ray } from "babylonjs/Culling/ray";
  28089. import { Collider } from "babylonjs/Collisions/collider";
  28090. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28091. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28092. /** @hidden */
  28093. class _FacetDataStorage {
  28094. facetPositions: Vector3[];
  28095. facetNormals: Vector3[];
  28096. facetPartitioning: number[][];
  28097. facetNb: number;
  28098. partitioningSubdivisions: number;
  28099. partitioningBBoxRatio: number;
  28100. facetDataEnabled: boolean;
  28101. facetParameters: any;
  28102. bbSize: Vector3;
  28103. subDiv: {
  28104. max: number;
  28105. X: number;
  28106. Y: number;
  28107. Z: number;
  28108. };
  28109. facetDepthSort: boolean;
  28110. facetDepthSortEnabled: boolean;
  28111. depthSortedIndices: IndicesArray;
  28112. depthSortedFacets: {
  28113. ind: number;
  28114. sqDistance: number;
  28115. }[];
  28116. facetDepthSortFunction: (f1: {
  28117. ind: number;
  28118. sqDistance: number;
  28119. }, f2: {
  28120. ind: number;
  28121. sqDistance: number;
  28122. }) => number;
  28123. facetDepthSortFrom: Vector3;
  28124. facetDepthSortOrigin: Vector3;
  28125. invertedMatrix: Matrix;
  28126. }
  28127. /**
  28128. * @hidden
  28129. **/
  28130. class _InternalAbstractMeshDataInfo {
  28131. _hasVertexAlpha: boolean;
  28132. _useVertexColors: boolean;
  28133. _numBoneInfluencers: number;
  28134. _applyFog: boolean;
  28135. _receiveShadows: boolean;
  28136. _facetData: _FacetDataStorage;
  28137. _visibility: number;
  28138. _skeleton: Nullable<Skeleton>;
  28139. _layerMask: number;
  28140. _computeBonesUsingShaders: boolean;
  28141. _isActive: boolean;
  28142. _onlyForInstances: boolean;
  28143. _isActiveIntermediate: boolean;
  28144. _onlyForInstancesIntermediate: boolean;
  28145. _actAsRegularMesh: boolean;
  28146. }
  28147. /**
  28148. * Class used to store all common mesh properties
  28149. */
  28150. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28151. /** No occlusion */
  28152. static OCCLUSION_TYPE_NONE: number;
  28153. /** Occlusion set to optimisitic */
  28154. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28155. /** Occlusion set to strict */
  28156. static OCCLUSION_TYPE_STRICT: number;
  28157. /** Use an accurante occlusion algorithm */
  28158. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28159. /** Use a conservative occlusion algorithm */
  28160. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28161. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28162. * Test order :
  28163. * Is the bounding sphere outside the frustum ?
  28164. * If not, are the bounding box vertices outside the frustum ?
  28165. * It not, then the cullable object is in the frustum.
  28166. */
  28167. static readonly CULLINGSTRATEGY_STANDARD: number;
  28168. /** Culling strategy : Bounding Sphere Only.
  28169. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28170. * It's also less accurate than the standard because some not visible objects can still be selected.
  28171. * Test : is the bounding sphere outside the frustum ?
  28172. * If not, then the cullable object is in the frustum.
  28173. */
  28174. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28175. /** Culling strategy : Optimistic Inclusion.
  28176. * This in an inclusion test first, then the standard exclusion test.
  28177. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28178. * 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.
  28179. * Anyway, it's as accurate as the standard strategy.
  28180. * Test :
  28181. * Is the cullable object bounding sphere center in the frustum ?
  28182. * If not, apply the default culling strategy.
  28183. */
  28184. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28185. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28186. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28187. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28188. * 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.
  28189. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28190. * Test :
  28191. * Is the cullable object bounding sphere center in the frustum ?
  28192. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28193. */
  28194. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28195. /**
  28196. * No billboard
  28197. */
  28198. static readonly BILLBOARDMODE_NONE: number;
  28199. /** Billboard on X axis */
  28200. static readonly BILLBOARDMODE_X: number;
  28201. /** Billboard on Y axis */
  28202. static readonly BILLBOARDMODE_Y: number;
  28203. /** Billboard on Z axis */
  28204. static readonly BILLBOARDMODE_Z: number;
  28205. /** Billboard on all axes */
  28206. static readonly BILLBOARDMODE_ALL: number;
  28207. /** Billboard on using position instead of orientation */
  28208. static readonly BILLBOARDMODE_USE_POSITION: number;
  28209. /** @hidden */
  28210. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28211. /**
  28212. * The culling strategy to use to check whether the mesh must be rendered or not.
  28213. * This value can be changed at any time and will be used on the next render mesh selection.
  28214. * The possible values are :
  28215. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28216. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28217. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28218. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28219. * Please read each static variable documentation to get details about the culling process.
  28220. * */
  28221. cullingStrategy: number;
  28222. /**
  28223. * Gets the number of facets in the mesh
  28224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28225. */
  28226. readonly facetNb: number;
  28227. /**
  28228. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28230. */
  28231. partitioningSubdivisions: number;
  28232. /**
  28233. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28234. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28236. */
  28237. partitioningBBoxRatio: number;
  28238. /**
  28239. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28240. * Works only for updatable meshes.
  28241. * Doesn't work with multi-materials
  28242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28243. */
  28244. mustDepthSortFacets: boolean;
  28245. /**
  28246. * The location (Vector3) where the facet depth sort must be computed from.
  28247. * By default, the active camera position.
  28248. * Used only when facet depth sort is enabled
  28249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28250. */
  28251. facetDepthSortFrom: Vector3;
  28252. /**
  28253. * gets a boolean indicating if facetData is enabled
  28254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28255. */
  28256. readonly isFacetDataEnabled: boolean;
  28257. /** @hidden */
  28258. _updateNonUniformScalingState(value: boolean): boolean;
  28259. /**
  28260. * An event triggered when this mesh collides with another one
  28261. */
  28262. onCollideObservable: Observable<AbstractMesh>;
  28263. /** Set a function to call when this mesh collides with another one */
  28264. onCollide: () => void;
  28265. /**
  28266. * An event triggered when the collision's position changes
  28267. */
  28268. onCollisionPositionChangeObservable: Observable<Vector3>;
  28269. /** Set a function to call when the collision's position changes */
  28270. onCollisionPositionChange: () => void;
  28271. /**
  28272. * An event triggered when material is changed
  28273. */
  28274. onMaterialChangedObservable: Observable<AbstractMesh>;
  28275. /**
  28276. * Gets or sets the orientation for POV movement & rotation
  28277. */
  28278. definedFacingForward: boolean;
  28279. /** @hidden */
  28280. _occlusionQuery: Nullable<WebGLQuery>;
  28281. /** @hidden */
  28282. _renderingGroup: Nullable<RenderingGroup>;
  28283. /**
  28284. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28285. */
  28286. /**
  28287. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28288. */
  28289. visibility: number;
  28290. /** Gets or sets the alpha index used to sort transparent meshes
  28291. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28292. */
  28293. alphaIndex: number;
  28294. /**
  28295. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28296. */
  28297. isVisible: boolean;
  28298. /**
  28299. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28300. */
  28301. isPickable: boolean;
  28302. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28303. showSubMeshesBoundingBox: boolean;
  28304. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28305. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28306. */
  28307. isBlocker: boolean;
  28308. /**
  28309. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28310. */
  28311. enablePointerMoveEvents: boolean;
  28312. /**
  28313. * Specifies the rendering group id for this mesh (0 by default)
  28314. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28315. */
  28316. renderingGroupId: number;
  28317. private _material;
  28318. /** Gets or sets current material */
  28319. material: Nullable<Material>;
  28320. /**
  28321. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28322. * @see http://doc.babylonjs.com/babylon101/shadows
  28323. */
  28324. receiveShadows: boolean;
  28325. /** Defines color to use when rendering outline */
  28326. outlineColor: Color3;
  28327. /** Define width to use when rendering outline */
  28328. outlineWidth: number;
  28329. /** Defines color to use when rendering overlay */
  28330. overlayColor: Color3;
  28331. /** Defines alpha to use when rendering overlay */
  28332. overlayAlpha: number;
  28333. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28334. hasVertexAlpha: boolean;
  28335. /** 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) */
  28336. useVertexColors: boolean;
  28337. /**
  28338. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28339. */
  28340. computeBonesUsingShaders: boolean;
  28341. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28342. numBoneInfluencers: number;
  28343. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28344. applyFog: boolean;
  28345. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28346. useOctreeForRenderingSelection: boolean;
  28347. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28348. useOctreeForPicking: boolean;
  28349. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28350. useOctreeForCollisions: boolean;
  28351. /**
  28352. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28353. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28354. */
  28355. layerMask: number;
  28356. /**
  28357. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28358. */
  28359. alwaysSelectAsActiveMesh: boolean;
  28360. /**
  28361. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28362. */
  28363. doNotSyncBoundingInfo: boolean;
  28364. /**
  28365. * Gets or sets the current action manager
  28366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28367. */
  28368. actionManager: Nullable<AbstractActionManager>;
  28369. private _meshCollisionData;
  28370. /**
  28371. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28373. */
  28374. ellipsoid: Vector3;
  28375. /**
  28376. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28377. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28378. */
  28379. ellipsoidOffset: Vector3;
  28380. /**
  28381. * Gets or sets a collision mask used to mask collisions (default is -1).
  28382. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28383. */
  28384. collisionMask: number;
  28385. /**
  28386. * Gets or sets the current collision group mask (-1 by default).
  28387. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28388. */
  28389. collisionGroup: number;
  28390. /**
  28391. * Defines edge width used when edgesRenderer is enabled
  28392. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28393. */
  28394. edgesWidth: number;
  28395. /**
  28396. * Defines edge color used when edgesRenderer is enabled
  28397. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28398. */
  28399. edgesColor: Color4;
  28400. /** @hidden */
  28401. _edgesRenderer: Nullable<IEdgesRenderer>;
  28402. /** @hidden */
  28403. _masterMesh: Nullable<AbstractMesh>;
  28404. /** @hidden */
  28405. _boundingInfo: Nullable<BoundingInfo>;
  28406. /** @hidden */
  28407. _renderId: number;
  28408. /**
  28409. * Gets or sets the list of subMeshes
  28410. * @see http://doc.babylonjs.com/how_to/multi_materials
  28411. */
  28412. subMeshes: SubMesh[];
  28413. /** @hidden */
  28414. _intersectionsInProgress: AbstractMesh[];
  28415. /** @hidden */
  28416. _unIndexed: boolean;
  28417. /** @hidden */
  28418. _lightSources: Light[];
  28419. /** Gets the list of lights affecting that mesh */
  28420. readonly lightSources: Light[];
  28421. /** @hidden */
  28422. readonly _positions: Nullable<Vector3[]>;
  28423. /** @hidden */
  28424. _waitingData: {
  28425. lods: Nullable<any>;
  28426. actions: Nullable<any>;
  28427. freezeWorldMatrix: Nullable<boolean>;
  28428. };
  28429. /** @hidden */
  28430. _bonesTransformMatrices: Nullable<Float32Array>;
  28431. /** @hidden */
  28432. _transformMatrixTexture: Nullable<RawTexture>;
  28433. /**
  28434. * Gets or sets a skeleton to apply skining transformations
  28435. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28436. */
  28437. skeleton: Nullable<Skeleton>;
  28438. /**
  28439. * An event triggered when the mesh is rebuilt.
  28440. */
  28441. onRebuildObservable: Observable<AbstractMesh>;
  28442. /**
  28443. * Creates a new AbstractMesh
  28444. * @param name defines the name of the mesh
  28445. * @param scene defines the hosting scene
  28446. */
  28447. constructor(name: string, scene?: Nullable<Scene>);
  28448. /**
  28449. * Returns the string "AbstractMesh"
  28450. * @returns "AbstractMesh"
  28451. */
  28452. getClassName(): string;
  28453. /**
  28454. * Gets a string representation of the current mesh
  28455. * @param fullDetails defines a boolean indicating if full details must be included
  28456. * @returns a string representation of the current mesh
  28457. */
  28458. toString(fullDetails?: boolean): string;
  28459. /**
  28460. * @hidden
  28461. */
  28462. protected _getEffectiveParent(): Nullable<Node>;
  28463. /** @hidden */
  28464. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28465. /** @hidden */
  28466. _rebuild(): void;
  28467. /** @hidden */
  28468. _resyncLightSources(): void;
  28469. /** @hidden */
  28470. _resyncLightSource(light: Light): void;
  28471. /** @hidden */
  28472. _unBindEffect(): void;
  28473. /** @hidden */
  28474. _removeLightSource(light: Light, dispose: boolean): void;
  28475. private _markSubMeshesAsDirty;
  28476. /** @hidden */
  28477. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28478. /** @hidden */
  28479. _markSubMeshesAsAttributesDirty(): void;
  28480. /** @hidden */
  28481. _markSubMeshesAsMiscDirty(): void;
  28482. /**
  28483. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28484. */
  28485. scaling: Vector3;
  28486. /**
  28487. * Returns true if the mesh is blocked. Implemented by child classes
  28488. */
  28489. readonly isBlocked: boolean;
  28490. /**
  28491. * Returns the mesh itself by default. Implemented by child classes
  28492. * @param camera defines the camera to use to pick the right LOD level
  28493. * @returns the currentAbstractMesh
  28494. */
  28495. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28496. /**
  28497. * Returns 0 by default. Implemented by child classes
  28498. * @returns an integer
  28499. */
  28500. getTotalVertices(): number;
  28501. /**
  28502. * Returns a positive integer : the total number of indices in this mesh geometry.
  28503. * @returns the numner of indices or zero if the mesh has no geometry.
  28504. */
  28505. getTotalIndices(): number;
  28506. /**
  28507. * Returns null by default. Implemented by child classes
  28508. * @returns null
  28509. */
  28510. getIndices(): Nullable<IndicesArray>;
  28511. /**
  28512. * Returns the array of the requested vertex data kind. Implemented by child classes
  28513. * @param kind defines the vertex data kind to use
  28514. * @returns null
  28515. */
  28516. getVerticesData(kind: string): Nullable<FloatArray>;
  28517. /**
  28518. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28519. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28520. * Note that a new underlying VertexBuffer object is created each call.
  28521. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28522. * @param kind defines vertex data kind:
  28523. * * VertexBuffer.PositionKind
  28524. * * VertexBuffer.UVKind
  28525. * * VertexBuffer.UV2Kind
  28526. * * VertexBuffer.UV3Kind
  28527. * * VertexBuffer.UV4Kind
  28528. * * VertexBuffer.UV5Kind
  28529. * * VertexBuffer.UV6Kind
  28530. * * VertexBuffer.ColorKind
  28531. * * VertexBuffer.MatricesIndicesKind
  28532. * * VertexBuffer.MatricesIndicesExtraKind
  28533. * * VertexBuffer.MatricesWeightsKind
  28534. * * VertexBuffer.MatricesWeightsExtraKind
  28535. * @param data defines the data source
  28536. * @param updatable defines if the data must be flagged as updatable (or static)
  28537. * @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
  28538. * @returns the current mesh
  28539. */
  28540. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28541. /**
  28542. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28543. * If the mesh has no geometry, it is simply returned as it is.
  28544. * @param kind defines vertex data kind:
  28545. * * VertexBuffer.PositionKind
  28546. * * VertexBuffer.UVKind
  28547. * * VertexBuffer.UV2Kind
  28548. * * VertexBuffer.UV3Kind
  28549. * * VertexBuffer.UV4Kind
  28550. * * VertexBuffer.UV5Kind
  28551. * * VertexBuffer.UV6Kind
  28552. * * VertexBuffer.ColorKind
  28553. * * VertexBuffer.MatricesIndicesKind
  28554. * * VertexBuffer.MatricesIndicesExtraKind
  28555. * * VertexBuffer.MatricesWeightsKind
  28556. * * VertexBuffer.MatricesWeightsExtraKind
  28557. * @param data defines the data source
  28558. * @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
  28559. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28560. * @returns the current mesh
  28561. */
  28562. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28563. /**
  28564. * Sets the mesh indices,
  28565. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28566. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28567. * @param totalVertices Defines the total number of vertices
  28568. * @returns the current mesh
  28569. */
  28570. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28571. /**
  28572. * Gets a boolean indicating if specific vertex data is present
  28573. * @param kind defines the vertex data kind to use
  28574. * @returns true is data kind is present
  28575. */
  28576. isVerticesDataPresent(kind: string): boolean;
  28577. /**
  28578. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28579. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28580. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28581. * @returns a BoundingInfo
  28582. */
  28583. getBoundingInfo(): BoundingInfo;
  28584. /**
  28585. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28586. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28587. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28588. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28589. * @returns the current mesh
  28590. */
  28591. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28592. /**
  28593. * Overwrite the current bounding info
  28594. * @param boundingInfo defines the new bounding info
  28595. * @returns the current mesh
  28596. */
  28597. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28598. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28599. readonly useBones: boolean;
  28600. /** @hidden */
  28601. _preActivate(): void;
  28602. /** @hidden */
  28603. _preActivateForIntermediateRendering(renderId: number): void;
  28604. /** @hidden */
  28605. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28606. /** @hidden */
  28607. _postActivate(): void;
  28608. /** @hidden */
  28609. _freeze(): void;
  28610. /** @hidden */
  28611. _unFreeze(): void;
  28612. /**
  28613. * Gets the current world matrix
  28614. * @returns a Matrix
  28615. */
  28616. getWorldMatrix(): Matrix;
  28617. /** @hidden */
  28618. _getWorldMatrixDeterminant(): number;
  28619. /**
  28620. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28621. */
  28622. readonly isAnInstance: boolean;
  28623. /**
  28624. * Gets a boolean indicating if this mesh has instances
  28625. */
  28626. readonly hasInstances: boolean;
  28627. /**
  28628. * Perform relative position change from the point of view of behind the front of the mesh.
  28629. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28630. * Supports definition of mesh facing forward or backward
  28631. * @param amountRight defines the distance on the right axis
  28632. * @param amountUp defines the distance on the up axis
  28633. * @param amountForward defines the distance on the forward axis
  28634. * @returns the current mesh
  28635. */
  28636. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28637. /**
  28638. * Calculate relative position change from the point of view of behind the front of the mesh.
  28639. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28640. * Supports definition of mesh facing forward or backward
  28641. * @param amountRight defines the distance on the right axis
  28642. * @param amountUp defines the distance on the up axis
  28643. * @param amountForward defines the distance on the forward axis
  28644. * @returns the new displacement vector
  28645. */
  28646. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28647. /**
  28648. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28649. * Supports definition of mesh facing forward or backward
  28650. * @param flipBack defines the flip
  28651. * @param twirlClockwise defines the twirl
  28652. * @param tiltRight defines the tilt
  28653. * @returns the current mesh
  28654. */
  28655. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28656. /**
  28657. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28658. * Supports definition of mesh facing forward or backward.
  28659. * @param flipBack defines the flip
  28660. * @param twirlClockwise defines the twirl
  28661. * @param tiltRight defines the tilt
  28662. * @returns the new rotation vector
  28663. */
  28664. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28665. /**
  28666. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28667. * This means the mesh underlying bounding box and sphere are recomputed.
  28668. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28669. * @returns the current mesh
  28670. */
  28671. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28672. /** @hidden */
  28673. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28674. /** @hidden */
  28675. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28676. /** @hidden */
  28677. _updateBoundingInfo(): AbstractMesh;
  28678. /** @hidden */
  28679. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28680. /** @hidden */
  28681. protected _afterComputeWorldMatrix(): void;
  28682. /** @hidden */
  28683. readonly _effectiveMesh: AbstractMesh;
  28684. /**
  28685. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28686. * A mesh is in the frustum if its bounding box intersects the frustum
  28687. * @param frustumPlanes defines the frustum to test
  28688. * @returns true if the mesh is in the frustum planes
  28689. */
  28690. isInFrustum(frustumPlanes: Plane[]): boolean;
  28691. /**
  28692. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28693. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28694. * @param frustumPlanes defines the frustum to test
  28695. * @returns true if the mesh is completely in the frustum planes
  28696. */
  28697. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28698. /**
  28699. * True if the mesh intersects another mesh or a SolidParticle object
  28700. * @param mesh defines a target mesh or SolidParticle to test
  28701. * @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)
  28702. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28703. * @returns true if there is an intersection
  28704. */
  28705. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28706. /**
  28707. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28708. * @param point defines the point to test
  28709. * @returns true if there is an intersection
  28710. */
  28711. intersectsPoint(point: Vector3): boolean;
  28712. /**
  28713. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28714. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28715. */
  28716. checkCollisions: boolean;
  28717. /**
  28718. * Gets Collider object used to compute collisions (not physics)
  28719. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28720. */
  28721. readonly collider: Nullable<Collider>;
  28722. /**
  28723. * Move the mesh using collision engine
  28724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28725. * @param displacement defines the requested displacement vector
  28726. * @returns the current mesh
  28727. */
  28728. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28729. private _onCollisionPositionChange;
  28730. /** @hidden */
  28731. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28732. /** @hidden */
  28733. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28734. /** @hidden */
  28735. _checkCollision(collider: Collider): AbstractMesh;
  28736. /** @hidden */
  28737. _generatePointsArray(): boolean;
  28738. /**
  28739. * Checks if the passed Ray intersects with the mesh
  28740. * @param ray defines the ray to use
  28741. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28742. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28743. * @returns the picking info
  28744. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28745. */
  28746. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28747. /**
  28748. * Clones the current mesh
  28749. * @param name defines the mesh name
  28750. * @param newParent defines the new mesh parent
  28751. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28752. * @returns the new mesh
  28753. */
  28754. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28755. /**
  28756. * Disposes all the submeshes of the current meshnp
  28757. * @returns the current mesh
  28758. */
  28759. releaseSubMeshes(): AbstractMesh;
  28760. /**
  28761. * Releases resources associated with this abstract mesh.
  28762. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28763. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28764. */
  28765. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28766. /**
  28767. * Adds the passed mesh as a child to the current mesh
  28768. * @param mesh defines the child mesh
  28769. * @returns the current mesh
  28770. */
  28771. addChild(mesh: AbstractMesh): AbstractMesh;
  28772. /**
  28773. * Removes the passed mesh from the current mesh children list
  28774. * @param mesh defines the child mesh
  28775. * @returns the current mesh
  28776. */
  28777. removeChild(mesh: AbstractMesh): AbstractMesh;
  28778. /** @hidden */
  28779. private _initFacetData;
  28780. /**
  28781. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28782. * This method can be called within the render loop.
  28783. * 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
  28784. * @returns the current mesh
  28785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28786. */
  28787. updateFacetData(): AbstractMesh;
  28788. /**
  28789. * Returns the facetLocalNormals array.
  28790. * The normals are expressed in the mesh local spac
  28791. * @returns an array of Vector3
  28792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28793. */
  28794. getFacetLocalNormals(): Vector3[];
  28795. /**
  28796. * Returns the facetLocalPositions array.
  28797. * The facet positions are expressed in the mesh local space
  28798. * @returns an array of Vector3
  28799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28800. */
  28801. getFacetLocalPositions(): Vector3[];
  28802. /**
  28803. * Returns the facetLocalPartioning array
  28804. * @returns an array of array of numbers
  28805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28806. */
  28807. getFacetLocalPartitioning(): number[][];
  28808. /**
  28809. * Returns the i-th facet position in the world system.
  28810. * This method allocates a new Vector3 per call
  28811. * @param i defines the facet index
  28812. * @returns a new Vector3
  28813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28814. */
  28815. getFacetPosition(i: number): Vector3;
  28816. /**
  28817. * Sets the reference Vector3 with the i-th facet position in the world system
  28818. * @param i defines the facet index
  28819. * @param ref defines the target vector
  28820. * @returns the current mesh
  28821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28822. */
  28823. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28824. /**
  28825. * Returns the i-th facet normal in the world system.
  28826. * This method allocates a new Vector3 per call
  28827. * @param i defines the facet index
  28828. * @returns a new Vector3
  28829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28830. */
  28831. getFacetNormal(i: number): Vector3;
  28832. /**
  28833. * Sets the reference Vector3 with the i-th facet normal in the world system
  28834. * @param i defines the facet index
  28835. * @param ref defines the target vector
  28836. * @returns the current mesh
  28837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28838. */
  28839. getFacetNormalToRef(i: number, ref: Vector3): this;
  28840. /**
  28841. * 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)
  28842. * @param x defines x coordinate
  28843. * @param y defines y coordinate
  28844. * @param z defines z coordinate
  28845. * @returns the array of facet indexes
  28846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28847. */
  28848. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28849. /**
  28850. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28851. * @param projected sets as the (x,y,z) world projection on the facet
  28852. * @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
  28853. * @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
  28854. * @param x defines x coordinate
  28855. * @param y defines y coordinate
  28856. * @param z defines z coordinate
  28857. * @returns the face index if found (or null instead)
  28858. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28859. */
  28860. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28861. /**
  28862. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28863. * @param projected sets as the (x,y,z) local projection on the facet
  28864. * @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
  28865. * @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
  28866. * @param x defines x coordinate
  28867. * @param y defines y coordinate
  28868. * @param z defines z coordinate
  28869. * @returns the face index if found (or null instead)
  28870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28871. */
  28872. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28873. /**
  28874. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28875. * @returns the parameters
  28876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28877. */
  28878. getFacetDataParameters(): any;
  28879. /**
  28880. * Disables the feature FacetData and frees the related memory
  28881. * @returns the current mesh
  28882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28883. */
  28884. disableFacetData(): AbstractMesh;
  28885. /**
  28886. * Updates the AbstractMesh indices array
  28887. * @param indices defines the data source
  28888. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28889. * @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)
  28890. * @returns the current mesh
  28891. */
  28892. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28893. /**
  28894. * Creates new normals data for the mesh
  28895. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28896. * @returns the current mesh
  28897. */
  28898. createNormals(updatable: boolean): AbstractMesh;
  28899. /**
  28900. * Align the mesh with a normal
  28901. * @param normal defines the normal to use
  28902. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28903. * @returns the current mesh
  28904. */
  28905. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28906. /** @hidden */
  28907. _checkOcclusionQuery(): boolean;
  28908. /**
  28909. * Disables the mesh edge rendering mode
  28910. * @returns the currentAbstractMesh
  28911. */
  28912. disableEdgesRendering(): AbstractMesh;
  28913. /**
  28914. * Enables the edge rendering mode on the mesh.
  28915. * This mode makes the mesh edges visible
  28916. * @param epsilon defines the maximal distance between two angles to detect a face
  28917. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28918. * @returns the currentAbstractMesh
  28919. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28920. */
  28921. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28922. }
  28923. }
  28924. declare module "babylonjs/Actions/actionEvent" {
  28925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28926. import { Nullable } from "babylonjs/types";
  28927. import { Sprite } from "babylonjs/Sprites/sprite";
  28928. import { Scene } from "babylonjs/scene";
  28929. import { Vector2 } from "babylonjs/Maths/math.vector";
  28930. /**
  28931. * Interface used to define ActionEvent
  28932. */
  28933. export interface IActionEvent {
  28934. /** The mesh or sprite that triggered the action */
  28935. source: any;
  28936. /** The X mouse cursor position at the time of the event */
  28937. pointerX: number;
  28938. /** The Y mouse cursor position at the time of the event */
  28939. pointerY: number;
  28940. /** The mesh that is currently pointed at (can be null) */
  28941. meshUnderPointer: Nullable<AbstractMesh>;
  28942. /** the original (browser) event that triggered the ActionEvent */
  28943. sourceEvent?: any;
  28944. /** additional data for the event */
  28945. additionalData?: any;
  28946. }
  28947. /**
  28948. * ActionEvent is the event being sent when an action is triggered.
  28949. */
  28950. export class ActionEvent implements IActionEvent {
  28951. /** The mesh or sprite that triggered the action */
  28952. source: any;
  28953. /** The X mouse cursor position at the time of the event */
  28954. pointerX: number;
  28955. /** The Y mouse cursor position at the time of the event */
  28956. pointerY: number;
  28957. /** The mesh that is currently pointed at (can be null) */
  28958. meshUnderPointer: Nullable<AbstractMesh>;
  28959. /** the original (browser) event that triggered the ActionEvent */
  28960. sourceEvent?: any;
  28961. /** additional data for the event */
  28962. additionalData?: any;
  28963. /**
  28964. * Creates a new ActionEvent
  28965. * @param source The mesh or sprite that triggered the action
  28966. * @param pointerX The X mouse cursor position at the time of the event
  28967. * @param pointerY The Y mouse cursor position at the time of the event
  28968. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28969. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28970. * @param additionalData additional data for the event
  28971. */
  28972. constructor(
  28973. /** The mesh or sprite that triggered the action */
  28974. source: any,
  28975. /** The X mouse cursor position at the time of the event */
  28976. pointerX: number,
  28977. /** The Y mouse cursor position at the time of the event */
  28978. pointerY: number,
  28979. /** The mesh that is currently pointed at (can be null) */
  28980. meshUnderPointer: Nullable<AbstractMesh>,
  28981. /** the original (browser) event that triggered the ActionEvent */
  28982. sourceEvent?: any,
  28983. /** additional data for the event */
  28984. additionalData?: any);
  28985. /**
  28986. * Helper function to auto-create an ActionEvent from a source mesh.
  28987. * @param source The source mesh that triggered the event
  28988. * @param evt The original (browser) event
  28989. * @param additionalData additional data for the event
  28990. * @returns the new ActionEvent
  28991. */
  28992. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28993. /**
  28994. * Helper function to auto-create an ActionEvent from a source sprite
  28995. * @param source The source sprite that triggered the event
  28996. * @param scene Scene associated with the sprite
  28997. * @param evt The original (browser) event
  28998. * @param additionalData additional data for the event
  28999. * @returns the new ActionEvent
  29000. */
  29001. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29002. /**
  29003. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29004. * @param scene the scene where the event occurred
  29005. * @param evt The original (browser) event
  29006. * @returns the new ActionEvent
  29007. */
  29008. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29009. /**
  29010. * Helper function to auto-create an ActionEvent from a primitive
  29011. * @param prim defines the target primitive
  29012. * @param pointerPos defines the pointer position
  29013. * @param evt The original (browser) event
  29014. * @param additionalData additional data for the event
  29015. * @returns the new ActionEvent
  29016. */
  29017. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29018. }
  29019. }
  29020. declare module "babylonjs/Actions/abstractActionManager" {
  29021. import { IDisposable } from "babylonjs/scene";
  29022. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29023. import { IAction } from "babylonjs/Actions/action";
  29024. import { Nullable } from "babylonjs/types";
  29025. /**
  29026. * Abstract class used to decouple action Manager from scene and meshes.
  29027. * Do not instantiate.
  29028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29029. */
  29030. export abstract class AbstractActionManager implements IDisposable {
  29031. /** Gets the list of active triggers */
  29032. static Triggers: {
  29033. [key: string]: number;
  29034. };
  29035. /** Gets the cursor to use when hovering items */
  29036. hoverCursor: string;
  29037. /** Gets the list of actions */
  29038. actions: IAction[];
  29039. /**
  29040. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29041. */
  29042. isRecursive: boolean;
  29043. /**
  29044. * Releases all associated resources
  29045. */
  29046. abstract dispose(): void;
  29047. /**
  29048. * Does this action manager has pointer triggers
  29049. */
  29050. abstract readonly hasPointerTriggers: boolean;
  29051. /**
  29052. * Does this action manager has pick triggers
  29053. */
  29054. abstract readonly hasPickTriggers: boolean;
  29055. /**
  29056. * Process a specific trigger
  29057. * @param trigger defines the trigger to process
  29058. * @param evt defines the event details to be processed
  29059. */
  29060. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29061. /**
  29062. * Does this action manager handles actions of any of the given triggers
  29063. * @param triggers defines the triggers to be tested
  29064. * @return a boolean indicating whether one (or more) of the triggers is handled
  29065. */
  29066. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29067. /**
  29068. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29069. * speed.
  29070. * @param triggerA defines the trigger to be tested
  29071. * @param triggerB defines the trigger to be tested
  29072. * @return a boolean indicating whether one (or more) of the triggers is handled
  29073. */
  29074. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29075. /**
  29076. * Does this action manager handles actions of a given trigger
  29077. * @param trigger defines the trigger to be tested
  29078. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29079. * @return whether the trigger is handled
  29080. */
  29081. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29082. /**
  29083. * Serialize this manager to a JSON object
  29084. * @param name defines the property name to store this manager
  29085. * @returns a JSON representation of this manager
  29086. */
  29087. abstract serialize(name: string): any;
  29088. /**
  29089. * Registers an action to this action manager
  29090. * @param action defines the action to be registered
  29091. * @return the action amended (prepared) after registration
  29092. */
  29093. abstract registerAction(action: IAction): Nullable<IAction>;
  29094. /**
  29095. * Unregisters an action to this action manager
  29096. * @param action defines the action to be unregistered
  29097. * @return a boolean indicating whether the action has been unregistered
  29098. */
  29099. abstract unregisterAction(action: IAction): Boolean;
  29100. /**
  29101. * Does exist one action manager with at least one trigger
  29102. **/
  29103. static readonly HasTriggers: boolean;
  29104. /**
  29105. * Does exist one action manager with at least one pick trigger
  29106. **/
  29107. static readonly HasPickTriggers: boolean;
  29108. /**
  29109. * Does exist one action manager that handles actions of a given trigger
  29110. * @param trigger defines the trigger to be tested
  29111. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29112. **/
  29113. static HasSpecificTrigger(trigger: number): boolean;
  29114. }
  29115. }
  29116. declare module "babylonjs/node" {
  29117. import { Scene } from "babylonjs/scene";
  29118. import { Nullable } from "babylonjs/types";
  29119. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29120. import { Engine } from "babylonjs/Engines/engine";
  29121. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29122. import { Observable } from "babylonjs/Misc/observable";
  29123. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29124. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29125. import { Animatable } from "babylonjs/Animations/animatable";
  29126. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29127. import { Animation } from "babylonjs/Animations/animation";
  29128. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29130. /**
  29131. * Defines how a node can be built from a string name.
  29132. */
  29133. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29134. /**
  29135. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29136. */
  29137. export class Node implements IBehaviorAware<Node> {
  29138. /** @hidden */
  29139. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29140. private static _NodeConstructors;
  29141. /**
  29142. * Add a new node constructor
  29143. * @param type defines the type name of the node to construct
  29144. * @param constructorFunc defines the constructor function
  29145. */
  29146. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29147. /**
  29148. * Returns a node constructor based on type name
  29149. * @param type defines the type name
  29150. * @param name defines the new node name
  29151. * @param scene defines the hosting scene
  29152. * @param options defines optional options to transmit to constructors
  29153. * @returns the new constructor or null
  29154. */
  29155. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29156. /**
  29157. * Gets or sets the name of the node
  29158. */
  29159. name: string;
  29160. /**
  29161. * Gets or sets the id of the node
  29162. */
  29163. id: string;
  29164. /**
  29165. * Gets or sets the unique id of the node
  29166. */
  29167. uniqueId: number;
  29168. /**
  29169. * Gets or sets a string used to store user defined state for the node
  29170. */
  29171. state: string;
  29172. /**
  29173. * Gets or sets an object used to store user defined information for the node
  29174. */
  29175. metadata: any;
  29176. /**
  29177. * For internal use only. Please do not use.
  29178. */
  29179. reservedDataStore: any;
  29180. /**
  29181. * List of inspectable custom properties (used by the Inspector)
  29182. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29183. */
  29184. inspectableCustomProperties: IInspectable[];
  29185. private _doNotSerialize;
  29186. /**
  29187. * Gets or sets a boolean used to define if the node must be serialized
  29188. */
  29189. doNotSerialize: boolean;
  29190. /** @hidden */
  29191. _isDisposed: boolean;
  29192. /**
  29193. * Gets a list of Animations associated with the node
  29194. */
  29195. animations: import("babylonjs/Animations/animation").Animation[];
  29196. protected _ranges: {
  29197. [name: string]: Nullable<AnimationRange>;
  29198. };
  29199. /**
  29200. * Callback raised when the node is ready to be used
  29201. */
  29202. onReady: Nullable<(node: Node) => void>;
  29203. private _isEnabled;
  29204. private _isParentEnabled;
  29205. private _isReady;
  29206. /** @hidden */
  29207. _currentRenderId: number;
  29208. private _parentUpdateId;
  29209. /** @hidden */
  29210. _childUpdateId: number;
  29211. /** @hidden */
  29212. _waitingParentId: Nullable<string>;
  29213. /** @hidden */
  29214. _scene: Scene;
  29215. /** @hidden */
  29216. _cache: any;
  29217. private _parentNode;
  29218. private _children;
  29219. /** @hidden */
  29220. _worldMatrix: Matrix;
  29221. /** @hidden */
  29222. _worldMatrixDeterminant: number;
  29223. /** @hidden */
  29224. _worldMatrixDeterminantIsDirty: boolean;
  29225. /** @hidden */
  29226. private _sceneRootNodesIndex;
  29227. /**
  29228. * Gets a boolean indicating if the node has been disposed
  29229. * @returns true if the node was disposed
  29230. */
  29231. isDisposed(): boolean;
  29232. /**
  29233. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29234. * @see https://doc.babylonjs.com/how_to/parenting
  29235. */
  29236. parent: Nullable<Node>;
  29237. /** @hidden */
  29238. _addToSceneRootNodes(): void;
  29239. /** @hidden */
  29240. _removeFromSceneRootNodes(): void;
  29241. private _animationPropertiesOverride;
  29242. /**
  29243. * Gets or sets the animation properties override
  29244. */
  29245. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29246. /**
  29247. * Gets a string idenfifying the name of the class
  29248. * @returns "Node" string
  29249. */
  29250. getClassName(): string;
  29251. /** @hidden */
  29252. readonly _isNode: boolean;
  29253. /**
  29254. * An event triggered when the mesh is disposed
  29255. */
  29256. onDisposeObservable: Observable<Node>;
  29257. private _onDisposeObserver;
  29258. /**
  29259. * Sets a callback that will be raised when the node will be disposed
  29260. */
  29261. onDispose: () => void;
  29262. /**
  29263. * Creates a new Node
  29264. * @param name the name and id to be given to this node
  29265. * @param scene the scene this node will be added to
  29266. */
  29267. constructor(name: string, scene?: Nullable<Scene>);
  29268. /**
  29269. * Gets the scene of the node
  29270. * @returns a scene
  29271. */
  29272. getScene(): Scene;
  29273. /**
  29274. * Gets the engine of the node
  29275. * @returns a Engine
  29276. */
  29277. getEngine(): Engine;
  29278. private _behaviors;
  29279. /**
  29280. * Attach a behavior to the node
  29281. * @see http://doc.babylonjs.com/features/behaviour
  29282. * @param behavior defines the behavior to attach
  29283. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29284. * @returns the current Node
  29285. */
  29286. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29287. /**
  29288. * Remove an attached behavior
  29289. * @see http://doc.babylonjs.com/features/behaviour
  29290. * @param behavior defines the behavior to attach
  29291. * @returns the current Node
  29292. */
  29293. removeBehavior(behavior: Behavior<Node>): Node;
  29294. /**
  29295. * Gets the list of attached behaviors
  29296. * @see http://doc.babylonjs.com/features/behaviour
  29297. */
  29298. readonly behaviors: Behavior<Node>[];
  29299. /**
  29300. * Gets an attached behavior by name
  29301. * @param name defines the name of the behavior to look for
  29302. * @see http://doc.babylonjs.com/features/behaviour
  29303. * @returns null if behavior was not found else the requested behavior
  29304. */
  29305. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29306. /**
  29307. * Returns the latest update of the World matrix
  29308. * @returns a Matrix
  29309. */
  29310. getWorldMatrix(): Matrix;
  29311. /** @hidden */
  29312. _getWorldMatrixDeterminant(): number;
  29313. /**
  29314. * Returns directly the latest state of the mesh World matrix.
  29315. * A Matrix is returned.
  29316. */
  29317. readonly worldMatrixFromCache: Matrix;
  29318. /** @hidden */
  29319. _initCache(): void;
  29320. /** @hidden */
  29321. updateCache(force?: boolean): void;
  29322. /** @hidden */
  29323. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29324. /** @hidden */
  29325. _updateCache(ignoreParentClass?: boolean): void;
  29326. /** @hidden */
  29327. _isSynchronized(): boolean;
  29328. /** @hidden */
  29329. _markSyncedWithParent(): void;
  29330. /** @hidden */
  29331. isSynchronizedWithParent(): boolean;
  29332. /** @hidden */
  29333. isSynchronized(): boolean;
  29334. /**
  29335. * Is this node ready to be used/rendered
  29336. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29337. * @return true if the node is ready
  29338. */
  29339. isReady(completeCheck?: boolean): boolean;
  29340. /**
  29341. * Is this node enabled?
  29342. * 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
  29343. * @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
  29344. * @return whether this node (and its parent) is enabled
  29345. */
  29346. isEnabled(checkAncestors?: boolean): boolean;
  29347. /** @hidden */
  29348. protected _syncParentEnabledState(): void;
  29349. /**
  29350. * Set the enabled state of this node
  29351. * @param value defines the new enabled state
  29352. */
  29353. setEnabled(value: boolean): void;
  29354. /**
  29355. * Is this node a descendant of the given node?
  29356. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29357. * @param ancestor defines the parent node to inspect
  29358. * @returns a boolean indicating if this node is a descendant of the given node
  29359. */
  29360. isDescendantOf(ancestor: Node): boolean;
  29361. /** @hidden */
  29362. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29363. /**
  29364. * Will return all nodes that have this node as ascendant
  29365. * @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
  29366. * @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
  29367. * @return all children nodes of all types
  29368. */
  29369. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29370. /**
  29371. * Get all child-meshes of this node
  29372. * @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)
  29373. * @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
  29374. * @returns an array of AbstractMesh
  29375. */
  29376. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29377. /**
  29378. * Get all direct children of this node
  29379. * @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
  29380. * @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)
  29381. * @returns an array of Node
  29382. */
  29383. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29384. /** @hidden */
  29385. _setReady(state: boolean): void;
  29386. /**
  29387. * Get an animation by name
  29388. * @param name defines the name of the animation to look for
  29389. * @returns null if not found else the requested animation
  29390. */
  29391. getAnimationByName(name: string): Nullable<Animation>;
  29392. /**
  29393. * Creates an animation range for this node
  29394. * @param name defines the name of the range
  29395. * @param from defines the starting key
  29396. * @param to defines the end key
  29397. */
  29398. createAnimationRange(name: string, from: number, to: number): void;
  29399. /**
  29400. * Delete a specific animation range
  29401. * @param name defines the name of the range to delete
  29402. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29403. */
  29404. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29405. /**
  29406. * Get an animation range by name
  29407. * @param name defines the name of the animation range to look for
  29408. * @returns null if not found else the requested animation range
  29409. */
  29410. getAnimationRange(name: string): Nullable<AnimationRange>;
  29411. /**
  29412. * Gets the list of all animation ranges defined on this node
  29413. * @returns an array
  29414. */
  29415. getAnimationRanges(): Nullable<AnimationRange>[];
  29416. /**
  29417. * Will start the animation sequence
  29418. * @param name defines the range frames for animation sequence
  29419. * @param loop defines if the animation should loop (false by default)
  29420. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29421. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29422. * @returns the object created for this animation. If range does not exist, it will return null
  29423. */
  29424. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29425. /**
  29426. * Serialize animation ranges into a JSON compatible object
  29427. * @returns serialization object
  29428. */
  29429. serializeAnimationRanges(): any;
  29430. /**
  29431. * Computes the world matrix of the node
  29432. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29433. * @returns the world matrix
  29434. */
  29435. computeWorldMatrix(force?: boolean): Matrix;
  29436. /**
  29437. * Releases resources associated with this node.
  29438. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29439. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29440. */
  29441. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29442. /**
  29443. * Parse animation range data from a serialization object and store them into a given node
  29444. * @param node defines where to store the animation ranges
  29445. * @param parsedNode defines the serialization object to read data from
  29446. * @param scene defines the hosting scene
  29447. */
  29448. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29449. /**
  29450. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29451. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29452. * @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
  29453. * @returns the new bounding vectors
  29454. */
  29455. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29456. min: Vector3;
  29457. max: Vector3;
  29458. };
  29459. }
  29460. }
  29461. declare module "babylonjs/Animations/animation" {
  29462. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29463. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29464. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29465. import { Nullable } from "babylonjs/types";
  29466. import { Scene } from "babylonjs/scene";
  29467. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29468. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29469. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29470. import { Node } from "babylonjs/node";
  29471. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29472. import { Size } from "babylonjs/Maths/math.size";
  29473. import { Animatable } from "babylonjs/Animations/animatable";
  29474. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29475. /**
  29476. * @hidden
  29477. */
  29478. export class _IAnimationState {
  29479. key: number;
  29480. repeatCount: number;
  29481. workValue?: any;
  29482. loopMode?: number;
  29483. offsetValue?: any;
  29484. highLimitValue?: any;
  29485. }
  29486. /**
  29487. * Class used to store any kind of animation
  29488. */
  29489. export class Animation {
  29490. /**Name of the animation */
  29491. name: string;
  29492. /**Property to animate */
  29493. targetProperty: string;
  29494. /**The frames per second of the animation */
  29495. framePerSecond: number;
  29496. /**The data type of the animation */
  29497. dataType: number;
  29498. /**The loop mode of the animation */
  29499. loopMode?: number | undefined;
  29500. /**Specifies if blending should be enabled */
  29501. enableBlending?: boolean | undefined;
  29502. /**
  29503. * Use matrix interpolation instead of using direct key value when animating matrices
  29504. */
  29505. static AllowMatricesInterpolation: boolean;
  29506. /**
  29507. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29508. */
  29509. static AllowMatrixDecomposeForInterpolation: boolean;
  29510. /**
  29511. * Stores the key frames of the animation
  29512. */
  29513. private _keys;
  29514. /**
  29515. * Stores the easing function of the animation
  29516. */
  29517. private _easingFunction;
  29518. /**
  29519. * @hidden Internal use only
  29520. */
  29521. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29522. /**
  29523. * The set of event that will be linked to this animation
  29524. */
  29525. private _events;
  29526. /**
  29527. * Stores an array of target property paths
  29528. */
  29529. targetPropertyPath: string[];
  29530. /**
  29531. * Stores the blending speed of the animation
  29532. */
  29533. blendingSpeed: number;
  29534. /**
  29535. * Stores the animation ranges for the animation
  29536. */
  29537. private _ranges;
  29538. /**
  29539. * @hidden Internal use
  29540. */
  29541. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29542. /**
  29543. * Sets up an animation
  29544. * @param property The property to animate
  29545. * @param animationType The animation type to apply
  29546. * @param framePerSecond The frames per second of the animation
  29547. * @param easingFunction The easing function used in the animation
  29548. * @returns The created animation
  29549. */
  29550. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29551. /**
  29552. * Create and start an animation on a node
  29553. * @param name defines the name of the global animation that will be run on all nodes
  29554. * @param node defines the root node where the animation will take place
  29555. * @param targetProperty defines property to animate
  29556. * @param framePerSecond defines the number of frame per second yo use
  29557. * @param totalFrame defines the number of frames in total
  29558. * @param from defines the initial value
  29559. * @param to defines the final value
  29560. * @param loopMode defines which loop mode you want to use (off by default)
  29561. * @param easingFunction defines the easing function to use (linear by default)
  29562. * @param onAnimationEnd defines the callback to call when animation end
  29563. * @returns the animatable created for this animation
  29564. */
  29565. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29566. /**
  29567. * Create and start an animation on a node and its descendants
  29568. * @param name defines the name of the global animation that will be run on all nodes
  29569. * @param node defines the root node where the animation will take place
  29570. * @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
  29571. * @param targetProperty defines property to animate
  29572. * @param framePerSecond defines the number of frame per second to use
  29573. * @param totalFrame defines the number of frames in total
  29574. * @param from defines the initial value
  29575. * @param to defines the final value
  29576. * @param loopMode defines which loop mode you want to use (off by default)
  29577. * @param easingFunction defines the easing function to use (linear by default)
  29578. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29579. * @returns the list of animatables created for all nodes
  29580. * @example https://www.babylonjs-playground.com/#MH0VLI
  29581. */
  29582. 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[]>;
  29583. /**
  29584. * Creates a new animation, merges it with the existing animations and starts it
  29585. * @param name Name of the animation
  29586. * @param node Node which contains the scene that begins the animations
  29587. * @param targetProperty Specifies which property to animate
  29588. * @param framePerSecond The frames per second of the animation
  29589. * @param totalFrame The total number of frames
  29590. * @param from The frame at the beginning of the animation
  29591. * @param to The frame at the end of the animation
  29592. * @param loopMode Specifies the loop mode of the animation
  29593. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29594. * @param onAnimationEnd Callback to run once the animation is complete
  29595. * @returns Nullable animation
  29596. */
  29597. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29598. /**
  29599. * Transition property of an host to the target Value
  29600. * @param property The property to transition
  29601. * @param targetValue The target Value of the property
  29602. * @param host The object where the property to animate belongs
  29603. * @param scene Scene used to run the animation
  29604. * @param frameRate Framerate (in frame/s) to use
  29605. * @param transition The transition type we want to use
  29606. * @param duration The duration of the animation, in milliseconds
  29607. * @param onAnimationEnd Callback trigger at the end of the animation
  29608. * @returns Nullable animation
  29609. */
  29610. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29611. /**
  29612. * Return the array of runtime animations currently using this animation
  29613. */
  29614. readonly runtimeAnimations: RuntimeAnimation[];
  29615. /**
  29616. * Specifies if any of the runtime animations are currently running
  29617. */
  29618. readonly hasRunningRuntimeAnimations: boolean;
  29619. /**
  29620. * Initializes the animation
  29621. * @param name Name of the animation
  29622. * @param targetProperty Property to animate
  29623. * @param framePerSecond The frames per second of the animation
  29624. * @param dataType The data type of the animation
  29625. * @param loopMode The loop mode of the animation
  29626. * @param enableBlending Specifies if blending should be enabled
  29627. */
  29628. constructor(
  29629. /**Name of the animation */
  29630. name: string,
  29631. /**Property to animate */
  29632. targetProperty: string,
  29633. /**The frames per second of the animation */
  29634. framePerSecond: number,
  29635. /**The data type of the animation */
  29636. dataType: number,
  29637. /**The loop mode of the animation */
  29638. loopMode?: number | undefined,
  29639. /**Specifies if blending should be enabled */
  29640. enableBlending?: boolean | undefined);
  29641. /**
  29642. * Converts the animation to a string
  29643. * @param fullDetails support for multiple levels of logging within scene loading
  29644. * @returns String form of the animation
  29645. */
  29646. toString(fullDetails?: boolean): string;
  29647. /**
  29648. * Add an event to this animation
  29649. * @param event Event to add
  29650. */
  29651. addEvent(event: AnimationEvent): void;
  29652. /**
  29653. * Remove all events found at the given frame
  29654. * @param frame The frame to remove events from
  29655. */
  29656. removeEvents(frame: number): void;
  29657. /**
  29658. * Retrieves all the events from the animation
  29659. * @returns Events from the animation
  29660. */
  29661. getEvents(): AnimationEvent[];
  29662. /**
  29663. * Creates an animation range
  29664. * @param name Name of the animation range
  29665. * @param from Starting frame of the animation range
  29666. * @param to Ending frame of the animation
  29667. */
  29668. createRange(name: string, from: number, to: number): void;
  29669. /**
  29670. * Deletes an animation range by name
  29671. * @param name Name of the animation range to delete
  29672. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29673. */
  29674. deleteRange(name: string, deleteFrames?: boolean): void;
  29675. /**
  29676. * Gets the animation range by name, or null if not defined
  29677. * @param name Name of the animation range
  29678. * @returns Nullable animation range
  29679. */
  29680. getRange(name: string): Nullable<AnimationRange>;
  29681. /**
  29682. * Gets the key frames from the animation
  29683. * @returns The key frames of the animation
  29684. */
  29685. getKeys(): Array<IAnimationKey>;
  29686. /**
  29687. * Gets the highest frame rate of the animation
  29688. * @returns Highest frame rate of the animation
  29689. */
  29690. getHighestFrame(): number;
  29691. /**
  29692. * Gets the easing function of the animation
  29693. * @returns Easing function of the animation
  29694. */
  29695. getEasingFunction(): IEasingFunction;
  29696. /**
  29697. * Sets the easing function of the animation
  29698. * @param easingFunction A custom mathematical formula for animation
  29699. */
  29700. setEasingFunction(easingFunction: EasingFunction): void;
  29701. /**
  29702. * Interpolates a scalar linearly
  29703. * @param startValue Start value of the animation curve
  29704. * @param endValue End value of the animation curve
  29705. * @param gradient Scalar amount to interpolate
  29706. * @returns Interpolated scalar value
  29707. */
  29708. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29709. /**
  29710. * Interpolates a scalar cubically
  29711. * @param startValue Start value of the animation curve
  29712. * @param outTangent End tangent of the animation
  29713. * @param endValue End value of the animation curve
  29714. * @param inTangent Start tangent of the animation curve
  29715. * @param gradient Scalar amount to interpolate
  29716. * @returns Interpolated scalar value
  29717. */
  29718. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29719. /**
  29720. * Interpolates a quaternion using a spherical linear interpolation
  29721. * @param startValue Start value of the animation curve
  29722. * @param endValue End value of the animation curve
  29723. * @param gradient Scalar amount to interpolate
  29724. * @returns Interpolated quaternion value
  29725. */
  29726. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29727. /**
  29728. * Interpolates a quaternion cubically
  29729. * @param startValue Start value of the animation curve
  29730. * @param outTangent End tangent of the animation curve
  29731. * @param endValue End value of the animation curve
  29732. * @param inTangent Start tangent of the animation curve
  29733. * @param gradient Scalar amount to interpolate
  29734. * @returns Interpolated quaternion value
  29735. */
  29736. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29737. /**
  29738. * Interpolates a Vector3 linearl
  29739. * @param startValue Start value of the animation curve
  29740. * @param endValue End value of the animation curve
  29741. * @param gradient Scalar amount to interpolate
  29742. * @returns Interpolated scalar value
  29743. */
  29744. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29745. /**
  29746. * Interpolates a Vector3 cubically
  29747. * @param startValue Start value of the animation curve
  29748. * @param outTangent End tangent of the animation
  29749. * @param endValue End value of the animation curve
  29750. * @param inTangent Start tangent of the animation curve
  29751. * @param gradient Scalar amount to interpolate
  29752. * @returns InterpolatedVector3 value
  29753. */
  29754. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29755. /**
  29756. * Interpolates a Vector2 linearly
  29757. * @param startValue Start value of the animation curve
  29758. * @param endValue End value of the animation curve
  29759. * @param gradient Scalar amount to interpolate
  29760. * @returns Interpolated Vector2 value
  29761. */
  29762. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29763. /**
  29764. * Interpolates a Vector2 cubically
  29765. * @param startValue Start value of the animation curve
  29766. * @param outTangent End tangent of the animation
  29767. * @param endValue End value of the animation curve
  29768. * @param inTangent Start tangent of the animation curve
  29769. * @param gradient Scalar amount to interpolate
  29770. * @returns Interpolated Vector2 value
  29771. */
  29772. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29773. /**
  29774. * Interpolates a size linearly
  29775. * @param startValue Start value of the animation curve
  29776. * @param endValue End value of the animation curve
  29777. * @param gradient Scalar amount to interpolate
  29778. * @returns Interpolated Size value
  29779. */
  29780. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29781. /**
  29782. * Interpolates a Color3 linearly
  29783. * @param startValue Start value of the animation curve
  29784. * @param endValue End value of the animation curve
  29785. * @param gradient Scalar amount to interpolate
  29786. * @returns Interpolated Color3 value
  29787. */
  29788. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29789. /**
  29790. * Interpolates a Color4 linearly
  29791. * @param startValue Start value of the animation curve
  29792. * @param endValue End value of the animation curve
  29793. * @param gradient Scalar amount to interpolate
  29794. * @returns Interpolated Color3 value
  29795. */
  29796. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29797. /**
  29798. * @hidden Internal use only
  29799. */
  29800. _getKeyValue(value: any): any;
  29801. /**
  29802. * @hidden Internal use only
  29803. */
  29804. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29805. /**
  29806. * Defines the function to use to interpolate matrices
  29807. * @param startValue defines the start matrix
  29808. * @param endValue defines the end matrix
  29809. * @param gradient defines the gradient between both matrices
  29810. * @param result defines an optional target matrix where to store the interpolation
  29811. * @returns the interpolated matrix
  29812. */
  29813. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29814. /**
  29815. * Makes a copy of the animation
  29816. * @returns Cloned animation
  29817. */
  29818. clone(): Animation;
  29819. /**
  29820. * Sets the key frames of the animation
  29821. * @param values The animation key frames to set
  29822. */
  29823. setKeys(values: Array<IAnimationKey>): void;
  29824. /**
  29825. * Serializes the animation to an object
  29826. * @returns Serialized object
  29827. */
  29828. serialize(): any;
  29829. /**
  29830. * Float animation type
  29831. */
  29832. static readonly ANIMATIONTYPE_FLOAT: number;
  29833. /**
  29834. * Vector3 animation type
  29835. */
  29836. static readonly ANIMATIONTYPE_VECTOR3: number;
  29837. /**
  29838. * Quaternion animation type
  29839. */
  29840. static readonly ANIMATIONTYPE_QUATERNION: number;
  29841. /**
  29842. * Matrix animation type
  29843. */
  29844. static readonly ANIMATIONTYPE_MATRIX: number;
  29845. /**
  29846. * Color3 animation type
  29847. */
  29848. static readonly ANIMATIONTYPE_COLOR3: number;
  29849. /**
  29850. * Color3 animation type
  29851. */
  29852. static readonly ANIMATIONTYPE_COLOR4: number;
  29853. /**
  29854. * Vector2 animation type
  29855. */
  29856. static readonly ANIMATIONTYPE_VECTOR2: number;
  29857. /**
  29858. * Size animation type
  29859. */
  29860. static readonly ANIMATIONTYPE_SIZE: number;
  29861. /**
  29862. * Relative Loop Mode
  29863. */
  29864. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29865. /**
  29866. * Cycle Loop Mode
  29867. */
  29868. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29869. /**
  29870. * Constant Loop Mode
  29871. */
  29872. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29873. /** @hidden */
  29874. static _UniversalLerp(left: any, right: any, amount: number): any;
  29875. /**
  29876. * Parses an animation object and creates an animation
  29877. * @param parsedAnimation Parsed animation object
  29878. * @returns Animation object
  29879. */
  29880. static Parse(parsedAnimation: any): Animation;
  29881. /**
  29882. * Appends the serialized animations from the source animations
  29883. * @param source Source containing the animations
  29884. * @param destination Target to store the animations
  29885. */
  29886. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29887. }
  29888. }
  29889. declare module "babylonjs/Animations/animatable.interface" {
  29890. import { Nullable } from "babylonjs/types";
  29891. import { Animation } from "babylonjs/Animations/animation";
  29892. /**
  29893. * Interface containing an array of animations
  29894. */
  29895. export interface IAnimatable {
  29896. /**
  29897. * Array of animations
  29898. */
  29899. animations: Nullable<Array<Animation>>;
  29900. }
  29901. }
  29902. declare module "babylonjs/Misc/decorators" {
  29903. import { Nullable } from "babylonjs/types";
  29904. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29905. import { Scene } from "babylonjs/scene";
  29906. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29907. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29908. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29909. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29910. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29911. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29912. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29913. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29914. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29915. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29916. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29917. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29918. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29919. /**
  29920. * Decorator used to define property that can be serialized as reference to a camera
  29921. * @param sourceName defines the name of the property to decorate
  29922. */
  29923. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29924. /**
  29925. * Class used to help serialization objects
  29926. */
  29927. export class SerializationHelper {
  29928. /** @hidden */
  29929. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29930. /** @hidden */
  29931. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29932. /** @hidden */
  29933. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29934. /** @hidden */
  29935. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29936. /**
  29937. * Appends the serialized animations from the source animations
  29938. * @param source Source containing the animations
  29939. * @param destination Target to store the animations
  29940. */
  29941. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29942. /**
  29943. * Static function used to serialized a specific entity
  29944. * @param entity defines the entity to serialize
  29945. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29946. * @returns a JSON compatible object representing the serialization of the entity
  29947. */
  29948. static Serialize<T>(entity: T, serializationObject?: any): any;
  29949. /**
  29950. * Creates a new entity from a serialization data object
  29951. * @param creationFunction defines a function used to instanciated the new entity
  29952. * @param source defines the source serialization data
  29953. * @param scene defines the hosting scene
  29954. * @param rootUrl defines the root url for resources
  29955. * @returns a new entity
  29956. */
  29957. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29958. /**
  29959. * Clones an object
  29960. * @param creationFunction defines the function used to instanciate the new object
  29961. * @param source defines the source object
  29962. * @returns the cloned object
  29963. */
  29964. static Clone<T>(creationFunction: () => T, source: T): T;
  29965. /**
  29966. * Instanciates a new object based on a source one (some data will be shared between both object)
  29967. * @param creationFunction defines the function used to instanciate the new object
  29968. * @param source defines the source object
  29969. * @returns the new object
  29970. */
  29971. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29972. }
  29973. }
  29974. declare module "babylonjs/Misc/guid" {
  29975. /**
  29976. * Class used to manipulate GUIDs
  29977. */
  29978. export class GUID {
  29979. /**
  29980. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29981. * Be aware Math.random() could cause collisions, but:
  29982. * "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"
  29983. * @returns a pseudo random id
  29984. */
  29985. static RandomId(): string;
  29986. }
  29987. }
  29988. declare module "babylonjs/Materials/Textures/baseTexture" {
  29989. import { Observable } from "babylonjs/Misc/observable";
  29990. import { Nullable } from "babylonjs/types";
  29991. import { Scene } from "babylonjs/scene";
  29992. import { Matrix } from "babylonjs/Maths/math.vector";
  29993. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29994. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29995. import { ISize } from "babylonjs/Maths/math.size";
  29996. /**
  29997. * Base class of all the textures in babylon.
  29998. * It groups all the common properties the materials, post process, lights... might need
  29999. * in order to make a correct use of the texture.
  30000. */
  30001. export class BaseTexture implements IAnimatable {
  30002. /**
  30003. * Default anisotropic filtering level for the application.
  30004. * It is set to 4 as a good tradeoff between perf and quality.
  30005. */
  30006. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30007. /**
  30008. * Gets or sets the unique id of the texture
  30009. */
  30010. uniqueId: number;
  30011. /**
  30012. * Define the name of the texture.
  30013. */
  30014. name: string;
  30015. /**
  30016. * Gets or sets an object used to store user defined information.
  30017. */
  30018. metadata: any;
  30019. /**
  30020. * For internal use only. Please do not use.
  30021. */
  30022. reservedDataStore: any;
  30023. private _hasAlpha;
  30024. /**
  30025. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30026. */
  30027. hasAlpha: boolean;
  30028. /**
  30029. * Defines if the alpha value should be determined via the rgb values.
  30030. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30031. */
  30032. getAlphaFromRGB: boolean;
  30033. /**
  30034. * Intensity or strength of the texture.
  30035. * It is commonly used by materials to fine tune the intensity of the texture
  30036. */
  30037. level: number;
  30038. /**
  30039. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30040. * This is part of the texture as textures usually maps to one uv set.
  30041. */
  30042. coordinatesIndex: number;
  30043. private _coordinatesMode;
  30044. /**
  30045. * How a texture is mapped.
  30046. *
  30047. * | Value | Type | Description |
  30048. * | ----- | ----------------------------------- | ----------- |
  30049. * | 0 | EXPLICIT_MODE | |
  30050. * | 1 | SPHERICAL_MODE | |
  30051. * | 2 | PLANAR_MODE | |
  30052. * | 3 | CUBIC_MODE | |
  30053. * | 4 | PROJECTION_MODE | |
  30054. * | 5 | SKYBOX_MODE | |
  30055. * | 6 | INVCUBIC_MODE | |
  30056. * | 7 | EQUIRECTANGULAR_MODE | |
  30057. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30058. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30059. */
  30060. coordinatesMode: number;
  30061. /**
  30062. * | Value | Type | Description |
  30063. * | ----- | ------------------ | ----------- |
  30064. * | 0 | CLAMP_ADDRESSMODE | |
  30065. * | 1 | WRAP_ADDRESSMODE | |
  30066. * | 2 | MIRROR_ADDRESSMODE | |
  30067. */
  30068. wrapU: number;
  30069. /**
  30070. * | Value | Type | Description |
  30071. * | ----- | ------------------ | ----------- |
  30072. * | 0 | CLAMP_ADDRESSMODE | |
  30073. * | 1 | WRAP_ADDRESSMODE | |
  30074. * | 2 | MIRROR_ADDRESSMODE | |
  30075. */
  30076. wrapV: number;
  30077. /**
  30078. * | Value | Type | Description |
  30079. * | ----- | ------------------ | ----------- |
  30080. * | 0 | CLAMP_ADDRESSMODE | |
  30081. * | 1 | WRAP_ADDRESSMODE | |
  30082. * | 2 | MIRROR_ADDRESSMODE | |
  30083. */
  30084. wrapR: number;
  30085. /**
  30086. * With compliant hardware and browser (supporting anisotropic filtering)
  30087. * this defines the level of anisotropic filtering in the texture.
  30088. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30089. */
  30090. anisotropicFilteringLevel: number;
  30091. /**
  30092. * Define if the texture is a cube texture or if false a 2d texture.
  30093. */
  30094. isCube: boolean;
  30095. /**
  30096. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30097. */
  30098. is3D: boolean;
  30099. /**
  30100. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30101. */
  30102. is2DArray: boolean;
  30103. /**
  30104. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30105. * HDR texture are usually stored in linear space.
  30106. * This only impacts the PBR and Background materials
  30107. */
  30108. gammaSpace: boolean;
  30109. /**
  30110. * Gets or sets whether or not the texture contains RGBD data.
  30111. */
  30112. isRGBD: boolean;
  30113. /**
  30114. * Is Z inverted in the texture (useful in a cube texture).
  30115. */
  30116. invertZ: boolean;
  30117. /**
  30118. * Are mip maps generated for this texture or not.
  30119. */
  30120. readonly noMipmap: boolean;
  30121. /**
  30122. * @hidden
  30123. */
  30124. lodLevelInAlpha: boolean;
  30125. /**
  30126. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30127. */
  30128. lodGenerationOffset: number;
  30129. /**
  30130. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30131. */
  30132. lodGenerationScale: number;
  30133. /**
  30134. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30135. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30136. * average roughness values.
  30137. */
  30138. linearSpecularLOD: boolean;
  30139. /**
  30140. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30141. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30142. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30143. */
  30144. irradianceTexture: Nullable<BaseTexture>;
  30145. /**
  30146. * Define if the texture is a render target.
  30147. */
  30148. isRenderTarget: boolean;
  30149. /**
  30150. * Define the unique id of the texture in the scene.
  30151. */
  30152. readonly uid: string;
  30153. /**
  30154. * Return a string representation of the texture.
  30155. * @returns the texture as a string
  30156. */
  30157. toString(): string;
  30158. /**
  30159. * Get the class name of the texture.
  30160. * @returns "BaseTexture"
  30161. */
  30162. getClassName(): string;
  30163. /**
  30164. * Define the list of animation attached to the texture.
  30165. */
  30166. animations: import("babylonjs/Animations/animation").Animation[];
  30167. /**
  30168. * An event triggered when the texture is disposed.
  30169. */
  30170. onDisposeObservable: Observable<BaseTexture>;
  30171. private _onDisposeObserver;
  30172. /**
  30173. * Callback triggered when the texture has been disposed.
  30174. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30175. */
  30176. onDispose: () => void;
  30177. /**
  30178. * Define the current state of the loading sequence when in delayed load mode.
  30179. */
  30180. delayLoadState: number;
  30181. private _scene;
  30182. /** @hidden */
  30183. _texture: Nullable<InternalTexture>;
  30184. private _uid;
  30185. /**
  30186. * Define if the texture is preventinga material to render or not.
  30187. * If not and the texture is not ready, the engine will use a default black texture instead.
  30188. */
  30189. readonly isBlocking: boolean;
  30190. /**
  30191. * Instantiates a new BaseTexture.
  30192. * Base class of all the textures in babylon.
  30193. * It groups all the common properties the materials, post process, lights... might need
  30194. * in order to make a correct use of the texture.
  30195. * @param scene Define the scene the texture blongs to
  30196. */
  30197. constructor(scene: Nullable<Scene>);
  30198. /**
  30199. * Get the scene the texture belongs to.
  30200. * @returns the scene or null if undefined
  30201. */
  30202. getScene(): Nullable<Scene>;
  30203. /**
  30204. * Get the texture transform matrix used to offset tile the texture for istance.
  30205. * @returns the transformation matrix
  30206. */
  30207. getTextureMatrix(): Matrix;
  30208. /**
  30209. * Get the texture reflection matrix used to rotate/transform the reflection.
  30210. * @returns the reflection matrix
  30211. */
  30212. getReflectionTextureMatrix(): Matrix;
  30213. /**
  30214. * Get the underlying lower level texture from Babylon.
  30215. * @returns the insternal texture
  30216. */
  30217. getInternalTexture(): Nullable<InternalTexture>;
  30218. /**
  30219. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30220. * @returns true if ready or not blocking
  30221. */
  30222. isReadyOrNotBlocking(): boolean;
  30223. /**
  30224. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30225. * @returns true if fully ready
  30226. */
  30227. isReady(): boolean;
  30228. private _cachedSize;
  30229. /**
  30230. * Get the size of the texture.
  30231. * @returns the texture size.
  30232. */
  30233. getSize(): ISize;
  30234. /**
  30235. * Get the base size of the texture.
  30236. * It can be different from the size if the texture has been resized for POT for instance
  30237. * @returns the base size
  30238. */
  30239. getBaseSize(): ISize;
  30240. /**
  30241. * Update the sampling mode of the texture.
  30242. * Default is Trilinear mode.
  30243. *
  30244. * | Value | Type | Description |
  30245. * | ----- | ------------------ | ----------- |
  30246. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30247. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30248. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30249. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30250. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30251. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30252. * | 7 | NEAREST_LINEAR | |
  30253. * | 8 | NEAREST_NEAREST | |
  30254. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30255. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30256. * | 11 | LINEAR_LINEAR | |
  30257. * | 12 | LINEAR_NEAREST | |
  30258. *
  30259. * > _mag_: magnification filter (close to the viewer)
  30260. * > _min_: minification filter (far from the viewer)
  30261. * > _mip_: filter used between mip map levels
  30262. *@param samplingMode Define the new sampling mode of the texture
  30263. */
  30264. updateSamplingMode(samplingMode: number): void;
  30265. /**
  30266. * Scales the texture if is `canRescale()`
  30267. * @param ratio the resize factor we want to use to rescale
  30268. */
  30269. scale(ratio: number): void;
  30270. /**
  30271. * Get if the texture can rescale.
  30272. */
  30273. readonly canRescale: boolean;
  30274. /** @hidden */
  30275. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30276. /** @hidden */
  30277. _rebuild(): void;
  30278. /**
  30279. * Triggers the load sequence in delayed load mode.
  30280. */
  30281. delayLoad(): void;
  30282. /**
  30283. * Clones the texture.
  30284. * @returns the cloned texture
  30285. */
  30286. clone(): Nullable<BaseTexture>;
  30287. /**
  30288. * Get the texture underlying type (INT, FLOAT...)
  30289. */
  30290. readonly textureType: number;
  30291. /**
  30292. * Get the texture underlying format (RGB, RGBA...)
  30293. */
  30294. readonly textureFormat: number;
  30295. /**
  30296. * Indicates that textures need to be re-calculated for all materials
  30297. */
  30298. protected _markAllSubMeshesAsTexturesDirty(): void;
  30299. /**
  30300. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30301. * This will returns an RGBA array buffer containing either in values (0-255) or
  30302. * float values (0-1) depending of the underlying buffer type.
  30303. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30304. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30305. * @param buffer defines a user defined buffer to fill with data (can be null)
  30306. * @returns The Array buffer containing the pixels data.
  30307. */
  30308. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30309. /**
  30310. * Release and destroy the underlying lower level texture aka internalTexture.
  30311. */
  30312. releaseInternalTexture(): void;
  30313. /** @hidden */
  30314. readonly _lodTextureHigh: Nullable<BaseTexture>;
  30315. /** @hidden */
  30316. readonly _lodTextureMid: Nullable<BaseTexture>;
  30317. /** @hidden */
  30318. readonly _lodTextureLow: Nullable<BaseTexture>;
  30319. /**
  30320. * Dispose the texture and release its associated resources.
  30321. */
  30322. dispose(): void;
  30323. /**
  30324. * Serialize the texture into a JSON representation that can be parsed later on.
  30325. * @returns the JSON representation of the texture
  30326. */
  30327. serialize(): any;
  30328. /**
  30329. * Helper function to be called back once a list of texture contains only ready textures.
  30330. * @param textures Define the list of textures to wait for
  30331. * @param callback Define the callback triggered once the entire list will be ready
  30332. */
  30333. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30334. }
  30335. }
  30336. declare module "babylonjs/Materials/effect" {
  30337. import { Observable } from "babylonjs/Misc/observable";
  30338. import { Nullable } from "babylonjs/types";
  30339. import { IDisposable } from "babylonjs/scene";
  30340. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30341. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30342. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30343. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30344. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30345. import { Engine } from "babylonjs/Engines/engine";
  30346. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30347. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30349. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30350. /**
  30351. * Options to be used when creating an effect.
  30352. */
  30353. export interface IEffectCreationOptions {
  30354. /**
  30355. * Atrributes that will be used in the shader.
  30356. */
  30357. attributes: string[];
  30358. /**
  30359. * Uniform varible names that will be set in the shader.
  30360. */
  30361. uniformsNames: string[];
  30362. /**
  30363. * Uniform buffer variable names that will be set in the shader.
  30364. */
  30365. uniformBuffersNames: string[];
  30366. /**
  30367. * Sampler texture variable names that will be set in the shader.
  30368. */
  30369. samplers: string[];
  30370. /**
  30371. * Define statements that will be set in the shader.
  30372. */
  30373. defines: any;
  30374. /**
  30375. * Possible fallbacks for this effect to improve performance when needed.
  30376. */
  30377. fallbacks: Nullable<IEffectFallbacks>;
  30378. /**
  30379. * Callback that will be called when the shader is compiled.
  30380. */
  30381. onCompiled: Nullable<(effect: Effect) => void>;
  30382. /**
  30383. * Callback that will be called if an error occurs during shader compilation.
  30384. */
  30385. onError: Nullable<(effect: Effect, errors: string) => void>;
  30386. /**
  30387. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30388. */
  30389. indexParameters?: any;
  30390. /**
  30391. * Max number of lights that can be used in the shader.
  30392. */
  30393. maxSimultaneousLights?: number;
  30394. /**
  30395. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30396. */
  30397. transformFeedbackVaryings?: Nullable<string[]>;
  30398. }
  30399. /**
  30400. * Effect containing vertex and fragment shader that can be executed on an object.
  30401. */
  30402. export class Effect implements IDisposable {
  30403. /**
  30404. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30405. */
  30406. static ShadersRepository: string;
  30407. /**
  30408. * Name of the effect.
  30409. */
  30410. name: any;
  30411. /**
  30412. * String container all the define statements that should be set on the shader.
  30413. */
  30414. defines: string;
  30415. /**
  30416. * Callback that will be called when the shader is compiled.
  30417. */
  30418. onCompiled: Nullable<(effect: Effect) => void>;
  30419. /**
  30420. * Callback that will be called if an error occurs during shader compilation.
  30421. */
  30422. onError: Nullable<(effect: Effect, errors: string) => void>;
  30423. /**
  30424. * Callback that will be called when effect is bound.
  30425. */
  30426. onBind: Nullable<(effect: Effect) => void>;
  30427. /**
  30428. * Unique ID of the effect.
  30429. */
  30430. uniqueId: number;
  30431. /**
  30432. * Observable that will be called when the shader is compiled.
  30433. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30434. */
  30435. onCompileObservable: Observable<Effect>;
  30436. /**
  30437. * Observable that will be called if an error occurs during shader compilation.
  30438. */
  30439. onErrorObservable: Observable<Effect>;
  30440. /** @hidden */
  30441. _onBindObservable: Nullable<Observable<Effect>>;
  30442. /**
  30443. * Observable that will be called when effect is bound.
  30444. */
  30445. readonly onBindObservable: Observable<Effect>;
  30446. /** @hidden */
  30447. _bonesComputationForcedToCPU: boolean;
  30448. private static _uniqueIdSeed;
  30449. private _engine;
  30450. private _uniformBuffersNames;
  30451. private _uniformsNames;
  30452. private _samplerList;
  30453. private _samplers;
  30454. private _isReady;
  30455. private _compilationError;
  30456. private _allFallbacksProcessed;
  30457. private _attributesNames;
  30458. private _attributes;
  30459. private _uniforms;
  30460. /**
  30461. * Key for the effect.
  30462. * @hidden
  30463. */
  30464. _key: string;
  30465. private _indexParameters;
  30466. private _fallbacks;
  30467. private _vertexSourceCode;
  30468. private _fragmentSourceCode;
  30469. private _vertexSourceCodeOverride;
  30470. private _fragmentSourceCodeOverride;
  30471. private _transformFeedbackVaryings;
  30472. /**
  30473. * Compiled shader to webGL program.
  30474. * @hidden
  30475. */
  30476. _pipelineContext: Nullable<IPipelineContext>;
  30477. private _valueCache;
  30478. private static _baseCache;
  30479. /**
  30480. * Instantiates an effect.
  30481. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30482. * @param baseName Name of the effect.
  30483. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30484. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30485. * @param samplers List of sampler variables that will be passed to the shader.
  30486. * @param engine Engine to be used to render the effect
  30487. * @param defines Define statements to be added to the shader.
  30488. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30489. * @param onCompiled Callback that will be called when the shader is compiled.
  30490. * @param onError Callback that will be called if an error occurs during shader compilation.
  30491. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30492. */
  30493. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30494. private _useFinalCode;
  30495. /**
  30496. * Unique key for this effect
  30497. */
  30498. readonly key: string;
  30499. /**
  30500. * If the effect has been compiled and prepared.
  30501. * @returns if the effect is compiled and prepared.
  30502. */
  30503. isReady(): boolean;
  30504. private _isReadyInternal;
  30505. /**
  30506. * The engine the effect was initialized with.
  30507. * @returns the engine.
  30508. */
  30509. getEngine(): Engine;
  30510. /**
  30511. * The pipeline context for this effect
  30512. * @returns the associated pipeline context
  30513. */
  30514. getPipelineContext(): Nullable<IPipelineContext>;
  30515. /**
  30516. * The set of names of attribute variables for the shader.
  30517. * @returns An array of attribute names.
  30518. */
  30519. getAttributesNames(): string[];
  30520. /**
  30521. * Returns the attribute at the given index.
  30522. * @param index The index of the attribute.
  30523. * @returns The location of the attribute.
  30524. */
  30525. getAttributeLocation(index: number): number;
  30526. /**
  30527. * Returns the attribute based on the name of the variable.
  30528. * @param name of the attribute to look up.
  30529. * @returns the attribute location.
  30530. */
  30531. getAttributeLocationByName(name: string): number;
  30532. /**
  30533. * The number of attributes.
  30534. * @returns the numnber of attributes.
  30535. */
  30536. getAttributesCount(): number;
  30537. /**
  30538. * Gets the index of a uniform variable.
  30539. * @param uniformName of the uniform to look up.
  30540. * @returns the index.
  30541. */
  30542. getUniformIndex(uniformName: string): number;
  30543. /**
  30544. * Returns the attribute based on the name of the variable.
  30545. * @param uniformName of the uniform to look up.
  30546. * @returns the location of the uniform.
  30547. */
  30548. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30549. /**
  30550. * Returns an array of sampler variable names
  30551. * @returns The array of sampler variable neames.
  30552. */
  30553. getSamplers(): string[];
  30554. /**
  30555. * The error from the last compilation.
  30556. * @returns the error string.
  30557. */
  30558. getCompilationError(): string;
  30559. /**
  30560. * Gets a boolean indicating that all fallbacks were used during compilation
  30561. * @returns true if all fallbacks were used
  30562. */
  30563. allFallbacksProcessed(): boolean;
  30564. /**
  30565. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30566. * @param func The callback to be used.
  30567. */
  30568. executeWhenCompiled(func: (effect: Effect) => void): void;
  30569. private _checkIsReady;
  30570. private _loadShader;
  30571. /**
  30572. * Recompiles the webGL program
  30573. * @param vertexSourceCode The source code for the vertex shader.
  30574. * @param fragmentSourceCode The source code for the fragment shader.
  30575. * @param onCompiled Callback called when completed.
  30576. * @param onError Callback called on error.
  30577. * @hidden
  30578. */
  30579. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30580. /**
  30581. * Prepares the effect
  30582. * @hidden
  30583. */
  30584. _prepareEffect(): void;
  30585. private _processCompilationErrors;
  30586. /**
  30587. * Checks if the effect is supported. (Must be called after compilation)
  30588. */
  30589. readonly isSupported: boolean;
  30590. /**
  30591. * Binds a texture to the engine to be used as output of the shader.
  30592. * @param channel Name of the output variable.
  30593. * @param texture Texture to bind.
  30594. * @hidden
  30595. */
  30596. _bindTexture(channel: string, texture: InternalTexture): void;
  30597. /**
  30598. * Sets a texture on the engine to be used in the shader.
  30599. * @param channel Name of the sampler variable.
  30600. * @param texture Texture to set.
  30601. */
  30602. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30603. /**
  30604. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30605. * @param channel Name of the sampler variable.
  30606. * @param texture Texture to set.
  30607. */
  30608. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30609. /**
  30610. * Sets an array of textures on the engine to be used in the shader.
  30611. * @param channel Name of the variable.
  30612. * @param textures Textures to set.
  30613. */
  30614. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30615. /**
  30616. * 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)
  30617. * @param channel Name of the sampler variable.
  30618. * @param postProcess Post process to get the input texture from.
  30619. */
  30620. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30621. /**
  30622. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30623. * 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)
  30624. * @param channel Name of the sampler variable.
  30625. * @param postProcess Post process to get the output texture from.
  30626. */
  30627. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30628. /** @hidden */
  30629. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30630. /** @hidden */
  30631. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30632. /** @hidden */
  30633. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30634. /** @hidden */
  30635. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30636. /**
  30637. * Binds a buffer to a uniform.
  30638. * @param buffer Buffer to bind.
  30639. * @param name Name of the uniform variable to bind to.
  30640. */
  30641. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30642. /**
  30643. * Binds block to a uniform.
  30644. * @param blockName Name of the block to bind.
  30645. * @param index Index to bind.
  30646. */
  30647. bindUniformBlock(blockName: string, index: number): void;
  30648. /**
  30649. * Sets an interger value on a uniform variable.
  30650. * @param uniformName Name of the variable.
  30651. * @param value Value to be set.
  30652. * @returns this effect.
  30653. */
  30654. setInt(uniformName: string, value: number): Effect;
  30655. /**
  30656. * Sets an int array on a uniform variable.
  30657. * @param uniformName Name of the variable.
  30658. * @param array array to be set.
  30659. * @returns this effect.
  30660. */
  30661. setIntArray(uniformName: string, array: Int32Array): Effect;
  30662. /**
  30663. * 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)
  30664. * @param uniformName Name of the variable.
  30665. * @param array array to be set.
  30666. * @returns this effect.
  30667. */
  30668. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30669. /**
  30670. * 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)
  30671. * @param uniformName Name of the variable.
  30672. * @param array array to be set.
  30673. * @returns this effect.
  30674. */
  30675. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30676. /**
  30677. * 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)
  30678. * @param uniformName Name of the variable.
  30679. * @param array array to be set.
  30680. * @returns this effect.
  30681. */
  30682. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30683. /**
  30684. * Sets an float array on a uniform variable.
  30685. * @param uniformName Name of the variable.
  30686. * @param array array to be set.
  30687. * @returns this effect.
  30688. */
  30689. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30690. /**
  30691. * 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)
  30692. * @param uniformName Name of the variable.
  30693. * @param array array to be set.
  30694. * @returns this effect.
  30695. */
  30696. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30697. /**
  30698. * 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)
  30699. * @param uniformName Name of the variable.
  30700. * @param array array to be set.
  30701. * @returns this effect.
  30702. */
  30703. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30704. /**
  30705. * 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)
  30706. * @param uniformName Name of the variable.
  30707. * @param array array to be set.
  30708. * @returns this effect.
  30709. */
  30710. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30711. /**
  30712. * Sets an array on a uniform variable.
  30713. * @param uniformName Name of the variable.
  30714. * @param array array to be set.
  30715. * @returns this effect.
  30716. */
  30717. setArray(uniformName: string, array: number[]): Effect;
  30718. /**
  30719. * 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)
  30720. * @param uniformName Name of the variable.
  30721. * @param array array to be set.
  30722. * @returns this effect.
  30723. */
  30724. setArray2(uniformName: string, array: number[]): Effect;
  30725. /**
  30726. * 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)
  30727. * @param uniformName Name of the variable.
  30728. * @param array array to be set.
  30729. * @returns this effect.
  30730. */
  30731. setArray3(uniformName: string, array: number[]): Effect;
  30732. /**
  30733. * 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)
  30734. * @param uniformName Name of the variable.
  30735. * @param array array to be set.
  30736. * @returns this effect.
  30737. */
  30738. setArray4(uniformName: string, array: number[]): Effect;
  30739. /**
  30740. * Sets matrices on a uniform variable.
  30741. * @param uniformName Name of the variable.
  30742. * @param matrices matrices to be set.
  30743. * @returns this effect.
  30744. */
  30745. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30746. /**
  30747. * Sets matrix on a uniform variable.
  30748. * @param uniformName Name of the variable.
  30749. * @param matrix matrix to be set.
  30750. * @returns this effect.
  30751. */
  30752. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30753. /**
  30754. * 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)
  30755. * @param uniformName Name of the variable.
  30756. * @param matrix matrix to be set.
  30757. * @returns this effect.
  30758. */
  30759. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30760. /**
  30761. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30762. * @param uniformName Name of the variable.
  30763. * @param matrix matrix to be set.
  30764. * @returns this effect.
  30765. */
  30766. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30767. /**
  30768. * Sets a float on a uniform variable.
  30769. * @param uniformName Name of the variable.
  30770. * @param value value to be set.
  30771. * @returns this effect.
  30772. */
  30773. setFloat(uniformName: string, value: number): Effect;
  30774. /**
  30775. * Sets a boolean on a uniform variable.
  30776. * @param uniformName Name of the variable.
  30777. * @param bool value to be set.
  30778. * @returns this effect.
  30779. */
  30780. setBool(uniformName: string, bool: boolean): Effect;
  30781. /**
  30782. * Sets a Vector2 on a uniform variable.
  30783. * @param uniformName Name of the variable.
  30784. * @param vector2 vector2 to be set.
  30785. * @returns this effect.
  30786. */
  30787. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30788. /**
  30789. * Sets a float2 on a uniform variable.
  30790. * @param uniformName Name of the variable.
  30791. * @param x First float in float2.
  30792. * @param y Second float in float2.
  30793. * @returns this effect.
  30794. */
  30795. setFloat2(uniformName: string, x: number, y: number): Effect;
  30796. /**
  30797. * Sets a Vector3 on a uniform variable.
  30798. * @param uniformName Name of the variable.
  30799. * @param vector3 Value to be set.
  30800. * @returns this effect.
  30801. */
  30802. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30803. /**
  30804. * Sets a float3 on a uniform variable.
  30805. * @param uniformName Name of the variable.
  30806. * @param x First float in float3.
  30807. * @param y Second float in float3.
  30808. * @param z Third float in float3.
  30809. * @returns this effect.
  30810. */
  30811. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30812. /**
  30813. * Sets a Vector4 on a uniform variable.
  30814. * @param uniformName Name of the variable.
  30815. * @param vector4 Value to be set.
  30816. * @returns this effect.
  30817. */
  30818. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30819. /**
  30820. * Sets a float4 on a uniform variable.
  30821. * @param uniformName Name of the variable.
  30822. * @param x First float in float4.
  30823. * @param y Second float in float4.
  30824. * @param z Third float in float4.
  30825. * @param w Fourth float in float4.
  30826. * @returns this effect.
  30827. */
  30828. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30829. /**
  30830. * Sets a Color3 on a uniform variable.
  30831. * @param uniformName Name of the variable.
  30832. * @param color3 Value to be set.
  30833. * @returns this effect.
  30834. */
  30835. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30836. /**
  30837. * Sets a Color4 on a uniform variable.
  30838. * @param uniformName Name of the variable.
  30839. * @param color3 Value to be set.
  30840. * @param alpha Alpha value to be set.
  30841. * @returns this effect.
  30842. */
  30843. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30844. /**
  30845. * Sets a Color4 on a uniform variable
  30846. * @param uniformName defines the name of the variable
  30847. * @param color4 defines the value to be set
  30848. * @returns this effect.
  30849. */
  30850. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30851. /** Release all associated resources */
  30852. dispose(): void;
  30853. /**
  30854. * This function will add a new shader to the shader store
  30855. * @param name the name of the shader
  30856. * @param pixelShader optional pixel shader content
  30857. * @param vertexShader optional vertex shader content
  30858. */
  30859. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30860. /**
  30861. * Store of each shader (The can be looked up using effect.key)
  30862. */
  30863. static ShadersStore: {
  30864. [key: string]: string;
  30865. };
  30866. /**
  30867. * Store of each included file for a shader (The can be looked up using effect.key)
  30868. */
  30869. static IncludesShadersStore: {
  30870. [key: string]: string;
  30871. };
  30872. /**
  30873. * Resets the cache of effects.
  30874. */
  30875. static ResetCache(): void;
  30876. }
  30877. }
  30878. declare module "babylonjs/Engines/engineCapabilities" {
  30879. /**
  30880. * Interface used to describe the capabilities of the engine relatively to the current browser
  30881. */
  30882. export interface EngineCapabilities {
  30883. /** Maximum textures units per fragment shader */
  30884. maxTexturesImageUnits: number;
  30885. /** Maximum texture units per vertex shader */
  30886. maxVertexTextureImageUnits: number;
  30887. /** Maximum textures units in the entire pipeline */
  30888. maxCombinedTexturesImageUnits: number;
  30889. /** Maximum texture size */
  30890. maxTextureSize: number;
  30891. /** Maximum texture samples */
  30892. maxSamples?: number;
  30893. /** Maximum cube texture size */
  30894. maxCubemapTextureSize: number;
  30895. /** Maximum render texture size */
  30896. maxRenderTextureSize: number;
  30897. /** Maximum number of vertex attributes */
  30898. maxVertexAttribs: number;
  30899. /** Maximum number of varyings */
  30900. maxVaryingVectors: number;
  30901. /** Maximum number of uniforms per vertex shader */
  30902. maxVertexUniformVectors: number;
  30903. /** Maximum number of uniforms per fragment shader */
  30904. maxFragmentUniformVectors: number;
  30905. /** Defines if standard derivates (dx/dy) are supported */
  30906. standardDerivatives: boolean;
  30907. /** Defines if s3tc texture compression is supported */
  30908. s3tc?: WEBGL_compressed_texture_s3tc;
  30909. /** Defines if pvrtc texture compression is supported */
  30910. pvrtc: any;
  30911. /** Defines if etc1 texture compression is supported */
  30912. etc1: any;
  30913. /** Defines if etc2 texture compression is supported */
  30914. etc2: any;
  30915. /** Defines if astc texture compression is supported */
  30916. astc: any;
  30917. /** Defines if float textures are supported */
  30918. textureFloat: boolean;
  30919. /** Defines if vertex array objects are supported */
  30920. vertexArrayObject: boolean;
  30921. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30922. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30923. /** Gets the maximum level of anisotropy supported */
  30924. maxAnisotropy: number;
  30925. /** Defines if instancing is supported */
  30926. instancedArrays: boolean;
  30927. /** Defines if 32 bits indices are supported */
  30928. uintIndices: boolean;
  30929. /** Defines if high precision shaders are supported */
  30930. highPrecisionShaderSupported: boolean;
  30931. /** Defines if depth reading in the fragment shader is supported */
  30932. fragmentDepthSupported: boolean;
  30933. /** Defines if float texture linear filtering is supported*/
  30934. textureFloatLinearFiltering: boolean;
  30935. /** Defines if rendering to float textures is supported */
  30936. textureFloatRender: boolean;
  30937. /** Defines if half float textures are supported*/
  30938. textureHalfFloat: boolean;
  30939. /** Defines if half float texture linear filtering is supported*/
  30940. textureHalfFloatLinearFiltering: boolean;
  30941. /** Defines if rendering to half float textures is supported */
  30942. textureHalfFloatRender: boolean;
  30943. /** Defines if textureLOD shader command is supported */
  30944. textureLOD: boolean;
  30945. /** Defines if draw buffers extension is supported */
  30946. drawBuffersExtension: boolean;
  30947. /** Defines if depth textures are supported */
  30948. depthTextureExtension: boolean;
  30949. /** Defines if float color buffer are supported */
  30950. colorBufferFloat: boolean;
  30951. /** Gets disjoint timer query extension (null if not supported) */
  30952. timerQuery?: EXT_disjoint_timer_query;
  30953. /** Defines if timestamp can be used with timer query */
  30954. canUseTimestampForTimerQuery: boolean;
  30955. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30956. multiview?: any;
  30957. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30958. oculusMultiview?: any;
  30959. /** Function used to let the system compiles shaders in background */
  30960. parallelShaderCompile?: {
  30961. COMPLETION_STATUS_KHR: number;
  30962. };
  30963. /** Max number of texture samples for MSAA */
  30964. maxMSAASamples: number;
  30965. /** Defines if the blend min max extension is supported */
  30966. blendMinMax: boolean;
  30967. }
  30968. }
  30969. declare module "babylonjs/States/depthCullingState" {
  30970. import { Nullable } from "babylonjs/types";
  30971. /**
  30972. * @hidden
  30973. **/
  30974. export class DepthCullingState {
  30975. private _isDepthTestDirty;
  30976. private _isDepthMaskDirty;
  30977. private _isDepthFuncDirty;
  30978. private _isCullFaceDirty;
  30979. private _isCullDirty;
  30980. private _isZOffsetDirty;
  30981. private _isFrontFaceDirty;
  30982. private _depthTest;
  30983. private _depthMask;
  30984. private _depthFunc;
  30985. private _cull;
  30986. private _cullFace;
  30987. private _zOffset;
  30988. private _frontFace;
  30989. /**
  30990. * Initializes the state.
  30991. */
  30992. constructor();
  30993. readonly isDirty: boolean;
  30994. zOffset: number;
  30995. cullFace: Nullable<number>;
  30996. cull: Nullable<boolean>;
  30997. depthFunc: Nullable<number>;
  30998. depthMask: boolean;
  30999. depthTest: boolean;
  31000. frontFace: Nullable<number>;
  31001. reset(): void;
  31002. apply(gl: WebGLRenderingContext): void;
  31003. }
  31004. }
  31005. declare module "babylonjs/States/stencilState" {
  31006. /**
  31007. * @hidden
  31008. **/
  31009. export class StencilState {
  31010. /** 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 */
  31011. static readonly ALWAYS: number;
  31012. /** Passed to stencilOperation to specify that stencil value must be kept */
  31013. static readonly KEEP: number;
  31014. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31015. static readonly REPLACE: number;
  31016. private _isStencilTestDirty;
  31017. private _isStencilMaskDirty;
  31018. private _isStencilFuncDirty;
  31019. private _isStencilOpDirty;
  31020. private _stencilTest;
  31021. private _stencilMask;
  31022. private _stencilFunc;
  31023. private _stencilFuncRef;
  31024. private _stencilFuncMask;
  31025. private _stencilOpStencilFail;
  31026. private _stencilOpDepthFail;
  31027. private _stencilOpStencilDepthPass;
  31028. readonly isDirty: boolean;
  31029. stencilFunc: number;
  31030. stencilFuncRef: number;
  31031. stencilFuncMask: number;
  31032. stencilOpStencilFail: number;
  31033. stencilOpDepthFail: number;
  31034. stencilOpStencilDepthPass: number;
  31035. stencilMask: number;
  31036. stencilTest: boolean;
  31037. constructor();
  31038. reset(): void;
  31039. apply(gl: WebGLRenderingContext): void;
  31040. }
  31041. }
  31042. declare module "babylonjs/States/alphaCullingState" {
  31043. /**
  31044. * @hidden
  31045. **/
  31046. export class AlphaState {
  31047. private _isAlphaBlendDirty;
  31048. private _isBlendFunctionParametersDirty;
  31049. private _isBlendEquationParametersDirty;
  31050. private _isBlendConstantsDirty;
  31051. private _alphaBlend;
  31052. private _blendFunctionParameters;
  31053. private _blendEquationParameters;
  31054. private _blendConstants;
  31055. /**
  31056. * Initializes the state.
  31057. */
  31058. constructor();
  31059. readonly isDirty: boolean;
  31060. alphaBlend: boolean;
  31061. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31062. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31063. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31064. reset(): void;
  31065. apply(gl: WebGLRenderingContext): void;
  31066. }
  31067. }
  31068. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31069. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31070. /** @hidden */
  31071. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31072. attributeProcessor(attribute: string): string;
  31073. varyingProcessor(varying: string, isFragment: boolean): string;
  31074. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31075. }
  31076. }
  31077. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31078. /**
  31079. * Interface for attribute information associated with buffer instanciation
  31080. */
  31081. export interface InstancingAttributeInfo {
  31082. /**
  31083. * Index/offset of the attribute in the vertex shader
  31084. */
  31085. index: number;
  31086. /**
  31087. * size of the attribute, 1, 2, 3 or 4
  31088. */
  31089. attributeSize: number;
  31090. /**
  31091. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31092. * default is FLOAT
  31093. */
  31094. attributeType: number;
  31095. /**
  31096. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31097. */
  31098. normalized: boolean;
  31099. /**
  31100. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31101. */
  31102. offset: number;
  31103. /**
  31104. * Name of the GLSL attribute, for debugging purpose only
  31105. */
  31106. attributeName: string;
  31107. }
  31108. }
  31109. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31110. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31111. import { Nullable } from "babylonjs/types";
  31112. module "babylonjs/Engines/thinEngine" {
  31113. interface ThinEngine {
  31114. /**
  31115. * Update a video texture
  31116. * @param texture defines the texture to update
  31117. * @param video defines the video element to use
  31118. * @param invertY defines if data must be stored with Y axis inverted
  31119. */
  31120. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31121. }
  31122. }
  31123. }
  31124. declare module "babylonjs/Materials/Textures/videoTexture" {
  31125. import { Observable } from "babylonjs/Misc/observable";
  31126. import { Nullable } from "babylonjs/types";
  31127. import { Scene } from "babylonjs/scene";
  31128. import { Texture } from "babylonjs/Materials/Textures/texture";
  31129. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31130. /**
  31131. * Settings for finer control over video usage
  31132. */
  31133. export interface VideoTextureSettings {
  31134. /**
  31135. * Applies `autoplay` to video, if specified
  31136. */
  31137. autoPlay?: boolean;
  31138. /**
  31139. * Applies `loop` to video, if specified
  31140. */
  31141. loop?: boolean;
  31142. /**
  31143. * Automatically updates internal texture from video at every frame in the render loop
  31144. */
  31145. autoUpdateTexture: boolean;
  31146. /**
  31147. * Image src displayed during the video loading or until the user interacts with the video.
  31148. */
  31149. poster?: string;
  31150. }
  31151. /**
  31152. * If you want to display a video in your scene, this is the special texture for that.
  31153. * This special texture works similar to other textures, with the exception of a few parameters.
  31154. * @see https://doc.babylonjs.com/how_to/video_texture
  31155. */
  31156. export class VideoTexture extends Texture {
  31157. /**
  31158. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31159. */
  31160. readonly autoUpdateTexture: boolean;
  31161. /**
  31162. * The video instance used by the texture internally
  31163. */
  31164. readonly video: HTMLVideoElement;
  31165. private _onUserActionRequestedObservable;
  31166. /**
  31167. * Event triggerd when a dom action is required by the user to play the video.
  31168. * This happens due to recent changes in browser policies preventing video to auto start.
  31169. */
  31170. readonly onUserActionRequestedObservable: Observable<Texture>;
  31171. private _generateMipMaps;
  31172. private _engine;
  31173. private _stillImageCaptured;
  31174. private _displayingPosterTexture;
  31175. private _settings;
  31176. private _createInternalTextureOnEvent;
  31177. private _frameId;
  31178. /**
  31179. * Creates a video texture.
  31180. * If you want to display a video in your scene, this is the special texture for that.
  31181. * This special texture works similar to other textures, with the exception of a few parameters.
  31182. * @see https://doc.babylonjs.com/how_to/video_texture
  31183. * @param name optional name, will detect from video source, if not defined
  31184. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31185. * @param scene is obviously the current scene.
  31186. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31187. * @param invertY is false by default but can be used to invert video on Y axis
  31188. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31189. * @param settings allows finer control over video usage
  31190. */
  31191. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31192. private _getName;
  31193. private _getVideo;
  31194. private _createInternalTexture;
  31195. private reset;
  31196. /**
  31197. * @hidden Internal method to initiate `update`.
  31198. */
  31199. _rebuild(): void;
  31200. /**
  31201. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31202. */
  31203. update(): void;
  31204. /**
  31205. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31206. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31207. */
  31208. updateTexture(isVisible: boolean): void;
  31209. protected _updateInternalTexture: () => void;
  31210. /**
  31211. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31212. * @param url New url.
  31213. */
  31214. updateURL(url: string): void;
  31215. /**
  31216. * Dispose the texture and release its associated resources.
  31217. */
  31218. dispose(): void;
  31219. /**
  31220. * Creates a video texture straight from a stream.
  31221. * @param scene Define the scene the texture should be created in
  31222. * @param stream Define the stream the texture should be created from
  31223. * @returns The created video texture as a promise
  31224. */
  31225. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31226. /**
  31227. * Creates a video texture straight from your WebCam video feed.
  31228. * @param scene Define the scene the texture should be created in
  31229. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31230. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31231. * @returns The created video texture as a promise
  31232. */
  31233. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31234. minWidth: number;
  31235. maxWidth: number;
  31236. minHeight: number;
  31237. maxHeight: number;
  31238. deviceId: string;
  31239. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31240. /**
  31241. * Creates a video texture straight from your WebCam video feed.
  31242. * @param scene Define the scene the texture should be created in
  31243. * @param onReady Define a callback to triggered once the texture will be ready
  31244. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31245. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31246. */
  31247. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31248. minWidth: number;
  31249. maxWidth: number;
  31250. minHeight: number;
  31251. maxHeight: number;
  31252. deviceId: string;
  31253. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31254. }
  31255. }
  31256. declare module "babylonjs/Engines/thinEngine" {
  31257. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31258. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31259. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31260. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31261. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31262. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31263. import { Observable } from "babylonjs/Misc/observable";
  31264. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31265. import { StencilState } from "babylonjs/States/stencilState";
  31266. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31267. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31268. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31269. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31270. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31271. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31272. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31273. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31274. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31276. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31277. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31278. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31279. /**
  31280. * Defines the interface used by objects working like Scene
  31281. * @hidden
  31282. */
  31283. interface ISceneLike {
  31284. _addPendingData(data: any): void;
  31285. _removePendingData(data: any): void;
  31286. offlineProvider: IOfflineProvider;
  31287. }
  31288. /** Interface defining initialization parameters for Engine class */
  31289. export interface EngineOptions extends WebGLContextAttributes {
  31290. /**
  31291. * Defines if the engine should no exceed a specified device ratio
  31292. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31293. */
  31294. limitDeviceRatio?: number;
  31295. /**
  31296. * Defines if webvr should be enabled automatically
  31297. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31298. */
  31299. autoEnableWebVR?: boolean;
  31300. /**
  31301. * Defines if webgl2 should be turned off even if supported
  31302. * @see http://doc.babylonjs.com/features/webgl2
  31303. */
  31304. disableWebGL2Support?: boolean;
  31305. /**
  31306. * Defines if webaudio should be initialized as well
  31307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31308. */
  31309. audioEngine?: boolean;
  31310. /**
  31311. * Defines if animations should run using a deterministic lock step
  31312. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31313. */
  31314. deterministicLockstep?: boolean;
  31315. /** Defines the maximum steps to use with deterministic lock step mode */
  31316. lockstepMaxSteps?: number;
  31317. /** Defines the seconds between each deterministic lock step */
  31318. timeStep?: number;
  31319. /**
  31320. * Defines that engine should ignore context lost events
  31321. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31322. */
  31323. doNotHandleContextLost?: boolean;
  31324. /**
  31325. * Defines that engine should ignore modifying touch action attribute and style
  31326. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31327. */
  31328. doNotHandleTouchAction?: boolean;
  31329. /**
  31330. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31331. */
  31332. useHighPrecisionFloats?: boolean;
  31333. }
  31334. /**
  31335. * The base engine class (root of all engines)
  31336. */
  31337. export class ThinEngine {
  31338. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31339. static ExceptionList: ({
  31340. key: string;
  31341. capture: string;
  31342. captureConstraint: number;
  31343. targets: string[];
  31344. } | {
  31345. key: string;
  31346. capture: null;
  31347. captureConstraint: null;
  31348. targets: string[];
  31349. })[];
  31350. /** @hidden */
  31351. static _TextureLoaders: IInternalTextureLoader[];
  31352. /**
  31353. * Returns the current npm package of the sdk
  31354. */
  31355. static readonly NpmPackage: string;
  31356. /**
  31357. * Returns the current version of the framework
  31358. */
  31359. static readonly Version: string;
  31360. /**
  31361. * Returns a string describing the current engine
  31362. */
  31363. readonly description: string;
  31364. /**
  31365. * Gets or sets the epsilon value used by collision engine
  31366. */
  31367. static CollisionsEpsilon: number;
  31368. /**
  31369. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31370. */
  31371. static ShadersRepository: string;
  31372. /** @hidden */
  31373. _shaderProcessor: IShaderProcessor;
  31374. /**
  31375. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31376. */
  31377. forcePOTTextures: boolean;
  31378. /**
  31379. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31380. */
  31381. isFullscreen: boolean;
  31382. /**
  31383. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31384. */
  31385. cullBackFaces: boolean;
  31386. /**
  31387. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31388. */
  31389. renderEvenInBackground: boolean;
  31390. /**
  31391. * Gets or sets a boolean indicating that cache can be kept between frames
  31392. */
  31393. preventCacheWipeBetweenFrames: boolean;
  31394. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31395. validateShaderPrograms: boolean;
  31396. /**
  31397. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31398. * This can provide greater z depth for distant objects.
  31399. */
  31400. useReverseDepthBuffer: boolean;
  31401. /**
  31402. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31403. */
  31404. disableUniformBuffers: boolean;
  31405. /** @hidden */
  31406. _uniformBuffers: UniformBuffer[];
  31407. /**
  31408. * Gets a boolean indicating that the engine supports uniform buffers
  31409. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31410. */
  31411. readonly supportsUniformBuffers: boolean;
  31412. /** @hidden */
  31413. _gl: WebGLRenderingContext;
  31414. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31415. protected _windowIsBackground: boolean;
  31416. protected _webGLVersion: number;
  31417. protected _creationOptions: EngineOptions;
  31418. protected _highPrecisionShadersAllowed: boolean;
  31419. /** @hidden */
  31420. readonly _shouldUseHighPrecisionShader: boolean;
  31421. /**
  31422. * Gets a boolean indicating that only power of 2 textures are supported
  31423. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31424. */
  31425. readonly needPOTTextures: boolean;
  31426. /** @hidden */
  31427. _badOS: boolean;
  31428. /** @hidden */
  31429. _badDesktopOS: boolean;
  31430. private _hardwareScalingLevel;
  31431. /** @hidden */
  31432. _caps: EngineCapabilities;
  31433. private _isStencilEnable;
  31434. protected _colorWrite: boolean;
  31435. private _glVersion;
  31436. private _glRenderer;
  31437. private _glVendor;
  31438. /** @hidden */
  31439. _videoTextureSupported: boolean;
  31440. protected _renderingQueueLaunched: boolean;
  31441. protected _activeRenderLoops: (() => void)[];
  31442. /**
  31443. * Observable signaled when a context lost event is raised
  31444. */
  31445. onContextLostObservable: Observable<ThinEngine>;
  31446. /**
  31447. * Observable signaled when a context restored event is raised
  31448. */
  31449. onContextRestoredObservable: Observable<ThinEngine>;
  31450. private _onContextLost;
  31451. private _onContextRestored;
  31452. protected _contextWasLost: boolean;
  31453. /** @hidden */
  31454. _doNotHandleContextLost: boolean;
  31455. /**
  31456. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31457. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31458. */
  31459. doNotHandleContextLost: boolean;
  31460. /**
  31461. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31462. */
  31463. disableVertexArrayObjects: boolean;
  31464. /** @hidden */
  31465. protected _depthCullingState: DepthCullingState;
  31466. /** @hidden */
  31467. protected _stencilState: StencilState;
  31468. /** @hidden */
  31469. protected _alphaState: AlphaState;
  31470. /** @hidden */
  31471. _internalTexturesCache: InternalTexture[];
  31472. /** @hidden */
  31473. protected _activeChannel: number;
  31474. private _currentTextureChannel;
  31475. /** @hidden */
  31476. protected _boundTexturesCache: {
  31477. [key: string]: Nullable<InternalTexture>;
  31478. };
  31479. /** @hidden */
  31480. protected _currentEffect: Nullable<Effect>;
  31481. /** @hidden */
  31482. protected _currentProgram: Nullable<WebGLProgram>;
  31483. private _compiledEffects;
  31484. private _vertexAttribArraysEnabled;
  31485. /** @hidden */
  31486. protected _cachedViewport: Nullable<IViewportLike>;
  31487. private _cachedVertexArrayObject;
  31488. /** @hidden */
  31489. protected _cachedVertexBuffers: any;
  31490. /** @hidden */
  31491. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31492. /** @hidden */
  31493. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31494. /** @hidden */
  31495. _currentRenderTarget: Nullable<InternalTexture>;
  31496. private _uintIndicesCurrentlySet;
  31497. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31498. /** @hidden */
  31499. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31500. private _currentBufferPointers;
  31501. private _currentInstanceLocations;
  31502. private _currentInstanceBuffers;
  31503. private _textureUnits;
  31504. /** @hidden */
  31505. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31506. /** @hidden */
  31507. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31508. /** @hidden */
  31509. _boundRenderFunction: any;
  31510. private _vaoRecordInProgress;
  31511. private _mustWipeVertexAttributes;
  31512. private _emptyTexture;
  31513. private _emptyCubeTexture;
  31514. private _emptyTexture3D;
  31515. private _emptyTexture2DArray;
  31516. /** @hidden */
  31517. _frameHandler: number;
  31518. private _nextFreeTextureSlots;
  31519. private _maxSimultaneousTextures;
  31520. private _activeRequests;
  31521. protected _texturesSupported: string[];
  31522. /** @hidden */
  31523. _textureFormatInUse: Nullable<string>;
  31524. protected readonly _supportsHardwareTextureRescaling: boolean;
  31525. /**
  31526. * Gets the list of texture formats supported
  31527. */
  31528. readonly texturesSupported: Array<string>;
  31529. /**
  31530. * Gets the list of texture formats in use
  31531. */
  31532. readonly textureFormatInUse: Nullable<string>;
  31533. /**
  31534. * Gets the current viewport
  31535. */
  31536. readonly currentViewport: Nullable<IViewportLike>;
  31537. /**
  31538. * Gets the default empty texture
  31539. */
  31540. readonly emptyTexture: InternalTexture;
  31541. /**
  31542. * Gets the default empty 3D texture
  31543. */
  31544. readonly emptyTexture3D: InternalTexture;
  31545. /**
  31546. * Gets the default empty 2D array texture
  31547. */
  31548. readonly emptyTexture2DArray: InternalTexture;
  31549. /**
  31550. * Gets the default empty cube texture
  31551. */
  31552. readonly emptyCubeTexture: InternalTexture;
  31553. /**
  31554. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31555. */
  31556. readonly premultipliedAlpha: boolean;
  31557. /**
  31558. * Observable event triggered before each texture is initialized
  31559. */
  31560. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31561. /**
  31562. * Creates a new engine
  31563. * @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
  31564. * @param antialias defines enable antialiasing (default: false)
  31565. * @param options defines further options to be sent to the getContext() function
  31566. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31567. */
  31568. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31569. private _rebuildInternalTextures;
  31570. private _rebuildEffects;
  31571. /**
  31572. * Gets a boolean indicating if all created effects are ready
  31573. * @returns true if all effects are ready
  31574. */
  31575. areAllEffectsReady(): boolean;
  31576. protected _rebuildBuffers(): void;
  31577. private _initGLContext;
  31578. /**
  31579. * Gets version of the current webGL context
  31580. */
  31581. readonly webGLVersion: number;
  31582. /**
  31583. * Gets a string idenfifying the name of the class
  31584. * @returns "Engine" string
  31585. */
  31586. getClassName(): string;
  31587. /**
  31588. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31589. */
  31590. readonly isStencilEnable: boolean;
  31591. /** @hidden */
  31592. _prepareWorkingCanvas(): void;
  31593. /**
  31594. * Reset the texture cache to empty state
  31595. */
  31596. resetTextureCache(): void;
  31597. /**
  31598. * Gets an object containing information about the current webGL context
  31599. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31600. */
  31601. getGlInfo(): {
  31602. vendor: string;
  31603. renderer: string;
  31604. version: string;
  31605. };
  31606. /**
  31607. * Defines the hardware scaling level.
  31608. * By default the hardware scaling level is computed from the window device ratio.
  31609. * 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.
  31610. * @param level defines the level to use
  31611. */
  31612. setHardwareScalingLevel(level: number): void;
  31613. /**
  31614. * Gets the current hardware scaling level.
  31615. * By default the hardware scaling level is computed from the window device ratio.
  31616. * 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.
  31617. * @returns a number indicating the current hardware scaling level
  31618. */
  31619. getHardwareScalingLevel(): number;
  31620. /**
  31621. * Gets the list of loaded textures
  31622. * @returns an array containing all loaded textures
  31623. */
  31624. getLoadedTexturesCache(): InternalTexture[];
  31625. /**
  31626. * Gets the object containing all engine capabilities
  31627. * @returns the EngineCapabilities object
  31628. */
  31629. getCaps(): EngineCapabilities;
  31630. /**
  31631. * stop executing a render loop function and remove it from the execution array
  31632. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31633. */
  31634. stopRenderLoop(renderFunction?: () => void): void;
  31635. /** @hidden */
  31636. _renderLoop(): void;
  31637. /**
  31638. * Gets the HTML canvas attached with the current webGL context
  31639. * @returns a HTML canvas
  31640. */
  31641. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31642. /**
  31643. * Gets host window
  31644. * @returns the host window object
  31645. */
  31646. getHostWindow(): Nullable<Window>;
  31647. /**
  31648. * Gets the current render width
  31649. * @param useScreen defines if screen size must be used (or the current render target if any)
  31650. * @returns a number defining the current render width
  31651. */
  31652. getRenderWidth(useScreen?: boolean): number;
  31653. /**
  31654. * Gets the current render height
  31655. * @param useScreen defines if screen size must be used (or the current render target if any)
  31656. * @returns a number defining the current render height
  31657. */
  31658. getRenderHeight(useScreen?: boolean): number;
  31659. /**
  31660. * Can be used to override the current requestAnimationFrame requester.
  31661. * @hidden
  31662. */
  31663. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31664. /**
  31665. * Register and execute a render loop. The engine can have more than one render function
  31666. * @param renderFunction defines the function to continuously execute
  31667. */
  31668. runRenderLoop(renderFunction: () => void): void;
  31669. /**
  31670. * Clear the current render buffer or the current render target (if any is set up)
  31671. * @param color defines the color to use
  31672. * @param backBuffer defines if the back buffer must be cleared
  31673. * @param depth defines if the depth buffer must be cleared
  31674. * @param stencil defines if the stencil buffer must be cleared
  31675. */
  31676. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31677. private _viewportCached;
  31678. /** @hidden */
  31679. _viewport(x: number, y: number, width: number, height: number): void;
  31680. /**
  31681. * Set the WebGL's viewport
  31682. * @param viewport defines the viewport element to be used
  31683. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31684. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31685. */
  31686. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31687. /**
  31688. * Begin a new frame
  31689. */
  31690. beginFrame(): void;
  31691. /**
  31692. * Enf the current frame
  31693. */
  31694. endFrame(): void;
  31695. /**
  31696. * Resize the view according to the canvas' size
  31697. */
  31698. resize(): void;
  31699. /**
  31700. * Force a specific size of the canvas
  31701. * @param width defines the new canvas' width
  31702. * @param height defines the new canvas' height
  31703. */
  31704. setSize(width: number, height: number): void;
  31705. /**
  31706. * Binds the frame buffer to the specified texture.
  31707. * @param texture The texture to render to or null for the default canvas
  31708. * @param faceIndex The face of the texture to render to in case of cube texture
  31709. * @param requiredWidth The width of the target to render to
  31710. * @param requiredHeight The height of the target to render to
  31711. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31712. * @param depthStencilTexture The depth stencil texture to use to render
  31713. * @param lodLevel defines le lod level to bind to the frame buffer
  31714. */
  31715. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31716. /** @hidden */
  31717. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31718. /**
  31719. * Unbind the current render target texture from the webGL context
  31720. * @param texture defines the render target texture to unbind
  31721. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31722. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31723. */
  31724. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31725. /**
  31726. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31727. */
  31728. flushFramebuffer(): void;
  31729. /**
  31730. * Unbind the current render target and bind the default framebuffer
  31731. */
  31732. restoreDefaultFramebuffer(): void;
  31733. /** @hidden */
  31734. protected _resetVertexBufferBinding(): void;
  31735. /**
  31736. * Creates a vertex buffer
  31737. * @param data the data for the vertex buffer
  31738. * @returns the new WebGL static buffer
  31739. */
  31740. createVertexBuffer(data: DataArray): DataBuffer;
  31741. private _createVertexBuffer;
  31742. /**
  31743. * Creates a dynamic vertex buffer
  31744. * @param data the data for the dynamic vertex buffer
  31745. * @returns the new WebGL dynamic buffer
  31746. */
  31747. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31748. protected _resetIndexBufferBinding(): void;
  31749. /**
  31750. * Creates a new index buffer
  31751. * @param indices defines the content of the index buffer
  31752. * @param updatable defines if the index buffer must be updatable
  31753. * @returns a new webGL buffer
  31754. */
  31755. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31756. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31757. /**
  31758. * Bind a webGL buffer to the webGL context
  31759. * @param buffer defines the buffer to bind
  31760. */
  31761. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31762. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31763. private bindBuffer;
  31764. /**
  31765. * update the bound buffer with the given data
  31766. * @param data defines the data to update
  31767. */
  31768. updateArrayBuffer(data: Float32Array): void;
  31769. private _vertexAttribPointer;
  31770. private _bindIndexBufferWithCache;
  31771. private _bindVertexBuffersAttributes;
  31772. /**
  31773. * Records a vertex array object
  31774. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31775. * @param vertexBuffers defines the list of vertex buffers to store
  31776. * @param indexBuffer defines the index buffer to store
  31777. * @param effect defines the effect to store
  31778. * @returns the new vertex array object
  31779. */
  31780. recordVertexArrayObject(vertexBuffers: {
  31781. [key: string]: VertexBuffer;
  31782. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31783. /**
  31784. * Bind a specific vertex array object
  31785. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31786. * @param vertexArrayObject defines the vertex array object to bind
  31787. * @param indexBuffer defines the index buffer to bind
  31788. */
  31789. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31790. /**
  31791. * Bind webGl buffers directly to the webGL context
  31792. * @param vertexBuffer defines the vertex buffer to bind
  31793. * @param indexBuffer defines the index buffer to bind
  31794. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31795. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31796. * @param effect defines the effect associated with the vertex buffer
  31797. */
  31798. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31799. private _unbindVertexArrayObject;
  31800. /**
  31801. * Bind a list of vertex buffers to the webGL context
  31802. * @param vertexBuffers defines the list of vertex buffers to bind
  31803. * @param indexBuffer defines the index buffer to bind
  31804. * @param effect defines the effect associated with the vertex buffers
  31805. */
  31806. bindBuffers(vertexBuffers: {
  31807. [key: string]: Nullable<VertexBuffer>;
  31808. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31809. /**
  31810. * Unbind all instance attributes
  31811. */
  31812. unbindInstanceAttributes(): void;
  31813. /**
  31814. * Release and free the memory of a vertex array object
  31815. * @param vao defines the vertex array object to delete
  31816. */
  31817. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31818. /** @hidden */
  31819. _releaseBuffer(buffer: DataBuffer): boolean;
  31820. protected _deleteBuffer(buffer: DataBuffer): void;
  31821. /**
  31822. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31823. * @param instancesBuffer defines the webGL buffer to update and bind
  31824. * @param data defines the data to store in the buffer
  31825. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31826. */
  31827. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31828. /**
  31829. * Apply all cached states (depth, culling, stencil and alpha)
  31830. */
  31831. applyStates(): void;
  31832. /**
  31833. * Send a draw order
  31834. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31835. * @param indexStart defines the starting index
  31836. * @param indexCount defines the number of index to draw
  31837. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31838. */
  31839. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31840. /**
  31841. * Draw a list of points
  31842. * @param verticesStart defines the index of first vertex to draw
  31843. * @param verticesCount defines the count of vertices to draw
  31844. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31845. */
  31846. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31847. /**
  31848. * Draw a list of unindexed primitives
  31849. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31850. * @param verticesStart defines the index of first vertex to draw
  31851. * @param verticesCount defines the count of vertices to draw
  31852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31853. */
  31854. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31855. /**
  31856. * Draw a list of indexed primitives
  31857. * @param fillMode defines the primitive to use
  31858. * @param indexStart defines the starting index
  31859. * @param indexCount defines the number of index to draw
  31860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31861. */
  31862. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31863. /**
  31864. * Draw a list of unindexed primitives
  31865. * @param fillMode defines the primitive to use
  31866. * @param verticesStart defines the index of first vertex to draw
  31867. * @param verticesCount defines the count of vertices to draw
  31868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31869. */
  31870. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31871. private _drawMode;
  31872. /** @hidden */
  31873. protected _reportDrawCall(): void;
  31874. /** @hidden */
  31875. _releaseEffect(effect: Effect): void;
  31876. /** @hidden */
  31877. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31878. /**
  31879. * Create a new effect (used to store vertex/fragment shaders)
  31880. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31881. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31882. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31883. * @param samplers defines an array of string used to represent textures
  31884. * @param defines defines the string containing the defines to use to compile the shaders
  31885. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31886. * @param onCompiled defines a function to call when the effect creation is successful
  31887. * @param onError defines a function to call when the effect creation has failed
  31888. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31889. * @returns the new Effect
  31890. */
  31891. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31892. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31893. private _compileShader;
  31894. private _compileRawShader;
  31895. /**
  31896. * Directly creates a webGL program
  31897. * @param pipelineContext defines the pipeline context to attach to
  31898. * @param vertexCode defines the vertex shader code to use
  31899. * @param fragmentCode defines the fragment shader code to use
  31900. * @param context defines the webGL context to use (if not set, the current one will be used)
  31901. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31902. * @returns the new webGL program
  31903. */
  31904. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31905. /**
  31906. * Creates a webGL program
  31907. * @param pipelineContext defines the pipeline context to attach to
  31908. * @param vertexCode defines the vertex shader code to use
  31909. * @param fragmentCode defines the fragment shader code to use
  31910. * @param defines defines the string containing the defines to use to compile the shaders
  31911. * @param context defines the webGL context to use (if not set, the current one will be used)
  31912. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31913. * @returns the new webGL program
  31914. */
  31915. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31916. /**
  31917. * Creates a new pipeline context
  31918. * @returns the new pipeline
  31919. */
  31920. createPipelineContext(): IPipelineContext;
  31921. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31922. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31923. /** @hidden */
  31924. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31925. /** @hidden */
  31926. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31927. /** @hidden */
  31928. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31929. /**
  31930. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31931. * @param pipelineContext defines the pipeline context to use
  31932. * @param uniformsNames defines the list of uniform names
  31933. * @returns an array of webGL uniform locations
  31934. */
  31935. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31936. /**
  31937. * Gets the lsit of active attributes for a given webGL program
  31938. * @param pipelineContext defines the pipeline context to use
  31939. * @param attributesNames defines the list of attribute names to get
  31940. * @returns an array of indices indicating the offset of each attribute
  31941. */
  31942. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31943. /**
  31944. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31945. * @param effect defines the effect to activate
  31946. */
  31947. enableEffect(effect: Nullable<Effect>): void;
  31948. /**
  31949. * Set the value of an uniform to a number (int)
  31950. * @param uniform defines the webGL uniform location where to store the value
  31951. * @param value defines the int number to store
  31952. */
  31953. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31954. /**
  31955. * Set the value of an uniform to an array of int32
  31956. * @param uniform defines the webGL uniform location where to store the value
  31957. * @param array defines the array of int32 to store
  31958. */
  31959. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31960. /**
  31961. * Set the value of an uniform to an array of int32 (stored as vec2)
  31962. * @param uniform defines the webGL uniform location where to store the value
  31963. * @param array defines the array of int32 to store
  31964. */
  31965. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31966. /**
  31967. * Set the value of an uniform to an array of int32 (stored as vec3)
  31968. * @param uniform defines the webGL uniform location where to store the value
  31969. * @param array defines the array of int32 to store
  31970. */
  31971. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31972. /**
  31973. * Set the value of an uniform to an array of int32 (stored as vec4)
  31974. * @param uniform defines the webGL uniform location where to store the value
  31975. * @param array defines the array of int32 to store
  31976. */
  31977. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31978. /**
  31979. * Set the value of an uniform to an array of number
  31980. * @param uniform defines the webGL uniform location where to store the value
  31981. * @param array defines the array of number to store
  31982. */
  31983. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31984. /**
  31985. * Set the value of an uniform to an array of number (stored as vec2)
  31986. * @param uniform defines the webGL uniform location where to store the value
  31987. * @param array defines the array of number to store
  31988. */
  31989. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31990. /**
  31991. * Set the value of an uniform to an array of number (stored as vec3)
  31992. * @param uniform defines the webGL uniform location where to store the value
  31993. * @param array defines the array of number to store
  31994. */
  31995. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31996. /**
  31997. * Set the value of an uniform to an array of number (stored as vec4)
  31998. * @param uniform defines the webGL uniform location where to store the value
  31999. * @param array defines the array of number to store
  32000. */
  32001. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32002. /**
  32003. * Set the value of an uniform to an array of float32 (stored as matrices)
  32004. * @param uniform defines the webGL uniform location where to store the value
  32005. * @param matrices defines the array of float32 to store
  32006. */
  32007. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32008. /**
  32009. * Set the value of an uniform to a matrix (3x3)
  32010. * @param uniform defines the webGL uniform location where to store the value
  32011. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32012. */
  32013. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32014. /**
  32015. * Set the value of an uniform to a matrix (2x2)
  32016. * @param uniform defines the webGL uniform location where to store the value
  32017. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32018. */
  32019. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32020. /**
  32021. * Set the value of an uniform to a number (float)
  32022. * @param uniform defines the webGL uniform location where to store the value
  32023. * @param value defines the float number to store
  32024. */
  32025. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32026. /**
  32027. * Set the value of an uniform to a vec2
  32028. * @param uniform defines the webGL uniform location where to store the value
  32029. * @param x defines the 1st component of the value
  32030. * @param y defines the 2nd component of the value
  32031. */
  32032. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32033. /**
  32034. * Set the value of an uniform to a vec3
  32035. * @param uniform defines the webGL uniform location where to store the value
  32036. * @param x defines the 1st component of the value
  32037. * @param y defines the 2nd component of the value
  32038. * @param z defines the 3rd component of the value
  32039. */
  32040. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32041. /**
  32042. * Set the value of an uniform to a vec4
  32043. * @param uniform defines the webGL uniform location where to store the value
  32044. * @param x defines the 1st component of the value
  32045. * @param y defines the 2nd component of the value
  32046. * @param z defines the 3rd component of the value
  32047. * @param w defines the 4th component of the value
  32048. */
  32049. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32050. /**
  32051. * Gets the depth culling state manager
  32052. */
  32053. readonly depthCullingState: DepthCullingState;
  32054. /**
  32055. * Gets the alpha state manager
  32056. */
  32057. readonly alphaState: AlphaState;
  32058. /**
  32059. * Gets the stencil state manager
  32060. */
  32061. readonly stencilState: StencilState;
  32062. /**
  32063. * Clears the list of texture accessible through engine.
  32064. * This can help preventing texture load conflict due to name collision.
  32065. */
  32066. clearInternalTexturesCache(): void;
  32067. /**
  32068. * Force the entire cache to be cleared
  32069. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32070. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32071. */
  32072. wipeCaches(bruteForce?: boolean): void;
  32073. /** @hidden */
  32074. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32075. min: number;
  32076. mag: number;
  32077. };
  32078. /** @hidden */
  32079. _createTexture(): WebGLTexture;
  32080. /**
  32081. * Usually called from Texture.ts.
  32082. * Passed information to create a WebGLTexture
  32083. * @param urlArg defines a value which contains one of the following:
  32084. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32085. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32086. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32087. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32088. * @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)
  32089. * @param scene needed for loading to the correct scene
  32090. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32091. * @param onLoad optional callback to be called upon successful completion
  32092. * @param onError optional callback to be called upon failure
  32093. * @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
  32094. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32095. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32096. * @param forcedExtension defines the extension to use to pick the right loader
  32097. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32098. * @param mimeType defines an optional mime type
  32099. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32100. */
  32101. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32102. /**
  32103. * @hidden
  32104. */
  32105. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32106. /**
  32107. * Creates a raw texture
  32108. * @param data defines the data to store in the texture
  32109. * @param width defines the width of the texture
  32110. * @param height defines the height of the texture
  32111. * @param format defines the format of the data
  32112. * @param generateMipMaps defines if the engine should generate the mip levels
  32113. * @param invertY defines if data must be stored with Y axis inverted
  32114. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32115. * @param compression defines the compression used (null by default)
  32116. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32117. * @returns the raw texture inside an InternalTexture
  32118. */
  32119. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32120. /**
  32121. * Creates a new raw cube texture
  32122. * @param data defines the array of data to use to create each face
  32123. * @param size defines the size of the textures
  32124. * @param format defines the format of the data
  32125. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32126. * @param generateMipMaps defines if the engine should generate the mip levels
  32127. * @param invertY defines if data must be stored with Y axis inverted
  32128. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32129. * @param compression defines the compression used (null by default)
  32130. * @returns the cube texture as an InternalTexture
  32131. */
  32132. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32133. /**
  32134. * Creates a new raw 3D texture
  32135. * @param data defines the data used to create the texture
  32136. * @param width defines the width of the texture
  32137. * @param height defines the height of the texture
  32138. * @param depth defines the depth of the texture
  32139. * @param format defines the format of the texture
  32140. * @param generateMipMaps defines if the engine must generate mip levels
  32141. * @param invertY defines if data must be stored with Y axis inverted
  32142. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32143. * @param compression defines the compressed used (can be null)
  32144. * @param textureType defines the compressed used (can be null)
  32145. * @returns a new raw 3D texture (stored in an InternalTexture)
  32146. */
  32147. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32148. /**
  32149. * Creates a new raw 2D array texture
  32150. * @param data defines the data used to create the texture
  32151. * @param width defines the width of the texture
  32152. * @param height defines the height of the texture
  32153. * @param depth defines the number of layers of the texture
  32154. * @param format defines the format of the texture
  32155. * @param generateMipMaps defines if the engine must generate mip levels
  32156. * @param invertY defines if data must be stored with Y axis inverted
  32157. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32158. * @param compression defines the compressed used (can be null)
  32159. * @param textureType defines the compressed used (can be null)
  32160. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32161. */
  32162. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32163. private _unpackFlipYCached;
  32164. /**
  32165. * In case you are sharing the context with other applications, it might
  32166. * be interested to not cache the unpack flip y state to ensure a consistent
  32167. * value would be set.
  32168. */
  32169. enableUnpackFlipYCached: boolean;
  32170. /** @hidden */
  32171. _unpackFlipY(value: boolean): void;
  32172. /** @hidden */
  32173. _getUnpackAlignement(): number;
  32174. /**
  32175. * Update the sampling mode of a given texture
  32176. * @param samplingMode defines the required sampling mode
  32177. * @param texture defines the texture to update
  32178. */
  32179. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32180. /** @hidden */
  32181. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32182. width: number;
  32183. height: number;
  32184. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32185. /** @hidden */
  32186. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32187. /** @hidden */
  32188. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32189. /** @hidden */
  32190. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32191. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32192. private _prepareWebGLTexture;
  32193. /** @hidden */
  32194. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32195. /** @hidden */
  32196. _releaseFramebufferObjects(texture: InternalTexture): void;
  32197. /** @hidden */
  32198. _releaseTexture(texture: InternalTexture): void;
  32199. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32200. protected _setProgram(program: WebGLProgram): void;
  32201. protected _boundUniforms: {
  32202. [key: number]: WebGLUniformLocation;
  32203. };
  32204. /**
  32205. * Binds an effect to the webGL context
  32206. * @param effect defines the effect to bind
  32207. */
  32208. bindSamplers(effect: Effect): void;
  32209. private _activateCurrentTexture;
  32210. /** @hidden */
  32211. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32212. /** @hidden */
  32213. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32214. /**
  32215. * Unbind all textures from the webGL context
  32216. */
  32217. unbindAllTextures(): void;
  32218. /**
  32219. * Sets a texture to the according uniform.
  32220. * @param channel The texture channel
  32221. * @param uniform The uniform to set
  32222. * @param texture The texture to apply
  32223. */
  32224. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32225. private _bindSamplerUniformToChannel;
  32226. private _getTextureWrapMode;
  32227. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32228. /**
  32229. * Sets an array of texture to the webGL context
  32230. * @param channel defines the channel where the texture array must be set
  32231. * @param uniform defines the associated uniform location
  32232. * @param textures defines the array of textures to bind
  32233. */
  32234. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32235. /** @hidden */
  32236. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32237. private _setTextureParameterFloat;
  32238. private _setTextureParameterInteger;
  32239. /**
  32240. * Unbind all vertex attributes from the webGL context
  32241. */
  32242. unbindAllAttributes(): void;
  32243. /**
  32244. * 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
  32245. */
  32246. releaseEffects(): void;
  32247. /**
  32248. * Dispose and release all associated resources
  32249. */
  32250. dispose(): void;
  32251. /**
  32252. * Attach a new callback raised when context lost event is fired
  32253. * @param callback defines the callback to call
  32254. */
  32255. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32256. /**
  32257. * Attach a new callback raised when context restored event is fired
  32258. * @param callback defines the callback to call
  32259. */
  32260. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32261. /**
  32262. * Get the current error code of the webGL context
  32263. * @returns the error code
  32264. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32265. */
  32266. getError(): number;
  32267. private _canRenderToFloatFramebuffer;
  32268. private _canRenderToHalfFloatFramebuffer;
  32269. private _canRenderToFramebuffer;
  32270. /** @hidden */
  32271. _getWebGLTextureType(type: number): number;
  32272. /** @hidden */
  32273. _getInternalFormat(format: number): number;
  32274. /** @hidden */
  32275. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32276. /** @hidden */
  32277. _getRGBAMultiSampleBufferFormat(type: number): number;
  32278. /** @hidden */
  32279. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  32280. /**
  32281. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32282. * @returns true if the engine can be created
  32283. * @ignorenaming
  32284. */
  32285. static isSupported(): boolean;
  32286. /**
  32287. * Find the next highest power of two.
  32288. * @param x Number to start search from.
  32289. * @return Next highest power of two.
  32290. */
  32291. static CeilingPOT(x: number): number;
  32292. /**
  32293. * Find the next lowest power of two.
  32294. * @param x Number to start search from.
  32295. * @return Next lowest power of two.
  32296. */
  32297. static FloorPOT(x: number): number;
  32298. /**
  32299. * Find the nearest power of two.
  32300. * @param x Number to start search from.
  32301. * @return Next nearest power of two.
  32302. */
  32303. static NearestPOT(x: number): number;
  32304. /**
  32305. * Get the closest exponent of two
  32306. * @param value defines the value to approximate
  32307. * @param max defines the maximum value to return
  32308. * @param mode defines how to define the closest value
  32309. * @returns closest exponent of two of the given value
  32310. */
  32311. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32312. /**
  32313. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32314. * @param func - the function to be called
  32315. * @param requester - the object that will request the next frame. Falls back to window.
  32316. * @returns frame number
  32317. */
  32318. static QueueNewFrame(func: () => void, requester?: any): number;
  32319. /**
  32320. * Gets host document
  32321. * @returns the host document object
  32322. */
  32323. getHostDocument(): Document;
  32324. }
  32325. }
  32326. declare module "babylonjs/Maths/sphericalPolynomial" {
  32327. import { Vector3 } from "babylonjs/Maths/math.vector";
  32328. import { Color3 } from "babylonjs/Maths/math.color";
  32329. /**
  32330. * Class representing spherical harmonics coefficients to the 3rd degree
  32331. */
  32332. export class SphericalHarmonics {
  32333. /**
  32334. * Defines whether or not the harmonics have been prescaled for rendering.
  32335. */
  32336. preScaled: boolean;
  32337. /**
  32338. * The l0,0 coefficients of the spherical harmonics
  32339. */
  32340. l00: Vector3;
  32341. /**
  32342. * The l1,-1 coefficients of the spherical harmonics
  32343. */
  32344. l1_1: Vector3;
  32345. /**
  32346. * The l1,0 coefficients of the spherical harmonics
  32347. */
  32348. l10: Vector3;
  32349. /**
  32350. * The l1,1 coefficients of the spherical harmonics
  32351. */
  32352. l11: Vector3;
  32353. /**
  32354. * The l2,-2 coefficients of the spherical harmonics
  32355. */
  32356. l2_2: Vector3;
  32357. /**
  32358. * The l2,-1 coefficients of the spherical harmonics
  32359. */
  32360. l2_1: Vector3;
  32361. /**
  32362. * The l2,0 coefficients of the spherical harmonics
  32363. */
  32364. l20: Vector3;
  32365. /**
  32366. * The l2,1 coefficients of the spherical harmonics
  32367. */
  32368. l21: Vector3;
  32369. /**
  32370. * The l2,2 coefficients of the spherical harmonics
  32371. */
  32372. l22: Vector3;
  32373. /**
  32374. * Adds a light to the spherical harmonics
  32375. * @param direction the direction of the light
  32376. * @param color the color of the light
  32377. * @param deltaSolidAngle the delta solid angle of the light
  32378. */
  32379. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32380. /**
  32381. * Scales the spherical harmonics by the given amount
  32382. * @param scale the amount to scale
  32383. */
  32384. scaleInPlace(scale: number): void;
  32385. /**
  32386. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32387. *
  32388. * ```
  32389. * E_lm = A_l * L_lm
  32390. * ```
  32391. *
  32392. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32393. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32394. * the scaling factors are given in equation 9.
  32395. */
  32396. convertIncidentRadianceToIrradiance(): void;
  32397. /**
  32398. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32399. *
  32400. * ```
  32401. * L = (1/pi) * E * rho
  32402. * ```
  32403. *
  32404. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32405. */
  32406. convertIrradianceToLambertianRadiance(): void;
  32407. /**
  32408. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32409. * required operations at run time.
  32410. *
  32411. * This is simply done by scaling back the SH with Ylm constants parameter.
  32412. * The trigonometric part being applied by the shader at run time.
  32413. */
  32414. preScaleForRendering(): void;
  32415. /**
  32416. * Constructs a spherical harmonics from an array.
  32417. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32418. * @returns the spherical harmonics
  32419. */
  32420. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32421. /**
  32422. * Gets the spherical harmonics from polynomial
  32423. * @param polynomial the spherical polynomial
  32424. * @returns the spherical harmonics
  32425. */
  32426. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32427. }
  32428. /**
  32429. * Class representing spherical polynomial coefficients to the 3rd degree
  32430. */
  32431. export class SphericalPolynomial {
  32432. private _harmonics;
  32433. /**
  32434. * The spherical harmonics used to create the polynomials.
  32435. */
  32436. readonly preScaledHarmonics: SphericalHarmonics;
  32437. /**
  32438. * The x coefficients of the spherical polynomial
  32439. */
  32440. x: Vector3;
  32441. /**
  32442. * The y coefficients of the spherical polynomial
  32443. */
  32444. y: Vector3;
  32445. /**
  32446. * The z coefficients of the spherical polynomial
  32447. */
  32448. z: Vector3;
  32449. /**
  32450. * The xx coefficients of the spherical polynomial
  32451. */
  32452. xx: Vector3;
  32453. /**
  32454. * The yy coefficients of the spherical polynomial
  32455. */
  32456. yy: Vector3;
  32457. /**
  32458. * The zz coefficients of the spherical polynomial
  32459. */
  32460. zz: Vector3;
  32461. /**
  32462. * The xy coefficients of the spherical polynomial
  32463. */
  32464. xy: Vector3;
  32465. /**
  32466. * The yz coefficients of the spherical polynomial
  32467. */
  32468. yz: Vector3;
  32469. /**
  32470. * The zx coefficients of the spherical polynomial
  32471. */
  32472. zx: Vector3;
  32473. /**
  32474. * Adds an ambient color to the spherical polynomial
  32475. * @param color the color to add
  32476. */
  32477. addAmbient(color: Color3): void;
  32478. /**
  32479. * Scales the spherical polynomial by the given amount
  32480. * @param scale the amount to scale
  32481. */
  32482. scaleInPlace(scale: number): void;
  32483. /**
  32484. * Gets the spherical polynomial from harmonics
  32485. * @param harmonics the spherical harmonics
  32486. * @returns the spherical polynomial
  32487. */
  32488. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32489. /**
  32490. * Constructs a spherical polynomial from an array.
  32491. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32492. * @returns the spherical polynomial
  32493. */
  32494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32495. }
  32496. }
  32497. declare module "babylonjs/Materials/Textures/internalTexture" {
  32498. import { Observable } from "babylonjs/Misc/observable";
  32499. import { Nullable, int } from "babylonjs/types";
  32500. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32502. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32503. /**
  32504. * Defines the source of the internal texture
  32505. */
  32506. export enum InternalTextureSource {
  32507. /**
  32508. * The source of the texture data is unknown
  32509. */
  32510. Unknown = 0,
  32511. /**
  32512. * Texture data comes from an URL
  32513. */
  32514. Url = 1,
  32515. /**
  32516. * Texture data is only used for temporary storage
  32517. */
  32518. Temp = 2,
  32519. /**
  32520. * Texture data comes from raw data (ArrayBuffer)
  32521. */
  32522. Raw = 3,
  32523. /**
  32524. * Texture content is dynamic (video or dynamic texture)
  32525. */
  32526. Dynamic = 4,
  32527. /**
  32528. * Texture content is generated by rendering to it
  32529. */
  32530. RenderTarget = 5,
  32531. /**
  32532. * Texture content is part of a multi render target process
  32533. */
  32534. MultiRenderTarget = 6,
  32535. /**
  32536. * Texture data comes from a cube data file
  32537. */
  32538. Cube = 7,
  32539. /**
  32540. * Texture data comes from a raw cube data
  32541. */
  32542. CubeRaw = 8,
  32543. /**
  32544. * Texture data come from a prefiltered cube data file
  32545. */
  32546. CubePrefiltered = 9,
  32547. /**
  32548. * Texture content is raw 3D data
  32549. */
  32550. Raw3D = 10,
  32551. /**
  32552. * Texture content is raw 2D array data
  32553. */
  32554. Raw2DArray = 11,
  32555. /**
  32556. * Texture content is a depth texture
  32557. */
  32558. Depth = 12,
  32559. /**
  32560. * Texture data comes from a raw cube data encoded with RGBD
  32561. */
  32562. CubeRawRGBD = 13
  32563. }
  32564. /**
  32565. * Class used to store data associated with WebGL texture data for the engine
  32566. * This class should not be used directly
  32567. */
  32568. export class InternalTexture {
  32569. /** @hidden */
  32570. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32571. /**
  32572. * Defines if the texture is ready
  32573. */
  32574. isReady: boolean;
  32575. /**
  32576. * Defines if the texture is a cube texture
  32577. */
  32578. isCube: boolean;
  32579. /**
  32580. * Defines if the texture contains 3D data
  32581. */
  32582. is3D: boolean;
  32583. /**
  32584. * Defines if the texture contains 2D array data
  32585. */
  32586. is2DArray: boolean;
  32587. /**
  32588. * Defines if the texture contains multiview data
  32589. */
  32590. isMultiview: boolean;
  32591. /**
  32592. * Gets the URL used to load this texture
  32593. */
  32594. url: string;
  32595. /**
  32596. * Gets the sampling mode of the texture
  32597. */
  32598. samplingMode: number;
  32599. /**
  32600. * Gets a boolean indicating if the texture needs mipmaps generation
  32601. */
  32602. generateMipMaps: boolean;
  32603. /**
  32604. * Gets the number of samples used by the texture (WebGL2+ only)
  32605. */
  32606. samples: number;
  32607. /**
  32608. * Gets the type of the texture (int, float...)
  32609. */
  32610. type: number;
  32611. /**
  32612. * Gets the format of the texture (RGB, RGBA...)
  32613. */
  32614. format: number;
  32615. /**
  32616. * Observable called when the texture is loaded
  32617. */
  32618. onLoadedObservable: Observable<InternalTexture>;
  32619. /**
  32620. * Gets the width of the texture
  32621. */
  32622. width: number;
  32623. /**
  32624. * Gets the height of the texture
  32625. */
  32626. height: number;
  32627. /**
  32628. * Gets the depth of the texture
  32629. */
  32630. depth: number;
  32631. /**
  32632. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32633. */
  32634. baseWidth: number;
  32635. /**
  32636. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32637. */
  32638. baseHeight: number;
  32639. /**
  32640. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32641. */
  32642. baseDepth: number;
  32643. /**
  32644. * Gets a boolean indicating if the texture is inverted on Y axis
  32645. */
  32646. invertY: boolean;
  32647. /** @hidden */
  32648. _invertVScale: boolean;
  32649. /** @hidden */
  32650. _associatedChannel: number;
  32651. /** @hidden */
  32652. _source: InternalTextureSource;
  32653. /** @hidden */
  32654. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32655. /** @hidden */
  32656. _bufferView: Nullable<ArrayBufferView>;
  32657. /** @hidden */
  32658. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32659. /** @hidden */
  32660. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32661. /** @hidden */
  32662. _size: number;
  32663. /** @hidden */
  32664. _extension: string;
  32665. /** @hidden */
  32666. _files: Nullable<string[]>;
  32667. /** @hidden */
  32668. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32669. /** @hidden */
  32670. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32671. /** @hidden */
  32672. _framebuffer: Nullable<WebGLFramebuffer>;
  32673. /** @hidden */
  32674. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32675. /** @hidden */
  32676. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32677. /** @hidden */
  32678. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32679. /** @hidden */
  32680. _attachments: Nullable<number[]>;
  32681. /** @hidden */
  32682. _cachedCoordinatesMode: Nullable<number>;
  32683. /** @hidden */
  32684. _cachedWrapU: Nullable<number>;
  32685. /** @hidden */
  32686. _cachedWrapV: Nullable<number>;
  32687. /** @hidden */
  32688. _cachedWrapR: Nullable<number>;
  32689. /** @hidden */
  32690. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32691. /** @hidden */
  32692. _isDisabled: boolean;
  32693. /** @hidden */
  32694. _compression: Nullable<string>;
  32695. /** @hidden */
  32696. _generateStencilBuffer: boolean;
  32697. /** @hidden */
  32698. _generateDepthBuffer: boolean;
  32699. /** @hidden */
  32700. _comparisonFunction: number;
  32701. /** @hidden */
  32702. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32703. /** @hidden */
  32704. _lodGenerationScale: number;
  32705. /** @hidden */
  32706. _lodGenerationOffset: number;
  32707. /** @hidden */
  32708. _colorTextureArray: Nullable<WebGLTexture>;
  32709. /** @hidden */
  32710. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32711. /** @hidden */
  32712. _lodTextureHigh: Nullable<BaseTexture>;
  32713. /** @hidden */
  32714. _lodTextureMid: Nullable<BaseTexture>;
  32715. /** @hidden */
  32716. _lodTextureLow: Nullable<BaseTexture>;
  32717. /** @hidden */
  32718. _isRGBD: boolean;
  32719. /** @hidden */
  32720. _linearSpecularLOD: boolean;
  32721. /** @hidden */
  32722. _irradianceTexture: Nullable<BaseTexture>;
  32723. /** @hidden */
  32724. _webGLTexture: Nullable<WebGLTexture>;
  32725. /** @hidden */
  32726. _references: number;
  32727. private _engine;
  32728. /**
  32729. * Gets the Engine the texture belongs to.
  32730. * @returns The babylon engine
  32731. */
  32732. getEngine(): ThinEngine;
  32733. /**
  32734. * Gets the data source type of the texture
  32735. */
  32736. readonly source: InternalTextureSource;
  32737. /**
  32738. * Creates a new InternalTexture
  32739. * @param engine defines the engine to use
  32740. * @param source defines the type of data that will be used
  32741. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32742. */
  32743. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32744. /**
  32745. * Increments the number of references (ie. the number of Texture that point to it)
  32746. */
  32747. incrementReferences(): void;
  32748. /**
  32749. * Change the size of the texture (not the size of the content)
  32750. * @param width defines the new width
  32751. * @param height defines the new height
  32752. * @param depth defines the new depth (1 by default)
  32753. */
  32754. updateSize(width: int, height: int, depth?: int): void;
  32755. /** @hidden */
  32756. _rebuild(): void;
  32757. /** @hidden */
  32758. _swapAndDie(target: InternalTexture): void;
  32759. /**
  32760. * Dispose the current allocated resources
  32761. */
  32762. dispose(): void;
  32763. }
  32764. }
  32765. declare module "babylonjs/Audio/analyser" {
  32766. import { Scene } from "babylonjs/scene";
  32767. /**
  32768. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32770. */
  32771. export class Analyser {
  32772. /**
  32773. * Gets or sets the smoothing
  32774. * @ignorenaming
  32775. */
  32776. SMOOTHING: number;
  32777. /**
  32778. * Gets or sets the FFT table size
  32779. * @ignorenaming
  32780. */
  32781. FFT_SIZE: number;
  32782. /**
  32783. * Gets or sets the bar graph amplitude
  32784. * @ignorenaming
  32785. */
  32786. BARGRAPHAMPLITUDE: number;
  32787. /**
  32788. * Gets or sets the position of the debug canvas
  32789. * @ignorenaming
  32790. */
  32791. DEBUGCANVASPOS: {
  32792. x: number;
  32793. y: number;
  32794. };
  32795. /**
  32796. * Gets or sets the debug canvas size
  32797. * @ignorenaming
  32798. */
  32799. DEBUGCANVASSIZE: {
  32800. width: number;
  32801. height: number;
  32802. };
  32803. private _byteFreqs;
  32804. private _byteTime;
  32805. private _floatFreqs;
  32806. private _webAudioAnalyser;
  32807. private _debugCanvas;
  32808. private _debugCanvasContext;
  32809. private _scene;
  32810. private _registerFunc;
  32811. private _audioEngine;
  32812. /**
  32813. * Creates a new analyser
  32814. * @param scene defines hosting scene
  32815. */
  32816. constructor(scene: Scene);
  32817. /**
  32818. * Get the number of data values you will have to play with for the visualization
  32819. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32820. * @returns a number
  32821. */
  32822. getFrequencyBinCount(): number;
  32823. /**
  32824. * Gets the current frequency data as a byte array
  32825. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32826. * @returns a Uint8Array
  32827. */
  32828. getByteFrequencyData(): Uint8Array;
  32829. /**
  32830. * Gets the current waveform as a byte array
  32831. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32832. * @returns a Uint8Array
  32833. */
  32834. getByteTimeDomainData(): Uint8Array;
  32835. /**
  32836. * Gets the current frequency data as a float array
  32837. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32838. * @returns a Float32Array
  32839. */
  32840. getFloatFrequencyData(): Float32Array;
  32841. /**
  32842. * Renders the debug canvas
  32843. */
  32844. drawDebugCanvas(): void;
  32845. /**
  32846. * Stops rendering the debug canvas and removes it
  32847. */
  32848. stopDebugCanvas(): void;
  32849. /**
  32850. * Connects two audio nodes
  32851. * @param inputAudioNode defines first node to connect
  32852. * @param outputAudioNode defines second node to connect
  32853. */
  32854. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32855. /**
  32856. * Releases all associated resources
  32857. */
  32858. dispose(): void;
  32859. }
  32860. }
  32861. declare module "babylonjs/Audio/audioEngine" {
  32862. import { IDisposable } from "babylonjs/scene";
  32863. import { Analyser } from "babylonjs/Audio/analyser";
  32864. import { Nullable } from "babylonjs/types";
  32865. import { Observable } from "babylonjs/Misc/observable";
  32866. /**
  32867. * This represents an audio engine and it is responsible
  32868. * to play, synchronize and analyse sounds throughout the application.
  32869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32870. */
  32871. export interface IAudioEngine extends IDisposable {
  32872. /**
  32873. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32874. */
  32875. readonly canUseWebAudio: boolean;
  32876. /**
  32877. * Gets the current AudioContext if available.
  32878. */
  32879. readonly audioContext: Nullable<AudioContext>;
  32880. /**
  32881. * The master gain node defines the global audio volume of your audio engine.
  32882. */
  32883. readonly masterGain: GainNode;
  32884. /**
  32885. * Gets whether or not mp3 are supported by your browser.
  32886. */
  32887. readonly isMP3supported: boolean;
  32888. /**
  32889. * Gets whether or not ogg are supported by your browser.
  32890. */
  32891. readonly isOGGsupported: boolean;
  32892. /**
  32893. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32894. * @ignoreNaming
  32895. */
  32896. WarnedWebAudioUnsupported: boolean;
  32897. /**
  32898. * Defines if the audio engine relies on a custom unlocked button.
  32899. * In this case, the embedded button will not be displayed.
  32900. */
  32901. useCustomUnlockedButton: boolean;
  32902. /**
  32903. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32904. */
  32905. readonly unlocked: boolean;
  32906. /**
  32907. * Event raised when audio has been unlocked on the browser.
  32908. */
  32909. onAudioUnlockedObservable: Observable<AudioEngine>;
  32910. /**
  32911. * Event raised when audio has been locked on the browser.
  32912. */
  32913. onAudioLockedObservable: Observable<AudioEngine>;
  32914. /**
  32915. * Flags the audio engine in Locked state.
  32916. * This happens due to new browser policies preventing audio to autoplay.
  32917. */
  32918. lock(): void;
  32919. /**
  32920. * Unlocks the audio engine once a user action has been done on the dom.
  32921. * This is helpful to resume play once browser policies have been satisfied.
  32922. */
  32923. unlock(): void;
  32924. }
  32925. /**
  32926. * This represents the default audio engine used in babylon.
  32927. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32929. */
  32930. export class AudioEngine implements IAudioEngine {
  32931. private _audioContext;
  32932. private _audioContextInitialized;
  32933. private _muteButton;
  32934. private _hostElement;
  32935. /**
  32936. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32937. */
  32938. canUseWebAudio: boolean;
  32939. /**
  32940. * The master gain node defines the global audio volume of your audio engine.
  32941. */
  32942. masterGain: GainNode;
  32943. /**
  32944. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32945. * @ignoreNaming
  32946. */
  32947. WarnedWebAudioUnsupported: boolean;
  32948. /**
  32949. * Gets whether or not mp3 are supported by your browser.
  32950. */
  32951. isMP3supported: boolean;
  32952. /**
  32953. * Gets whether or not ogg are supported by your browser.
  32954. */
  32955. isOGGsupported: boolean;
  32956. /**
  32957. * Gets whether audio has been unlocked on the device.
  32958. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32959. * a user interaction has happened.
  32960. */
  32961. unlocked: boolean;
  32962. /**
  32963. * Defines if the audio engine relies on a custom unlocked button.
  32964. * In this case, the embedded button will not be displayed.
  32965. */
  32966. useCustomUnlockedButton: boolean;
  32967. /**
  32968. * Event raised when audio has been unlocked on the browser.
  32969. */
  32970. onAudioUnlockedObservable: Observable<AudioEngine>;
  32971. /**
  32972. * Event raised when audio has been locked on the browser.
  32973. */
  32974. onAudioLockedObservable: Observable<AudioEngine>;
  32975. /**
  32976. * Gets the current AudioContext if available.
  32977. */
  32978. readonly audioContext: Nullable<AudioContext>;
  32979. private _connectedAnalyser;
  32980. /**
  32981. * Instantiates a new audio engine.
  32982. *
  32983. * There should be only one per page as some browsers restrict the number
  32984. * of audio contexts you can create.
  32985. * @param hostElement defines the host element where to display the mute icon if necessary
  32986. */
  32987. constructor(hostElement?: Nullable<HTMLElement>);
  32988. /**
  32989. * Flags the audio engine in Locked state.
  32990. * This happens due to new browser policies preventing audio to autoplay.
  32991. */
  32992. lock(): void;
  32993. /**
  32994. * Unlocks the audio engine once a user action has been done on the dom.
  32995. * This is helpful to resume play once browser policies have been satisfied.
  32996. */
  32997. unlock(): void;
  32998. private _resumeAudioContext;
  32999. private _initializeAudioContext;
  33000. private _tryToRun;
  33001. private _triggerRunningState;
  33002. private _triggerSuspendedState;
  33003. private _displayMuteButton;
  33004. private _moveButtonToTopLeft;
  33005. private _onResize;
  33006. private _hideMuteButton;
  33007. /**
  33008. * Destroy and release the resources associated with the audio ccontext.
  33009. */
  33010. dispose(): void;
  33011. /**
  33012. * Gets the global volume sets on the master gain.
  33013. * @returns the global volume if set or -1 otherwise
  33014. */
  33015. getGlobalVolume(): number;
  33016. /**
  33017. * Sets the global volume of your experience (sets on the master gain).
  33018. * @param newVolume Defines the new global volume of the application
  33019. */
  33020. setGlobalVolume(newVolume: number): void;
  33021. /**
  33022. * Connect the audio engine to an audio analyser allowing some amazing
  33023. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33025. * @param analyser The analyser to connect to the engine
  33026. */
  33027. connectToAnalyser(analyser: Analyser): void;
  33028. }
  33029. }
  33030. declare module "babylonjs/Loading/loadingScreen" {
  33031. /**
  33032. * Interface used to present a loading screen while loading a scene
  33033. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33034. */
  33035. export interface ILoadingScreen {
  33036. /**
  33037. * Function called to display the loading screen
  33038. */
  33039. displayLoadingUI: () => void;
  33040. /**
  33041. * Function called to hide the loading screen
  33042. */
  33043. hideLoadingUI: () => void;
  33044. /**
  33045. * Gets or sets the color to use for the background
  33046. */
  33047. loadingUIBackgroundColor: string;
  33048. /**
  33049. * Gets or sets the text to display while loading
  33050. */
  33051. loadingUIText: string;
  33052. }
  33053. /**
  33054. * Class used for the default loading screen
  33055. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33056. */
  33057. export class DefaultLoadingScreen implements ILoadingScreen {
  33058. private _renderingCanvas;
  33059. private _loadingText;
  33060. private _loadingDivBackgroundColor;
  33061. private _loadingDiv;
  33062. private _loadingTextDiv;
  33063. /** Gets or sets the logo url to use for the default loading screen */
  33064. static DefaultLogoUrl: string;
  33065. /** Gets or sets the spinner url to use for the default loading screen */
  33066. static DefaultSpinnerUrl: string;
  33067. /**
  33068. * Creates a new default loading screen
  33069. * @param _renderingCanvas defines the canvas used to render the scene
  33070. * @param _loadingText defines the default text to display
  33071. * @param _loadingDivBackgroundColor defines the default background color
  33072. */
  33073. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33074. /**
  33075. * Function called to display the loading screen
  33076. */
  33077. displayLoadingUI(): void;
  33078. /**
  33079. * Function called to hide the loading screen
  33080. */
  33081. hideLoadingUI(): void;
  33082. /**
  33083. * Gets or sets the text to display while loading
  33084. */
  33085. loadingUIText: string;
  33086. /**
  33087. * Gets or sets the color to use for the background
  33088. */
  33089. loadingUIBackgroundColor: string;
  33090. private _resizeLoadingUI;
  33091. }
  33092. }
  33093. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33094. /**
  33095. * Interface for any object that can request an animation frame
  33096. */
  33097. export interface ICustomAnimationFrameRequester {
  33098. /**
  33099. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33100. */
  33101. renderFunction?: Function;
  33102. /**
  33103. * Called to request the next frame to render to
  33104. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33105. */
  33106. requestAnimationFrame: Function;
  33107. /**
  33108. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33109. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33110. */
  33111. requestID?: number;
  33112. }
  33113. }
  33114. declare module "babylonjs/Misc/performanceMonitor" {
  33115. /**
  33116. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33117. */
  33118. export class PerformanceMonitor {
  33119. private _enabled;
  33120. private _rollingFrameTime;
  33121. private _lastFrameTimeMs;
  33122. /**
  33123. * constructor
  33124. * @param frameSampleSize The number of samples required to saturate the sliding window
  33125. */
  33126. constructor(frameSampleSize?: number);
  33127. /**
  33128. * Samples current frame
  33129. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33130. */
  33131. sampleFrame(timeMs?: number): void;
  33132. /**
  33133. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33134. */
  33135. readonly averageFrameTime: number;
  33136. /**
  33137. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33138. */
  33139. readonly averageFrameTimeVariance: number;
  33140. /**
  33141. * Returns the frame time of the most recent frame
  33142. */
  33143. readonly instantaneousFrameTime: number;
  33144. /**
  33145. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33146. */
  33147. readonly averageFPS: number;
  33148. /**
  33149. * Returns the average framerate in frames per second using the most recent frame time
  33150. */
  33151. readonly instantaneousFPS: number;
  33152. /**
  33153. * Returns true if enough samples have been taken to completely fill the sliding window
  33154. */
  33155. readonly isSaturated: boolean;
  33156. /**
  33157. * Enables contributions to the sliding window sample set
  33158. */
  33159. enable(): void;
  33160. /**
  33161. * Disables contributions to the sliding window sample set
  33162. * Samples will not be interpolated over the disabled period
  33163. */
  33164. disable(): void;
  33165. /**
  33166. * Returns true if sampling is enabled
  33167. */
  33168. readonly isEnabled: boolean;
  33169. /**
  33170. * Resets performance monitor
  33171. */
  33172. reset(): void;
  33173. }
  33174. /**
  33175. * RollingAverage
  33176. *
  33177. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33178. */
  33179. export class RollingAverage {
  33180. /**
  33181. * Current average
  33182. */
  33183. average: number;
  33184. /**
  33185. * Current variance
  33186. */
  33187. variance: number;
  33188. protected _samples: Array<number>;
  33189. protected _sampleCount: number;
  33190. protected _pos: number;
  33191. protected _m2: number;
  33192. /**
  33193. * constructor
  33194. * @param length The number of samples required to saturate the sliding window
  33195. */
  33196. constructor(length: number);
  33197. /**
  33198. * Adds a sample to the sample set
  33199. * @param v The sample value
  33200. */
  33201. add(v: number): void;
  33202. /**
  33203. * Returns previously added values or null if outside of history or outside the sliding window domain
  33204. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33205. * @return Value previously recorded with add() or null if outside of range
  33206. */
  33207. history(i: number): number;
  33208. /**
  33209. * Returns true if enough samples have been taken to completely fill the sliding window
  33210. * @return true if sample-set saturated
  33211. */
  33212. isSaturated(): boolean;
  33213. /**
  33214. * Resets the rolling average (equivalent to 0 samples taken so far)
  33215. */
  33216. reset(): void;
  33217. /**
  33218. * Wraps a value around the sample range boundaries
  33219. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33220. * @return Wrapped position in sample range
  33221. */
  33222. protected _wrapPosition(i: number): number;
  33223. }
  33224. }
  33225. declare module "babylonjs/Misc/perfCounter" {
  33226. /**
  33227. * This class is used to track a performance counter which is number based.
  33228. * The user has access to many properties which give statistics of different nature.
  33229. *
  33230. * The implementer can track two kinds of Performance Counter: time and count.
  33231. * 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.
  33232. * 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.
  33233. */
  33234. export class PerfCounter {
  33235. /**
  33236. * Gets or sets a global boolean to turn on and off all the counters
  33237. */
  33238. static Enabled: boolean;
  33239. /**
  33240. * Returns the smallest value ever
  33241. */
  33242. readonly min: number;
  33243. /**
  33244. * Returns the biggest value ever
  33245. */
  33246. readonly max: number;
  33247. /**
  33248. * Returns the average value since the performance counter is running
  33249. */
  33250. readonly average: number;
  33251. /**
  33252. * Returns the average value of the last second the counter was monitored
  33253. */
  33254. readonly lastSecAverage: number;
  33255. /**
  33256. * Returns the current value
  33257. */
  33258. readonly current: number;
  33259. /**
  33260. * Gets the accumulated total
  33261. */
  33262. readonly total: number;
  33263. /**
  33264. * Gets the total value count
  33265. */
  33266. readonly count: number;
  33267. /**
  33268. * Creates a new counter
  33269. */
  33270. constructor();
  33271. /**
  33272. * Call this method to start monitoring a new frame.
  33273. * 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.
  33274. */
  33275. fetchNewFrame(): void;
  33276. /**
  33277. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33278. * @param newCount the count value to add to the monitored count
  33279. * @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.
  33280. */
  33281. addCount(newCount: number, fetchResult: boolean): void;
  33282. /**
  33283. * Start monitoring this performance counter
  33284. */
  33285. beginMonitoring(): void;
  33286. /**
  33287. * Compute the time lapsed since the previous beginMonitoring() call.
  33288. * @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
  33289. */
  33290. endMonitoring(newFrame?: boolean): void;
  33291. private _fetchResult;
  33292. private _startMonitoringTime;
  33293. private _min;
  33294. private _max;
  33295. private _average;
  33296. private _current;
  33297. private _totalValueCount;
  33298. private _totalAccumulated;
  33299. private _lastSecAverage;
  33300. private _lastSecAccumulated;
  33301. private _lastSecTime;
  33302. private _lastSecValueCount;
  33303. }
  33304. }
  33305. declare module "babylonjs/Engines/engine" {
  33306. import { Observable } from "babylonjs/Misc/observable";
  33307. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33308. import { Scene } from "babylonjs/scene";
  33309. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33310. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33311. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33312. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33313. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33314. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33315. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33316. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33317. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33318. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33319. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33320. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33321. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33322. import { Material } from "babylonjs/Materials/material";
  33323. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33324. /**
  33325. * Defines the interface used by display changed events
  33326. */
  33327. export interface IDisplayChangedEventArgs {
  33328. /** Gets the vrDisplay object (if any) */
  33329. vrDisplay: Nullable<any>;
  33330. /** Gets a boolean indicating if webVR is supported */
  33331. vrSupported: boolean;
  33332. }
  33333. /**
  33334. * Defines the interface used by objects containing a viewport (like a camera)
  33335. */
  33336. interface IViewportOwnerLike {
  33337. /**
  33338. * Gets or sets the viewport
  33339. */
  33340. viewport: IViewportLike;
  33341. }
  33342. /**
  33343. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33344. */
  33345. export class Engine extends ThinEngine {
  33346. /** Defines that alpha blending is disabled */
  33347. static readonly ALPHA_DISABLE: number;
  33348. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33349. static readonly ALPHA_ADD: number;
  33350. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33351. static readonly ALPHA_COMBINE: number;
  33352. /** Defines that alpha blending to DEST - SRC * DEST */
  33353. static readonly ALPHA_SUBTRACT: number;
  33354. /** Defines that alpha blending to SRC * DEST */
  33355. static readonly ALPHA_MULTIPLY: number;
  33356. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33357. static readonly ALPHA_MAXIMIZED: number;
  33358. /** Defines that alpha blending to SRC + DEST */
  33359. static readonly ALPHA_ONEONE: number;
  33360. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33361. static readonly ALPHA_PREMULTIPLIED: number;
  33362. /**
  33363. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33364. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33365. */
  33366. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33367. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33368. static readonly ALPHA_INTERPOLATE: number;
  33369. /**
  33370. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33371. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33372. */
  33373. static readonly ALPHA_SCREENMODE: number;
  33374. /** Defines that the ressource is not delayed*/
  33375. static readonly DELAYLOADSTATE_NONE: number;
  33376. /** Defines that the ressource was successfully delay loaded */
  33377. static readonly DELAYLOADSTATE_LOADED: number;
  33378. /** Defines that the ressource is currently delay loading */
  33379. static readonly DELAYLOADSTATE_LOADING: number;
  33380. /** Defines that the ressource is delayed and has not started loading */
  33381. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33382. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33383. static readonly NEVER: number;
  33384. /** 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 */
  33385. static readonly ALWAYS: number;
  33386. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33387. static readonly LESS: number;
  33388. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33389. static readonly EQUAL: number;
  33390. /** 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 */
  33391. static readonly LEQUAL: number;
  33392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33393. static readonly GREATER: number;
  33394. /** 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 */
  33395. static readonly GEQUAL: number;
  33396. /** 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 */
  33397. static readonly NOTEQUAL: number;
  33398. /** Passed to stencilOperation to specify that stencil value must be kept */
  33399. static readonly KEEP: number;
  33400. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33401. static readonly REPLACE: number;
  33402. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33403. static readonly INCR: number;
  33404. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33405. static readonly DECR: number;
  33406. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33407. static readonly INVERT: number;
  33408. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33409. static readonly INCR_WRAP: number;
  33410. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33411. static readonly DECR_WRAP: number;
  33412. /** Texture is not repeating outside of 0..1 UVs */
  33413. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33414. /** Texture is repeating outside of 0..1 UVs */
  33415. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33416. /** Texture is repeating and mirrored */
  33417. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33418. /** ALPHA */
  33419. static readonly TEXTUREFORMAT_ALPHA: number;
  33420. /** LUMINANCE */
  33421. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33422. /** LUMINANCE_ALPHA */
  33423. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33424. /** RGB */
  33425. static readonly TEXTUREFORMAT_RGB: number;
  33426. /** RGBA */
  33427. static readonly TEXTUREFORMAT_RGBA: number;
  33428. /** RED */
  33429. static readonly TEXTUREFORMAT_RED: number;
  33430. /** RED (2nd reference) */
  33431. static readonly TEXTUREFORMAT_R: number;
  33432. /** RG */
  33433. static readonly TEXTUREFORMAT_RG: number;
  33434. /** RED_INTEGER */
  33435. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33436. /** RED_INTEGER (2nd reference) */
  33437. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33438. /** RG_INTEGER */
  33439. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33440. /** RGB_INTEGER */
  33441. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33442. /** RGBA_INTEGER */
  33443. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33444. /** UNSIGNED_BYTE */
  33445. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33446. /** UNSIGNED_BYTE (2nd reference) */
  33447. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33448. /** FLOAT */
  33449. static readonly TEXTURETYPE_FLOAT: number;
  33450. /** HALF_FLOAT */
  33451. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33452. /** BYTE */
  33453. static readonly TEXTURETYPE_BYTE: number;
  33454. /** SHORT */
  33455. static readonly TEXTURETYPE_SHORT: number;
  33456. /** UNSIGNED_SHORT */
  33457. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33458. /** INT */
  33459. static readonly TEXTURETYPE_INT: number;
  33460. /** UNSIGNED_INT */
  33461. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33462. /** UNSIGNED_SHORT_4_4_4_4 */
  33463. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33464. /** UNSIGNED_SHORT_5_5_5_1 */
  33465. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33466. /** UNSIGNED_SHORT_5_6_5 */
  33467. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33468. /** UNSIGNED_INT_2_10_10_10_REV */
  33469. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33470. /** UNSIGNED_INT_24_8 */
  33471. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33472. /** UNSIGNED_INT_10F_11F_11F_REV */
  33473. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33474. /** UNSIGNED_INT_5_9_9_9_REV */
  33475. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33476. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33477. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33478. /** nearest is mag = nearest and min = nearest and mip = linear */
  33479. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33480. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33481. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33482. /** Trilinear is mag = linear and min = linear and mip = linear */
  33483. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33484. /** nearest is mag = nearest and min = nearest and mip = linear */
  33485. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33487. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33488. /** Trilinear is mag = linear and min = linear and mip = linear */
  33489. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33490. /** mag = nearest and min = nearest and mip = nearest */
  33491. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33492. /** mag = nearest and min = linear and mip = nearest */
  33493. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33494. /** mag = nearest and min = linear and mip = linear */
  33495. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33496. /** mag = nearest and min = linear and mip = none */
  33497. static readonly TEXTURE_NEAREST_LINEAR: number;
  33498. /** mag = nearest and min = nearest and mip = none */
  33499. static readonly TEXTURE_NEAREST_NEAREST: number;
  33500. /** mag = linear and min = nearest and mip = nearest */
  33501. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33502. /** mag = linear and min = nearest and mip = linear */
  33503. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33504. /** mag = linear and min = linear and mip = none */
  33505. static readonly TEXTURE_LINEAR_LINEAR: number;
  33506. /** mag = linear and min = nearest and mip = none */
  33507. static readonly TEXTURE_LINEAR_NEAREST: number;
  33508. /** Explicit coordinates mode */
  33509. static readonly TEXTURE_EXPLICIT_MODE: number;
  33510. /** Spherical coordinates mode */
  33511. static readonly TEXTURE_SPHERICAL_MODE: number;
  33512. /** Planar coordinates mode */
  33513. static readonly TEXTURE_PLANAR_MODE: number;
  33514. /** Cubic coordinates mode */
  33515. static readonly TEXTURE_CUBIC_MODE: number;
  33516. /** Projection coordinates mode */
  33517. static readonly TEXTURE_PROJECTION_MODE: number;
  33518. /** Skybox coordinates mode */
  33519. static readonly TEXTURE_SKYBOX_MODE: number;
  33520. /** Inverse Cubic coordinates mode */
  33521. static readonly TEXTURE_INVCUBIC_MODE: number;
  33522. /** Equirectangular coordinates mode */
  33523. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33524. /** Equirectangular Fixed coordinates mode */
  33525. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33526. /** Equirectangular Fixed Mirrored coordinates mode */
  33527. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33528. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33529. static readonly SCALEMODE_FLOOR: number;
  33530. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33531. static readonly SCALEMODE_NEAREST: number;
  33532. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33533. static readonly SCALEMODE_CEILING: number;
  33534. /**
  33535. * Returns the current npm package of the sdk
  33536. */
  33537. static readonly NpmPackage: string;
  33538. /**
  33539. * Returns the current version of the framework
  33540. */
  33541. static readonly Version: string;
  33542. /** Gets the list of created engines */
  33543. static readonly Instances: Engine[];
  33544. /**
  33545. * Gets the latest created engine
  33546. */
  33547. static readonly LastCreatedEngine: Nullable<Engine>;
  33548. /**
  33549. * Gets the latest created scene
  33550. */
  33551. static readonly LastCreatedScene: Nullable<Scene>;
  33552. /**
  33553. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33554. * @param flag defines which part of the materials must be marked as dirty
  33555. * @param predicate defines a predicate used to filter which materials should be affected
  33556. */
  33557. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33558. /**
  33559. * Method called to create the default loading screen.
  33560. * This can be overriden in your own app.
  33561. * @param canvas The rendering canvas element
  33562. * @returns The loading screen
  33563. */
  33564. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33565. /**
  33566. * Method called to create the default rescale post process on each engine.
  33567. */
  33568. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33569. /**
  33570. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33571. **/
  33572. enableOfflineSupport: boolean;
  33573. /**
  33574. * 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)
  33575. **/
  33576. disableManifestCheck: boolean;
  33577. /**
  33578. * Gets the list of created scenes
  33579. */
  33580. scenes: Scene[];
  33581. /**
  33582. * Event raised when a new scene is created
  33583. */
  33584. onNewSceneAddedObservable: Observable<Scene>;
  33585. /**
  33586. * Gets the list of created postprocesses
  33587. */
  33588. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33589. /**
  33590. * Gets a boolean indicating if the pointer is currently locked
  33591. */
  33592. isPointerLock: boolean;
  33593. /**
  33594. * Observable event triggered each time the rendering canvas is resized
  33595. */
  33596. onResizeObservable: Observable<Engine>;
  33597. /**
  33598. * Observable event triggered each time the canvas loses focus
  33599. */
  33600. onCanvasBlurObservable: Observable<Engine>;
  33601. /**
  33602. * Observable event triggered each time the canvas gains focus
  33603. */
  33604. onCanvasFocusObservable: Observable<Engine>;
  33605. /**
  33606. * Observable event triggered each time the canvas receives pointerout event
  33607. */
  33608. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33609. /**
  33610. * Observable raised when the engine begins a new frame
  33611. */
  33612. onBeginFrameObservable: Observable<Engine>;
  33613. /**
  33614. * If set, will be used to request the next animation frame for the render loop
  33615. */
  33616. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33617. /**
  33618. * Observable raised when the engine ends the current frame
  33619. */
  33620. onEndFrameObservable: Observable<Engine>;
  33621. /**
  33622. * Observable raised when the engine is about to compile a shader
  33623. */
  33624. onBeforeShaderCompilationObservable: Observable<Engine>;
  33625. /**
  33626. * Observable raised when the engine has jsut compiled a shader
  33627. */
  33628. onAfterShaderCompilationObservable: Observable<Engine>;
  33629. /**
  33630. * Gets the audio engine
  33631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33632. * @ignorenaming
  33633. */
  33634. static audioEngine: IAudioEngine;
  33635. /**
  33636. * Default AudioEngine factory responsible of creating the Audio Engine.
  33637. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33638. */
  33639. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33640. /**
  33641. * Default offline support factory responsible of creating a tool used to store data locally.
  33642. * By default, this will create a Database object if the workload has been embedded.
  33643. */
  33644. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33645. private _loadingScreen;
  33646. private _pointerLockRequested;
  33647. private _dummyFramebuffer;
  33648. private _rescalePostProcess;
  33649. /** @hidden */
  33650. protected _alphaMode: number;
  33651. /** @hidden */
  33652. protected _alphaEquation: number;
  33653. private _deterministicLockstep;
  33654. private _lockstepMaxSteps;
  33655. private _timeStep;
  33656. protected readonly _supportsHardwareTextureRescaling: boolean;
  33657. private _fps;
  33658. private _deltaTime;
  33659. /** @hidden */
  33660. _drawCalls: PerfCounter;
  33661. /**
  33662. * Turn this value on if you want to pause FPS computation when in background
  33663. */
  33664. disablePerformanceMonitorInBackground: boolean;
  33665. private _performanceMonitor;
  33666. /**
  33667. * Gets the performance monitor attached to this engine
  33668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33669. */
  33670. readonly performanceMonitor: PerformanceMonitor;
  33671. private _onFocus;
  33672. private _onBlur;
  33673. private _onCanvasPointerOut;
  33674. private _onCanvasBlur;
  33675. private _onCanvasFocus;
  33676. private _onFullscreenChange;
  33677. private _onPointerLockChange;
  33678. /**
  33679. * Gets the HTML element used to attach event listeners
  33680. * @returns a HTML element
  33681. */
  33682. getInputElement(): Nullable<HTMLElement>;
  33683. /**
  33684. * Creates a new engine
  33685. * @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
  33686. * @param antialias defines enable antialiasing (default: false)
  33687. * @param options defines further options to be sent to the getContext() function
  33688. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33689. */
  33690. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33691. /**
  33692. * Gets current aspect ratio
  33693. * @param viewportOwner defines the camera to use to get the aspect ratio
  33694. * @param useScreen defines if screen size must be used (or the current render target if any)
  33695. * @returns a number defining the aspect ratio
  33696. */
  33697. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33698. /**
  33699. * Gets current screen aspect ratio
  33700. * @returns a number defining the aspect ratio
  33701. */
  33702. getScreenAspectRatio(): number;
  33703. /**
  33704. * Gets the client rect of the HTML canvas attached with the current webGL context
  33705. * @returns a client rectanglee
  33706. */
  33707. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33708. /**
  33709. * Gets the client rect of the HTML element used for events
  33710. * @returns a client rectanglee
  33711. */
  33712. getInputElementClientRect(): Nullable<ClientRect>;
  33713. /**
  33714. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33715. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33716. * @returns true if engine is in deterministic lock step mode
  33717. */
  33718. isDeterministicLockStep(): boolean;
  33719. /**
  33720. * Gets the max steps when engine is running in deterministic lock step
  33721. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33722. * @returns the max steps
  33723. */
  33724. getLockstepMaxSteps(): number;
  33725. /**
  33726. * Returns the time in ms between steps when using deterministic lock step.
  33727. * @returns time step in (ms)
  33728. */
  33729. getTimeStep(): number;
  33730. /**
  33731. * Force the mipmap generation for the given render target texture
  33732. * @param texture defines the render target texture to use
  33733. */
  33734. generateMipMapsForCubemap(texture: InternalTexture): void;
  33735. /** States */
  33736. /**
  33737. * Set various states to the webGL context
  33738. * @param culling defines backface culling state
  33739. * @param zOffset defines the value to apply to zOffset (0 by default)
  33740. * @param force defines if states must be applied even if cache is up to date
  33741. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33742. */
  33743. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33744. /**
  33745. * Set the z offset to apply to current rendering
  33746. * @param value defines the offset to apply
  33747. */
  33748. setZOffset(value: number): void;
  33749. /**
  33750. * Gets the current value of the zOffset
  33751. * @returns the current zOffset state
  33752. */
  33753. getZOffset(): number;
  33754. /**
  33755. * Enable or disable depth buffering
  33756. * @param enable defines the state to set
  33757. */
  33758. setDepthBuffer(enable: boolean): void;
  33759. /**
  33760. * Gets a boolean indicating if depth writing is enabled
  33761. * @returns the current depth writing state
  33762. */
  33763. getDepthWrite(): boolean;
  33764. /**
  33765. * Enable or disable depth writing
  33766. * @param enable defines the state to set
  33767. */
  33768. setDepthWrite(enable: boolean): void;
  33769. /**
  33770. * Enable or disable color writing
  33771. * @param enable defines the state to set
  33772. */
  33773. setColorWrite(enable: boolean): void;
  33774. /**
  33775. * Gets a boolean indicating if color writing is enabled
  33776. * @returns the current color writing state
  33777. */
  33778. getColorWrite(): boolean;
  33779. /**
  33780. * Sets alpha constants used by some alpha blending modes
  33781. * @param r defines the red component
  33782. * @param g defines the green component
  33783. * @param b defines the blue component
  33784. * @param a defines the alpha component
  33785. */
  33786. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33787. /**
  33788. * Sets the current alpha mode
  33789. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33790. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33791. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33792. */
  33793. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33794. /**
  33795. * Gets the current alpha mode
  33796. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33797. * @returns the current alpha mode
  33798. */
  33799. getAlphaMode(): number;
  33800. /**
  33801. * Sets the current alpha equation
  33802. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33803. */
  33804. setAlphaEquation(equation: number): void;
  33805. /**
  33806. * Gets the current alpha equation.
  33807. * @returns the current alpha equation
  33808. */
  33809. getAlphaEquation(): number;
  33810. /**
  33811. * Gets a boolean indicating if stencil buffer is enabled
  33812. * @returns the current stencil buffer state
  33813. */
  33814. getStencilBuffer(): boolean;
  33815. /**
  33816. * Enable or disable the stencil buffer
  33817. * @param enable defines if the stencil buffer must be enabled or disabled
  33818. */
  33819. setStencilBuffer(enable: boolean): void;
  33820. /**
  33821. * Gets the current stencil mask
  33822. * @returns a number defining the new stencil mask to use
  33823. */
  33824. getStencilMask(): number;
  33825. /**
  33826. * Sets the current stencil mask
  33827. * @param mask defines the new stencil mask to use
  33828. */
  33829. setStencilMask(mask: number): void;
  33830. /**
  33831. * Gets the current stencil function
  33832. * @returns a number defining the stencil function to use
  33833. */
  33834. getStencilFunction(): number;
  33835. /**
  33836. * Gets the current stencil reference value
  33837. * @returns a number defining the stencil reference value to use
  33838. */
  33839. getStencilFunctionReference(): number;
  33840. /**
  33841. * Gets the current stencil mask
  33842. * @returns a number defining the stencil mask to use
  33843. */
  33844. getStencilFunctionMask(): number;
  33845. /**
  33846. * Sets the current stencil function
  33847. * @param stencilFunc defines the new stencil function to use
  33848. */
  33849. setStencilFunction(stencilFunc: number): void;
  33850. /**
  33851. * Sets the current stencil reference
  33852. * @param reference defines the new stencil reference to use
  33853. */
  33854. setStencilFunctionReference(reference: number): void;
  33855. /**
  33856. * Sets the current stencil mask
  33857. * @param mask defines the new stencil mask to use
  33858. */
  33859. setStencilFunctionMask(mask: number): void;
  33860. /**
  33861. * Gets the current stencil operation when stencil fails
  33862. * @returns a number defining stencil operation to use when stencil fails
  33863. */
  33864. getStencilOperationFail(): number;
  33865. /**
  33866. * Gets the current stencil operation when depth fails
  33867. * @returns a number defining stencil operation to use when depth fails
  33868. */
  33869. getStencilOperationDepthFail(): number;
  33870. /**
  33871. * Gets the current stencil operation when stencil passes
  33872. * @returns a number defining stencil operation to use when stencil passes
  33873. */
  33874. getStencilOperationPass(): number;
  33875. /**
  33876. * Sets the stencil operation to use when stencil fails
  33877. * @param operation defines the stencil operation to use when stencil fails
  33878. */
  33879. setStencilOperationFail(operation: number): void;
  33880. /**
  33881. * Sets the stencil operation to use when depth fails
  33882. * @param operation defines the stencil operation to use when depth fails
  33883. */
  33884. setStencilOperationDepthFail(operation: number): void;
  33885. /**
  33886. * Sets the stencil operation to use when stencil passes
  33887. * @param operation defines the stencil operation to use when stencil passes
  33888. */
  33889. setStencilOperationPass(operation: number): void;
  33890. /**
  33891. * Sets a boolean indicating if the dithering state is enabled or disabled
  33892. * @param value defines the dithering state
  33893. */
  33894. setDitheringState(value: boolean): void;
  33895. /**
  33896. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33897. * @param value defines the rasterizer state
  33898. */
  33899. setRasterizerState(value: boolean): void;
  33900. /**
  33901. * Gets the current depth function
  33902. * @returns a number defining the depth function
  33903. */
  33904. getDepthFunction(): Nullable<number>;
  33905. /**
  33906. * Sets the current depth function
  33907. * @param depthFunc defines the function to use
  33908. */
  33909. setDepthFunction(depthFunc: number): void;
  33910. /**
  33911. * Sets the current depth function to GREATER
  33912. */
  33913. setDepthFunctionToGreater(): void;
  33914. /**
  33915. * Sets the current depth function to GEQUAL
  33916. */
  33917. setDepthFunctionToGreaterOrEqual(): void;
  33918. /**
  33919. * Sets the current depth function to LESS
  33920. */
  33921. setDepthFunctionToLess(): void;
  33922. /**
  33923. * Sets the current depth function to LEQUAL
  33924. */
  33925. setDepthFunctionToLessOrEqual(): void;
  33926. private _cachedStencilBuffer;
  33927. private _cachedStencilFunction;
  33928. private _cachedStencilMask;
  33929. private _cachedStencilOperationPass;
  33930. private _cachedStencilOperationFail;
  33931. private _cachedStencilOperationDepthFail;
  33932. private _cachedStencilReference;
  33933. /**
  33934. * Caches the the state of the stencil buffer
  33935. */
  33936. cacheStencilState(): void;
  33937. /**
  33938. * Restores the state of the stencil buffer
  33939. */
  33940. restoreStencilState(): void;
  33941. /**
  33942. * Directly set the WebGL Viewport
  33943. * @param x defines the x coordinate of the viewport (in screen space)
  33944. * @param y defines the y coordinate of the viewport (in screen space)
  33945. * @param width defines the width of the viewport (in screen space)
  33946. * @param height defines the height of the viewport (in screen space)
  33947. * @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
  33948. */
  33949. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33950. /**
  33951. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33952. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33953. * @param y defines the y-coordinate of the corner of the clear rectangle
  33954. * @param width defines the width of the clear rectangle
  33955. * @param height defines the height of the clear rectangle
  33956. * @param clearColor defines the clear color
  33957. */
  33958. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33959. /**
  33960. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33961. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33962. * @param y defines the y-coordinate of the corner of the clear rectangle
  33963. * @param width defines the width of the clear rectangle
  33964. * @param height defines the height of the clear rectangle
  33965. */
  33966. enableScissor(x: number, y: number, width: number, height: number): void;
  33967. /**
  33968. * Disable previously set scissor test rectangle
  33969. */
  33970. disableScissor(): void;
  33971. protected _reportDrawCall(): void;
  33972. /**
  33973. * Initializes a webVR display and starts listening to display change events
  33974. * The onVRDisplayChangedObservable will be notified upon these changes
  33975. * @returns The onVRDisplayChangedObservable
  33976. */
  33977. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33978. /** @hidden */
  33979. _prepareVRComponent(): void;
  33980. /** @hidden */
  33981. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33982. /** @hidden */
  33983. _submitVRFrame(): void;
  33984. /**
  33985. * Call this function to leave webVR mode
  33986. * Will do nothing if webVR is not supported or if there is no webVR device
  33987. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33988. */
  33989. disableVR(): void;
  33990. /**
  33991. * Gets a boolean indicating that the system is in VR mode and is presenting
  33992. * @returns true if VR mode is engaged
  33993. */
  33994. isVRPresenting(): boolean;
  33995. /** @hidden */
  33996. _requestVRFrame(): void;
  33997. /** @hidden */
  33998. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33999. /**
  34000. * Gets the source code of the vertex shader associated with a specific webGL program
  34001. * @param program defines the program to use
  34002. * @returns a string containing the source code of the vertex shader associated with the program
  34003. */
  34004. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34005. /**
  34006. * Gets the source code of the fragment shader associated with a specific webGL program
  34007. * @param program defines the program to use
  34008. * @returns a string containing the source code of the fragment shader associated with the program
  34009. */
  34010. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34011. /**
  34012. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34013. * @param x defines the x coordinate of the rectangle where pixels must be read
  34014. * @param y defines the y coordinate of the rectangle where pixels must be read
  34015. * @param width defines the width of the rectangle where pixels must be read
  34016. * @param height defines the height of the rectangle where pixels must be read
  34017. * @returns a Uint8Array containing RGBA colors
  34018. */
  34019. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  34020. /**
  34021. * Sets a depth stencil texture from a render target to the according uniform.
  34022. * @param channel The texture channel
  34023. * @param uniform The uniform to set
  34024. * @param texture The render target texture containing the depth stencil texture to apply
  34025. */
  34026. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34027. /**
  34028. * Sets a texture to the webGL context from a postprocess
  34029. * @param channel defines the channel to use
  34030. * @param postProcess defines the source postprocess
  34031. */
  34032. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34033. /**
  34034. * Binds the output of the passed in post process to the texture channel specified
  34035. * @param channel The channel the texture should be bound to
  34036. * @param postProcess The post process which's output should be bound
  34037. */
  34038. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34039. /** @hidden */
  34040. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34041. protected _rebuildBuffers(): void;
  34042. /** @hidden */
  34043. _renderFrame(): void;
  34044. _renderLoop(): void;
  34045. /** @hidden */
  34046. _renderViews(): boolean;
  34047. /**
  34048. * Toggle full screen mode
  34049. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34050. */
  34051. switchFullscreen(requestPointerLock: boolean): void;
  34052. /**
  34053. * Enters full screen mode
  34054. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34055. */
  34056. enterFullscreen(requestPointerLock: boolean): void;
  34057. /**
  34058. * Exits full screen mode
  34059. */
  34060. exitFullscreen(): void;
  34061. /**
  34062. * Enters Pointerlock mode
  34063. */
  34064. enterPointerlock(): void;
  34065. /**
  34066. * Exits Pointerlock mode
  34067. */
  34068. exitPointerlock(): void;
  34069. /**
  34070. * Begin a new frame
  34071. */
  34072. beginFrame(): void;
  34073. /**
  34074. * Enf the current frame
  34075. */
  34076. endFrame(): void;
  34077. resize(): void;
  34078. /**
  34079. * Set the compressed texture format to use, based on the formats you have, and the formats
  34080. * supported by the hardware / browser.
  34081. *
  34082. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34083. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34084. * to API arguments needed to compressed textures. This puts the burden on the container
  34085. * generator to house the arcane code for determining these for current & future formats.
  34086. *
  34087. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34088. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34089. *
  34090. * Note: The result of this call is not taken into account when a texture is base64.
  34091. *
  34092. * @param formatsAvailable defines the list of those format families you have created
  34093. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34094. *
  34095. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34096. * @returns The extension selected.
  34097. */
  34098. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34099. /**
  34100. * Force a specific size of the canvas
  34101. * @param width defines the new canvas' width
  34102. * @param height defines the new canvas' height
  34103. */
  34104. setSize(width: number, height: number): void;
  34105. /**
  34106. * Updates a dynamic vertex buffer.
  34107. * @param vertexBuffer the vertex buffer to update
  34108. * @param data the data used to update the vertex buffer
  34109. * @param byteOffset the byte offset of the data
  34110. * @param byteLength the byte length of the data
  34111. */
  34112. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34113. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34114. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34115. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34116. _releaseTexture(texture: InternalTexture): void;
  34117. /**
  34118. * @hidden
  34119. * Rescales a texture
  34120. * @param source input texutre
  34121. * @param destination destination texture
  34122. * @param scene scene to use to render the resize
  34123. * @param internalFormat format to use when resizing
  34124. * @param onComplete callback to be called when resize has completed
  34125. */
  34126. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34127. /**
  34128. * Gets the current framerate
  34129. * @returns a number representing the framerate
  34130. */
  34131. getFps(): number;
  34132. /**
  34133. * Gets the time spent between current and previous frame
  34134. * @returns a number representing the delta time in ms
  34135. */
  34136. getDeltaTime(): number;
  34137. private _measureFps;
  34138. /** @hidden */
  34139. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34140. /**
  34141. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34142. * @param renderTarget The render target to set the frame buffer for
  34143. */
  34144. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34145. /**
  34146. * Update a dynamic index buffer
  34147. * @param indexBuffer defines the target index buffer
  34148. * @param indices defines the data to update
  34149. * @param offset defines the offset in the target index buffer where update should start
  34150. */
  34151. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34152. /**
  34153. * Updates the sample count of a render target texture
  34154. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34155. * @param texture defines the texture to update
  34156. * @param samples defines the sample count to set
  34157. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34158. */
  34159. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34160. /**
  34161. * Updates a depth texture Comparison Mode and Function.
  34162. * If the comparison Function is equal to 0, the mode will be set to none.
  34163. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34164. * @param texture The texture to set the comparison function for
  34165. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34166. */
  34167. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34168. /**
  34169. * Creates a webGL buffer to use with instanciation
  34170. * @param capacity defines the size of the buffer
  34171. * @returns the webGL buffer
  34172. */
  34173. createInstancesBuffer(capacity: number): DataBuffer;
  34174. /**
  34175. * Delete a webGL buffer used with instanciation
  34176. * @param buffer defines the webGL buffer to delete
  34177. */
  34178. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34179. /** @hidden */
  34180. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34181. dispose(): void;
  34182. private _disableTouchAction;
  34183. /**
  34184. * Display the loading screen
  34185. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34186. */
  34187. displayLoadingUI(): void;
  34188. /**
  34189. * Hide the loading screen
  34190. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34191. */
  34192. hideLoadingUI(): void;
  34193. /**
  34194. * Gets the current loading screen object
  34195. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34196. */
  34197. /**
  34198. * Sets the current loading screen object
  34199. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34200. */
  34201. loadingScreen: ILoadingScreen;
  34202. /**
  34203. * Sets the current loading screen text
  34204. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34205. */
  34206. loadingUIText: string;
  34207. /**
  34208. * Sets the current loading screen background color
  34209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34210. */
  34211. loadingUIBackgroundColor: string;
  34212. /** Pointerlock and fullscreen */
  34213. /**
  34214. * Ask the browser to promote the current element to pointerlock mode
  34215. * @param element defines the DOM element to promote
  34216. */
  34217. static _RequestPointerlock(element: HTMLElement): void;
  34218. /**
  34219. * Asks the browser to exit pointerlock mode
  34220. */
  34221. static _ExitPointerlock(): void;
  34222. /**
  34223. * Ask the browser to promote the current element to fullscreen rendering mode
  34224. * @param element defines the DOM element to promote
  34225. */
  34226. static _RequestFullscreen(element: HTMLElement): void;
  34227. /**
  34228. * Asks the browser to exit fullscreen mode
  34229. */
  34230. static _ExitFullscreen(): void;
  34231. }
  34232. }
  34233. declare module "babylonjs/Engines/engineStore" {
  34234. import { Nullable } from "babylonjs/types";
  34235. import { Engine } from "babylonjs/Engines/engine";
  34236. import { Scene } from "babylonjs/scene";
  34237. /**
  34238. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34239. * during the life time of the application.
  34240. */
  34241. export class EngineStore {
  34242. /** Gets the list of created engines */
  34243. static Instances: import("babylonjs/Engines/engine").Engine[];
  34244. /** @hidden */
  34245. static _LastCreatedScene: Nullable<Scene>;
  34246. /**
  34247. * Gets the latest created engine
  34248. */
  34249. static readonly LastCreatedEngine: Nullable<Engine>;
  34250. /**
  34251. * Gets the latest created scene
  34252. */
  34253. static readonly LastCreatedScene: Nullable<Scene>;
  34254. /**
  34255. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34256. * @ignorenaming
  34257. */
  34258. static UseFallbackTexture: boolean;
  34259. /**
  34260. * Texture content used if a texture cannot loaded
  34261. * @ignorenaming
  34262. */
  34263. static FallbackTexture: string;
  34264. }
  34265. }
  34266. declare module "babylonjs/Misc/promise" {
  34267. /**
  34268. * Helper class that provides a small promise polyfill
  34269. */
  34270. export class PromisePolyfill {
  34271. /**
  34272. * Static function used to check if the polyfill is required
  34273. * If this is the case then the function will inject the polyfill to window.Promise
  34274. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34275. */
  34276. static Apply(force?: boolean): void;
  34277. }
  34278. }
  34279. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34280. /**
  34281. * Interface for screenshot methods with describe argument called `size` as object with options
  34282. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34283. */
  34284. export interface IScreenshotSize {
  34285. /**
  34286. * number in pixels for canvas height
  34287. */
  34288. height?: number;
  34289. /**
  34290. * multiplier allowing render at a higher or lower resolution
  34291. * If value is defined then height and width will be ignored and taken from camera
  34292. */
  34293. precision?: number;
  34294. /**
  34295. * number in pixels for canvas width
  34296. */
  34297. width?: number;
  34298. }
  34299. }
  34300. declare module "babylonjs/Misc/tools" {
  34301. import { Nullable, float } from "babylonjs/types";
  34302. import { DomManagement } from "babylonjs/Misc/domManagement";
  34303. import { WebRequest } from "babylonjs/Misc/webRequest";
  34304. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34305. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34306. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34307. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34308. import { Camera } from "babylonjs/Cameras/camera";
  34309. import { Engine } from "babylonjs/Engines/engine";
  34310. interface IColor4Like {
  34311. r: float;
  34312. g: float;
  34313. b: float;
  34314. a: float;
  34315. }
  34316. /**
  34317. * Class containing a set of static utilities functions
  34318. */
  34319. export class Tools {
  34320. /**
  34321. * Gets or sets the base URL to use to load assets
  34322. */
  34323. static BaseUrl: string;
  34324. /**
  34325. * Enable/Disable Custom HTTP Request Headers globally.
  34326. * default = false
  34327. * @see CustomRequestHeaders
  34328. */
  34329. static UseCustomRequestHeaders: boolean;
  34330. /**
  34331. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34332. * i.e. when loading files, where the server/service expects an Authorization header
  34333. */
  34334. static CustomRequestHeaders: {
  34335. [key: string]: string;
  34336. };
  34337. /**
  34338. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34339. */
  34340. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  34341. /**
  34342. * Default behaviour for cors in the application.
  34343. * It can be a string if the expected behavior is identical in the entire app.
  34344. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34345. */
  34346. static CorsBehavior: string | ((url: string | string[]) => string);
  34347. /**
  34348. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34349. * @ignorenaming
  34350. */
  34351. static UseFallbackTexture: boolean;
  34352. /**
  34353. * Use this object to register external classes like custom textures or material
  34354. * to allow the laoders to instantiate them
  34355. */
  34356. static RegisteredExternalClasses: {
  34357. [key: string]: Object;
  34358. };
  34359. /**
  34360. * Texture content used if a texture cannot loaded
  34361. * @ignorenaming
  34362. */
  34363. static fallbackTexture: string;
  34364. /**
  34365. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34366. * @param u defines the coordinate on X axis
  34367. * @param v defines the coordinate on Y axis
  34368. * @param width defines the width of the source data
  34369. * @param height defines the height of the source data
  34370. * @param pixels defines the source byte array
  34371. * @param color defines the output color
  34372. */
  34373. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34374. /**
  34375. * Interpolates between a and b via alpha
  34376. * @param a The lower value (returned when alpha = 0)
  34377. * @param b The upper value (returned when alpha = 1)
  34378. * @param alpha The interpolation-factor
  34379. * @return The mixed value
  34380. */
  34381. static Mix(a: number, b: number, alpha: number): number;
  34382. /**
  34383. * Tries to instantiate a new object from a given class name
  34384. * @param className defines the class name to instantiate
  34385. * @returns the new object or null if the system was not able to do the instantiation
  34386. */
  34387. static Instantiate(className: string): any;
  34388. /**
  34389. * Provides a slice function that will work even on IE
  34390. * @param data defines the array to slice
  34391. * @param start defines the start of the data (optional)
  34392. * @param end defines the end of the data (optional)
  34393. * @returns the new sliced array
  34394. */
  34395. static Slice<T>(data: T, start?: number, end?: number): T;
  34396. /**
  34397. * Polyfill for setImmediate
  34398. * @param action defines the action to execute after the current execution block
  34399. */
  34400. static SetImmediate(action: () => void): void;
  34401. /**
  34402. * Function indicating if a number is an exponent of 2
  34403. * @param value defines the value to test
  34404. * @returns true if the value is an exponent of 2
  34405. */
  34406. static IsExponentOfTwo(value: number): boolean;
  34407. private static _tmpFloatArray;
  34408. /**
  34409. * Returns the nearest 32-bit single precision float representation of a Number
  34410. * @param value A Number. If the parameter is of a different type, it will get converted
  34411. * to a number or to NaN if it cannot be converted
  34412. * @returns number
  34413. */
  34414. static FloatRound(value: number): number;
  34415. /**
  34416. * Extracts the filename from a path
  34417. * @param path defines the path to use
  34418. * @returns the filename
  34419. */
  34420. static GetFilename(path: string): string;
  34421. /**
  34422. * Extracts the "folder" part of a path (everything before the filename).
  34423. * @param uri The URI to extract the info from
  34424. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34425. * @returns The "folder" part of the path
  34426. */
  34427. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34428. /**
  34429. * Extracts text content from a DOM element hierarchy
  34430. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34431. */
  34432. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34433. /**
  34434. * Convert an angle in radians to degrees
  34435. * @param angle defines the angle to convert
  34436. * @returns the angle in degrees
  34437. */
  34438. static ToDegrees(angle: number): number;
  34439. /**
  34440. * Convert an angle in degrees to radians
  34441. * @param angle defines the angle to convert
  34442. * @returns the angle in radians
  34443. */
  34444. static ToRadians(angle: number): number;
  34445. /**
  34446. * Returns an array if obj is not an array
  34447. * @param obj defines the object to evaluate as an array
  34448. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34449. * @returns either obj directly if obj is an array or a new array containing obj
  34450. */
  34451. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34452. /**
  34453. * Gets the pointer prefix to use
  34454. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34455. */
  34456. static GetPointerPrefix(): string;
  34457. /**
  34458. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34459. * @param url define the url we are trying
  34460. * @param element define the dom element where to configure the cors policy
  34461. */
  34462. static SetCorsBehavior(url: string | string[], element: {
  34463. crossOrigin: string | null;
  34464. }): void;
  34465. /**
  34466. * Removes unwanted characters from an url
  34467. * @param url defines the url to clean
  34468. * @returns the cleaned url
  34469. */
  34470. static CleanUrl(url: string): string;
  34471. /**
  34472. * Gets or sets a function used to pre-process url before using them to load assets
  34473. */
  34474. static PreprocessUrl: (url: string) => string;
  34475. /**
  34476. * Loads an image as an HTMLImageElement.
  34477. * @param input url string, ArrayBuffer, or Blob to load
  34478. * @param onLoad callback called when the image successfully loads
  34479. * @param onError callback called when the image fails to load
  34480. * @param offlineProvider offline provider for caching
  34481. * @param mimeType optional mime type
  34482. * @returns the HTMLImageElement of the loaded image
  34483. */
  34484. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34485. /**
  34486. * Loads a file from a url
  34487. * @param url url string, ArrayBuffer, or Blob to load
  34488. * @param onSuccess callback called when the file successfully loads
  34489. * @param onProgress callback called while file is loading (if the server supports this mode)
  34490. * @param offlineProvider defines the offline provider for caching
  34491. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34492. * @param onError callback called when the file fails to load
  34493. * @returns a file request object
  34494. */
  34495. 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;
  34496. /**
  34497. * Loads a file from a url
  34498. * @param url the file url to load
  34499. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34500. */
  34501. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34502. /**
  34503. * Load a script (identified by an url). When the url returns, the
  34504. * content of this file is added into a new script element, attached to the DOM (body element)
  34505. * @param scriptUrl defines the url of the script to laod
  34506. * @param onSuccess defines the callback called when the script is loaded
  34507. * @param onError defines the callback to call if an error occurs
  34508. * @param scriptId defines the id of the script element
  34509. */
  34510. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34511. /**
  34512. * Load an asynchronous script (identified by an url). When the url returns, the
  34513. * content of this file is added into a new script element, attached to the DOM (body element)
  34514. * @param scriptUrl defines the url of the script to laod
  34515. * @param scriptId defines the id of the script element
  34516. * @returns a promise request object
  34517. */
  34518. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34519. /**
  34520. * Loads a file from a blob
  34521. * @param fileToLoad defines the blob to use
  34522. * @param callback defines the callback to call when data is loaded
  34523. * @param progressCallback defines the callback to call during loading process
  34524. * @returns a file request object
  34525. */
  34526. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34527. /**
  34528. * Reads a file from a File object
  34529. * @param file defines the file to load
  34530. * @param onSuccess defines the callback to call when data is loaded
  34531. * @param onProgress defines the callback to call during loading process
  34532. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34533. * @param onError defines the callback to call when an error occurs
  34534. * @returns a file request object
  34535. */
  34536. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34537. /**
  34538. * Creates a data url from a given string content
  34539. * @param content defines the content to convert
  34540. * @returns the new data url link
  34541. */
  34542. static FileAsURL(content: string): string;
  34543. /**
  34544. * Format the given number to a specific decimal format
  34545. * @param value defines the number to format
  34546. * @param decimals defines the number of decimals to use
  34547. * @returns the formatted string
  34548. */
  34549. static Format(value: number, decimals?: number): string;
  34550. /**
  34551. * Tries to copy an object by duplicating every property
  34552. * @param source defines the source object
  34553. * @param destination defines the target object
  34554. * @param doNotCopyList defines a list of properties to avoid
  34555. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34556. */
  34557. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34558. /**
  34559. * Gets a boolean indicating if the given object has no own property
  34560. * @param obj defines the object to test
  34561. * @returns true if object has no own property
  34562. */
  34563. static IsEmpty(obj: any): boolean;
  34564. /**
  34565. * Function used to register events at window level
  34566. * @param windowElement defines the Window object to use
  34567. * @param events defines the events to register
  34568. */
  34569. static RegisterTopRootEvents(windowElement: Window, events: {
  34570. name: string;
  34571. handler: Nullable<(e: FocusEvent) => any>;
  34572. }[]): void;
  34573. /**
  34574. * Function used to unregister events from window level
  34575. * @param windowElement defines the Window object to use
  34576. * @param events defines the events to unregister
  34577. */
  34578. static UnregisterTopRootEvents(windowElement: Window, events: {
  34579. name: string;
  34580. handler: Nullable<(e: FocusEvent) => any>;
  34581. }[]): void;
  34582. /**
  34583. * @ignore
  34584. */
  34585. static _ScreenshotCanvas: HTMLCanvasElement;
  34586. /**
  34587. * Dumps the current bound framebuffer
  34588. * @param width defines the rendering width
  34589. * @param height defines the rendering height
  34590. * @param engine defines the hosting engine
  34591. * @param successCallback defines the callback triggered once the data are available
  34592. * @param mimeType defines the mime type of the result
  34593. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34594. */
  34595. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34596. /**
  34597. * Converts the canvas data to blob.
  34598. * This acts as a polyfill for browsers not supporting the to blob function.
  34599. * @param canvas Defines the canvas to extract the data from
  34600. * @param successCallback Defines the callback triggered once the data are available
  34601. * @param mimeType Defines the mime type of the result
  34602. */
  34603. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34604. /**
  34605. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34606. * @param successCallback defines the callback triggered once the data are available
  34607. * @param mimeType defines the mime type of the result
  34608. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34609. */
  34610. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34611. /**
  34612. * Downloads a blob in the browser
  34613. * @param blob defines the blob to download
  34614. * @param fileName defines the name of the downloaded file
  34615. */
  34616. static Download(blob: Blob, fileName: string): void;
  34617. /**
  34618. * Captures a screenshot of the current rendering
  34619. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34620. * @param engine defines the rendering engine
  34621. * @param camera defines the source camera
  34622. * @param size This parameter can be set to a single number or to an object with the
  34623. * following (optional) properties: precision, width, height. If a single number is passed,
  34624. * it will be used for both width and height. If an object is passed, the screenshot size
  34625. * will be derived from the parameters. The precision property is a multiplier allowing
  34626. * rendering at a higher or lower resolution
  34627. * @param successCallback defines the callback receives a single parameter which contains the
  34628. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34629. * src parameter of an <img> to display it
  34630. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34631. * Check your browser for supported MIME types
  34632. */
  34633. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34634. /**
  34635. * Captures a screenshot of the current rendering
  34636. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34637. * @param engine defines the rendering engine
  34638. * @param camera defines the source camera
  34639. * @param size This parameter can be set to a single number or to an object with the
  34640. * following (optional) properties: precision, width, height. If a single number is passed,
  34641. * it will be used for both width and height. If an object is passed, the screenshot size
  34642. * will be derived from the parameters. The precision property is a multiplier allowing
  34643. * rendering at a higher or lower resolution
  34644. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34645. * Check your browser for supported MIME types
  34646. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34647. * to the src parameter of an <img> to display it
  34648. */
  34649. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34650. /**
  34651. * Generates an image screenshot from the specified camera.
  34652. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34653. * @param engine The engine to use for rendering
  34654. * @param camera The camera to use for rendering
  34655. * @param size This parameter can be set to a single number or to an object with the
  34656. * following (optional) properties: precision, width, height. If a single number is passed,
  34657. * it will be used for both width and height. If an object is passed, the screenshot size
  34658. * will be derived from the parameters. The precision property is a multiplier allowing
  34659. * rendering at a higher or lower resolution
  34660. * @param successCallback The callback receives a single parameter which contains the
  34661. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34662. * src parameter of an <img> to display it
  34663. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34664. * Check your browser for supported MIME types
  34665. * @param samples Texture samples (default: 1)
  34666. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34667. * @param fileName A name for for the downloaded file.
  34668. */
  34669. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34670. /**
  34671. * Generates an image screenshot from the specified camera.
  34672. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34673. * @param engine The engine to use for rendering
  34674. * @param camera The camera to use for rendering
  34675. * @param size This parameter can be set to a single number or to an object with the
  34676. * following (optional) properties: precision, width, height. If a single number is passed,
  34677. * it will be used for both width and height. If an object is passed, the screenshot size
  34678. * will be derived from the parameters. The precision property is a multiplier allowing
  34679. * rendering at a higher or lower resolution
  34680. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34681. * Check your browser for supported MIME types
  34682. * @param samples Texture samples (default: 1)
  34683. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34684. * @param fileName A name for for the downloaded file.
  34685. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34686. * to the src parameter of an <img> to display it
  34687. */
  34688. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34689. /**
  34690. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34691. * Be aware Math.random() could cause collisions, but:
  34692. * "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"
  34693. * @returns a pseudo random id
  34694. */
  34695. static RandomId(): string;
  34696. /**
  34697. * Test if the given uri is a base64 string
  34698. * @param uri The uri to test
  34699. * @return True if the uri is a base64 string or false otherwise
  34700. */
  34701. static IsBase64(uri: string): boolean;
  34702. /**
  34703. * Decode the given base64 uri.
  34704. * @param uri The uri to decode
  34705. * @return The decoded base64 data.
  34706. */
  34707. static DecodeBase64(uri: string): ArrayBuffer;
  34708. /**
  34709. * Gets the absolute url.
  34710. * @param url the input url
  34711. * @return the absolute url
  34712. */
  34713. static GetAbsoluteUrl(url: string): string;
  34714. /**
  34715. * No log
  34716. */
  34717. static readonly NoneLogLevel: number;
  34718. /**
  34719. * Only message logs
  34720. */
  34721. static readonly MessageLogLevel: number;
  34722. /**
  34723. * Only warning logs
  34724. */
  34725. static readonly WarningLogLevel: number;
  34726. /**
  34727. * Only error logs
  34728. */
  34729. static readonly ErrorLogLevel: number;
  34730. /**
  34731. * All logs
  34732. */
  34733. static readonly AllLogLevel: number;
  34734. /**
  34735. * Gets a value indicating the number of loading errors
  34736. * @ignorenaming
  34737. */
  34738. static readonly errorsCount: number;
  34739. /**
  34740. * Callback called when a new log is added
  34741. */
  34742. static OnNewCacheEntry: (entry: string) => void;
  34743. /**
  34744. * Log a message to the console
  34745. * @param message defines the message to log
  34746. */
  34747. static Log(message: string): void;
  34748. /**
  34749. * Write a warning message to the console
  34750. * @param message defines the message to log
  34751. */
  34752. static Warn(message: string): void;
  34753. /**
  34754. * Write an error message to the console
  34755. * @param message defines the message to log
  34756. */
  34757. static Error(message: string): void;
  34758. /**
  34759. * Gets current log cache (list of logs)
  34760. */
  34761. static readonly LogCache: string;
  34762. /**
  34763. * Clears the log cache
  34764. */
  34765. static ClearLogCache(): void;
  34766. /**
  34767. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34768. */
  34769. static LogLevels: number;
  34770. /**
  34771. * Checks if the window object exists
  34772. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34773. */
  34774. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34775. /**
  34776. * No performance log
  34777. */
  34778. static readonly PerformanceNoneLogLevel: number;
  34779. /**
  34780. * Use user marks to log performance
  34781. */
  34782. static readonly PerformanceUserMarkLogLevel: number;
  34783. /**
  34784. * Log performance to the console
  34785. */
  34786. static readonly PerformanceConsoleLogLevel: number;
  34787. private static _performance;
  34788. /**
  34789. * Sets the current performance log level
  34790. */
  34791. static PerformanceLogLevel: number;
  34792. private static _StartPerformanceCounterDisabled;
  34793. private static _EndPerformanceCounterDisabled;
  34794. private static _StartUserMark;
  34795. private static _EndUserMark;
  34796. private static _StartPerformanceConsole;
  34797. private static _EndPerformanceConsole;
  34798. /**
  34799. * Starts a performance counter
  34800. */
  34801. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34802. /**
  34803. * Ends a specific performance coutner
  34804. */
  34805. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34806. /**
  34807. * Gets either window.performance.now() if supported or Date.now() else
  34808. */
  34809. static readonly Now: number;
  34810. /**
  34811. * This method will return the name of the class used to create the instance of the given object.
  34812. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34813. * @param object the object to get the class name from
  34814. * @param isType defines if the object is actually a type
  34815. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34816. */
  34817. static GetClassName(object: any, isType?: boolean): string;
  34818. /**
  34819. * Gets the first element of an array satisfying a given predicate
  34820. * @param array defines the array to browse
  34821. * @param predicate defines the predicate to use
  34822. * @returns null if not found or the element
  34823. */
  34824. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34825. /**
  34826. * This method will return the name of the full name of the class, including its owning module (if any).
  34827. * 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).
  34828. * @param object the object to get the class name from
  34829. * @param isType defines if the object is actually a type
  34830. * @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.
  34831. * @ignorenaming
  34832. */
  34833. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34834. /**
  34835. * Returns a promise that resolves after the given amount of time.
  34836. * @param delay Number of milliseconds to delay
  34837. * @returns Promise that resolves after the given amount of time
  34838. */
  34839. static DelayAsync(delay: number): Promise<void>;
  34840. }
  34841. /**
  34842. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34843. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34844. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34845. * @param name The name of the class, case should be preserved
  34846. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34847. */
  34848. export function className(name: string, module?: string): (target: Object) => void;
  34849. /**
  34850. * An implementation of a loop for asynchronous functions.
  34851. */
  34852. export class AsyncLoop {
  34853. /**
  34854. * Defines the number of iterations for the loop
  34855. */
  34856. iterations: number;
  34857. /**
  34858. * Defines the current index of the loop.
  34859. */
  34860. index: number;
  34861. private _done;
  34862. private _fn;
  34863. private _successCallback;
  34864. /**
  34865. * Constructor.
  34866. * @param iterations the number of iterations.
  34867. * @param func the function to run each iteration
  34868. * @param successCallback the callback that will be called upon succesful execution
  34869. * @param offset starting offset.
  34870. */
  34871. constructor(
  34872. /**
  34873. * Defines the number of iterations for the loop
  34874. */
  34875. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34876. /**
  34877. * Execute the next iteration. Must be called after the last iteration was finished.
  34878. */
  34879. executeNext(): void;
  34880. /**
  34881. * Break the loop and run the success callback.
  34882. */
  34883. breakLoop(): void;
  34884. /**
  34885. * Create and run an async loop.
  34886. * @param iterations the number of iterations.
  34887. * @param fn the function to run each iteration
  34888. * @param successCallback the callback that will be called upon succesful execution
  34889. * @param offset starting offset.
  34890. * @returns the created async loop object
  34891. */
  34892. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34893. /**
  34894. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34895. * @param iterations total number of iterations
  34896. * @param syncedIterations number of synchronous iterations in each async iteration.
  34897. * @param fn the function to call each iteration.
  34898. * @param callback a success call back that will be called when iterating stops.
  34899. * @param breakFunction a break condition (optional)
  34900. * @param timeout timeout settings for the setTimeout function. default - 0.
  34901. * @returns the created async loop object
  34902. */
  34903. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34904. }
  34905. }
  34906. declare module "babylonjs/Misc/stringDictionary" {
  34907. import { Nullable } from "babylonjs/types";
  34908. /**
  34909. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34910. * The underlying implementation relies on an associative array to ensure the best performances.
  34911. * The value can be anything including 'null' but except 'undefined'
  34912. */
  34913. export class StringDictionary<T> {
  34914. /**
  34915. * This will clear this dictionary and copy the content from the 'source' one.
  34916. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34917. * @param source the dictionary to take the content from and copy to this dictionary
  34918. */
  34919. copyFrom(source: StringDictionary<T>): void;
  34920. /**
  34921. * Get a value based from its key
  34922. * @param key the given key to get the matching value from
  34923. * @return the value if found, otherwise undefined is returned
  34924. */
  34925. get(key: string): T | undefined;
  34926. /**
  34927. * Get a value from its key or add it if it doesn't exist.
  34928. * This method will ensure you that a given key/data will be present in the dictionary.
  34929. * @param key the given key to get the matching value from
  34930. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34931. * The factory will only be invoked if there's no data for the given key.
  34932. * @return the value corresponding to the key.
  34933. */
  34934. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34935. /**
  34936. * Get a value from its key if present in the dictionary otherwise add it
  34937. * @param key the key to get the value from
  34938. * @param val if there's no such key/value pair in the dictionary add it with this value
  34939. * @return the value corresponding to the key
  34940. */
  34941. getOrAdd(key: string, val: T): T;
  34942. /**
  34943. * Check if there's a given key in the dictionary
  34944. * @param key the key to check for
  34945. * @return true if the key is present, false otherwise
  34946. */
  34947. contains(key: string): boolean;
  34948. /**
  34949. * Add a new key and its corresponding value
  34950. * @param key the key to add
  34951. * @param value the value corresponding to the key
  34952. * @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
  34953. */
  34954. add(key: string, value: T): boolean;
  34955. /**
  34956. * Update a specific value associated to a key
  34957. * @param key defines the key to use
  34958. * @param value defines the value to store
  34959. * @returns true if the value was updated (or false if the key was not found)
  34960. */
  34961. set(key: string, value: T): boolean;
  34962. /**
  34963. * Get the element of the given key and remove it from the dictionary
  34964. * @param key defines the key to search
  34965. * @returns the value associated with the key or null if not found
  34966. */
  34967. getAndRemove(key: string): Nullable<T>;
  34968. /**
  34969. * Remove a key/value from the dictionary.
  34970. * @param key the key to remove
  34971. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34972. */
  34973. remove(key: string): boolean;
  34974. /**
  34975. * Clear the whole content of the dictionary
  34976. */
  34977. clear(): void;
  34978. /**
  34979. * Gets the current count
  34980. */
  34981. readonly count: number;
  34982. /**
  34983. * Execute a callback on each key/val of the dictionary.
  34984. * Note that you can remove any element in this dictionary in the callback implementation
  34985. * @param callback the callback to execute on a given key/value pair
  34986. */
  34987. forEach(callback: (key: string, val: T) => void): void;
  34988. /**
  34989. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34990. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34991. * Note that you can remove any element in this dictionary in the callback implementation
  34992. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34993. * @returns the first item
  34994. */
  34995. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34996. private _count;
  34997. private _data;
  34998. }
  34999. }
  35000. declare module "babylonjs/Collisions/collisionCoordinator" {
  35001. import { Nullable } from "babylonjs/types";
  35002. import { Scene } from "babylonjs/scene";
  35003. import { Vector3 } from "babylonjs/Maths/math.vector";
  35004. import { Collider } from "babylonjs/Collisions/collider";
  35005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35006. /** @hidden */
  35007. export interface ICollisionCoordinator {
  35008. createCollider(): Collider;
  35009. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35010. init(scene: Scene): void;
  35011. }
  35012. /** @hidden */
  35013. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35014. private _scene;
  35015. private _scaledPosition;
  35016. private _scaledVelocity;
  35017. private _finalPosition;
  35018. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35019. createCollider(): Collider;
  35020. init(scene: Scene): void;
  35021. private _collideWithWorld;
  35022. }
  35023. }
  35024. declare module "babylonjs/Inputs/scene.inputManager" {
  35025. import { Nullable } from "babylonjs/types";
  35026. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35027. import { Vector2 } from "babylonjs/Maths/math.vector";
  35028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35029. import { Scene } from "babylonjs/scene";
  35030. /**
  35031. * Class used to manage all inputs for the scene.
  35032. */
  35033. export class InputManager {
  35034. /** The distance in pixel that you have to move to prevent some events */
  35035. static DragMovementThreshold: number;
  35036. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35037. static LongPressDelay: number;
  35038. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35039. static DoubleClickDelay: number;
  35040. /** If you need to check double click without raising a single click at first click, enable this flag */
  35041. static ExclusiveDoubleClickMode: boolean;
  35042. private _wheelEventName;
  35043. private _onPointerMove;
  35044. private _onPointerDown;
  35045. private _onPointerUp;
  35046. private _initClickEvent;
  35047. private _initActionManager;
  35048. private _delayedSimpleClick;
  35049. private _delayedSimpleClickTimeout;
  35050. private _previousDelayedSimpleClickTimeout;
  35051. private _meshPickProceed;
  35052. private _previousButtonPressed;
  35053. private _currentPickResult;
  35054. private _previousPickResult;
  35055. private _totalPointersPressed;
  35056. private _doubleClickOccured;
  35057. private _pointerOverMesh;
  35058. private _pickedDownMesh;
  35059. private _pickedUpMesh;
  35060. private _pointerX;
  35061. private _pointerY;
  35062. private _unTranslatedPointerX;
  35063. private _unTranslatedPointerY;
  35064. private _startingPointerPosition;
  35065. private _previousStartingPointerPosition;
  35066. private _startingPointerTime;
  35067. private _previousStartingPointerTime;
  35068. private _pointerCaptures;
  35069. private _onKeyDown;
  35070. private _onKeyUp;
  35071. private _onCanvasFocusObserver;
  35072. private _onCanvasBlurObserver;
  35073. private _scene;
  35074. /**
  35075. * Creates a new InputManager
  35076. * @param scene defines the hosting scene
  35077. */
  35078. constructor(scene: Scene);
  35079. /**
  35080. * Gets the mesh that is currently under the pointer
  35081. */
  35082. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35083. /**
  35084. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35085. */
  35086. readonly unTranslatedPointer: Vector2;
  35087. /**
  35088. * Gets or sets the current on-screen X position of the pointer
  35089. */
  35090. pointerX: number;
  35091. /**
  35092. * Gets or sets the current on-screen Y position of the pointer
  35093. */
  35094. pointerY: number;
  35095. private _updatePointerPosition;
  35096. private _processPointerMove;
  35097. private _setRayOnPointerInfo;
  35098. private _checkPrePointerObservable;
  35099. /**
  35100. * Use this method to simulate a pointer move on a mesh
  35101. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35102. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35103. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35104. */
  35105. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35106. /**
  35107. * Use this method to simulate a pointer down on a mesh
  35108. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35109. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35110. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35111. */
  35112. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35113. private _processPointerDown;
  35114. /** @hidden */
  35115. _isPointerSwiping(): boolean;
  35116. /**
  35117. * Use this method to simulate a pointer up on a mesh
  35118. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35119. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35120. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35121. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35122. */
  35123. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35124. private _processPointerUp;
  35125. /**
  35126. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35127. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35128. * @returns true if the pointer was captured
  35129. */
  35130. isPointerCaptured(pointerId?: number): boolean;
  35131. /**
  35132. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35133. * @param attachUp defines if you want to attach events to pointerup
  35134. * @param attachDown defines if you want to attach events to pointerdown
  35135. * @param attachMove defines if you want to attach events to pointermove
  35136. */
  35137. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35138. /**
  35139. * Detaches all event handlers
  35140. */
  35141. detachControl(): void;
  35142. /**
  35143. * Force the value of meshUnderPointer
  35144. * @param mesh defines the mesh to use
  35145. */
  35146. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35147. /**
  35148. * Gets the mesh under the pointer
  35149. * @returns a Mesh or null if no mesh is under the pointer
  35150. */
  35151. getPointerOverMesh(): Nullable<AbstractMesh>;
  35152. }
  35153. }
  35154. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35155. /**
  35156. * Helper class used to generate session unique ID
  35157. */
  35158. export class UniqueIdGenerator {
  35159. private static _UniqueIdCounter;
  35160. /**
  35161. * Gets an unique (relatively to the current scene) Id
  35162. */
  35163. static readonly UniqueId: number;
  35164. }
  35165. }
  35166. declare module "babylonjs/Animations/animationGroup" {
  35167. import { Animatable } from "babylonjs/Animations/animatable";
  35168. import { Animation } from "babylonjs/Animations/animation";
  35169. import { Scene, IDisposable } from "babylonjs/scene";
  35170. import { Observable } from "babylonjs/Misc/observable";
  35171. import { Nullable } from "babylonjs/types";
  35172. import "babylonjs/Animations/animatable";
  35173. /**
  35174. * This class defines the direct association between an animation and a target
  35175. */
  35176. export class TargetedAnimation {
  35177. /**
  35178. * Animation to perform
  35179. */
  35180. animation: Animation;
  35181. /**
  35182. * Target to animate
  35183. */
  35184. target: any;
  35185. /**
  35186. * Serialize the object
  35187. * @returns the JSON object representing the current entity
  35188. */
  35189. serialize(): any;
  35190. }
  35191. /**
  35192. * Use this class to create coordinated animations on multiple targets
  35193. */
  35194. export class AnimationGroup implements IDisposable {
  35195. /** The name of the animation group */
  35196. name: string;
  35197. private _scene;
  35198. private _targetedAnimations;
  35199. private _animatables;
  35200. private _from;
  35201. private _to;
  35202. private _isStarted;
  35203. private _isPaused;
  35204. private _speedRatio;
  35205. private _loopAnimation;
  35206. /**
  35207. * Gets or sets the unique id of the node
  35208. */
  35209. uniqueId: number;
  35210. /**
  35211. * This observable will notify when one animation have ended
  35212. */
  35213. onAnimationEndObservable: Observable<TargetedAnimation>;
  35214. /**
  35215. * Observer raised when one animation loops
  35216. */
  35217. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35218. /**
  35219. * Observer raised when all animations have looped
  35220. */
  35221. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35222. /**
  35223. * This observable will notify when all animations have ended.
  35224. */
  35225. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35226. /**
  35227. * This observable will notify when all animations have paused.
  35228. */
  35229. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35230. /**
  35231. * This observable will notify when all animations are playing.
  35232. */
  35233. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35234. /**
  35235. * Gets the first frame
  35236. */
  35237. readonly from: number;
  35238. /**
  35239. * Gets the last frame
  35240. */
  35241. readonly to: number;
  35242. /**
  35243. * Define if the animations are started
  35244. */
  35245. readonly isStarted: boolean;
  35246. /**
  35247. * Gets a value indicating that the current group is playing
  35248. */
  35249. readonly isPlaying: boolean;
  35250. /**
  35251. * Gets or sets the speed ratio to use for all animations
  35252. */
  35253. /**
  35254. * Gets or sets the speed ratio to use for all animations
  35255. */
  35256. speedRatio: number;
  35257. /**
  35258. * Gets or sets if all animations should loop or not
  35259. */
  35260. loopAnimation: boolean;
  35261. /**
  35262. * Gets the targeted animations for this animation group
  35263. */
  35264. readonly targetedAnimations: Array<TargetedAnimation>;
  35265. /**
  35266. * returning the list of animatables controlled by this animation group.
  35267. */
  35268. readonly animatables: Array<Animatable>;
  35269. /**
  35270. * Instantiates a new Animation Group.
  35271. * This helps managing several animations at once.
  35272. * @see http://doc.babylonjs.com/how_to/group
  35273. * @param name Defines the name of the group
  35274. * @param scene Defines the scene the group belongs to
  35275. */
  35276. constructor(
  35277. /** The name of the animation group */
  35278. name: string, scene?: Nullable<Scene>);
  35279. /**
  35280. * Add an animation (with its target) in the group
  35281. * @param animation defines the animation we want to add
  35282. * @param target defines the target of the animation
  35283. * @returns the TargetedAnimation object
  35284. */
  35285. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35286. /**
  35287. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35288. * It can add constant keys at begin or end
  35289. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35290. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35291. * @returns the animation group
  35292. */
  35293. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35294. private _animationLoopCount;
  35295. private _animationLoopFlags;
  35296. private _processLoop;
  35297. /**
  35298. * Start all animations on given targets
  35299. * @param loop defines if animations must loop
  35300. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35301. * @param from defines the from key (optional)
  35302. * @param to defines the to key (optional)
  35303. * @returns the current animation group
  35304. */
  35305. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35306. /**
  35307. * Pause all animations
  35308. * @returns the animation group
  35309. */
  35310. pause(): AnimationGroup;
  35311. /**
  35312. * Play all animations to initial state
  35313. * This function will start() the animations if they were not started or will restart() them if they were paused
  35314. * @param loop defines if animations must loop
  35315. * @returns the animation group
  35316. */
  35317. play(loop?: boolean): AnimationGroup;
  35318. /**
  35319. * Reset all animations to initial state
  35320. * @returns the animation group
  35321. */
  35322. reset(): AnimationGroup;
  35323. /**
  35324. * Restart animations from key 0
  35325. * @returns the animation group
  35326. */
  35327. restart(): AnimationGroup;
  35328. /**
  35329. * Stop all animations
  35330. * @returns the animation group
  35331. */
  35332. stop(): AnimationGroup;
  35333. /**
  35334. * Set animation weight for all animatables
  35335. * @param weight defines the weight to use
  35336. * @return the animationGroup
  35337. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35338. */
  35339. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35340. /**
  35341. * Synchronize and normalize all animatables with a source animatable
  35342. * @param root defines the root animatable to synchronize with
  35343. * @return the animationGroup
  35344. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35345. */
  35346. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35347. /**
  35348. * Goes to a specific frame in this animation group
  35349. * @param frame the frame number to go to
  35350. * @return the animationGroup
  35351. */
  35352. goToFrame(frame: number): AnimationGroup;
  35353. /**
  35354. * Dispose all associated resources
  35355. */
  35356. dispose(): void;
  35357. private _checkAnimationGroupEnded;
  35358. /**
  35359. * Clone the current animation group and returns a copy
  35360. * @param newName defines the name of the new group
  35361. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35362. * @returns the new aniamtion group
  35363. */
  35364. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35365. /**
  35366. * Serializes the animationGroup to an object
  35367. * @returns Serialized object
  35368. */
  35369. serialize(): any;
  35370. /**
  35371. * Returns a new AnimationGroup object parsed from the source provided.
  35372. * @param parsedAnimationGroup defines the source
  35373. * @param scene defines the scene that will receive the animationGroup
  35374. * @returns a new AnimationGroup
  35375. */
  35376. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35377. /**
  35378. * Returns the string "AnimationGroup"
  35379. * @returns "AnimationGroup"
  35380. */
  35381. getClassName(): string;
  35382. /**
  35383. * Creates a detailled string about the object
  35384. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35385. * @returns a string representing the object
  35386. */
  35387. toString(fullDetails?: boolean): string;
  35388. }
  35389. }
  35390. declare module "babylonjs/scene" {
  35391. import { Nullable } from "babylonjs/types";
  35392. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35393. import { Observable } from "babylonjs/Misc/observable";
  35394. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35395. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35396. import { Geometry } from "babylonjs/Meshes/geometry";
  35397. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35398. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35400. import { Mesh } from "babylonjs/Meshes/mesh";
  35401. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35402. import { Bone } from "babylonjs/Bones/bone";
  35403. import { Skeleton } from "babylonjs/Bones/skeleton";
  35404. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35405. import { Camera } from "babylonjs/Cameras/camera";
  35406. import { AbstractScene } from "babylonjs/abstractScene";
  35407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35408. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35409. import { Material } from "babylonjs/Materials/material";
  35410. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35411. import { Effect } from "babylonjs/Materials/effect";
  35412. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35413. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35414. import { Light } from "babylonjs/Lights/light";
  35415. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35416. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35417. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35418. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35420. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35421. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35422. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35423. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35424. import { Engine } from "babylonjs/Engines/engine";
  35425. import { Node } from "babylonjs/node";
  35426. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35427. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35428. import { WebRequest } from "babylonjs/Misc/webRequest";
  35429. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35430. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35431. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35432. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35433. import { Plane } from "babylonjs/Maths/math.plane";
  35434. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35435. import { Ray } from "babylonjs/Culling/ray";
  35436. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35437. import { Animation } from "babylonjs/Animations/animation";
  35438. import { Animatable } from "babylonjs/Animations/animatable";
  35439. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35440. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35441. import { Collider } from "babylonjs/Collisions/collider";
  35442. /**
  35443. * Define an interface for all classes that will hold resources
  35444. */
  35445. export interface IDisposable {
  35446. /**
  35447. * Releases all held resources
  35448. */
  35449. dispose(): void;
  35450. }
  35451. /** Interface defining initialization parameters for Scene class */
  35452. export interface SceneOptions {
  35453. /**
  35454. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35455. * It will improve performance when the number of geometries becomes important.
  35456. */
  35457. useGeometryUniqueIdsMap?: boolean;
  35458. /**
  35459. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35460. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35461. */
  35462. useMaterialMeshMap?: boolean;
  35463. /**
  35464. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35465. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35466. */
  35467. useClonedMeshhMap?: boolean;
  35468. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35469. virtual?: boolean;
  35470. }
  35471. /**
  35472. * Represents a scene to be rendered by the engine.
  35473. * @see http://doc.babylonjs.com/features/scene
  35474. */
  35475. export class Scene extends AbstractScene implements IAnimatable {
  35476. /** The fog is deactivated */
  35477. static readonly FOGMODE_NONE: number;
  35478. /** The fog density is following an exponential function */
  35479. static readonly FOGMODE_EXP: number;
  35480. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35481. static readonly FOGMODE_EXP2: number;
  35482. /** The fog density is following a linear function. */
  35483. static readonly FOGMODE_LINEAR: number;
  35484. /**
  35485. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35486. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35487. */
  35488. static MinDeltaTime: number;
  35489. /**
  35490. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35491. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35492. */
  35493. static MaxDeltaTime: number;
  35494. /**
  35495. * Factory used to create the default material.
  35496. * @param name The name of the material to create
  35497. * @param scene The scene to create the material for
  35498. * @returns The default material
  35499. */
  35500. static DefaultMaterialFactory(scene: Scene): Material;
  35501. /**
  35502. * Factory used to create the a collision coordinator.
  35503. * @returns The collision coordinator
  35504. */
  35505. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35506. /** @hidden */
  35507. _inputManager: InputManager;
  35508. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35509. cameraToUseForPointers: Nullable<Camera>;
  35510. /** @hidden */
  35511. readonly _isScene: boolean;
  35512. /**
  35513. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35514. */
  35515. autoClear: boolean;
  35516. /**
  35517. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35518. */
  35519. autoClearDepthAndStencil: boolean;
  35520. /**
  35521. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35522. */
  35523. clearColor: Color4;
  35524. /**
  35525. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35526. */
  35527. ambientColor: Color3;
  35528. /**
  35529. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35530. * It should only be one of the following (if not the default embedded one):
  35531. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35532. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35533. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35534. * The material properties need to be setup according to the type of texture in use.
  35535. */
  35536. environmentBRDFTexture: BaseTexture;
  35537. /** @hidden */
  35538. protected _environmentTexture: Nullable<BaseTexture>;
  35539. /**
  35540. * Texture used in all pbr material as the reflection texture.
  35541. * As in the majority of the scene they are the same (exception for multi room and so on),
  35542. * this is easier to reference from here than from all the materials.
  35543. */
  35544. /**
  35545. * Texture used in all pbr material as the reflection texture.
  35546. * As in the majority of the scene they are the same (exception for multi room and so on),
  35547. * this is easier to set here than in all the materials.
  35548. */
  35549. environmentTexture: Nullable<BaseTexture>;
  35550. /** @hidden */
  35551. protected _environmentIntensity: number;
  35552. /**
  35553. * Intensity of the environment in all pbr material.
  35554. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35555. * As in the majority of the scene they are the same (exception for multi room and so on),
  35556. * this is easier to reference from here than from all the materials.
  35557. */
  35558. /**
  35559. * Intensity of the environment in all pbr material.
  35560. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35561. * As in the majority of the scene they are the same (exception for multi room and so on),
  35562. * this is easier to set here than in all the materials.
  35563. */
  35564. environmentIntensity: number;
  35565. /** @hidden */
  35566. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35567. /**
  35568. * Default image processing configuration used either in the rendering
  35569. * Forward main pass or through the imageProcessingPostProcess if present.
  35570. * As in the majority of the scene they are the same (exception for multi camera),
  35571. * this is easier to reference from here than from all the materials and post process.
  35572. *
  35573. * No setter as we it is a shared configuration, you can set the values instead.
  35574. */
  35575. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  35576. private _forceWireframe;
  35577. /**
  35578. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35579. */
  35580. forceWireframe: boolean;
  35581. private _forcePointsCloud;
  35582. /**
  35583. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35584. */
  35585. forcePointsCloud: boolean;
  35586. /**
  35587. * Gets or sets the active clipplane 1
  35588. */
  35589. clipPlane: Nullable<Plane>;
  35590. /**
  35591. * Gets or sets the active clipplane 2
  35592. */
  35593. clipPlane2: Nullable<Plane>;
  35594. /**
  35595. * Gets or sets the active clipplane 3
  35596. */
  35597. clipPlane3: Nullable<Plane>;
  35598. /**
  35599. * Gets or sets the active clipplane 4
  35600. */
  35601. clipPlane4: Nullable<Plane>;
  35602. /**
  35603. * Gets or sets a boolean indicating if animations are enabled
  35604. */
  35605. animationsEnabled: boolean;
  35606. private _animationPropertiesOverride;
  35607. /**
  35608. * Gets or sets the animation properties override
  35609. */
  35610. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  35611. /**
  35612. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35613. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35614. */
  35615. useConstantAnimationDeltaTime: boolean;
  35616. /**
  35617. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35618. * Please note that it requires to run a ray cast through the scene on every frame
  35619. */
  35620. constantlyUpdateMeshUnderPointer: boolean;
  35621. /**
  35622. * Defines the HTML cursor to use when hovering over interactive elements
  35623. */
  35624. hoverCursor: string;
  35625. /**
  35626. * Defines the HTML default cursor to use (empty by default)
  35627. */
  35628. defaultCursor: string;
  35629. /**
  35630. * Defines wether cursors are handled by the scene.
  35631. */
  35632. doNotHandleCursors: boolean;
  35633. /**
  35634. * This is used to call preventDefault() on pointer down
  35635. * in order to block unwanted artifacts like system double clicks
  35636. */
  35637. preventDefaultOnPointerDown: boolean;
  35638. /**
  35639. * This is used to call preventDefault() on pointer up
  35640. * in order to block unwanted artifacts like system double clicks
  35641. */
  35642. preventDefaultOnPointerUp: boolean;
  35643. /**
  35644. * Gets or sets user defined metadata
  35645. */
  35646. metadata: any;
  35647. /**
  35648. * For internal use only. Please do not use.
  35649. */
  35650. reservedDataStore: any;
  35651. /**
  35652. * Gets the name of the plugin used to load this scene (null by default)
  35653. */
  35654. loadingPluginName: string;
  35655. /**
  35656. * Use this array to add regular expressions used to disable offline support for specific urls
  35657. */
  35658. disableOfflineSupportExceptionRules: RegExp[];
  35659. /**
  35660. * An event triggered when the scene is disposed.
  35661. */
  35662. onDisposeObservable: Observable<Scene>;
  35663. private _onDisposeObserver;
  35664. /** Sets a function to be executed when this scene is disposed. */
  35665. onDispose: () => void;
  35666. /**
  35667. * An event triggered before rendering the scene (right after animations and physics)
  35668. */
  35669. onBeforeRenderObservable: Observable<Scene>;
  35670. private _onBeforeRenderObserver;
  35671. /** Sets a function to be executed before rendering this scene */
  35672. beforeRender: Nullable<() => void>;
  35673. /**
  35674. * An event triggered after rendering the scene
  35675. */
  35676. onAfterRenderObservable: Observable<Scene>;
  35677. /**
  35678. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35679. */
  35680. onAfterRenderCameraObservable: Observable<Camera>;
  35681. private _onAfterRenderObserver;
  35682. /** Sets a function to be executed after rendering this scene */
  35683. afterRender: Nullable<() => void>;
  35684. /**
  35685. * An event triggered before animating the scene
  35686. */
  35687. onBeforeAnimationsObservable: Observable<Scene>;
  35688. /**
  35689. * An event triggered after animations processing
  35690. */
  35691. onAfterAnimationsObservable: Observable<Scene>;
  35692. /**
  35693. * An event triggered before draw calls are ready to be sent
  35694. */
  35695. onBeforeDrawPhaseObservable: Observable<Scene>;
  35696. /**
  35697. * An event triggered after draw calls have been sent
  35698. */
  35699. onAfterDrawPhaseObservable: Observable<Scene>;
  35700. /**
  35701. * An event triggered when the scene is ready
  35702. */
  35703. onReadyObservable: Observable<Scene>;
  35704. /**
  35705. * An event triggered before rendering a camera
  35706. */
  35707. onBeforeCameraRenderObservable: Observable<Camera>;
  35708. private _onBeforeCameraRenderObserver;
  35709. /** Sets a function to be executed before rendering a camera*/
  35710. beforeCameraRender: () => void;
  35711. /**
  35712. * An event triggered after rendering a camera
  35713. */
  35714. onAfterCameraRenderObservable: Observable<Camera>;
  35715. private _onAfterCameraRenderObserver;
  35716. /** Sets a function to be executed after rendering a camera*/
  35717. afterCameraRender: () => void;
  35718. /**
  35719. * An event triggered when active meshes evaluation is about to start
  35720. */
  35721. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35722. /**
  35723. * An event triggered when active meshes evaluation is done
  35724. */
  35725. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35726. /**
  35727. * An event triggered when particles rendering is about to start
  35728. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35729. */
  35730. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35731. /**
  35732. * An event triggered when particles rendering is done
  35733. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35734. */
  35735. onAfterParticlesRenderingObservable: Observable<Scene>;
  35736. /**
  35737. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35738. */
  35739. onDataLoadedObservable: Observable<Scene>;
  35740. /**
  35741. * An event triggered when a camera is created
  35742. */
  35743. onNewCameraAddedObservable: Observable<Camera>;
  35744. /**
  35745. * An event triggered when a camera is removed
  35746. */
  35747. onCameraRemovedObservable: Observable<Camera>;
  35748. /**
  35749. * An event triggered when a light is created
  35750. */
  35751. onNewLightAddedObservable: Observable<Light>;
  35752. /**
  35753. * An event triggered when a light is removed
  35754. */
  35755. onLightRemovedObservable: Observable<Light>;
  35756. /**
  35757. * An event triggered when a geometry is created
  35758. */
  35759. onNewGeometryAddedObservable: Observable<Geometry>;
  35760. /**
  35761. * An event triggered when a geometry is removed
  35762. */
  35763. onGeometryRemovedObservable: Observable<Geometry>;
  35764. /**
  35765. * An event triggered when a transform node is created
  35766. */
  35767. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35768. /**
  35769. * An event triggered when a transform node is removed
  35770. */
  35771. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35772. /**
  35773. * An event triggered when a mesh is created
  35774. */
  35775. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35776. /**
  35777. * An event triggered when a mesh is removed
  35778. */
  35779. onMeshRemovedObservable: Observable<AbstractMesh>;
  35780. /**
  35781. * An event triggered when a skeleton is created
  35782. */
  35783. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35784. /**
  35785. * An event triggered when a skeleton is removed
  35786. */
  35787. onSkeletonRemovedObservable: Observable<Skeleton>;
  35788. /**
  35789. * An event triggered when a material is created
  35790. */
  35791. onNewMaterialAddedObservable: Observable<Material>;
  35792. /**
  35793. * An event triggered when a material is removed
  35794. */
  35795. onMaterialRemovedObservable: Observable<Material>;
  35796. /**
  35797. * An event triggered when a texture is created
  35798. */
  35799. onNewTextureAddedObservable: Observable<BaseTexture>;
  35800. /**
  35801. * An event triggered when a texture is removed
  35802. */
  35803. onTextureRemovedObservable: Observable<BaseTexture>;
  35804. /**
  35805. * An event triggered when render targets are about to be rendered
  35806. * Can happen multiple times per frame.
  35807. */
  35808. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35809. /**
  35810. * An event triggered when render targets were rendered.
  35811. * Can happen multiple times per frame.
  35812. */
  35813. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35814. /**
  35815. * An event triggered before calculating deterministic simulation step
  35816. */
  35817. onBeforeStepObservable: Observable<Scene>;
  35818. /**
  35819. * An event triggered after calculating deterministic simulation step
  35820. */
  35821. onAfterStepObservable: Observable<Scene>;
  35822. /**
  35823. * An event triggered when the activeCamera property is updated
  35824. */
  35825. onActiveCameraChanged: Observable<Scene>;
  35826. /**
  35827. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35828. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35829. * 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)
  35830. */
  35831. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35832. /**
  35833. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35834. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35835. * 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)
  35836. */
  35837. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35838. /**
  35839. * This Observable will when a mesh has been imported into the scene.
  35840. */
  35841. onMeshImportedObservable: Observable<AbstractMesh>;
  35842. /**
  35843. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35844. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35845. */
  35846. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35847. /** @hidden */
  35848. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35849. /**
  35850. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35851. */
  35852. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35853. /**
  35854. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35855. */
  35856. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35857. /**
  35858. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35859. */
  35860. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35861. /** Callback called when a pointer move is detected */
  35862. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35863. /** Callback called when a pointer down is detected */
  35864. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35865. /** Callback called when a pointer up is detected */
  35866. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35867. /** Callback called when a pointer pick is detected */
  35868. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35869. /**
  35870. * 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).
  35871. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35872. */
  35873. onPrePointerObservable: Observable<PointerInfoPre>;
  35874. /**
  35875. * Observable event triggered each time an input event is received from the rendering canvas
  35876. */
  35877. onPointerObservable: Observable<PointerInfo>;
  35878. /**
  35879. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35880. */
  35881. readonly unTranslatedPointer: Vector2;
  35882. /**
  35883. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35884. */
  35885. static DragMovementThreshold: number;
  35886. /**
  35887. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35888. */
  35889. static LongPressDelay: number;
  35890. /**
  35891. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35892. */
  35893. static DoubleClickDelay: number;
  35894. /** If you need to check double click without raising a single click at first click, enable this flag */
  35895. static ExclusiveDoubleClickMode: boolean;
  35896. /** @hidden */
  35897. _mirroredCameraPosition: Nullable<Vector3>;
  35898. /**
  35899. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35900. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35901. */
  35902. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35903. /**
  35904. * Observable event triggered each time an keyboard event is received from the hosting window
  35905. */
  35906. onKeyboardObservable: Observable<KeyboardInfo>;
  35907. private _useRightHandedSystem;
  35908. /**
  35909. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35910. */
  35911. useRightHandedSystem: boolean;
  35912. private _timeAccumulator;
  35913. private _currentStepId;
  35914. private _currentInternalStep;
  35915. /**
  35916. * Sets the step Id used by deterministic lock step
  35917. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35918. * @param newStepId defines the step Id
  35919. */
  35920. setStepId(newStepId: number): void;
  35921. /**
  35922. * Gets the step Id used by deterministic lock step
  35923. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35924. * @returns the step Id
  35925. */
  35926. getStepId(): number;
  35927. /**
  35928. * Gets the internal step used by deterministic lock step
  35929. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35930. * @returns the internal step
  35931. */
  35932. getInternalStep(): number;
  35933. private _fogEnabled;
  35934. /**
  35935. * Gets or sets a boolean indicating if fog is enabled on this scene
  35936. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35937. * (Default is true)
  35938. */
  35939. fogEnabled: boolean;
  35940. private _fogMode;
  35941. /**
  35942. * Gets or sets the fog mode to use
  35943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35944. * | mode | value |
  35945. * | --- | --- |
  35946. * | FOGMODE_NONE | 0 |
  35947. * | FOGMODE_EXP | 1 |
  35948. * | FOGMODE_EXP2 | 2 |
  35949. * | FOGMODE_LINEAR | 3 |
  35950. */
  35951. fogMode: number;
  35952. /**
  35953. * Gets or sets the fog color to use
  35954. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35955. * (Default is Color3(0.2, 0.2, 0.3))
  35956. */
  35957. fogColor: Color3;
  35958. /**
  35959. * Gets or sets the fog density to use
  35960. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35961. * (Default is 0.1)
  35962. */
  35963. fogDensity: number;
  35964. /**
  35965. * Gets or sets the fog start distance to use
  35966. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35967. * (Default is 0)
  35968. */
  35969. fogStart: number;
  35970. /**
  35971. * Gets or sets the fog end distance to use
  35972. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35973. * (Default is 1000)
  35974. */
  35975. fogEnd: number;
  35976. private _shadowsEnabled;
  35977. /**
  35978. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35979. */
  35980. shadowsEnabled: boolean;
  35981. private _lightsEnabled;
  35982. /**
  35983. * Gets or sets a boolean indicating if lights are enabled on this scene
  35984. */
  35985. lightsEnabled: boolean;
  35986. /** All of the active cameras added to this scene. */
  35987. activeCameras: Camera[];
  35988. /** @hidden */
  35989. _activeCamera: Nullable<Camera>;
  35990. /** Gets or sets the current active camera */
  35991. activeCamera: Nullable<Camera>;
  35992. private _defaultMaterial;
  35993. /** The default material used on meshes when no material is affected */
  35994. /** The default material used on meshes when no material is affected */
  35995. defaultMaterial: Material;
  35996. private _texturesEnabled;
  35997. /**
  35998. * Gets or sets a boolean indicating if textures are enabled on this scene
  35999. */
  36000. texturesEnabled: boolean;
  36001. /**
  36002. * Gets or sets a boolean indicating if particles are enabled on this scene
  36003. */
  36004. particlesEnabled: boolean;
  36005. /**
  36006. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36007. */
  36008. spritesEnabled: boolean;
  36009. private _skeletonsEnabled;
  36010. /**
  36011. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36012. */
  36013. skeletonsEnabled: boolean;
  36014. /**
  36015. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36016. */
  36017. lensFlaresEnabled: boolean;
  36018. /**
  36019. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36020. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36021. */
  36022. collisionsEnabled: boolean;
  36023. private _collisionCoordinator;
  36024. /** @hidden */
  36025. readonly collisionCoordinator: ICollisionCoordinator;
  36026. /**
  36027. * Defines the gravity applied to this scene (used only for collisions)
  36028. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36029. */
  36030. gravity: Vector3;
  36031. /**
  36032. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36033. */
  36034. postProcessesEnabled: boolean;
  36035. /**
  36036. * The list of postprocesses added to the scene
  36037. */
  36038. postProcesses: PostProcess[];
  36039. /**
  36040. * Gets the current postprocess manager
  36041. */
  36042. postProcessManager: PostProcessManager;
  36043. /**
  36044. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36045. */
  36046. renderTargetsEnabled: boolean;
  36047. /**
  36048. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36049. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36050. */
  36051. dumpNextRenderTargets: boolean;
  36052. /**
  36053. * The list of user defined render targets added to the scene
  36054. */
  36055. customRenderTargets: RenderTargetTexture[];
  36056. /**
  36057. * Defines if texture loading must be delayed
  36058. * If true, textures will only be loaded when they need to be rendered
  36059. */
  36060. useDelayedTextureLoading: boolean;
  36061. /**
  36062. * Gets the list of meshes imported to the scene through SceneLoader
  36063. */
  36064. importedMeshesFiles: String[];
  36065. /**
  36066. * Gets or sets a boolean indicating if probes are enabled on this scene
  36067. */
  36068. probesEnabled: boolean;
  36069. /**
  36070. * Gets or sets the current offline provider to use to store scene data
  36071. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36072. */
  36073. offlineProvider: IOfflineProvider;
  36074. /**
  36075. * Gets or sets the action manager associated with the scene
  36076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36077. */
  36078. actionManager: AbstractActionManager;
  36079. private _meshesForIntersections;
  36080. /**
  36081. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36082. */
  36083. proceduralTexturesEnabled: boolean;
  36084. private _engine;
  36085. private _totalVertices;
  36086. /** @hidden */
  36087. _activeIndices: PerfCounter;
  36088. /** @hidden */
  36089. _activeParticles: PerfCounter;
  36090. /** @hidden */
  36091. _activeBones: PerfCounter;
  36092. private _animationRatio;
  36093. /** @hidden */
  36094. _animationTimeLast: number;
  36095. /** @hidden */
  36096. _animationTime: number;
  36097. /**
  36098. * Gets or sets a general scale for animation speed
  36099. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36100. */
  36101. animationTimeScale: number;
  36102. /** @hidden */
  36103. _cachedMaterial: Nullable<Material>;
  36104. /** @hidden */
  36105. _cachedEffect: Nullable<Effect>;
  36106. /** @hidden */
  36107. _cachedVisibility: Nullable<number>;
  36108. private _renderId;
  36109. private _frameId;
  36110. private _executeWhenReadyTimeoutId;
  36111. private _intermediateRendering;
  36112. private _viewUpdateFlag;
  36113. private _projectionUpdateFlag;
  36114. /** @hidden */
  36115. _toBeDisposed: Nullable<IDisposable>[];
  36116. private _activeRequests;
  36117. /** @hidden */
  36118. _pendingData: any[];
  36119. private _isDisposed;
  36120. /**
  36121. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36122. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36123. */
  36124. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36125. private _activeMeshes;
  36126. private _processedMaterials;
  36127. private _renderTargets;
  36128. /** @hidden */
  36129. _activeParticleSystems: SmartArray<IParticleSystem>;
  36130. private _activeSkeletons;
  36131. private _softwareSkinnedMeshes;
  36132. private _renderingManager;
  36133. /** @hidden */
  36134. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36135. private _transformMatrix;
  36136. private _sceneUbo;
  36137. /** @hidden */
  36138. _viewMatrix: Matrix;
  36139. private _projectionMatrix;
  36140. /** @hidden */
  36141. _forcedViewPosition: Nullable<Vector3>;
  36142. /** @hidden */
  36143. _frustumPlanes: Plane[];
  36144. /**
  36145. * Gets the list of frustum planes (built from the active camera)
  36146. */
  36147. readonly frustumPlanes: Plane[];
  36148. /**
  36149. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36150. * This is useful if there are more lights that the maximum simulteanous authorized
  36151. */
  36152. requireLightSorting: boolean;
  36153. /** @hidden */
  36154. readonly useMaterialMeshMap: boolean;
  36155. /** @hidden */
  36156. readonly useClonedMeshhMap: boolean;
  36157. private _externalData;
  36158. private _uid;
  36159. /**
  36160. * @hidden
  36161. * Backing store of defined scene components.
  36162. */
  36163. _components: ISceneComponent[];
  36164. /**
  36165. * @hidden
  36166. * Backing store of defined scene components.
  36167. */
  36168. _serializableComponents: ISceneSerializableComponent[];
  36169. /**
  36170. * List of components to register on the next registration step.
  36171. */
  36172. private _transientComponents;
  36173. /**
  36174. * Registers the transient components if needed.
  36175. */
  36176. private _registerTransientComponents;
  36177. /**
  36178. * @hidden
  36179. * Add a component to the scene.
  36180. * Note that the ccomponent could be registered on th next frame if this is called after
  36181. * the register component stage.
  36182. * @param component Defines the component to add to the scene
  36183. */
  36184. _addComponent(component: ISceneComponent): void;
  36185. /**
  36186. * @hidden
  36187. * Gets a component from the scene.
  36188. * @param name defines the name of the component to retrieve
  36189. * @returns the component or null if not present
  36190. */
  36191. _getComponent(name: string): Nullable<ISceneComponent>;
  36192. /**
  36193. * @hidden
  36194. * Defines the actions happening before camera updates.
  36195. */
  36196. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36197. /**
  36198. * @hidden
  36199. * Defines the actions happening before clear the canvas.
  36200. */
  36201. _beforeClearStage: Stage<SimpleStageAction>;
  36202. /**
  36203. * @hidden
  36204. * Defines the actions when collecting render targets for the frame.
  36205. */
  36206. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36207. /**
  36208. * @hidden
  36209. * Defines the actions happening for one camera in the frame.
  36210. */
  36211. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36212. /**
  36213. * @hidden
  36214. * Defines the actions happening during the per mesh ready checks.
  36215. */
  36216. _isReadyForMeshStage: Stage<MeshStageAction>;
  36217. /**
  36218. * @hidden
  36219. * Defines the actions happening before evaluate active mesh checks.
  36220. */
  36221. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36222. /**
  36223. * @hidden
  36224. * Defines the actions happening during the evaluate sub mesh checks.
  36225. */
  36226. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36227. /**
  36228. * @hidden
  36229. * Defines the actions happening during the active mesh stage.
  36230. */
  36231. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36232. /**
  36233. * @hidden
  36234. * Defines the actions happening during the per camera render target step.
  36235. */
  36236. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36237. /**
  36238. * @hidden
  36239. * Defines the actions happening just before the active camera is drawing.
  36240. */
  36241. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36242. /**
  36243. * @hidden
  36244. * Defines the actions happening just before a render target is drawing.
  36245. */
  36246. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36247. /**
  36248. * @hidden
  36249. * Defines the actions happening just before a rendering group is drawing.
  36250. */
  36251. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36252. /**
  36253. * @hidden
  36254. * Defines the actions happening just before a mesh is drawing.
  36255. */
  36256. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36257. /**
  36258. * @hidden
  36259. * Defines the actions happening just after a mesh has been drawn.
  36260. */
  36261. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36262. /**
  36263. * @hidden
  36264. * Defines the actions happening just after a rendering group has been drawn.
  36265. */
  36266. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36267. /**
  36268. * @hidden
  36269. * Defines the actions happening just after the active camera has been drawn.
  36270. */
  36271. _afterCameraDrawStage: Stage<CameraStageAction>;
  36272. /**
  36273. * @hidden
  36274. * Defines the actions happening just after a render target has been drawn.
  36275. */
  36276. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36277. /**
  36278. * @hidden
  36279. * Defines the actions happening just after rendering all cameras and computing intersections.
  36280. */
  36281. _afterRenderStage: Stage<SimpleStageAction>;
  36282. /**
  36283. * @hidden
  36284. * Defines the actions happening when a pointer move event happens.
  36285. */
  36286. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36287. /**
  36288. * @hidden
  36289. * Defines the actions happening when a pointer down event happens.
  36290. */
  36291. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36292. /**
  36293. * @hidden
  36294. * Defines the actions happening when a pointer up event happens.
  36295. */
  36296. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36297. /**
  36298. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36299. */
  36300. private geometriesByUniqueId;
  36301. /**
  36302. * Creates a new Scene
  36303. * @param engine defines the engine to use to render this scene
  36304. * @param options defines the scene options
  36305. */
  36306. constructor(engine: Engine, options?: SceneOptions);
  36307. /**
  36308. * Gets a string idenfifying the name of the class
  36309. * @returns "Scene" string
  36310. */
  36311. getClassName(): string;
  36312. private _defaultMeshCandidates;
  36313. /**
  36314. * @hidden
  36315. */
  36316. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36317. private _defaultSubMeshCandidates;
  36318. /**
  36319. * @hidden
  36320. */
  36321. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36322. /**
  36323. * Sets the default candidate providers for the scene.
  36324. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36325. * and getCollidingSubMeshCandidates to their default function
  36326. */
  36327. setDefaultCandidateProviders(): void;
  36328. /**
  36329. * Gets the mesh that is currently under the pointer
  36330. */
  36331. readonly meshUnderPointer: Nullable<AbstractMesh>;
  36332. /**
  36333. * Gets or sets the current on-screen X position of the pointer
  36334. */
  36335. pointerX: number;
  36336. /**
  36337. * Gets or sets the current on-screen Y position of the pointer
  36338. */
  36339. pointerY: number;
  36340. /**
  36341. * Gets the cached material (ie. the latest rendered one)
  36342. * @returns the cached material
  36343. */
  36344. getCachedMaterial(): Nullable<Material>;
  36345. /**
  36346. * Gets the cached effect (ie. the latest rendered one)
  36347. * @returns the cached effect
  36348. */
  36349. getCachedEffect(): Nullable<Effect>;
  36350. /**
  36351. * Gets the cached visibility state (ie. the latest rendered one)
  36352. * @returns the cached visibility state
  36353. */
  36354. getCachedVisibility(): Nullable<number>;
  36355. /**
  36356. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36357. * @param material defines the current material
  36358. * @param effect defines the current effect
  36359. * @param visibility defines the current visibility state
  36360. * @returns true if one parameter is not cached
  36361. */
  36362. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36363. /**
  36364. * Gets the engine associated with the scene
  36365. * @returns an Engine
  36366. */
  36367. getEngine(): Engine;
  36368. /**
  36369. * Gets the total number of vertices rendered per frame
  36370. * @returns the total number of vertices rendered per frame
  36371. */
  36372. getTotalVertices(): number;
  36373. /**
  36374. * Gets the performance counter for total vertices
  36375. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36376. */
  36377. readonly totalVerticesPerfCounter: PerfCounter;
  36378. /**
  36379. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36380. * @returns the total number of active indices rendered per frame
  36381. */
  36382. getActiveIndices(): number;
  36383. /**
  36384. * Gets the performance counter for active indices
  36385. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36386. */
  36387. readonly totalActiveIndicesPerfCounter: PerfCounter;
  36388. /**
  36389. * Gets the total number of active particles rendered per frame
  36390. * @returns the total number of active particles rendered per frame
  36391. */
  36392. getActiveParticles(): number;
  36393. /**
  36394. * Gets the performance counter for active particles
  36395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36396. */
  36397. readonly activeParticlesPerfCounter: PerfCounter;
  36398. /**
  36399. * Gets the total number of active bones rendered per frame
  36400. * @returns the total number of active bones rendered per frame
  36401. */
  36402. getActiveBones(): number;
  36403. /**
  36404. * Gets the performance counter for active bones
  36405. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36406. */
  36407. readonly activeBonesPerfCounter: PerfCounter;
  36408. /**
  36409. * Gets the array of active meshes
  36410. * @returns an array of AbstractMesh
  36411. */
  36412. getActiveMeshes(): SmartArray<AbstractMesh>;
  36413. /**
  36414. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36415. * @returns a number
  36416. */
  36417. getAnimationRatio(): number;
  36418. /**
  36419. * Gets an unique Id for the current render phase
  36420. * @returns a number
  36421. */
  36422. getRenderId(): number;
  36423. /**
  36424. * Gets an unique Id for the current frame
  36425. * @returns a number
  36426. */
  36427. getFrameId(): number;
  36428. /** Call this function if you want to manually increment the render Id*/
  36429. incrementRenderId(): void;
  36430. private _createUbo;
  36431. /**
  36432. * Use this method to simulate a pointer move on a mesh
  36433. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36434. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36435. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36436. * @returns the current scene
  36437. */
  36438. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36439. /**
  36440. * Use this method to simulate a pointer down on a mesh
  36441. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36442. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36443. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36444. * @returns the current scene
  36445. */
  36446. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36447. /**
  36448. * Use this method to simulate a pointer up on a mesh
  36449. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36450. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36451. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36452. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36453. * @returns the current scene
  36454. */
  36455. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36456. /**
  36457. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36458. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36459. * @returns true if the pointer was captured
  36460. */
  36461. isPointerCaptured(pointerId?: number): boolean;
  36462. /**
  36463. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36464. * @param attachUp defines if you want to attach events to pointerup
  36465. * @param attachDown defines if you want to attach events to pointerdown
  36466. * @param attachMove defines if you want to attach events to pointermove
  36467. */
  36468. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36469. /** Detaches all event handlers*/
  36470. detachControl(): void;
  36471. /**
  36472. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36473. * Delay loaded resources are not taking in account
  36474. * @return true if all required resources are ready
  36475. */
  36476. isReady(): boolean;
  36477. /** Resets all cached information relative to material (including effect and visibility) */
  36478. resetCachedMaterial(): void;
  36479. /**
  36480. * Registers a function to be called before every frame render
  36481. * @param func defines the function to register
  36482. */
  36483. registerBeforeRender(func: () => void): void;
  36484. /**
  36485. * Unregisters a function called before every frame render
  36486. * @param func defines the function to unregister
  36487. */
  36488. unregisterBeforeRender(func: () => void): void;
  36489. /**
  36490. * Registers a function to be called after every frame render
  36491. * @param func defines the function to register
  36492. */
  36493. registerAfterRender(func: () => void): void;
  36494. /**
  36495. * Unregisters a function called after every frame render
  36496. * @param func defines the function to unregister
  36497. */
  36498. unregisterAfterRender(func: () => void): void;
  36499. private _executeOnceBeforeRender;
  36500. /**
  36501. * The provided function will run before render once and will be disposed afterwards.
  36502. * A timeout delay can be provided so that the function will be executed in N ms.
  36503. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36504. * @param func The function to be executed.
  36505. * @param timeout optional delay in ms
  36506. */
  36507. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36508. /** @hidden */
  36509. _addPendingData(data: any): void;
  36510. /** @hidden */
  36511. _removePendingData(data: any): void;
  36512. /**
  36513. * Returns the number of items waiting to be loaded
  36514. * @returns the number of items waiting to be loaded
  36515. */
  36516. getWaitingItemsCount(): number;
  36517. /**
  36518. * Returns a boolean indicating if the scene is still loading data
  36519. */
  36520. readonly isLoading: boolean;
  36521. /**
  36522. * Registers a function to be executed when the scene is ready
  36523. * @param {Function} func - the function to be executed
  36524. */
  36525. executeWhenReady(func: () => void): void;
  36526. /**
  36527. * Returns a promise that resolves when the scene is ready
  36528. * @returns A promise that resolves when the scene is ready
  36529. */
  36530. whenReadyAsync(): Promise<void>;
  36531. /** @hidden */
  36532. _checkIsReady(): void;
  36533. /**
  36534. * Gets all animatable attached to the scene
  36535. */
  36536. readonly animatables: Animatable[];
  36537. /**
  36538. * Resets the last animation time frame.
  36539. * Useful to override when animations start running when loading a scene for the first time.
  36540. */
  36541. resetLastAnimationTimeFrame(): void;
  36542. /**
  36543. * Gets the current view matrix
  36544. * @returns a Matrix
  36545. */
  36546. getViewMatrix(): Matrix;
  36547. /**
  36548. * Gets the current projection matrix
  36549. * @returns a Matrix
  36550. */
  36551. getProjectionMatrix(): Matrix;
  36552. /**
  36553. * Gets the current transform matrix
  36554. * @returns a Matrix made of View * Projection
  36555. */
  36556. getTransformMatrix(): Matrix;
  36557. /**
  36558. * Sets the current transform matrix
  36559. * @param viewL defines the View matrix to use
  36560. * @param projectionL defines the Projection matrix to use
  36561. * @param viewR defines the right View matrix to use (if provided)
  36562. * @param projectionR defines the right Projection matrix to use (if provided)
  36563. */
  36564. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36565. /**
  36566. * Gets the uniform buffer used to store scene data
  36567. * @returns a UniformBuffer
  36568. */
  36569. getSceneUniformBuffer(): UniformBuffer;
  36570. /**
  36571. * Gets an unique (relatively to the current scene) Id
  36572. * @returns an unique number for the scene
  36573. */
  36574. getUniqueId(): number;
  36575. /**
  36576. * Add a mesh to the list of scene's meshes
  36577. * @param newMesh defines the mesh to add
  36578. * @param recursive if all child meshes should also be added to the scene
  36579. */
  36580. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36581. /**
  36582. * Remove a mesh for the list of scene's meshes
  36583. * @param toRemove defines the mesh to remove
  36584. * @param recursive if all child meshes should also be removed from the scene
  36585. * @returns the index where the mesh was in the mesh list
  36586. */
  36587. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36588. /**
  36589. * Add a transform node to the list of scene's transform nodes
  36590. * @param newTransformNode defines the transform node to add
  36591. */
  36592. addTransformNode(newTransformNode: TransformNode): void;
  36593. /**
  36594. * Remove a transform node for the list of scene's transform nodes
  36595. * @param toRemove defines the transform node to remove
  36596. * @returns the index where the transform node was in the transform node list
  36597. */
  36598. removeTransformNode(toRemove: TransformNode): number;
  36599. /**
  36600. * Remove a skeleton for the list of scene's skeletons
  36601. * @param toRemove defines the skeleton to remove
  36602. * @returns the index where the skeleton was in the skeleton list
  36603. */
  36604. removeSkeleton(toRemove: Skeleton): number;
  36605. /**
  36606. * Remove a morph target for the list of scene's morph targets
  36607. * @param toRemove defines the morph target to remove
  36608. * @returns the index where the morph target was in the morph target list
  36609. */
  36610. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36611. /**
  36612. * Remove a light for the list of scene's lights
  36613. * @param toRemove defines the light to remove
  36614. * @returns the index where the light was in the light list
  36615. */
  36616. removeLight(toRemove: Light): number;
  36617. /**
  36618. * Remove a camera for the list of scene's cameras
  36619. * @param toRemove defines the camera to remove
  36620. * @returns the index where the camera was in the camera list
  36621. */
  36622. removeCamera(toRemove: Camera): number;
  36623. /**
  36624. * Remove a particle system for the list of scene's particle systems
  36625. * @param toRemove defines the particle system to remove
  36626. * @returns the index where the particle system was in the particle system list
  36627. */
  36628. removeParticleSystem(toRemove: IParticleSystem): number;
  36629. /**
  36630. * Remove a animation for the list of scene's animations
  36631. * @param toRemove defines the animation to remove
  36632. * @returns the index where the animation was in the animation list
  36633. */
  36634. removeAnimation(toRemove: Animation): number;
  36635. /**
  36636. * Will stop the animation of the given target
  36637. * @param target - the target
  36638. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36639. * @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)
  36640. */
  36641. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36642. /**
  36643. * Removes the given animation group from this scene.
  36644. * @param toRemove The animation group to remove
  36645. * @returns The index of the removed animation group
  36646. */
  36647. removeAnimationGroup(toRemove: AnimationGroup): number;
  36648. /**
  36649. * Removes the given multi-material from this scene.
  36650. * @param toRemove The multi-material to remove
  36651. * @returns The index of the removed multi-material
  36652. */
  36653. removeMultiMaterial(toRemove: MultiMaterial): number;
  36654. /**
  36655. * Removes the given material from this scene.
  36656. * @param toRemove The material to remove
  36657. * @returns The index of the removed material
  36658. */
  36659. removeMaterial(toRemove: Material): number;
  36660. /**
  36661. * Removes the given action manager from this scene.
  36662. * @param toRemove The action manager to remove
  36663. * @returns The index of the removed action manager
  36664. */
  36665. removeActionManager(toRemove: AbstractActionManager): number;
  36666. /**
  36667. * Removes the given texture from this scene.
  36668. * @param toRemove The texture to remove
  36669. * @returns The index of the removed texture
  36670. */
  36671. removeTexture(toRemove: BaseTexture): number;
  36672. /**
  36673. * Adds the given light to this scene
  36674. * @param newLight The light to add
  36675. */
  36676. addLight(newLight: Light): void;
  36677. /**
  36678. * Sorts the list list based on light priorities
  36679. */
  36680. sortLightsByPriority(): void;
  36681. /**
  36682. * Adds the given camera to this scene
  36683. * @param newCamera The camera to add
  36684. */
  36685. addCamera(newCamera: Camera): void;
  36686. /**
  36687. * Adds the given skeleton to this scene
  36688. * @param newSkeleton The skeleton to add
  36689. */
  36690. addSkeleton(newSkeleton: Skeleton): void;
  36691. /**
  36692. * Adds the given particle system to this scene
  36693. * @param newParticleSystem The particle system to add
  36694. */
  36695. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36696. /**
  36697. * Adds the given animation to this scene
  36698. * @param newAnimation The animation to add
  36699. */
  36700. addAnimation(newAnimation: Animation): void;
  36701. /**
  36702. * Adds the given animation group to this scene.
  36703. * @param newAnimationGroup The animation group to add
  36704. */
  36705. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36706. /**
  36707. * Adds the given multi-material to this scene
  36708. * @param newMultiMaterial The multi-material to add
  36709. */
  36710. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36711. /**
  36712. * Adds the given material to this scene
  36713. * @param newMaterial The material to add
  36714. */
  36715. addMaterial(newMaterial: Material): void;
  36716. /**
  36717. * Adds the given morph target to this scene
  36718. * @param newMorphTargetManager The morph target to add
  36719. */
  36720. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36721. /**
  36722. * Adds the given geometry to this scene
  36723. * @param newGeometry The geometry to add
  36724. */
  36725. addGeometry(newGeometry: Geometry): void;
  36726. /**
  36727. * Adds the given action manager to this scene
  36728. * @param newActionManager The action manager to add
  36729. */
  36730. addActionManager(newActionManager: AbstractActionManager): void;
  36731. /**
  36732. * Adds the given texture to this scene.
  36733. * @param newTexture The texture to add
  36734. */
  36735. addTexture(newTexture: BaseTexture): void;
  36736. /**
  36737. * Switch active camera
  36738. * @param newCamera defines the new active camera
  36739. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36740. */
  36741. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36742. /**
  36743. * sets the active camera of the scene using its ID
  36744. * @param id defines the camera's ID
  36745. * @return the new active camera or null if none found.
  36746. */
  36747. setActiveCameraByID(id: string): Nullable<Camera>;
  36748. /**
  36749. * sets the active camera of the scene using its name
  36750. * @param name defines the camera's name
  36751. * @returns the new active camera or null if none found.
  36752. */
  36753. setActiveCameraByName(name: string): Nullable<Camera>;
  36754. /**
  36755. * get an animation group using its name
  36756. * @param name defines the material's name
  36757. * @return the animation group or null if none found.
  36758. */
  36759. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36760. /**
  36761. * Get a material using its unique id
  36762. * @param uniqueId defines the material's unique id
  36763. * @return the material or null if none found.
  36764. */
  36765. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36766. /**
  36767. * get a material using its id
  36768. * @param id defines the material's ID
  36769. * @return the material or null if none found.
  36770. */
  36771. getMaterialByID(id: string): Nullable<Material>;
  36772. /**
  36773. * Gets a the last added material using a given id
  36774. * @param id defines the material's ID
  36775. * @return the last material with the given id or null if none found.
  36776. */
  36777. getLastMaterialByID(id: string): Nullable<Material>;
  36778. /**
  36779. * Gets a material using its name
  36780. * @param name defines the material's name
  36781. * @return the material or null if none found.
  36782. */
  36783. getMaterialByName(name: string): Nullable<Material>;
  36784. /**
  36785. * Get a texture using its unique id
  36786. * @param uniqueId defines the texture's unique id
  36787. * @return the texture or null if none found.
  36788. */
  36789. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36790. /**
  36791. * Gets a camera using its id
  36792. * @param id defines the id to look for
  36793. * @returns the camera or null if not found
  36794. */
  36795. getCameraByID(id: string): Nullable<Camera>;
  36796. /**
  36797. * Gets a camera using its unique id
  36798. * @param uniqueId defines the unique id to look for
  36799. * @returns the camera or null if not found
  36800. */
  36801. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36802. /**
  36803. * Gets a camera using its name
  36804. * @param name defines the camera's name
  36805. * @return the camera or null if none found.
  36806. */
  36807. getCameraByName(name: string): Nullable<Camera>;
  36808. /**
  36809. * Gets a bone using its id
  36810. * @param id defines the bone's id
  36811. * @return the bone or null if not found
  36812. */
  36813. getBoneByID(id: string): Nullable<Bone>;
  36814. /**
  36815. * Gets a bone using its id
  36816. * @param name defines the bone's name
  36817. * @return the bone or null if not found
  36818. */
  36819. getBoneByName(name: string): Nullable<Bone>;
  36820. /**
  36821. * Gets a light node using its name
  36822. * @param name defines the the light's name
  36823. * @return the light or null if none found.
  36824. */
  36825. getLightByName(name: string): Nullable<Light>;
  36826. /**
  36827. * Gets a light node using its id
  36828. * @param id defines the light's id
  36829. * @return the light or null if none found.
  36830. */
  36831. getLightByID(id: string): Nullable<Light>;
  36832. /**
  36833. * Gets a light node using its scene-generated unique ID
  36834. * @param uniqueId defines the light's unique id
  36835. * @return the light or null if none found.
  36836. */
  36837. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36838. /**
  36839. * Gets a particle system by id
  36840. * @param id defines the particle system id
  36841. * @return the corresponding system or null if none found
  36842. */
  36843. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36844. /**
  36845. * Gets a geometry using its ID
  36846. * @param id defines the geometry's id
  36847. * @return the geometry or null if none found.
  36848. */
  36849. getGeometryByID(id: string): Nullable<Geometry>;
  36850. private _getGeometryByUniqueID;
  36851. /**
  36852. * Add a new geometry to this scene
  36853. * @param geometry defines the geometry to be added to the scene.
  36854. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36855. * @return a boolean defining if the geometry was added or not
  36856. */
  36857. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36858. /**
  36859. * Removes an existing geometry
  36860. * @param geometry defines the geometry to be removed from the scene
  36861. * @return a boolean defining if the geometry was removed or not
  36862. */
  36863. removeGeometry(geometry: Geometry): boolean;
  36864. /**
  36865. * Gets the list of geometries attached to the scene
  36866. * @returns an array of Geometry
  36867. */
  36868. getGeometries(): Geometry[];
  36869. /**
  36870. * Gets the first added mesh found of a given ID
  36871. * @param id defines the id to search for
  36872. * @return the mesh found or null if not found at all
  36873. */
  36874. getMeshByID(id: string): Nullable<AbstractMesh>;
  36875. /**
  36876. * Gets a list of meshes using their id
  36877. * @param id defines the id to search for
  36878. * @returns a list of meshes
  36879. */
  36880. getMeshesByID(id: string): Array<AbstractMesh>;
  36881. /**
  36882. * Gets the first added transform node found of a given ID
  36883. * @param id defines the id to search for
  36884. * @return the found transform node or null if not found at all.
  36885. */
  36886. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36887. /**
  36888. * Gets a transform node with its auto-generated unique id
  36889. * @param uniqueId efines the unique id to search for
  36890. * @return the found transform node or null if not found at all.
  36891. */
  36892. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36893. /**
  36894. * Gets a list of transform nodes using their id
  36895. * @param id defines the id to search for
  36896. * @returns a list of transform nodes
  36897. */
  36898. getTransformNodesByID(id: string): Array<TransformNode>;
  36899. /**
  36900. * Gets a mesh with its auto-generated unique id
  36901. * @param uniqueId defines the unique id to search for
  36902. * @return the found mesh or null if not found at all.
  36903. */
  36904. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36905. /**
  36906. * Gets a the last added mesh using a given id
  36907. * @param id defines the id to search for
  36908. * @return the found mesh or null if not found at all.
  36909. */
  36910. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36911. /**
  36912. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36913. * @param id defines the id to search for
  36914. * @return the found node or null if not found at all
  36915. */
  36916. getLastEntryByID(id: string): Nullable<Node>;
  36917. /**
  36918. * Gets a node (Mesh, Camera, Light) using a given id
  36919. * @param id defines the id to search for
  36920. * @return the found node or null if not found at all
  36921. */
  36922. getNodeByID(id: string): Nullable<Node>;
  36923. /**
  36924. * Gets a node (Mesh, Camera, Light) using a given name
  36925. * @param name defines the name to search for
  36926. * @return the found node or null if not found at all.
  36927. */
  36928. getNodeByName(name: string): Nullable<Node>;
  36929. /**
  36930. * Gets a mesh using a given name
  36931. * @param name defines the name to search for
  36932. * @return the found mesh or null if not found at all.
  36933. */
  36934. getMeshByName(name: string): Nullable<AbstractMesh>;
  36935. /**
  36936. * Gets a transform node using a given name
  36937. * @param name defines the name to search for
  36938. * @return the found transform node or null if not found at all.
  36939. */
  36940. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36941. /**
  36942. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36943. * @param id defines the id to search for
  36944. * @return the found skeleton or null if not found at all.
  36945. */
  36946. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36947. /**
  36948. * Gets a skeleton using a given auto generated unique id
  36949. * @param uniqueId defines the unique id to search for
  36950. * @return the found skeleton or null if not found at all.
  36951. */
  36952. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36953. /**
  36954. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36955. * @param id defines the id to search for
  36956. * @return the found skeleton or null if not found at all.
  36957. */
  36958. getSkeletonById(id: string): Nullable<Skeleton>;
  36959. /**
  36960. * Gets a skeleton using a given name
  36961. * @param name defines the name to search for
  36962. * @return the found skeleton or null if not found at all.
  36963. */
  36964. getSkeletonByName(name: string): Nullable<Skeleton>;
  36965. /**
  36966. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36967. * @param id defines the id to search for
  36968. * @return the found morph target manager or null if not found at all.
  36969. */
  36970. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36971. /**
  36972. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36973. * @param id defines the id to search for
  36974. * @return the found morph target or null if not found at all.
  36975. */
  36976. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36977. /**
  36978. * Gets a boolean indicating if the given mesh is active
  36979. * @param mesh defines the mesh to look for
  36980. * @returns true if the mesh is in the active list
  36981. */
  36982. isActiveMesh(mesh: AbstractMesh): boolean;
  36983. /**
  36984. * Return a unique id as a string which can serve as an identifier for the scene
  36985. */
  36986. readonly uid: string;
  36987. /**
  36988. * Add an externaly attached data from its key.
  36989. * This method call will fail and return false, if such key already exists.
  36990. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36991. * @param key the unique key that identifies the data
  36992. * @param data the data object to associate to the key for this Engine instance
  36993. * @return true if no such key were already present and the data was added successfully, false otherwise
  36994. */
  36995. addExternalData<T>(key: string, data: T): boolean;
  36996. /**
  36997. * Get an externaly attached data from its key
  36998. * @param key the unique key that identifies the data
  36999. * @return the associated data, if present (can be null), or undefined if not present
  37000. */
  37001. getExternalData<T>(key: string): Nullable<T>;
  37002. /**
  37003. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37004. * @param key the unique key that identifies the data
  37005. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37006. * @return the associated data, can be null if the factory returned null.
  37007. */
  37008. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37009. /**
  37010. * Remove an externaly attached data from the Engine instance
  37011. * @param key the unique key that identifies the data
  37012. * @return true if the data was successfully removed, false if it doesn't exist
  37013. */
  37014. removeExternalData(key: string): boolean;
  37015. private _evaluateSubMesh;
  37016. /**
  37017. * Clear the processed materials smart array preventing retention point in material dispose.
  37018. */
  37019. freeProcessedMaterials(): void;
  37020. private _preventFreeActiveMeshesAndRenderingGroups;
  37021. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37022. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37023. * when disposing several meshes in a row or a hierarchy of meshes.
  37024. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37025. */
  37026. blockfreeActiveMeshesAndRenderingGroups: boolean;
  37027. /**
  37028. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37029. */
  37030. freeActiveMeshes(): void;
  37031. /**
  37032. * Clear the info related to rendering groups preventing retention points during dispose.
  37033. */
  37034. freeRenderingGroups(): void;
  37035. /** @hidden */
  37036. _isInIntermediateRendering(): boolean;
  37037. /**
  37038. * Lambda returning the list of potentially active meshes.
  37039. */
  37040. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37041. /**
  37042. * Lambda returning the list of potentially active sub meshes.
  37043. */
  37044. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37045. /**
  37046. * Lambda returning the list of potentially intersecting sub meshes.
  37047. */
  37048. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37049. /**
  37050. * Lambda returning the list of potentially colliding sub meshes.
  37051. */
  37052. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37053. private _activeMeshesFrozen;
  37054. private _skipEvaluateActiveMeshesCompletely;
  37055. /**
  37056. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37057. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37058. * @returns the current scene
  37059. */
  37060. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37061. /**
  37062. * Use this function to restart evaluating active meshes on every frame
  37063. * @returns the current scene
  37064. */
  37065. unfreezeActiveMeshes(): Scene;
  37066. private _evaluateActiveMeshes;
  37067. private _activeMesh;
  37068. /**
  37069. * Update the transform matrix to update from the current active camera
  37070. * @param force defines a boolean used to force the update even if cache is up to date
  37071. */
  37072. updateTransformMatrix(force?: boolean): void;
  37073. private _bindFrameBuffer;
  37074. /** @hidden */
  37075. _allowPostProcessClearColor: boolean;
  37076. /** @hidden */
  37077. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37078. private _processSubCameras;
  37079. private _checkIntersections;
  37080. /** @hidden */
  37081. _advancePhysicsEngineStep(step: number): void;
  37082. /**
  37083. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37084. */
  37085. getDeterministicFrameTime: () => number;
  37086. /** @hidden */
  37087. _animate(): void;
  37088. /** Execute all animations (for a frame) */
  37089. animate(): void;
  37090. /**
  37091. * Render the scene
  37092. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37093. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37094. */
  37095. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37096. /**
  37097. * Freeze all materials
  37098. * A frozen material will not be updatable but should be faster to render
  37099. */
  37100. freezeMaterials(): void;
  37101. /**
  37102. * Unfreeze all materials
  37103. * A frozen material will not be updatable but should be faster to render
  37104. */
  37105. unfreezeMaterials(): void;
  37106. /**
  37107. * Releases all held ressources
  37108. */
  37109. dispose(): void;
  37110. /**
  37111. * Gets if the scene is already disposed
  37112. */
  37113. readonly isDisposed: boolean;
  37114. /**
  37115. * Call this function to reduce memory footprint of the scene.
  37116. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37117. */
  37118. clearCachedVertexData(): void;
  37119. /**
  37120. * This function will remove the local cached buffer data from texture.
  37121. * It will save memory but will prevent the texture from being rebuilt
  37122. */
  37123. cleanCachedTextureBuffer(): void;
  37124. /**
  37125. * Get the world extend vectors with an optional filter
  37126. *
  37127. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37128. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37129. */
  37130. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37131. min: Vector3;
  37132. max: Vector3;
  37133. };
  37134. /**
  37135. * Creates a ray that can be used to pick in the scene
  37136. * @param x defines the x coordinate of the origin (on-screen)
  37137. * @param y defines the y coordinate of the origin (on-screen)
  37138. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37139. * @param camera defines the camera to use for the picking
  37140. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37141. * @returns a Ray
  37142. */
  37143. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37144. /**
  37145. * Creates a ray that can be used to pick in the scene
  37146. * @param x defines the x coordinate of the origin (on-screen)
  37147. * @param y defines the y coordinate of the origin (on-screen)
  37148. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37149. * @param result defines the ray where to store the picking ray
  37150. * @param camera defines the camera to use for the picking
  37151. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37152. * @returns the current scene
  37153. */
  37154. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37155. /**
  37156. * Creates a ray that can be used to pick in the scene
  37157. * @param x defines the x coordinate of the origin (on-screen)
  37158. * @param y defines the y coordinate of the origin (on-screen)
  37159. * @param camera defines the camera to use for the picking
  37160. * @returns a Ray
  37161. */
  37162. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37163. /**
  37164. * Creates a ray that can be used to pick in the scene
  37165. * @param x defines the x coordinate of the origin (on-screen)
  37166. * @param y defines the y coordinate of the origin (on-screen)
  37167. * @param result defines the ray where to store the picking ray
  37168. * @param camera defines the camera to use for the picking
  37169. * @returns the current scene
  37170. */
  37171. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37172. /** Launch a ray to try to pick a mesh in the scene
  37173. * @param x position on screen
  37174. * @param y position on screen
  37175. * @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
  37176. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37177. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37178. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37179. * @returns a PickingInfo
  37180. */
  37181. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37182. /** Use the given ray to pick a mesh in the scene
  37183. * @param ray The ray to use to pick meshes
  37184. * @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
  37185. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37186. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37187. * @returns a PickingInfo
  37188. */
  37189. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37190. /**
  37191. * Launch a ray to try to pick a mesh in the scene
  37192. * @param x X position on screen
  37193. * @param y Y position on screen
  37194. * @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
  37195. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37196. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37197. * @returns an array of PickingInfo
  37198. */
  37199. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37200. /**
  37201. * Launch a ray to try to pick a mesh in the scene
  37202. * @param ray Ray to use
  37203. * @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
  37204. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37205. * @returns an array of PickingInfo
  37206. */
  37207. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37208. /**
  37209. * Force the value of meshUnderPointer
  37210. * @param mesh defines the mesh to use
  37211. */
  37212. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37213. /**
  37214. * Gets the mesh under the pointer
  37215. * @returns a Mesh or null if no mesh is under the pointer
  37216. */
  37217. getPointerOverMesh(): Nullable<AbstractMesh>;
  37218. /** @hidden */
  37219. _rebuildGeometries(): void;
  37220. /** @hidden */
  37221. _rebuildTextures(): void;
  37222. private _getByTags;
  37223. /**
  37224. * Get a list of meshes by tags
  37225. * @param tagsQuery defines the tags query to use
  37226. * @param forEach defines a predicate used to filter results
  37227. * @returns an array of Mesh
  37228. */
  37229. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37230. /**
  37231. * Get a list of cameras by tags
  37232. * @param tagsQuery defines the tags query to use
  37233. * @param forEach defines a predicate used to filter results
  37234. * @returns an array of Camera
  37235. */
  37236. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37237. /**
  37238. * Get a list of lights by tags
  37239. * @param tagsQuery defines the tags query to use
  37240. * @param forEach defines a predicate used to filter results
  37241. * @returns an array of Light
  37242. */
  37243. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37244. /**
  37245. * Get a list of materials by tags
  37246. * @param tagsQuery defines the tags query to use
  37247. * @param forEach defines a predicate used to filter results
  37248. * @returns an array of Material
  37249. */
  37250. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37251. /**
  37252. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37253. * This allowed control for front to back rendering or reversly depending of the special needs.
  37254. *
  37255. * @param renderingGroupId The rendering group id corresponding to its index
  37256. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37257. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37258. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37259. */
  37260. 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;
  37261. /**
  37262. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37263. *
  37264. * @param renderingGroupId The rendering group id corresponding to its index
  37265. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37266. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37267. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37268. */
  37269. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37270. /**
  37271. * Gets the current auto clear configuration for one rendering group of the rendering
  37272. * manager.
  37273. * @param index the rendering group index to get the information for
  37274. * @returns The auto clear setup for the requested rendering group
  37275. */
  37276. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37277. private _blockMaterialDirtyMechanism;
  37278. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37279. blockMaterialDirtyMechanism: boolean;
  37280. /**
  37281. * Will flag all materials as dirty to trigger new shader compilation
  37282. * @param flag defines the flag used to specify which material part must be marked as dirty
  37283. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37284. */
  37285. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37286. /** @hidden */
  37287. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  37288. /** @hidden */
  37289. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37290. /** @hidden */
  37291. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  37292. /** @hidden */
  37293. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37294. /** @hidden */
  37295. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37296. /** @hidden */
  37297. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37298. }
  37299. }
  37300. declare module "babylonjs/assetContainer" {
  37301. import { AbstractScene } from "babylonjs/abstractScene";
  37302. import { Scene } from "babylonjs/scene";
  37303. import { Mesh } from "babylonjs/Meshes/mesh";
  37304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37305. import { Skeleton } from "babylonjs/Bones/skeleton";
  37306. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37307. /**
  37308. * Set of assets to keep when moving a scene into an asset container.
  37309. */
  37310. export class KeepAssets extends AbstractScene {
  37311. }
  37312. /**
  37313. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37314. */
  37315. export class InstantiatedEntries {
  37316. /**
  37317. * List of new root nodes (eg. nodes with no parent)
  37318. */
  37319. rootNodes: TransformNode[];
  37320. /**
  37321. * List of new skeletons
  37322. */
  37323. skeletons: Skeleton[];
  37324. /**
  37325. * List of new animation groups
  37326. */
  37327. animationGroups: AnimationGroup[];
  37328. }
  37329. /**
  37330. * Container with a set of assets that can be added or removed from a scene.
  37331. */
  37332. export class AssetContainer extends AbstractScene {
  37333. /**
  37334. * The scene the AssetContainer belongs to.
  37335. */
  37336. scene: Scene;
  37337. /**
  37338. * Instantiates an AssetContainer.
  37339. * @param scene The scene the AssetContainer belongs to.
  37340. */
  37341. constructor(scene: Scene);
  37342. /**
  37343. * Instantiate or clone all meshes and add the new ones to the scene.
  37344. * Skeletons and animation groups will all be cloned
  37345. * @param nameFunction defines an optional function used to get new names for clones
  37346. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37347. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37348. */
  37349. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37350. /**
  37351. * Adds all the assets from the container to the scene.
  37352. */
  37353. addAllToScene(): void;
  37354. /**
  37355. * Removes all the assets in the container from the scene
  37356. */
  37357. removeAllFromScene(): void;
  37358. /**
  37359. * Disposes all the assets in the container
  37360. */
  37361. dispose(): void;
  37362. private _moveAssets;
  37363. /**
  37364. * Removes all the assets contained in the scene and adds them to the container.
  37365. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37366. */
  37367. moveAllFromScene(keepAssets?: KeepAssets): void;
  37368. /**
  37369. * 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.
  37370. * @returns the root mesh
  37371. */
  37372. createRootMesh(): Mesh;
  37373. }
  37374. }
  37375. declare module "babylonjs/abstractScene" {
  37376. import { Scene } from "babylonjs/scene";
  37377. import { Nullable } from "babylonjs/types";
  37378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37379. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37380. import { Geometry } from "babylonjs/Meshes/geometry";
  37381. import { Skeleton } from "babylonjs/Bones/skeleton";
  37382. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37383. import { AssetContainer } from "babylonjs/assetContainer";
  37384. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37385. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37387. import { Material } from "babylonjs/Materials/material";
  37388. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37389. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37390. import { Camera } from "babylonjs/Cameras/camera";
  37391. import { Light } from "babylonjs/Lights/light";
  37392. import { Node } from "babylonjs/node";
  37393. import { Animation } from "babylonjs/Animations/animation";
  37394. /**
  37395. * Defines how the parser contract is defined.
  37396. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37397. */
  37398. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37399. /**
  37400. * Defines how the individual parser contract is defined.
  37401. * These parser can parse an individual asset
  37402. */
  37403. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37404. /**
  37405. * Base class of the scene acting as a container for the different elements composing a scene.
  37406. * This class is dynamically extended by the different components of the scene increasing
  37407. * flexibility and reducing coupling
  37408. */
  37409. export abstract class AbstractScene {
  37410. /**
  37411. * Stores the list of available parsers in the application.
  37412. */
  37413. private static _BabylonFileParsers;
  37414. /**
  37415. * Stores the list of available individual parsers in the application.
  37416. */
  37417. private static _IndividualBabylonFileParsers;
  37418. /**
  37419. * Adds a parser in the list of available ones
  37420. * @param name Defines the name of the parser
  37421. * @param parser Defines the parser to add
  37422. */
  37423. static AddParser(name: string, parser: BabylonFileParser): void;
  37424. /**
  37425. * Gets a general parser from the list of avaialble ones
  37426. * @param name Defines the name of the parser
  37427. * @returns the requested parser or null
  37428. */
  37429. static GetParser(name: string): Nullable<BabylonFileParser>;
  37430. /**
  37431. * Adds n individual parser in the list of available ones
  37432. * @param name Defines the name of the parser
  37433. * @param parser Defines the parser to add
  37434. */
  37435. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37436. /**
  37437. * Gets an individual parser from the list of avaialble ones
  37438. * @param name Defines the name of the parser
  37439. * @returns the requested parser or null
  37440. */
  37441. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37442. /**
  37443. * Parser json data and populate both a scene and its associated container object
  37444. * @param jsonData Defines the data to parse
  37445. * @param scene Defines the scene to parse the data for
  37446. * @param container Defines the container attached to the parsing sequence
  37447. * @param rootUrl Defines the root url of the data
  37448. */
  37449. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37450. /**
  37451. * Gets the list of root nodes (ie. nodes with no parent)
  37452. */
  37453. rootNodes: Node[];
  37454. /** All of the cameras added to this scene
  37455. * @see http://doc.babylonjs.com/babylon101/cameras
  37456. */
  37457. cameras: Camera[];
  37458. /**
  37459. * All of the lights added to this scene
  37460. * @see http://doc.babylonjs.com/babylon101/lights
  37461. */
  37462. lights: Light[];
  37463. /**
  37464. * All of the (abstract) meshes added to this scene
  37465. */
  37466. meshes: AbstractMesh[];
  37467. /**
  37468. * The list of skeletons added to the scene
  37469. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37470. */
  37471. skeletons: Skeleton[];
  37472. /**
  37473. * All of the particle systems added to this scene
  37474. * @see http://doc.babylonjs.com/babylon101/particles
  37475. */
  37476. particleSystems: IParticleSystem[];
  37477. /**
  37478. * Gets a list of Animations associated with the scene
  37479. */
  37480. animations: Animation[];
  37481. /**
  37482. * All of the animation groups added to this scene
  37483. * @see http://doc.babylonjs.com/how_to/group
  37484. */
  37485. animationGroups: AnimationGroup[];
  37486. /**
  37487. * All of the multi-materials added to this scene
  37488. * @see http://doc.babylonjs.com/how_to/multi_materials
  37489. */
  37490. multiMaterials: MultiMaterial[];
  37491. /**
  37492. * All of the materials added to this scene
  37493. * In the context of a Scene, it is not supposed to be modified manually.
  37494. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37495. * Note also that the order of the Material within the array is not significant and might change.
  37496. * @see http://doc.babylonjs.com/babylon101/materials
  37497. */
  37498. materials: Material[];
  37499. /**
  37500. * The list of morph target managers added to the scene
  37501. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37502. */
  37503. morphTargetManagers: MorphTargetManager[];
  37504. /**
  37505. * The list of geometries used in the scene.
  37506. */
  37507. geometries: Geometry[];
  37508. /**
  37509. * All of the tranform nodes added to this scene
  37510. * In the context of a Scene, it is not supposed to be modified manually.
  37511. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37512. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37513. * @see http://doc.babylonjs.com/how_to/transformnode
  37514. */
  37515. transformNodes: TransformNode[];
  37516. /**
  37517. * ActionManagers available on the scene.
  37518. */
  37519. actionManagers: AbstractActionManager[];
  37520. /**
  37521. * Textures to keep.
  37522. */
  37523. textures: BaseTexture[];
  37524. /**
  37525. * Environment texture for the scene
  37526. */
  37527. environmentTexture: Nullable<BaseTexture>;
  37528. }
  37529. }
  37530. declare module "babylonjs/Audio/sound" {
  37531. import { Observable } from "babylonjs/Misc/observable";
  37532. import { Vector3 } from "babylonjs/Maths/math.vector";
  37533. import { Nullable } from "babylonjs/types";
  37534. import { Scene } from "babylonjs/scene";
  37535. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37536. /**
  37537. * Interface used to define options for Sound class
  37538. */
  37539. export interface ISoundOptions {
  37540. /**
  37541. * Does the sound autoplay once loaded.
  37542. */
  37543. autoplay?: boolean;
  37544. /**
  37545. * Does the sound loop after it finishes playing once.
  37546. */
  37547. loop?: boolean;
  37548. /**
  37549. * Sound's volume
  37550. */
  37551. volume?: number;
  37552. /**
  37553. * Is it a spatial sound?
  37554. */
  37555. spatialSound?: boolean;
  37556. /**
  37557. * Maximum distance to hear that sound
  37558. */
  37559. maxDistance?: number;
  37560. /**
  37561. * Uses user defined attenuation function
  37562. */
  37563. useCustomAttenuation?: boolean;
  37564. /**
  37565. * Define the roll off factor of spatial sounds.
  37566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37567. */
  37568. rolloffFactor?: number;
  37569. /**
  37570. * Define the reference distance the sound should be heard perfectly.
  37571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37572. */
  37573. refDistance?: number;
  37574. /**
  37575. * Define the distance attenuation model the sound will follow.
  37576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37577. */
  37578. distanceModel?: string;
  37579. /**
  37580. * Defines the playback speed (1 by default)
  37581. */
  37582. playbackRate?: number;
  37583. /**
  37584. * Defines if the sound is from a streaming source
  37585. */
  37586. streaming?: boolean;
  37587. /**
  37588. * Defines an optional length (in seconds) inside the sound file
  37589. */
  37590. length?: number;
  37591. /**
  37592. * Defines an optional offset (in seconds) inside the sound file
  37593. */
  37594. offset?: number;
  37595. /**
  37596. * If true, URLs will not be required to state the audio file codec to use.
  37597. */
  37598. skipCodecCheck?: boolean;
  37599. }
  37600. /**
  37601. * Defines a sound that can be played in the application.
  37602. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37604. */
  37605. export class Sound {
  37606. /**
  37607. * The name of the sound in the scene.
  37608. */
  37609. name: string;
  37610. /**
  37611. * Does the sound autoplay once loaded.
  37612. */
  37613. autoplay: boolean;
  37614. /**
  37615. * Does the sound loop after it finishes playing once.
  37616. */
  37617. loop: boolean;
  37618. /**
  37619. * Does the sound use a custom attenuation curve to simulate the falloff
  37620. * happening when the source gets further away from the camera.
  37621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37622. */
  37623. useCustomAttenuation: boolean;
  37624. /**
  37625. * The sound track id this sound belongs to.
  37626. */
  37627. soundTrackId: number;
  37628. /**
  37629. * Is this sound currently played.
  37630. */
  37631. isPlaying: boolean;
  37632. /**
  37633. * Is this sound currently paused.
  37634. */
  37635. isPaused: boolean;
  37636. /**
  37637. * Does this sound enables spatial sound.
  37638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37639. */
  37640. spatialSound: boolean;
  37641. /**
  37642. * Define the reference distance the sound should be heard perfectly.
  37643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37644. */
  37645. refDistance: number;
  37646. /**
  37647. * Define the roll off factor of spatial sounds.
  37648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37649. */
  37650. rolloffFactor: number;
  37651. /**
  37652. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37654. */
  37655. maxDistance: number;
  37656. /**
  37657. * Define the distance attenuation model the sound will follow.
  37658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37659. */
  37660. distanceModel: string;
  37661. /**
  37662. * @hidden
  37663. * Back Compat
  37664. **/
  37665. onended: () => any;
  37666. /**
  37667. * Observable event when the current playing sound finishes.
  37668. */
  37669. onEndedObservable: Observable<Sound>;
  37670. private _panningModel;
  37671. private _playbackRate;
  37672. private _streaming;
  37673. private _startTime;
  37674. private _startOffset;
  37675. private _position;
  37676. /** @hidden */
  37677. _positionInEmitterSpace: boolean;
  37678. private _localDirection;
  37679. private _volume;
  37680. private _isReadyToPlay;
  37681. private _isDirectional;
  37682. private _readyToPlayCallback;
  37683. private _audioBuffer;
  37684. private _soundSource;
  37685. private _streamingSource;
  37686. private _soundPanner;
  37687. private _soundGain;
  37688. private _inputAudioNode;
  37689. private _outputAudioNode;
  37690. private _coneInnerAngle;
  37691. private _coneOuterAngle;
  37692. private _coneOuterGain;
  37693. private _scene;
  37694. private _connectedTransformNode;
  37695. private _customAttenuationFunction;
  37696. private _registerFunc;
  37697. private _isOutputConnected;
  37698. private _htmlAudioElement;
  37699. private _urlType;
  37700. private _length?;
  37701. private _offset?;
  37702. /** @hidden */
  37703. static _SceneComponentInitialization: (scene: Scene) => void;
  37704. /**
  37705. * Create a sound and attach it to a scene
  37706. * @param name Name of your sound
  37707. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37708. * @param scene defines the scene the sound belongs to
  37709. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37710. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37711. */
  37712. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37713. /**
  37714. * Release the sound and its associated resources
  37715. */
  37716. dispose(): void;
  37717. /**
  37718. * Gets if the sounds is ready to be played or not.
  37719. * @returns true if ready, otherwise false
  37720. */
  37721. isReady(): boolean;
  37722. private _soundLoaded;
  37723. /**
  37724. * Sets the data of the sound from an audiobuffer
  37725. * @param audioBuffer The audioBuffer containing the data
  37726. */
  37727. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37728. /**
  37729. * Updates the current sounds options such as maxdistance, loop...
  37730. * @param options A JSON object containing values named as the object properties
  37731. */
  37732. updateOptions(options: ISoundOptions): void;
  37733. private _createSpatialParameters;
  37734. private _updateSpatialParameters;
  37735. /**
  37736. * Switch the panning model to HRTF:
  37737. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37739. */
  37740. switchPanningModelToHRTF(): void;
  37741. /**
  37742. * Switch the panning model to Equal Power:
  37743. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37745. */
  37746. switchPanningModelToEqualPower(): void;
  37747. private _switchPanningModel;
  37748. /**
  37749. * Connect this sound to a sound track audio node like gain...
  37750. * @param soundTrackAudioNode the sound track audio node to connect to
  37751. */
  37752. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37753. /**
  37754. * Transform this sound into a directional source
  37755. * @param coneInnerAngle Size of the inner cone in degree
  37756. * @param coneOuterAngle Size of the outer cone in degree
  37757. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37758. */
  37759. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37760. /**
  37761. * Gets or sets the inner angle for the directional cone.
  37762. */
  37763. /**
  37764. * Gets or sets the inner angle for the directional cone.
  37765. */
  37766. directionalConeInnerAngle: number;
  37767. /**
  37768. * Gets or sets the outer angle for the directional cone.
  37769. */
  37770. /**
  37771. * Gets or sets the outer angle for the directional cone.
  37772. */
  37773. directionalConeOuterAngle: number;
  37774. /**
  37775. * Sets the position of the emitter if spatial sound is enabled
  37776. * @param newPosition Defines the new posisiton
  37777. */
  37778. setPosition(newPosition: Vector3): void;
  37779. /**
  37780. * Sets the local direction of the emitter if spatial sound is enabled
  37781. * @param newLocalDirection Defines the new local direction
  37782. */
  37783. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37784. private _updateDirection;
  37785. /** @hidden */
  37786. updateDistanceFromListener(): void;
  37787. /**
  37788. * Sets a new custom attenuation function for the sound.
  37789. * @param callback Defines the function used for the attenuation
  37790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37791. */
  37792. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37793. /**
  37794. * Play the sound
  37795. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37796. * @param offset (optional) Start the sound at a specific time in seconds
  37797. * @param length (optional) Sound duration (in seconds)
  37798. */
  37799. play(time?: number, offset?: number, length?: number): void;
  37800. private _onended;
  37801. /**
  37802. * Stop the sound
  37803. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37804. */
  37805. stop(time?: number): void;
  37806. /**
  37807. * Put the sound in pause
  37808. */
  37809. pause(): void;
  37810. /**
  37811. * Sets a dedicated volume for this sounds
  37812. * @param newVolume Define the new volume of the sound
  37813. * @param time Define time for gradual change to new volume
  37814. */
  37815. setVolume(newVolume: number, time?: number): void;
  37816. /**
  37817. * Set the sound play back rate
  37818. * @param newPlaybackRate Define the playback rate the sound should be played at
  37819. */
  37820. setPlaybackRate(newPlaybackRate: number): void;
  37821. /**
  37822. * Gets the volume of the sound.
  37823. * @returns the volume of the sound
  37824. */
  37825. getVolume(): number;
  37826. /**
  37827. * Attach the sound to a dedicated mesh
  37828. * @param transformNode The transform node to connect the sound with
  37829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37830. */
  37831. attachToMesh(transformNode: TransformNode): void;
  37832. /**
  37833. * Detach the sound from the previously attached mesh
  37834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37835. */
  37836. detachFromMesh(): void;
  37837. private _onRegisterAfterWorldMatrixUpdate;
  37838. /**
  37839. * Clone the current sound in the scene.
  37840. * @returns the new sound clone
  37841. */
  37842. clone(): Nullable<Sound>;
  37843. /**
  37844. * Gets the current underlying audio buffer containing the data
  37845. * @returns the audio buffer
  37846. */
  37847. getAudioBuffer(): Nullable<AudioBuffer>;
  37848. /**
  37849. * Serializes the Sound in a JSON representation
  37850. * @returns the JSON representation of the sound
  37851. */
  37852. serialize(): any;
  37853. /**
  37854. * Parse a JSON representation of a sound to innstantiate in a given scene
  37855. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37856. * @param scene Define the scene the new parsed sound should be created in
  37857. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37858. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37859. * @returns the newly parsed sound
  37860. */
  37861. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37862. }
  37863. }
  37864. declare module "babylonjs/Actions/directAudioActions" {
  37865. import { Action } from "babylonjs/Actions/action";
  37866. import { Condition } from "babylonjs/Actions/condition";
  37867. import { Sound } from "babylonjs/Audio/sound";
  37868. /**
  37869. * This defines an action helpful to play a defined sound on a triggered action.
  37870. */
  37871. export class PlaySoundAction extends Action {
  37872. private _sound;
  37873. /**
  37874. * Instantiate the action
  37875. * @param triggerOptions defines the trigger options
  37876. * @param sound defines the sound to play
  37877. * @param condition defines the trigger related conditions
  37878. */
  37879. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37880. /** @hidden */
  37881. _prepare(): void;
  37882. /**
  37883. * Execute the action and play the sound.
  37884. */
  37885. execute(): void;
  37886. /**
  37887. * Serializes the actions and its related information.
  37888. * @param parent defines the object to serialize in
  37889. * @returns the serialized object
  37890. */
  37891. serialize(parent: any): any;
  37892. }
  37893. /**
  37894. * This defines an action helpful to stop a defined sound on a triggered action.
  37895. */
  37896. export class StopSoundAction extends Action {
  37897. private _sound;
  37898. /**
  37899. * Instantiate the action
  37900. * @param triggerOptions defines the trigger options
  37901. * @param sound defines the sound to stop
  37902. * @param condition defines the trigger related conditions
  37903. */
  37904. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37905. /** @hidden */
  37906. _prepare(): void;
  37907. /**
  37908. * Execute the action and stop the sound.
  37909. */
  37910. execute(): void;
  37911. /**
  37912. * Serializes the actions and its related information.
  37913. * @param parent defines the object to serialize in
  37914. * @returns the serialized object
  37915. */
  37916. serialize(parent: any): any;
  37917. }
  37918. }
  37919. declare module "babylonjs/Actions/interpolateValueAction" {
  37920. import { Action } from "babylonjs/Actions/action";
  37921. import { Condition } from "babylonjs/Actions/condition";
  37922. import { Observable } from "babylonjs/Misc/observable";
  37923. /**
  37924. * This defines an action responsible to change the value of a property
  37925. * by interpolating between its current value and the newly set one once triggered.
  37926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37927. */
  37928. export class InterpolateValueAction extends Action {
  37929. /**
  37930. * Defines the path of the property where the value should be interpolated
  37931. */
  37932. propertyPath: string;
  37933. /**
  37934. * Defines the target value at the end of the interpolation.
  37935. */
  37936. value: any;
  37937. /**
  37938. * Defines the time it will take for the property to interpolate to the value.
  37939. */
  37940. duration: number;
  37941. /**
  37942. * Defines if the other scene animations should be stopped when the action has been triggered
  37943. */
  37944. stopOtherAnimations?: boolean;
  37945. /**
  37946. * Defines a callback raised once the interpolation animation has been done.
  37947. */
  37948. onInterpolationDone?: () => void;
  37949. /**
  37950. * Observable triggered once the interpolation animation has been done.
  37951. */
  37952. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37953. private _target;
  37954. private _effectiveTarget;
  37955. private _property;
  37956. /**
  37957. * Instantiate the action
  37958. * @param triggerOptions defines the trigger options
  37959. * @param target defines the object containing the value to interpolate
  37960. * @param propertyPath defines the path to the property in the target object
  37961. * @param value defines the target value at the end of the interpolation
  37962. * @param duration deines the time it will take for the property to interpolate to the value.
  37963. * @param condition defines the trigger related conditions
  37964. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37965. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37966. */
  37967. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37968. /** @hidden */
  37969. _prepare(): void;
  37970. /**
  37971. * Execute the action starts the value interpolation.
  37972. */
  37973. execute(): void;
  37974. /**
  37975. * Serializes the actions and its related information.
  37976. * @param parent defines the object to serialize in
  37977. * @returns the serialized object
  37978. */
  37979. serialize(parent: any): any;
  37980. }
  37981. }
  37982. declare module "babylonjs/Actions/index" {
  37983. export * from "babylonjs/Actions/abstractActionManager";
  37984. export * from "babylonjs/Actions/action";
  37985. export * from "babylonjs/Actions/actionEvent";
  37986. export * from "babylonjs/Actions/actionManager";
  37987. export * from "babylonjs/Actions/condition";
  37988. export * from "babylonjs/Actions/directActions";
  37989. export * from "babylonjs/Actions/directAudioActions";
  37990. export * from "babylonjs/Actions/interpolateValueAction";
  37991. }
  37992. declare module "babylonjs/Animations/index" {
  37993. export * from "babylonjs/Animations/animatable";
  37994. export * from "babylonjs/Animations/animation";
  37995. export * from "babylonjs/Animations/animationGroup";
  37996. export * from "babylonjs/Animations/animationPropertiesOverride";
  37997. export * from "babylonjs/Animations/easing";
  37998. export * from "babylonjs/Animations/runtimeAnimation";
  37999. export * from "babylonjs/Animations/animationEvent";
  38000. export * from "babylonjs/Animations/animationGroup";
  38001. export * from "babylonjs/Animations/animationKey";
  38002. export * from "babylonjs/Animations/animationRange";
  38003. export * from "babylonjs/Animations/animatable.interface";
  38004. }
  38005. declare module "babylonjs/Audio/soundTrack" {
  38006. import { Sound } from "babylonjs/Audio/sound";
  38007. import { Analyser } from "babylonjs/Audio/analyser";
  38008. import { Scene } from "babylonjs/scene";
  38009. /**
  38010. * Options allowed during the creation of a sound track.
  38011. */
  38012. export interface ISoundTrackOptions {
  38013. /**
  38014. * The volume the sound track should take during creation
  38015. */
  38016. volume?: number;
  38017. /**
  38018. * Define if the sound track is the main sound track of the scene
  38019. */
  38020. mainTrack?: boolean;
  38021. }
  38022. /**
  38023. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38024. * It will be also used in a future release to apply effects on a specific track.
  38025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38026. */
  38027. export class SoundTrack {
  38028. /**
  38029. * The unique identifier of the sound track in the scene.
  38030. */
  38031. id: number;
  38032. /**
  38033. * The list of sounds included in the sound track.
  38034. */
  38035. soundCollection: Array<Sound>;
  38036. private _outputAudioNode;
  38037. private _scene;
  38038. private _connectedAnalyser;
  38039. private _options;
  38040. private _isInitialized;
  38041. /**
  38042. * Creates a new sound track.
  38043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38044. * @param scene Define the scene the sound track belongs to
  38045. * @param options
  38046. */
  38047. constructor(scene: Scene, options?: ISoundTrackOptions);
  38048. private _initializeSoundTrackAudioGraph;
  38049. /**
  38050. * Release the sound track and its associated resources
  38051. */
  38052. dispose(): void;
  38053. /**
  38054. * Adds a sound to this sound track
  38055. * @param sound define the cound to add
  38056. * @ignoreNaming
  38057. */
  38058. AddSound(sound: Sound): void;
  38059. /**
  38060. * Removes a sound to this sound track
  38061. * @param sound define the cound to remove
  38062. * @ignoreNaming
  38063. */
  38064. RemoveSound(sound: Sound): void;
  38065. /**
  38066. * Set a global volume for the full sound track.
  38067. * @param newVolume Define the new volume of the sound track
  38068. */
  38069. setVolume(newVolume: number): void;
  38070. /**
  38071. * Switch the panning model to HRTF:
  38072. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38074. */
  38075. switchPanningModelToHRTF(): void;
  38076. /**
  38077. * Switch the panning model to Equal Power:
  38078. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38080. */
  38081. switchPanningModelToEqualPower(): void;
  38082. /**
  38083. * Connect the sound track to an audio analyser allowing some amazing
  38084. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38086. * @param analyser The analyser to connect to the engine
  38087. */
  38088. connectToAnalyser(analyser: Analyser): void;
  38089. }
  38090. }
  38091. declare module "babylonjs/Audio/audioSceneComponent" {
  38092. import { Sound } from "babylonjs/Audio/sound";
  38093. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38094. import { Nullable } from "babylonjs/types";
  38095. import { Vector3 } from "babylonjs/Maths/math.vector";
  38096. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38097. import { Scene } from "babylonjs/scene";
  38098. import { AbstractScene } from "babylonjs/abstractScene";
  38099. import "babylonjs/Audio/audioEngine";
  38100. module "babylonjs/abstractScene" {
  38101. interface AbstractScene {
  38102. /**
  38103. * The list of sounds used in the scene.
  38104. */
  38105. sounds: Nullable<Array<Sound>>;
  38106. }
  38107. }
  38108. module "babylonjs/scene" {
  38109. interface Scene {
  38110. /**
  38111. * @hidden
  38112. * Backing field
  38113. */
  38114. _mainSoundTrack: SoundTrack;
  38115. /**
  38116. * The main sound track played by the scene.
  38117. * It cotains your primary collection of sounds.
  38118. */
  38119. mainSoundTrack: SoundTrack;
  38120. /**
  38121. * The list of sound tracks added to the scene
  38122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38123. */
  38124. soundTracks: Nullable<Array<SoundTrack>>;
  38125. /**
  38126. * Gets a sound using a given name
  38127. * @param name defines the name to search for
  38128. * @return the found sound or null if not found at all.
  38129. */
  38130. getSoundByName(name: string): Nullable<Sound>;
  38131. /**
  38132. * Gets or sets if audio support is enabled
  38133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38134. */
  38135. audioEnabled: boolean;
  38136. /**
  38137. * Gets or sets if audio will be output to headphones
  38138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38139. */
  38140. headphone: boolean;
  38141. /**
  38142. * Gets or sets custom audio listener position provider
  38143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38144. */
  38145. audioListenerPositionProvider: Nullable<() => Vector3>;
  38146. /**
  38147. * Gets or sets a refresh rate when using 3D audio positioning
  38148. */
  38149. audioPositioningRefreshRate: number;
  38150. }
  38151. }
  38152. /**
  38153. * Defines the sound scene component responsible to manage any sounds
  38154. * in a given scene.
  38155. */
  38156. export class AudioSceneComponent implements ISceneSerializableComponent {
  38157. /**
  38158. * The component name helpfull to identify the component in the list of scene components.
  38159. */
  38160. readonly name: string;
  38161. /**
  38162. * The scene the component belongs to.
  38163. */
  38164. scene: Scene;
  38165. private _audioEnabled;
  38166. /**
  38167. * Gets whether audio is enabled or not.
  38168. * Please use related enable/disable method to switch state.
  38169. */
  38170. readonly audioEnabled: boolean;
  38171. private _headphone;
  38172. /**
  38173. * Gets whether audio is outputing to headphone or not.
  38174. * Please use the according Switch methods to change output.
  38175. */
  38176. readonly headphone: boolean;
  38177. /**
  38178. * Gets or sets a refresh rate when using 3D audio positioning
  38179. */
  38180. audioPositioningRefreshRate: number;
  38181. private _audioListenerPositionProvider;
  38182. /**
  38183. * Gets the current audio listener position provider
  38184. */
  38185. /**
  38186. * Sets a custom listener position for all sounds in the scene
  38187. * By default, this is the position of the first active camera
  38188. */
  38189. audioListenerPositionProvider: Nullable<() => Vector3>;
  38190. /**
  38191. * Creates a new instance of the component for the given scene
  38192. * @param scene Defines the scene to register the component in
  38193. */
  38194. constructor(scene: Scene);
  38195. /**
  38196. * Registers the component in a given scene
  38197. */
  38198. register(): void;
  38199. /**
  38200. * Rebuilds the elements related to this component in case of
  38201. * context lost for instance.
  38202. */
  38203. rebuild(): void;
  38204. /**
  38205. * Serializes the component data to the specified json object
  38206. * @param serializationObject The object to serialize to
  38207. */
  38208. serialize(serializationObject: any): void;
  38209. /**
  38210. * Adds all the elements from the container to the scene
  38211. * @param container the container holding the elements
  38212. */
  38213. addFromContainer(container: AbstractScene): void;
  38214. /**
  38215. * Removes all the elements in the container from the scene
  38216. * @param container contains the elements to remove
  38217. * @param dispose if the removed element should be disposed (default: false)
  38218. */
  38219. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38220. /**
  38221. * Disposes the component and the associated ressources.
  38222. */
  38223. dispose(): void;
  38224. /**
  38225. * Disables audio in the associated scene.
  38226. */
  38227. disableAudio(): void;
  38228. /**
  38229. * Enables audio in the associated scene.
  38230. */
  38231. enableAudio(): void;
  38232. /**
  38233. * Switch audio to headphone output.
  38234. */
  38235. switchAudioModeForHeadphones(): void;
  38236. /**
  38237. * Switch audio to normal speakers.
  38238. */
  38239. switchAudioModeForNormalSpeakers(): void;
  38240. private _cachedCameraDirection;
  38241. private _cachedCameraPosition;
  38242. private _lastCheck;
  38243. private _afterRender;
  38244. }
  38245. }
  38246. declare module "babylonjs/Audio/weightedsound" {
  38247. import { Sound } from "babylonjs/Audio/sound";
  38248. /**
  38249. * Wraps one or more Sound objects and selects one with random weight for playback.
  38250. */
  38251. export class WeightedSound {
  38252. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38253. loop: boolean;
  38254. private _coneInnerAngle;
  38255. private _coneOuterAngle;
  38256. private _volume;
  38257. /** A Sound is currently playing. */
  38258. isPlaying: boolean;
  38259. /** A Sound is currently paused. */
  38260. isPaused: boolean;
  38261. private _sounds;
  38262. private _weights;
  38263. private _currentIndex?;
  38264. /**
  38265. * Creates a new WeightedSound from the list of sounds given.
  38266. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38267. * @param sounds Array of Sounds that will be selected from.
  38268. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38269. */
  38270. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38271. /**
  38272. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38273. */
  38274. /**
  38275. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38276. */
  38277. directionalConeInnerAngle: number;
  38278. /**
  38279. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38280. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38281. */
  38282. /**
  38283. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38284. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38285. */
  38286. directionalConeOuterAngle: number;
  38287. /**
  38288. * Playback volume.
  38289. */
  38290. /**
  38291. * Playback volume.
  38292. */
  38293. volume: number;
  38294. private _onended;
  38295. /**
  38296. * Suspend playback
  38297. */
  38298. pause(): void;
  38299. /**
  38300. * Stop playback
  38301. */
  38302. stop(): void;
  38303. /**
  38304. * Start playback.
  38305. * @param startOffset Position the clip head at a specific time in seconds.
  38306. */
  38307. play(startOffset?: number): void;
  38308. }
  38309. }
  38310. declare module "babylonjs/Audio/index" {
  38311. export * from "babylonjs/Audio/analyser";
  38312. export * from "babylonjs/Audio/audioEngine";
  38313. export * from "babylonjs/Audio/audioSceneComponent";
  38314. export * from "babylonjs/Audio/sound";
  38315. export * from "babylonjs/Audio/soundTrack";
  38316. export * from "babylonjs/Audio/weightedsound";
  38317. }
  38318. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38319. import { Behavior } from "babylonjs/Behaviors/behavior";
  38320. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38321. import { BackEase } from "babylonjs/Animations/easing";
  38322. /**
  38323. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38325. */
  38326. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38327. /**
  38328. * Gets the name of the behavior.
  38329. */
  38330. readonly name: string;
  38331. /**
  38332. * The easing function used by animations
  38333. */
  38334. static EasingFunction: BackEase;
  38335. /**
  38336. * The easing mode used by animations
  38337. */
  38338. static EasingMode: number;
  38339. /**
  38340. * The duration of the animation, in milliseconds
  38341. */
  38342. transitionDuration: number;
  38343. /**
  38344. * Length of the distance animated by the transition when lower radius is reached
  38345. */
  38346. lowerRadiusTransitionRange: number;
  38347. /**
  38348. * Length of the distance animated by the transition when upper radius is reached
  38349. */
  38350. upperRadiusTransitionRange: number;
  38351. private _autoTransitionRange;
  38352. /**
  38353. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38354. */
  38355. /**
  38356. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38357. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38358. */
  38359. autoTransitionRange: boolean;
  38360. private _attachedCamera;
  38361. private _onAfterCheckInputsObserver;
  38362. private _onMeshTargetChangedObserver;
  38363. /**
  38364. * Initializes the behavior.
  38365. */
  38366. init(): void;
  38367. /**
  38368. * Attaches the behavior to its arc rotate camera.
  38369. * @param camera Defines the camera to attach the behavior to
  38370. */
  38371. attach(camera: ArcRotateCamera): void;
  38372. /**
  38373. * Detaches the behavior from its current arc rotate camera.
  38374. */
  38375. detach(): void;
  38376. private _radiusIsAnimating;
  38377. private _radiusBounceTransition;
  38378. private _animatables;
  38379. private _cachedWheelPrecision;
  38380. /**
  38381. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38382. * @param radiusLimit The limit to check against.
  38383. * @return Bool to indicate if at limit.
  38384. */
  38385. private _isRadiusAtLimit;
  38386. /**
  38387. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38388. * @param radiusDelta The delta by which to animate to. Can be negative.
  38389. */
  38390. private _applyBoundRadiusAnimation;
  38391. /**
  38392. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38393. */
  38394. protected _clearAnimationLocks(): void;
  38395. /**
  38396. * Stops and removes all animations that have been applied to the camera
  38397. */
  38398. stopAllAnimations(): void;
  38399. }
  38400. }
  38401. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38402. import { Behavior } from "babylonjs/Behaviors/behavior";
  38403. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38404. import { ExponentialEase } from "babylonjs/Animations/easing";
  38405. import { Nullable } from "babylonjs/types";
  38406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38407. import { Vector3 } from "babylonjs/Maths/math.vector";
  38408. /**
  38409. * 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.
  38410. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38411. */
  38412. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38413. /**
  38414. * Gets the name of the behavior.
  38415. */
  38416. readonly name: string;
  38417. private _mode;
  38418. private _radiusScale;
  38419. private _positionScale;
  38420. private _defaultElevation;
  38421. private _elevationReturnTime;
  38422. private _elevationReturnWaitTime;
  38423. private _zoomStopsAnimation;
  38424. private _framingTime;
  38425. /**
  38426. * The easing function used by animations
  38427. */
  38428. static EasingFunction: ExponentialEase;
  38429. /**
  38430. * The easing mode used by animations
  38431. */
  38432. static EasingMode: number;
  38433. /**
  38434. * Sets the current mode used by the behavior
  38435. */
  38436. /**
  38437. * Gets current mode used by the behavior.
  38438. */
  38439. mode: number;
  38440. /**
  38441. * Sets the scale applied to the radius (1 by default)
  38442. */
  38443. /**
  38444. * Gets the scale applied to the radius
  38445. */
  38446. radiusScale: number;
  38447. /**
  38448. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38449. */
  38450. /**
  38451. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38452. */
  38453. positionScale: number;
  38454. /**
  38455. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38456. * behaviour is triggered, in radians.
  38457. */
  38458. /**
  38459. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38460. * behaviour is triggered, in radians.
  38461. */
  38462. defaultElevation: number;
  38463. /**
  38464. * Sets the time (in milliseconds) taken to return to the default beta position.
  38465. * Negative value indicates camera should not return to default.
  38466. */
  38467. /**
  38468. * Gets the time (in milliseconds) taken to return to the default beta position.
  38469. * Negative value indicates camera should not return to default.
  38470. */
  38471. elevationReturnTime: number;
  38472. /**
  38473. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38474. */
  38475. /**
  38476. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38477. */
  38478. elevationReturnWaitTime: number;
  38479. /**
  38480. * Sets the flag that indicates if user zooming should stop animation.
  38481. */
  38482. /**
  38483. * Gets the flag that indicates if user zooming should stop animation.
  38484. */
  38485. zoomStopsAnimation: boolean;
  38486. /**
  38487. * Sets the transition time when framing the mesh, in milliseconds
  38488. */
  38489. /**
  38490. * Gets the transition time when framing the mesh, in milliseconds
  38491. */
  38492. framingTime: number;
  38493. /**
  38494. * Define if the behavior should automatically change the configured
  38495. * camera limits and sensibilities.
  38496. */
  38497. autoCorrectCameraLimitsAndSensibility: boolean;
  38498. private _onPrePointerObservableObserver;
  38499. private _onAfterCheckInputsObserver;
  38500. private _onMeshTargetChangedObserver;
  38501. private _attachedCamera;
  38502. private _isPointerDown;
  38503. private _lastInteractionTime;
  38504. /**
  38505. * Initializes the behavior.
  38506. */
  38507. init(): void;
  38508. /**
  38509. * Attaches the behavior to its arc rotate camera.
  38510. * @param camera Defines the camera to attach the behavior to
  38511. */
  38512. attach(camera: ArcRotateCamera): void;
  38513. /**
  38514. * Detaches the behavior from its current arc rotate camera.
  38515. */
  38516. detach(): void;
  38517. private _animatables;
  38518. private _betaIsAnimating;
  38519. private _betaTransition;
  38520. private _radiusTransition;
  38521. private _vectorTransition;
  38522. /**
  38523. * Targets the given mesh and updates zoom level accordingly.
  38524. * @param mesh The mesh to target.
  38525. * @param radius Optional. If a cached radius position already exists, overrides default.
  38526. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38527. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38528. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38529. */
  38530. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38531. /**
  38532. * Targets the given mesh with its children and updates zoom level accordingly.
  38533. * @param mesh The mesh to target.
  38534. * @param radius Optional. If a cached radius position already exists, overrides default.
  38535. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38536. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38537. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38538. */
  38539. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38540. /**
  38541. * Targets the given meshes with their children and updates zoom level accordingly.
  38542. * @param meshes The mesh to target.
  38543. * @param radius Optional. If a cached radius position already exists, overrides default.
  38544. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38545. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38546. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38547. */
  38548. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38549. /**
  38550. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38551. * @param minimumWorld Determines the smaller position of the bounding box extend
  38552. * @param maximumWorld Determines the bigger position of the bounding box extend
  38553. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38554. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38555. */
  38556. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38557. /**
  38558. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38559. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38560. * frustum width.
  38561. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38562. * to fully enclose the mesh in the viewing frustum.
  38563. */
  38564. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38565. /**
  38566. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38567. * is automatically returned to its default position (expected to be above ground plane).
  38568. */
  38569. private _maintainCameraAboveGround;
  38570. /**
  38571. * Returns the frustum slope based on the canvas ratio and camera FOV
  38572. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38573. */
  38574. private _getFrustumSlope;
  38575. /**
  38576. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38577. */
  38578. private _clearAnimationLocks;
  38579. /**
  38580. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38581. */
  38582. private _applyUserInteraction;
  38583. /**
  38584. * Stops and removes all animations that have been applied to the camera
  38585. */
  38586. stopAllAnimations(): void;
  38587. /**
  38588. * Gets a value indicating if the user is moving the camera
  38589. */
  38590. readonly isUserIsMoving: boolean;
  38591. /**
  38592. * The camera can move all the way towards the mesh.
  38593. */
  38594. static IgnoreBoundsSizeMode: number;
  38595. /**
  38596. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38597. */
  38598. static FitFrustumSidesMode: number;
  38599. }
  38600. }
  38601. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  38602. import { Nullable } from "babylonjs/types";
  38603. import { Camera } from "babylonjs/Cameras/camera";
  38604. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38605. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38606. /**
  38607. * Base class for Camera Pointer Inputs.
  38608. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38609. * for example usage.
  38610. */
  38611. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38612. /**
  38613. * Defines the camera the input is attached to.
  38614. */
  38615. abstract camera: Camera;
  38616. /**
  38617. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38618. */
  38619. protected _altKey: boolean;
  38620. protected _ctrlKey: boolean;
  38621. protected _metaKey: boolean;
  38622. protected _shiftKey: boolean;
  38623. /**
  38624. * Which mouse buttons were pressed at time of last mouse event.
  38625. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38626. */
  38627. protected _buttonsPressed: number;
  38628. /**
  38629. * Defines the buttons associated with the input to handle camera move.
  38630. */
  38631. buttons: number[];
  38632. /**
  38633. * Attach the input controls to a specific dom element to get the input from.
  38634. * @param element Defines the element the controls should be listened from
  38635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38636. */
  38637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38638. /**
  38639. * Detach the current controls from the specified dom element.
  38640. * @param element Defines the element to stop listening the inputs from
  38641. */
  38642. detachControl(element: Nullable<HTMLElement>): void;
  38643. /**
  38644. * Gets the class name of the current input.
  38645. * @returns the class name
  38646. */
  38647. getClassName(): string;
  38648. /**
  38649. * Get the friendly name associated with the input class.
  38650. * @returns the input friendly name
  38651. */
  38652. getSimpleName(): string;
  38653. /**
  38654. * Called on pointer POINTERDOUBLETAP event.
  38655. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38656. */
  38657. protected onDoubleTap(type: string): void;
  38658. /**
  38659. * Called on pointer POINTERMOVE event if only a single touch is active.
  38660. * Override this method to provide functionality.
  38661. */
  38662. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38663. /**
  38664. * Called on pointer POINTERMOVE event if multiple touches are active.
  38665. * Override this method to provide functionality.
  38666. */
  38667. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38668. /**
  38669. * Called on JS contextmenu event.
  38670. * Override this method to provide functionality.
  38671. */
  38672. protected onContextMenu(evt: PointerEvent): void;
  38673. /**
  38674. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38675. * press.
  38676. * Override this method to provide functionality.
  38677. */
  38678. protected onButtonDown(evt: PointerEvent): void;
  38679. /**
  38680. * Called each time a new POINTERUP event occurs. Ie, for each button
  38681. * release.
  38682. * Override this method to provide functionality.
  38683. */
  38684. protected onButtonUp(evt: PointerEvent): void;
  38685. /**
  38686. * Called when window becomes inactive.
  38687. * Override this method to provide functionality.
  38688. */
  38689. protected onLostFocus(): void;
  38690. private _pointerInput;
  38691. private _observer;
  38692. private _onLostFocus;
  38693. private pointA;
  38694. private pointB;
  38695. }
  38696. }
  38697. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  38698. import { Nullable } from "babylonjs/types";
  38699. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38700. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38701. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38702. /**
  38703. * Manage the pointers inputs to control an arc rotate camera.
  38704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38705. */
  38706. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38707. /**
  38708. * Defines the camera the input is attached to.
  38709. */
  38710. camera: ArcRotateCamera;
  38711. /**
  38712. * Gets the class name of the current input.
  38713. * @returns the class name
  38714. */
  38715. getClassName(): string;
  38716. /**
  38717. * Defines the buttons associated with the input to handle camera move.
  38718. */
  38719. buttons: number[];
  38720. /**
  38721. * Defines the pointer angular sensibility along the X axis or how fast is
  38722. * the camera rotating.
  38723. */
  38724. angularSensibilityX: number;
  38725. /**
  38726. * Defines the pointer angular sensibility along the Y axis or how fast is
  38727. * the camera rotating.
  38728. */
  38729. angularSensibilityY: number;
  38730. /**
  38731. * Defines the pointer pinch precision or how fast is the camera zooming.
  38732. */
  38733. pinchPrecision: number;
  38734. /**
  38735. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38736. * from 0.
  38737. * It defines the percentage of current camera.radius to use as delta when
  38738. * pinch zoom is used.
  38739. */
  38740. pinchDeltaPercentage: number;
  38741. /**
  38742. * Defines the pointer panning sensibility or how fast is the camera moving.
  38743. */
  38744. panningSensibility: number;
  38745. /**
  38746. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38747. */
  38748. multiTouchPanning: boolean;
  38749. /**
  38750. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38751. * zoom (pinch) through multitouch.
  38752. */
  38753. multiTouchPanAndZoom: boolean;
  38754. /**
  38755. * Revers pinch action direction.
  38756. */
  38757. pinchInwards: boolean;
  38758. private _isPanClick;
  38759. private _twoFingerActivityCount;
  38760. private _isPinching;
  38761. /**
  38762. * Called on pointer POINTERMOVE event if only a single touch is active.
  38763. */
  38764. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38765. /**
  38766. * Called on pointer POINTERDOUBLETAP event.
  38767. */
  38768. protected onDoubleTap(type: string): void;
  38769. /**
  38770. * Called on pointer POINTERMOVE event if multiple touches are active.
  38771. */
  38772. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38773. /**
  38774. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38775. * press.
  38776. */
  38777. protected onButtonDown(evt: PointerEvent): void;
  38778. /**
  38779. * Called each time a new POINTERUP event occurs. Ie, for each button
  38780. * release.
  38781. */
  38782. protected onButtonUp(evt: PointerEvent): void;
  38783. /**
  38784. * Called when window becomes inactive.
  38785. */
  38786. protected onLostFocus(): void;
  38787. }
  38788. }
  38789. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  38790. import { Nullable } from "babylonjs/types";
  38791. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38792. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38793. /**
  38794. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38796. */
  38797. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38798. /**
  38799. * Defines the camera the input is attached to.
  38800. */
  38801. camera: ArcRotateCamera;
  38802. /**
  38803. * Defines the list of key codes associated with the up action (increase alpha)
  38804. */
  38805. keysUp: number[];
  38806. /**
  38807. * Defines the list of key codes associated with the down action (decrease alpha)
  38808. */
  38809. keysDown: number[];
  38810. /**
  38811. * Defines the list of key codes associated with the left action (increase beta)
  38812. */
  38813. keysLeft: number[];
  38814. /**
  38815. * Defines the list of key codes associated with the right action (decrease beta)
  38816. */
  38817. keysRight: number[];
  38818. /**
  38819. * Defines the list of key codes associated with the reset action.
  38820. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38821. */
  38822. keysReset: number[];
  38823. /**
  38824. * Defines the panning sensibility of the inputs.
  38825. * (How fast is the camera paning)
  38826. */
  38827. panningSensibility: number;
  38828. /**
  38829. * Defines the zooming sensibility of the inputs.
  38830. * (How fast is the camera zooming)
  38831. */
  38832. zoomingSensibility: number;
  38833. /**
  38834. * Defines wether maintaining the alt key down switch the movement mode from
  38835. * orientation to zoom.
  38836. */
  38837. useAltToZoom: boolean;
  38838. /**
  38839. * Rotation speed of the camera
  38840. */
  38841. angularSpeed: number;
  38842. private _keys;
  38843. private _ctrlPressed;
  38844. private _altPressed;
  38845. private _onCanvasBlurObserver;
  38846. private _onKeyboardObserver;
  38847. private _engine;
  38848. private _scene;
  38849. /**
  38850. * Attach the input controls to a specific dom element to get the input from.
  38851. * @param element Defines the element the controls should be listened from
  38852. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38853. */
  38854. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38855. /**
  38856. * Detach the current controls from the specified dom element.
  38857. * @param element Defines the element to stop listening the inputs from
  38858. */
  38859. detachControl(element: Nullable<HTMLElement>): void;
  38860. /**
  38861. * Update the current camera state depending on the inputs that have been used this frame.
  38862. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38863. */
  38864. checkInputs(): void;
  38865. /**
  38866. * Gets the class name of the current intput.
  38867. * @returns the class name
  38868. */
  38869. getClassName(): string;
  38870. /**
  38871. * Get the friendly name associated with the input class.
  38872. * @returns the input friendly name
  38873. */
  38874. getSimpleName(): string;
  38875. }
  38876. }
  38877. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  38878. import { Nullable } from "babylonjs/types";
  38879. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38880. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38881. /**
  38882. * Manage the mouse wheel inputs to control an arc rotate camera.
  38883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38884. */
  38885. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38886. /**
  38887. * Defines the camera the input is attached to.
  38888. */
  38889. camera: ArcRotateCamera;
  38890. /**
  38891. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38892. */
  38893. wheelPrecision: number;
  38894. /**
  38895. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38896. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38897. */
  38898. wheelDeltaPercentage: number;
  38899. private _wheel;
  38900. private _observer;
  38901. private computeDeltaFromMouseWheelLegacyEvent;
  38902. /**
  38903. * Attach the input controls to a specific dom element to get the input from.
  38904. * @param element Defines the element the controls should be listened from
  38905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38906. */
  38907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38908. /**
  38909. * Detach the current controls from the specified dom element.
  38910. * @param element Defines the element to stop listening the inputs from
  38911. */
  38912. detachControl(element: Nullable<HTMLElement>): void;
  38913. /**
  38914. * Gets the class name of the current intput.
  38915. * @returns the class name
  38916. */
  38917. getClassName(): string;
  38918. /**
  38919. * Get the friendly name associated with the input class.
  38920. * @returns the input friendly name
  38921. */
  38922. getSimpleName(): string;
  38923. }
  38924. }
  38925. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38926. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38927. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38928. /**
  38929. * Default Inputs manager for the ArcRotateCamera.
  38930. * It groups all the default supported inputs for ease of use.
  38931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38932. */
  38933. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38934. /**
  38935. * Instantiates a new ArcRotateCameraInputsManager.
  38936. * @param camera Defines the camera the inputs belong to
  38937. */
  38938. constructor(camera: ArcRotateCamera);
  38939. /**
  38940. * Add mouse wheel input support to the input manager.
  38941. * @returns the current input manager
  38942. */
  38943. addMouseWheel(): ArcRotateCameraInputsManager;
  38944. /**
  38945. * Add pointers input support to the input manager.
  38946. * @returns the current input manager
  38947. */
  38948. addPointers(): ArcRotateCameraInputsManager;
  38949. /**
  38950. * Add keyboard input support to the input manager.
  38951. * @returns the current input manager
  38952. */
  38953. addKeyboard(): ArcRotateCameraInputsManager;
  38954. }
  38955. }
  38956. declare module "babylonjs/Cameras/arcRotateCamera" {
  38957. import { Observable } from "babylonjs/Misc/observable";
  38958. import { Nullable } from "babylonjs/types";
  38959. import { Scene } from "babylonjs/scene";
  38960. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  38961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38962. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38963. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38964. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  38965. import { Camera } from "babylonjs/Cameras/camera";
  38966. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38967. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  38968. import { Collider } from "babylonjs/Collisions/collider";
  38969. /**
  38970. * This represents an orbital type of camera.
  38971. *
  38972. * 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.
  38973. * 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.
  38974. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38975. */
  38976. export class ArcRotateCamera extends TargetCamera {
  38977. /**
  38978. * Defines the rotation angle of the camera along the longitudinal axis.
  38979. */
  38980. alpha: number;
  38981. /**
  38982. * Defines the rotation angle of the camera along the latitudinal axis.
  38983. */
  38984. beta: number;
  38985. /**
  38986. * Defines the radius of the camera from it s target point.
  38987. */
  38988. radius: number;
  38989. protected _target: Vector3;
  38990. protected _targetHost: Nullable<AbstractMesh>;
  38991. /**
  38992. * Defines the target point of the camera.
  38993. * The camera looks towards it form the radius distance.
  38994. */
  38995. target: Vector3;
  38996. /**
  38997. * Define the current local position of the camera in the scene
  38998. */
  38999. position: Vector3;
  39000. protected _upVector: Vector3;
  39001. protected _upToYMatrix: Matrix;
  39002. protected _YToUpMatrix: Matrix;
  39003. /**
  39004. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39005. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39006. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39007. */
  39008. upVector: Vector3;
  39009. /**
  39010. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39011. */
  39012. setMatUp(): void;
  39013. /**
  39014. * Current inertia value on the longitudinal axis.
  39015. * The bigger this number the longer it will take for the camera to stop.
  39016. */
  39017. inertialAlphaOffset: number;
  39018. /**
  39019. * Current inertia value on the latitudinal axis.
  39020. * The bigger this number the longer it will take for the camera to stop.
  39021. */
  39022. inertialBetaOffset: number;
  39023. /**
  39024. * Current inertia value on the radius axis.
  39025. * The bigger this number the longer it will take for the camera to stop.
  39026. */
  39027. inertialRadiusOffset: number;
  39028. /**
  39029. * Minimum allowed angle on the longitudinal axis.
  39030. * This can help limiting how the Camera is able to move in the scene.
  39031. */
  39032. lowerAlphaLimit: Nullable<number>;
  39033. /**
  39034. * Maximum allowed angle on the longitudinal axis.
  39035. * This can help limiting how the Camera is able to move in the scene.
  39036. */
  39037. upperAlphaLimit: Nullable<number>;
  39038. /**
  39039. * Minimum allowed angle on the latitudinal axis.
  39040. * This can help limiting how the Camera is able to move in the scene.
  39041. */
  39042. lowerBetaLimit: number;
  39043. /**
  39044. * Maximum allowed angle on the latitudinal axis.
  39045. * This can help limiting how the Camera is able to move in the scene.
  39046. */
  39047. upperBetaLimit: number;
  39048. /**
  39049. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39050. * This can help limiting how the Camera is able to move in the scene.
  39051. */
  39052. lowerRadiusLimit: Nullable<number>;
  39053. /**
  39054. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39055. * This can help limiting how the Camera is able to move in the scene.
  39056. */
  39057. upperRadiusLimit: Nullable<number>;
  39058. /**
  39059. * Defines the current inertia value used during panning of the camera along the X axis.
  39060. */
  39061. inertialPanningX: number;
  39062. /**
  39063. * Defines the current inertia value used during panning of the camera along the Y axis.
  39064. */
  39065. inertialPanningY: number;
  39066. /**
  39067. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39068. * Basically if your fingers moves away from more than this distance you will be considered
  39069. * in pinch mode.
  39070. */
  39071. pinchToPanMaxDistance: number;
  39072. /**
  39073. * Defines the maximum distance the camera can pan.
  39074. * This could help keeping the cammera always in your scene.
  39075. */
  39076. panningDistanceLimit: Nullable<number>;
  39077. /**
  39078. * Defines the target of the camera before paning.
  39079. */
  39080. panningOriginTarget: Vector3;
  39081. /**
  39082. * Defines the value of the inertia used during panning.
  39083. * 0 would mean stop inertia and one would mean no decelleration at all.
  39084. */
  39085. panningInertia: number;
  39086. /**
  39087. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39088. */
  39089. angularSensibilityX: number;
  39090. /**
  39091. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39092. */
  39093. angularSensibilityY: number;
  39094. /**
  39095. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39096. */
  39097. pinchPrecision: number;
  39098. /**
  39099. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39100. * It will be used instead of pinchDeltaPrecision if different from 0.
  39101. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39102. */
  39103. pinchDeltaPercentage: number;
  39104. /**
  39105. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39106. */
  39107. panningSensibility: number;
  39108. /**
  39109. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39110. */
  39111. keysUp: number[];
  39112. /**
  39113. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39114. */
  39115. keysDown: number[];
  39116. /**
  39117. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39118. */
  39119. keysLeft: number[];
  39120. /**
  39121. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39122. */
  39123. keysRight: number[];
  39124. /**
  39125. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39126. */
  39127. wheelPrecision: number;
  39128. /**
  39129. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39130. * It will be used instead of pinchDeltaPrecision if different from 0.
  39131. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39132. */
  39133. wheelDeltaPercentage: number;
  39134. /**
  39135. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39136. */
  39137. zoomOnFactor: number;
  39138. /**
  39139. * Defines a screen offset for the camera position.
  39140. */
  39141. targetScreenOffset: Vector2;
  39142. /**
  39143. * Allows the camera to be completely reversed.
  39144. * If false the camera can not arrive upside down.
  39145. */
  39146. allowUpsideDown: boolean;
  39147. /**
  39148. * Define if double tap/click is used to restore the previously saved state of the camera.
  39149. */
  39150. useInputToRestoreState: boolean;
  39151. /** @hidden */
  39152. _viewMatrix: Matrix;
  39153. /** @hidden */
  39154. _useCtrlForPanning: boolean;
  39155. /** @hidden */
  39156. _panningMouseButton: number;
  39157. /**
  39158. * Defines the input associated to the camera.
  39159. */
  39160. inputs: ArcRotateCameraInputsManager;
  39161. /** @hidden */
  39162. _reset: () => void;
  39163. /**
  39164. * Defines the allowed panning axis.
  39165. */
  39166. panningAxis: Vector3;
  39167. protected _localDirection: Vector3;
  39168. protected _transformedDirection: Vector3;
  39169. private _bouncingBehavior;
  39170. /**
  39171. * Gets the bouncing behavior of the camera if it has been enabled.
  39172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39173. */
  39174. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  39175. /**
  39176. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39178. */
  39179. useBouncingBehavior: boolean;
  39180. private _framingBehavior;
  39181. /**
  39182. * Gets the framing behavior of the camera if it has been enabled.
  39183. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39184. */
  39185. readonly framingBehavior: Nullable<FramingBehavior>;
  39186. /**
  39187. * Defines if the framing behavior of the camera is enabled on the camera.
  39188. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39189. */
  39190. useFramingBehavior: boolean;
  39191. private _autoRotationBehavior;
  39192. /**
  39193. * Gets the auto rotation behavior of the camera if it has been enabled.
  39194. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39195. */
  39196. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  39197. /**
  39198. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39199. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39200. */
  39201. useAutoRotationBehavior: boolean;
  39202. /**
  39203. * Observable triggered when the mesh target has been changed on the camera.
  39204. */
  39205. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39206. /**
  39207. * Event raised when the camera is colliding with a mesh.
  39208. */
  39209. onCollide: (collidedMesh: AbstractMesh) => void;
  39210. /**
  39211. * Defines whether the camera should check collision with the objects oh the scene.
  39212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39213. */
  39214. checkCollisions: boolean;
  39215. /**
  39216. * Defines the collision radius of the camera.
  39217. * This simulates a sphere around the camera.
  39218. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39219. */
  39220. collisionRadius: Vector3;
  39221. protected _collider: Collider;
  39222. protected _previousPosition: Vector3;
  39223. protected _collisionVelocity: Vector3;
  39224. protected _newPosition: Vector3;
  39225. protected _previousAlpha: number;
  39226. protected _previousBeta: number;
  39227. protected _previousRadius: number;
  39228. protected _collisionTriggered: boolean;
  39229. protected _targetBoundingCenter: Nullable<Vector3>;
  39230. private _computationVector;
  39231. /**
  39232. * Instantiates a new ArcRotateCamera in a given scene
  39233. * @param name Defines the name of the camera
  39234. * @param alpha Defines the camera rotation along the logitudinal axis
  39235. * @param beta Defines the camera rotation along the latitudinal axis
  39236. * @param radius Defines the camera distance from its target
  39237. * @param target Defines the camera target
  39238. * @param scene Defines the scene the camera belongs to
  39239. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39240. */
  39241. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39242. /** @hidden */
  39243. _initCache(): void;
  39244. /** @hidden */
  39245. _updateCache(ignoreParentClass?: boolean): void;
  39246. protected _getTargetPosition(): Vector3;
  39247. private _storedAlpha;
  39248. private _storedBeta;
  39249. private _storedRadius;
  39250. private _storedTarget;
  39251. private _storedTargetScreenOffset;
  39252. /**
  39253. * Stores the current state of the camera (alpha, beta, radius and target)
  39254. * @returns the camera itself
  39255. */
  39256. storeState(): Camera;
  39257. /**
  39258. * @hidden
  39259. * Restored camera state. You must call storeState() first
  39260. */
  39261. _restoreStateValues(): boolean;
  39262. /** @hidden */
  39263. _isSynchronizedViewMatrix(): boolean;
  39264. /**
  39265. * Attached controls to the current camera.
  39266. * @param element Defines the element the controls should be listened from
  39267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39268. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39269. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39270. */
  39271. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39272. /**
  39273. * Detach the current controls from the camera.
  39274. * The camera will stop reacting to inputs.
  39275. * @param element Defines the element to stop listening the inputs from
  39276. */
  39277. detachControl(element: HTMLElement): void;
  39278. /** @hidden */
  39279. _checkInputs(): void;
  39280. protected _checkLimits(): void;
  39281. /**
  39282. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39283. */
  39284. rebuildAnglesAndRadius(): void;
  39285. /**
  39286. * Use a position to define the current camera related information like alpha, beta and radius
  39287. * @param position Defines the position to set the camera at
  39288. */
  39289. setPosition(position: Vector3): void;
  39290. /**
  39291. * Defines the target the camera should look at.
  39292. * This will automatically adapt alpha beta and radius to fit within the new target.
  39293. * @param target Defines the new target as a Vector or a mesh
  39294. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39295. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39296. */
  39297. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39298. /** @hidden */
  39299. _getViewMatrix(): Matrix;
  39300. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39301. /**
  39302. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39303. * @param meshes Defines the mesh to zoom on
  39304. * @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)
  39305. */
  39306. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39307. /**
  39308. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39309. * The target will be changed but the radius
  39310. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39311. * @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)
  39312. */
  39313. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39314. min: Vector3;
  39315. max: Vector3;
  39316. distance: number;
  39317. }, doNotUpdateMaxZ?: boolean): void;
  39318. /**
  39319. * @override
  39320. * Override Camera.createRigCamera
  39321. */
  39322. createRigCamera(name: string, cameraIndex: number): Camera;
  39323. /**
  39324. * @hidden
  39325. * @override
  39326. * Override Camera._updateRigCameras
  39327. */
  39328. _updateRigCameras(): void;
  39329. /**
  39330. * Destroy the camera and release the current resources hold by it.
  39331. */
  39332. dispose(): void;
  39333. /**
  39334. * Gets the current object class name.
  39335. * @return the class name
  39336. */
  39337. getClassName(): string;
  39338. }
  39339. }
  39340. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39341. import { Behavior } from "babylonjs/Behaviors/behavior";
  39342. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39343. /**
  39344. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39345. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39346. */
  39347. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39348. /**
  39349. * Gets the name of the behavior.
  39350. */
  39351. readonly name: string;
  39352. private _zoomStopsAnimation;
  39353. private _idleRotationSpeed;
  39354. private _idleRotationWaitTime;
  39355. private _idleRotationSpinupTime;
  39356. /**
  39357. * Sets the flag that indicates if user zooming should stop animation.
  39358. */
  39359. /**
  39360. * Gets the flag that indicates if user zooming should stop animation.
  39361. */
  39362. zoomStopsAnimation: boolean;
  39363. /**
  39364. * Sets the default speed at which the camera rotates around the model.
  39365. */
  39366. /**
  39367. * Gets the default speed at which the camera rotates around the model.
  39368. */
  39369. idleRotationSpeed: number;
  39370. /**
  39371. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39372. */
  39373. /**
  39374. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39375. */
  39376. idleRotationWaitTime: number;
  39377. /**
  39378. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39379. */
  39380. /**
  39381. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39382. */
  39383. idleRotationSpinupTime: number;
  39384. /**
  39385. * Gets a value indicating if the camera is currently rotating because of this behavior
  39386. */
  39387. readonly rotationInProgress: boolean;
  39388. private _onPrePointerObservableObserver;
  39389. private _onAfterCheckInputsObserver;
  39390. private _attachedCamera;
  39391. private _isPointerDown;
  39392. private _lastFrameTime;
  39393. private _lastInteractionTime;
  39394. private _cameraRotationSpeed;
  39395. /**
  39396. * Initializes the behavior.
  39397. */
  39398. init(): void;
  39399. /**
  39400. * Attaches the behavior to its arc rotate camera.
  39401. * @param camera Defines the camera to attach the behavior to
  39402. */
  39403. attach(camera: ArcRotateCamera): void;
  39404. /**
  39405. * Detaches the behavior from its current arc rotate camera.
  39406. */
  39407. detach(): void;
  39408. /**
  39409. * Returns true if user is scrolling.
  39410. * @return true if user is scrolling.
  39411. */
  39412. private _userIsZooming;
  39413. private _lastFrameRadius;
  39414. private _shouldAnimationStopForInteraction;
  39415. /**
  39416. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39417. */
  39418. private _applyUserInteraction;
  39419. private _userIsMoving;
  39420. }
  39421. }
  39422. declare module "babylonjs/Behaviors/Cameras/index" {
  39423. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39424. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39425. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39426. }
  39427. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39428. import { Mesh } from "babylonjs/Meshes/mesh";
  39429. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39430. import { Behavior } from "babylonjs/Behaviors/behavior";
  39431. /**
  39432. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39433. */
  39434. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39435. private ui;
  39436. /**
  39437. * The name of the behavior
  39438. */
  39439. name: string;
  39440. /**
  39441. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39442. */
  39443. distanceAwayFromFace: number;
  39444. /**
  39445. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39446. */
  39447. distanceAwayFromBottomOfFace: number;
  39448. private _faceVectors;
  39449. private _target;
  39450. private _scene;
  39451. private _onRenderObserver;
  39452. private _tmpMatrix;
  39453. private _tmpVector;
  39454. /**
  39455. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39456. * @param ui The transform node that should be attched to the mesh
  39457. */
  39458. constructor(ui: TransformNode);
  39459. /**
  39460. * Initializes the behavior
  39461. */
  39462. init(): void;
  39463. private _closestFace;
  39464. private _zeroVector;
  39465. private _lookAtTmpMatrix;
  39466. private _lookAtToRef;
  39467. /**
  39468. * Attaches the AttachToBoxBehavior to the passed in mesh
  39469. * @param target The mesh that the specified node will be attached to
  39470. */
  39471. attach(target: Mesh): void;
  39472. /**
  39473. * Detaches the behavior from the mesh
  39474. */
  39475. detach(): void;
  39476. }
  39477. }
  39478. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39479. import { Behavior } from "babylonjs/Behaviors/behavior";
  39480. import { Mesh } from "babylonjs/Meshes/mesh";
  39481. /**
  39482. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39483. */
  39484. export class FadeInOutBehavior implements Behavior<Mesh> {
  39485. /**
  39486. * Time in milliseconds to delay before fading in (Default: 0)
  39487. */
  39488. delay: number;
  39489. /**
  39490. * Time in milliseconds for the mesh to fade in (Default: 300)
  39491. */
  39492. fadeInTime: number;
  39493. private _millisecondsPerFrame;
  39494. private _hovered;
  39495. private _hoverValue;
  39496. private _ownerNode;
  39497. /**
  39498. * Instatiates the FadeInOutBehavior
  39499. */
  39500. constructor();
  39501. /**
  39502. * The name of the behavior
  39503. */
  39504. readonly name: string;
  39505. /**
  39506. * Initializes the behavior
  39507. */
  39508. init(): void;
  39509. /**
  39510. * Attaches the fade behavior on the passed in mesh
  39511. * @param ownerNode The mesh that will be faded in/out once attached
  39512. */
  39513. attach(ownerNode: Mesh): void;
  39514. /**
  39515. * Detaches the behavior from the mesh
  39516. */
  39517. detach(): void;
  39518. /**
  39519. * Triggers the mesh to begin fading in or out
  39520. * @param value if the object should fade in or out (true to fade in)
  39521. */
  39522. fadeIn(value: boolean): void;
  39523. private _update;
  39524. private _setAllVisibility;
  39525. }
  39526. }
  39527. declare module "babylonjs/Misc/pivotTools" {
  39528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39529. /**
  39530. * Class containing a set of static utilities functions for managing Pivots
  39531. * @hidden
  39532. */
  39533. export class PivotTools {
  39534. private static _PivotCached;
  39535. private static _OldPivotPoint;
  39536. private static _PivotTranslation;
  39537. private static _PivotTmpVector;
  39538. /** @hidden */
  39539. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39540. /** @hidden */
  39541. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39542. }
  39543. }
  39544. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39545. import { Scene } from "babylonjs/scene";
  39546. import { Vector4 } from "babylonjs/Maths/math.vector";
  39547. import { Mesh } from "babylonjs/Meshes/mesh";
  39548. import { Nullable } from "babylonjs/types";
  39549. import { Plane } from "babylonjs/Maths/math.plane";
  39550. /**
  39551. * Class containing static functions to help procedurally build meshes
  39552. */
  39553. export class PlaneBuilder {
  39554. /**
  39555. * Creates a plane mesh
  39556. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39557. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39558. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39562. * @param name defines the name of the mesh
  39563. * @param options defines the options used to create the mesh
  39564. * @param scene defines the hosting scene
  39565. * @returns the plane mesh
  39566. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39567. */
  39568. static CreatePlane(name: string, options: {
  39569. size?: number;
  39570. width?: number;
  39571. height?: number;
  39572. sideOrientation?: number;
  39573. frontUVs?: Vector4;
  39574. backUVs?: Vector4;
  39575. updatable?: boolean;
  39576. sourcePlane?: Plane;
  39577. }, scene?: Nullable<Scene>): Mesh;
  39578. }
  39579. }
  39580. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  39581. import { Behavior } from "babylonjs/Behaviors/behavior";
  39582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39583. import { Observable } from "babylonjs/Misc/observable";
  39584. import { Vector3 } from "babylonjs/Maths/math.vector";
  39585. import { Ray } from "babylonjs/Culling/ray";
  39586. import "babylonjs/Meshes/Builders/planeBuilder";
  39587. /**
  39588. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39589. */
  39590. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39591. private static _AnyMouseID;
  39592. /**
  39593. * Abstract mesh the behavior is set on
  39594. */
  39595. attachedNode: AbstractMesh;
  39596. private _dragPlane;
  39597. private _scene;
  39598. private _pointerObserver;
  39599. private _beforeRenderObserver;
  39600. private static _planeScene;
  39601. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39602. /**
  39603. * 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)
  39604. */
  39605. maxDragAngle: number;
  39606. /**
  39607. * @hidden
  39608. */
  39609. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39610. /**
  39611. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39612. */
  39613. currentDraggingPointerID: number;
  39614. /**
  39615. * The last position where the pointer hit the drag plane in world space
  39616. */
  39617. lastDragPosition: Vector3;
  39618. /**
  39619. * If the behavior is currently in a dragging state
  39620. */
  39621. dragging: boolean;
  39622. /**
  39623. * 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)
  39624. */
  39625. dragDeltaRatio: number;
  39626. /**
  39627. * If the drag plane orientation should be updated during the dragging (Default: true)
  39628. */
  39629. updateDragPlane: boolean;
  39630. private _debugMode;
  39631. private _moving;
  39632. /**
  39633. * Fires each time the attached mesh is dragged with the pointer
  39634. * * delta between last drag position and current drag position in world space
  39635. * * dragDistance along the drag axis
  39636. * * dragPlaneNormal normal of the current drag plane used during the drag
  39637. * * dragPlanePoint in world space where the drag intersects the drag plane
  39638. */
  39639. onDragObservable: Observable<{
  39640. delta: Vector3;
  39641. dragPlanePoint: Vector3;
  39642. dragPlaneNormal: Vector3;
  39643. dragDistance: number;
  39644. pointerId: number;
  39645. }>;
  39646. /**
  39647. * Fires each time a drag begins (eg. mouse down on mesh)
  39648. */
  39649. onDragStartObservable: Observable<{
  39650. dragPlanePoint: Vector3;
  39651. pointerId: number;
  39652. }>;
  39653. /**
  39654. * Fires each time a drag ends (eg. mouse release after drag)
  39655. */
  39656. onDragEndObservable: Observable<{
  39657. dragPlanePoint: Vector3;
  39658. pointerId: number;
  39659. }>;
  39660. /**
  39661. * If the attached mesh should be moved when dragged
  39662. */
  39663. moveAttached: boolean;
  39664. /**
  39665. * If the drag behavior will react to drag events (Default: true)
  39666. */
  39667. enabled: boolean;
  39668. /**
  39669. * If pointer events should start and release the drag (Default: true)
  39670. */
  39671. startAndReleaseDragOnPointerEvents: boolean;
  39672. /**
  39673. * If camera controls should be detached during the drag
  39674. */
  39675. detachCameraControls: boolean;
  39676. /**
  39677. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39678. */
  39679. useObjectOrienationForDragging: boolean;
  39680. private _options;
  39681. /**
  39682. * Creates a pointer drag behavior that can be attached to a mesh
  39683. * @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)
  39684. */
  39685. constructor(options?: {
  39686. dragAxis?: Vector3;
  39687. dragPlaneNormal?: Vector3;
  39688. });
  39689. /**
  39690. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39691. */
  39692. validateDrag: (targetPosition: Vector3) => boolean;
  39693. /**
  39694. * The name of the behavior
  39695. */
  39696. readonly name: string;
  39697. /**
  39698. * Initializes the behavior
  39699. */
  39700. init(): void;
  39701. private _tmpVector;
  39702. private _alternatePickedPoint;
  39703. private _worldDragAxis;
  39704. private _targetPosition;
  39705. private _attachedElement;
  39706. /**
  39707. * Attaches the drag behavior the passed in mesh
  39708. * @param ownerNode The mesh that will be dragged around once attached
  39709. * @param predicate Predicate to use for pick filtering
  39710. */
  39711. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39712. /**
  39713. * Force relase the drag action by code.
  39714. */
  39715. releaseDrag(): void;
  39716. private _startDragRay;
  39717. private _lastPointerRay;
  39718. /**
  39719. * Simulates the start of a pointer drag event on the behavior
  39720. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39721. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39722. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39723. */
  39724. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39725. private _startDrag;
  39726. private _dragDelta;
  39727. private _moveDrag;
  39728. private _pickWithRayOnDragPlane;
  39729. private _pointA;
  39730. private _pointB;
  39731. private _pointC;
  39732. private _lineA;
  39733. private _lineB;
  39734. private _localAxis;
  39735. private _lookAt;
  39736. private _updateDragPlanePosition;
  39737. /**
  39738. * Detaches the behavior from the mesh
  39739. */
  39740. detach(): void;
  39741. }
  39742. }
  39743. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  39744. import { Mesh } from "babylonjs/Meshes/mesh";
  39745. import { Behavior } from "babylonjs/Behaviors/behavior";
  39746. /**
  39747. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39748. */
  39749. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39750. private _dragBehaviorA;
  39751. private _dragBehaviorB;
  39752. private _startDistance;
  39753. private _initialScale;
  39754. private _targetScale;
  39755. private _ownerNode;
  39756. private _sceneRenderObserver;
  39757. /**
  39758. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39759. */
  39760. constructor();
  39761. /**
  39762. * The name of the behavior
  39763. */
  39764. readonly name: string;
  39765. /**
  39766. * Initializes the behavior
  39767. */
  39768. init(): void;
  39769. private _getCurrentDistance;
  39770. /**
  39771. * Attaches the scale behavior the passed in mesh
  39772. * @param ownerNode The mesh that will be scaled around once attached
  39773. */
  39774. attach(ownerNode: Mesh): void;
  39775. /**
  39776. * Detaches the behavior from the mesh
  39777. */
  39778. detach(): void;
  39779. }
  39780. }
  39781. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  39782. import { Behavior } from "babylonjs/Behaviors/behavior";
  39783. import { Mesh } from "babylonjs/Meshes/mesh";
  39784. import { Observable } from "babylonjs/Misc/observable";
  39785. /**
  39786. * 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
  39787. */
  39788. export class SixDofDragBehavior implements Behavior<Mesh> {
  39789. private static _virtualScene;
  39790. private _ownerNode;
  39791. private _sceneRenderObserver;
  39792. private _scene;
  39793. private _targetPosition;
  39794. private _virtualOriginMesh;
  39795. private _virtualDragMesh;
  39796. private _pointerObserver;
  39797. private _moving;
  39798. private _startingOrientation;
  39799. /**
  39800. * 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)
  39801. */
  39802. private zDragFactor;
  39803. /**
  39804. * If the object should rotate to face the drag origin
  39805. */
  39806. rotateDraggedObject: boolean;
  39807. /**
  39808. * If the behavior is currently in a dragging state
  39809. */
  39810. dragging: boolean;
  39811. /**
  39812. * 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)
  39813. */
  39814. dragDeltaRatio: number;
  39815. /**
  39816. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39817. */
  39818. currentDraggingPointerID: number;
  39819. /**
  39820. * If camera controls should be detached during the drag
  39821. */
  39822. detachCameraControls: boolean;
  39823. /**
  39824. * Fires each time a drag starts
  39825. */
  39826. onDragStartObservable: Observable<{}>;
  39827. /**
  39828. * Fires each time a drag ends (eg. mouse release after drag)
  39829. */
  39830. onDragEndObservable: Observable<{}>;
  39831. /**
  39832. * 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
  39833. */
  39834. constructor();
  39835. /**
  39836. * The name of the behavior
  39837. */
  39838. readonly name: string;
  39839. /**
  39840. * Initializes the behavior
  39841. */
  39842. init(): void;
  39843. /**
  39844. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39845. */
  39846. private readonly _pointerCamera;
  39847. /**
  39848. * Attaches the scale behavior the passed in mesh
  39849. * @param ownerNode The mesh that will be scaled around once attached
  39850. */
  39851. attach(ownerNode: Mesh): void;
  39852. /**
  39853. * Detaches the behavior from the mesh
  39854. */
  39855. detach(): void;
  39856. }
  39857. }
  39858. declare module "babylonjs/Behaviors/Meshes/index" {
  39859. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  39860. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  39861. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  39862. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  39863. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  39864. }
  39865. declare module "babylonjs/Behaviors/index" {
  39866. export * from "babylonjs/Behaviors/behavior";
  39867. export * from "babylonjs/Behaviors/Cameras/index";
  39868. export * from "babylonjs/Behaviors/Meshes/index";
  39869. }
  39870. declare module "babylonjs/Bones/boneIKController" {
  39871. import { Bone } from "babylonjs/Bones/bone";
  39872. import { Vector3 } from "babylonjs/Maths/math.vector";
  39873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39874. import { Nullable } from "babylonjs/types";
  39875. /**
  39876. * Class used to apply inverse kinematics to bones
  39877. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39878. */
  39879. export class BoneIKController {
  39880. private static _tmpVecs;
  39881. private static _tmpQuat;
  39882. private static _tmpMats;
  39883. /**
  39884. * Gets or sets the target mesh
  39885. */
  39886. targetMesh: AbstractMesh;
  39887. /** Gets or sets the mesh used as pole */
  39888. poleTargetMesh: AbstractMesh;
  39889. /**
  39890. * Gets or sets the bone used as pole
  39891. */
  39892. poleTargetBone: Nullable<Bone>;
  39893. /**
  39894. * Gets or sets the target position
  39895. */
  39896. targetPosition: Vector3;
  39897. /**
  39898. * Gets or sets the pole target position
  39899. */
  39900. poleTargetPosition: Vector3;
  39901. /**
  39902. * Gets or sets the pole target local offset
  39903. */
  39904. poleTargetLocalOffset: Vector3;
  39905. /**
  39906. * Gets or sets the pole angle
  39907. */
  39908. poleAngle: number;
  39909. /**
  39910. * Gets or sets the mesh associated with the controller
  39911. */
  39912. mesh: AbstractMesh;
  39913. /**
  39914. * 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)
  39915. */
  39916. slerpAmount: number;
  39917. private _bone1Quat;
  39918. private _bone1Mat;
  39919. private _bone2Ang;
  39920. private _bone1;
  39921. private _bone2;
  39922. private _bone1Length;
  39923. private _bone2Length;
  39924. private _maxAngle;
  39925. private _maxReach;
  39926. private _rightHandedSystem;
  39927. private _bendAxis;
  39928. private _slerping;
  39929. private _adjustRoll;
  39930. /**
  39931. * Gets or sets maximum allowed angle
  39932. */
  39933. maxAngle: number;
  39934. /**
  39935. * Creates a new BoneIKController
  39936. * @param mesh defines the mesh to control
  39937. * @param bone defines the bone to control
  39938. * @param options defines options to set up the controller
  39939. */
  39940. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39941. targetMesh?: AbstractMesh;
  39942. poleTargetMesh?: AbstractMesh;
  39943. poleTargetBone?: Bone;
  39944. poleTargetLocalOffset?: Vector3;
  39945. poleAngle?: number;
  39946. bendAxis?: Vector3;
  39947. maxAngle?: number;
  39948. slerpAmount?: number;
  39949. });
  39950. private _setMaxAngle;
  39951. /**
  39952. * Force the controller to update the bones
  39953. */
  39954. update(): void;
  39955. }
  39956. }
  39957. declare module "babylonjs/Bones/boneLookController" {
  39958. import { Vector3 } from "babylonjs/Maths/math.vector";
  39959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39960. import { Bone } from "babylonjs/Bones/bone";
  39961. import { Space } from "babylonjs/Maths/math.axis";
  39962. /**
  39963. * Class used to make a bone look toward a point in space
  39964. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39965. */
  39966. export class BoneLookController {
  39967. private static _tmpVecs;
  39968. private static _tmpQuat;
  39969. private static _tmpMats;
  39970. /**
  39971. * The target Vector3 that the bone will look at
  39972. */
  39973. target: Vector3;
  39974. /**
  39975. * The mesh that the bone is attached to
  39976. */
  39977. mesh: AbstractMesh;
  39978. /**
  39979. * The bone that will be looking to the target
  39980. */
  39981. bone: Bone;
  39982. /**
  39983. * The up axis of the coordinate system that is used when the bone is rotated
  39984. */
  39985. upAxis: Vector3;
  39986. /**
  39987. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39988. */
  39989. upAxisSpace: Space;
  39990. /**
  39991. * Used to make an adjustment to the yaw of the bone
  39992. */
  39993. adjustYaw: number;
  39994. /**
  39995. * Used to make an adjustment to the pitch of the bone
  39996. */
  39997. adjustPitch: number;
  39998. /**
  39999. * Used to make an adjustment to the roll of the bone
  40000. */
  40001. adjustRoll: number;
  40002. /**
  40003. * 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)
  40004. */
  40005. slerpAmount: number;
  40006. private _minYaw;
  40007. private _maxYaw;
  40008. private _minPitch;
  40009. private _maxPitch;
  40010. private _minYawSin;
  40011. private _minYawCos;
  40012. private _maxYawSin;
  40013. private _maxYawCos;
  40014. private _midYawConstraint;
  40015. private _minPitchTan;
  40016. private _maxPitchTan;
  40017. private _boneQuat;
  40018. private _slerping;
  40019. private _transformYawPitch;
  40020. private _transformYawPitchInv;
  40021. private _firstFrameSkipped;
  40022. private _yawRange;
  40023. private _fowardAxis;
  40024. /**
  40025. * Gets or sets the minimum yaw angle that the bone can look to
  40026. */
  40027. minYaw: number;
  40028. /**
  40029. * Gets or sets the maximum yaw angle that the bone can look to
  40030. */
  40031. maxYaw: number;
  40032. /**
  40033. * Gets or sets the minimum pitch angle that the bone can look to
  40034. */
  40035. minPitch: number;
  40036. /**
  40037. * Gets or sets the maximum pitch angle that the bone can look to
  40038. */
  40039. maxPitch: number;
  40040. /**
  40041. * Create a BoneLookController
  40042. * @param mesh the mesh that the bone belongs to
  40043. * @param bone the bone that will be looking to the target
  40044. * @param target the target Vector3 to look at
  40045. * @param options optional settings:
  40046. * * maxYaw: the maximum angle the bone will yaw to
  40047. * * minYaw: the minimum angle the bone will yaw to
  40048. * * maxPitch: the maximum angle the bone will pitch to
  40049. * * minPitch: the minimum angle the bone will yaw to
  40050. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40051. * * upAxis: the up axis of the coordinate system
  40052. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40053. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40054. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40055. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40056. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40057. * * adjustRoll: used to make an adjustment to the roll of the bone
  40058. **/
  40059. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40060. maxYaw?: number;
  40061. minYaw?: number;
  40062. maxPitch?: number;
  40063. minPitch?: number;
  40064. slerpAmount?: number;
  40065. upAxis?: Vector3;
  40066. upAxisSpace?: Space;
  40067. yawAxis?: Vector3;
  40068. pitchAxis?: Vector3;
  40069. adjustYaw?: number;
  40070. adjustPitch?: number;
  40071. adjustRoll?: number;
  40072. });
  40073. /**
  40074. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40075. */
  40076. update(): void;
  40077. private _getAngleDiff;
  40078. private _getAngleBetween;
  40079. private _isAngleBetween;
  40080. }
  40081. }
  40082. declare module "babylonjs/Bones/index" {
  40083. export * from "babylonjs/Bones/bone";
  40084. export * from "babylonjs/Bones/boneIKController";
  40085. export * from "babylonjs/Bones/boneLookController";
  40086. export * from "babylonjs/Bones/skeleton";
  40087. }
  40088. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40089. import { Nullable } from "babylonjs/types";
  40090. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40091. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40092. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40093. /**
  40094. * Manage the gamepad inputs to control an arc rotate camera.
  40095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40096. */
  40097. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40098. /**
  40099. * Defines the camera the input is attached to.
  40100. */
  40101. camera: ArcRotateCamera;
  40102. /**
  40103. * Defines the gamepad the input is gathering event from.
  40104. */
  40105. gamepad: Nullable<Gamepad>;
  40106. /**
  40107. * Defines the gamepad rotation sensiblity.
  40108. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40109. */
  40110. gamepadRotationSensibility: number;
  40111. /**
  40112. * Defines the gamepad move sensiblity.
  40113. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40114. */
  40115. gamepadMoveSensibility: number;
  40116. private _yAxisScale;
  40117. /**
  40118. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40119. */
  40120. invertYAxis: boolean;
  40121. private _onGamepadConnectedObserver;
  40122. private _onGamepadDisconnectedObserver;
  40123. /**
  40124. * Attach the input controls to a specific dom element to get the input from.
  40125. * @param element Defines the element the controls should be listened from
  40126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40127. */
  40128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40129. /**
  40130. * Detach the current controls from the specified dom element.
  40131. * @param element Defines the element to stop listening the inputs from
  40132. */
  40133. detachControl(element: Nullable<HTMLElement>): void;
  40134. /**
  40135. * Update the current camera state depending on the inputs that have been used this frame.
  40136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40137. */
  40138. checkInputs(): void;
  40139. /**
  40140. * Gets the class name of the current intput.
  40141. * @returns the class name
  40142. */
  40143. getClassName(): string;
  40144. /**
  40145. * Get the friendly name associated with the input class.
  40146. * @returns the input friendly name
  40147. */
  40148. getSimpleName(): string;
  40149. }
  40150. }
  40151. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40152. import { Nullable } from "babylonjs/types";
  40153. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40154. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40155. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40156. interface ArcRotateCameraInputsManager {
  40157. /**
  40158. * Add orientation input support to the input manager.
  40159. * @returns the current input manager
  40160. */
  40161. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40162. }
  40163. }
  40164. /**
  40165. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40167. */
  40168. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40169. /**
  40170. * Defines the camera the input is attached to.
  40171. */
  40172. camera: ArcRotateCamera;
  40173. /**
  40174. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40175. */
  40176. alphaCorrection: number;
  40177. /**
  40178. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40179. */
  40180. gammaCorrection: number;
  40181. private _alpha;
  40182. private _gamma;
  40183. private _dirty;
  40184. private _deviceOrientationHandler;
  40185. /**
  40186. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40187. */
  40188. constructor();
  40189. /**
  40190. * Attach the input controls to a specific dom element to get the input from.
  40191. * @param element Defines the element the controls should be listened from
  40192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40193. */
  40194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40195. /** @hidden */
  40196. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40197. /**
  40198. * Update the current camera state depending on the inputs that have been used this frame.
  40199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40200. */
  40201. checkInputs(): void;
  40202. /**
  40203. * Detach the current controls from the specified dom element.
  40204. * @param element Defines the element to stop listening the inputs from
  40205. */
  40206. detachControl(element: Nullable<HTMLElement>): void;
  40207. /**
  40208. * Gets the class name of the current intput.
  40209. * @returns the class name
  40210. */
  40211. getClassName(): string;
  40212. /**
  40213. * Get the friendly name associated with the input class.
  40214. * @returns the input friendly name
  40215. */
  40216. getSimpleName(): string;
  40217. }
  40218. }
  40219. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40220. import { Nullable } from "babylonjs/types";
  40221. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40222. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40223. /**
  40224. * Listen to mouse events to control the camera.
  40225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40226. */
  40227. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40228. /**
  40229. * Defines the camera the input is attached to.
  40230. */
  40231. camera: FlyCamera;
  40232. /**
  40233. * Defines if touch is enabled. (Default is true.)
  40234. */
  40235. touchEnabled: boolean;
  40236. /**
  40237. * Defines the buttons associated with the input to handle camera rotation.
  40238. */
  40239. buttons: number[];
  40240. /**
  40241. * Assign buttons for Yaw control.
  40242. */
  40243. buttonsYaw: number[];
  40244. /**
  40245. * Assign buttons for Pitch control.
  40246. */
  40247. buttonsPitch: number[];
  40248. /**
  40249. * Assign buttons for Roll control.
  40250. */
  40251. buttonsRoll: number[];
  40252. /**
  40253. * Detect if any button is being pressed while mouse is moved.
  40254. * -1 = Mouse locked.
  40255. * 0 = Left button.
  40256. * 1 = Middle Button.
  40257. * 2 = Right Button.
  40258. */
  40259. activeButton: number;
  40260. /**
  40261. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40262. * Higher values reduce its sensitivity.
  40263. */
  40264. angularSensibility: number;
  40265. private _mousemoveCallback;
  40266. private _observer;
  40267. private _rollObserver;
  40268. private previousPosition;
  40269. private noPreventDefault;
  40270. private element;
  40271. /**
  40272. * Listen to mouse events to control the camera.
  40273. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40275. */
  40276. constructor(touchEnabled?: boolean);
  40277. /**
  40278. * Attach the mouse control to the HTML DOM element.
  40279. * @param element Defines the element that listens to the input events.
  40280. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40281. */
  40282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40283. /**
  40284. * Detach the current controls from the specified dom element.
  40285. * @param element Defines the element to stop listening the inputs from
  40286. */
  40287. detachControl(element: Nullable<HTMLElement>): void;
  40288. /**
  40289. * Gets the class name of the current input.
  40290. * @returns the class name.
  40291. */
  40292. getClassName(): string;
  40293. /**
  40294. * Get the friendly name associated with the input class.
  40295. * @returns the input's friendly name.
  40296. */
  40297. getSimpleName(): string;
  40298. private _pointerInput;
  40299. private _onMouseMove;
  40300. /**
  40301. * Rotate camera by mouse offset.
  40302. */
  40303. private rotateCamera;
  40304. }
  40305. }
  40306. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40307. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40308. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40309. /**
  40310. * Default Inputs manager for the FlyCamera.
  40311. * It groups all the default supported inputs for ease of use.
  40312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40313. */
  40314. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40315. /**
  40316. * Instantiates a new FlyCameraInputsManager.
  40317. * @param camera Defines the camera the inputs belong to.
  40318. */
  40319. constructor(camera: FlyCamera);
  40320. /**
  40321. * Add keyboard input support to the input manager.
  40322. * @returns the new FlyCameraKeyboardMoveInput().
  40323. */
  40324. addKeyboard(): FlyCameraInputsManager;
  40325. /**
  40326. * Add mouse input support to the input manager.
  40327. * @param touchEnabled Enable touch screen support.
  40328. * @returns the new FlyCameraMouseInput().
  40329. */
  40330. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40331. }
  40332. }
  40333. declare module "babylonjs/Cameras/flyCamera" {
  40334. import { Scene } from "babylonjs/scene";
  40335. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40337. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40338. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40339. /**
  40340. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40341. * such as in a 3D Space Shooter or a Flight Simulator.
  40342. */
  40343. export class FlyCamera extends TargetCamera {
  40344. /**
  40345. * Define the collision ellipsoid of the camera.
  40346. * This is helpful for simulating a camera body, like a player's body.
  40347. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40348. */
  40349. ellipsoid: Vector3;
  40350. /**
  40351. * Define an offset for the position of the ellipsoid around the camera.
  40352. * This can be helpful if the camera is attached away from the player's body center,
  40353. * such as at its head.
  40354. */
  40355. ellipsoidOffset: Vector3;
  40356. /**
  40357. * Enable or disable collisions of the camera with the rest of the scene objects.
  40358. */
  40359. checkCollisions: boolean;
  40360. /**
  40361. * Enable or disable gravity on the camera.
  40362. */
  40363. applyGravity: boolean;
  40364. /**
  40365. * Define the current direction the camera is moving to.
  40366. */
  40367. cameraDirection: Vector3;
  40368. /**
  40369. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40370. * This overrides and empties cameraRotation.
  40371. */
  40372. rotationQuaternion: Quaternion;
  40373. /**
  40374. * Track Roll to maintain the wanted Rolling when looking around.
  40375. */
  40376. _trackRoll: number;
  40377. /**
  40378. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40379. */
  40380. rollCorrect: number;
  40381. /**
  40382. * Mimic a banked turn, Rolling the camera when Yawing.
  40383. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40384. */
  40385. bankedTurn: boolean;
  40386. /**
  40387. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40388. */
  40389. bankedTurnLimit: number;
  40390. /**
  40391. * Value of 0 disables the banked Roll.
  40392. * Value of 1 is equal to the Yaw angle in radians.
  40393. */
  40394. bankedTurnMultiplier: number;
  40395. /**
  40396. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40397. */
  40398. inputs: FlyCameraInputsManager;
  40399. /**
  40400. * Gets the input sensibility for mouse input.
  40401. * Higher values reduce sensitivity.
  40402. */
  40403. /**
  40404. * Sets the input sensibility for a mouse input.
  40405. * Higher values reduce sensitivity.
  40406. */
  40407. angularSensibility: number;
  40408. /**
  40409. * Get the keys for camera movement forward.
  40410. */
  40411. /**
  40412. * Set the keys for camera movement forward.
  40413. */
  40414. keysForward: number[];
  40415. /**
  40416. * Get the keys for camera movement backward.
  40417. */
  40418. keysBackward: number[];
  40419. /**
  40420. * Get the keys for camera movement up.
  40421. */
  40422. /**
  40423. * Set the keys for camera movement up.
  40424. */
  40425. keysUp: number[];
  40426. /**
  40427. * Get the keys for camera movement down.
  40428. */
  40429. /**
  40430. * Set the keys for camera movement down.
  40431. */
  40432. keysDown: number[];
  40433. /**
  40434. * Get the keys for camera movement left.
  40435. */
  40436. /**
  40437. * Set the keys for camera movement left.
  40438. */
  40439. keysLeft: number[];
  40440. /**
  40441. * Set the keys for camera movement right.
  40442. */
  40443. /**
  40444. * Set the keys for camera movement right.
  40445. */
  40446. keysRight: number[];
  40447. /**
  40448. * Event raised when the camera collides with a mesh in the scene.
  40449. */
  40450. onCollide: (collidedMesh: AbstractMesh) => void;
  40451. private _collider;
  40452. private _needMoveForGravity;
  40453. private _oldPosition;
  40454. private _diffPosition;
  40455. private _newPosition;
  40456. /** @hidden */
  40457. _localDirection: Vector3;
  40458. /** @hidden */
  40459. _transformedDirection: Vector3;
  40460. /**
  40461. * Instantiates a FlyCamera.
  40462. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40463. * such as in a 3D Space Shooter or a Flight Simulator.
  40464. * @param name Define the name of the camera in the scene.
  40465. * @param position Define the starting position of the camera in the scene.
  40466. * @param scene Define the scene the camera belongs to.
  40467. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40468. */
  40469. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40470. /**
  40471. * Attach a control to the HTML DOM element.
  40472. * @param element Defines the element that listens to the input events.
  40473. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40474. */
  40475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40476. /**
  40477. * Detach a control from the HTML DOM element.
  40478. * The camera will stop reacting to that input.
  40479. * @param element Defines the element that listens to the input events.
  40480. */
  40481. detachControl(element: HTMLElement): void;
  40482. private _collisionMask;
  40483. /**
  40484. * Get the mask that the camera ignores in collision events.
  40485. */
  40486. /**
  40487. * Set the mask that the camera ignores in collision events.
  40488. */
  40489. collisionMask: number;
  40490. /** @hidden */
  40491. _collideWithWorld(displacement: Vector3): void;
  40492. /** @hidden */
  40493. private _onCollisionPositionChange;
  40494. /** @hidden */
  40495. _checkInputs(): void;
  40496. /** @hidden */
  40497. _decideIfNeedsToMove(): boolean;
  40498. /** @hidden */
  40499. _updatePosition(): void;
  40500. /**
  40501. * Restore the Roll to its target value at the rate specified.
  40502. * @param rate - Higher means slower restoring.
  40503. * @hidden
  40504. */
  40505. restoreRoll(rate: number): void;
  40506. /**
  40507. * Destroy the camera and release the current resources held by it.
  40508. */
  40509. dispose(): void;
  40510. /**
  40511. * Get the current object class name.
  40512. * @returns the class name.
  40513. */
  40514. getClassName(): string;
  40515. }
  40516. }
  40517. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40518. import { Nullable } from "babylonjs/types";
  40519. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40520. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40521. /**
  40522. * Listen to keyboard events to control the camera.
  40523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40524. */
  40525. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40526. /**
  40527. * Defines the camera the input is attached to.
  40528. */
  40529. camera: FlyCamera;
  40530. /**
  40531. * The list of keyboard keys used to control the forward move of the camera.
  40532. */
  40533. keysForward: number[];
  40534. /**
  40535. * The list of keyboard keys used to control the backward move of the camera.
  40536. */
  40537. keysBackward: number[];
  40538. /**
  40539. * The list of keyboard keys used to control the forward move of the camera.
  40540. */
  40541. keysUp: number[];
  40542. /**
  40543. * The list of keyboard keys used to control the backward move of the camera.
  40544. */
  40545. keysDown: number[];
  40546. /**
  40547. * The list of keyboard keys used to control the right strafe move of the camera.
  40548. */
  40549. keysRight: number[];
  40550. /**
  40551. * The list of keyboard keys used to control the left strafe move of the camera.
  40552. */
  40553. keysLeft: number[];
  40554. private _keys;
  40555. private _onCanvasBlurObserver;
  40556. private _onKeyboardObserver;
  40557. private _engine;
  40558. private _scene;
  40559. /**
  40560. * Attach the input controls to a specific dom element to get the input from.
  40561. * @param element Defines the element the controls should be listened from
  40562. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40563. */
  40564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40565. /**
  40566. * Detach the current controls from the specified dom element.
  40567. * @param element Defines the element to stop listening the inputs from
  40568. */
  40569. detachControl(element: Nullable<HTMLElement>): void;
  40570. /**
  40571. * Gets the class name of the current intput.
  40572. * @returns the class name
  40573. */
  40574. getClassName(): string;
  40575. /** @hidden */
  40576. _onLostFocus(e: FocusEvent): void;
  40577. /**
  40578. * Get the friendly name associated with the input class.
  40579. * @returns the input friendly name
  40580. */
  40581. getSimpleName(): string;
  40582. /**
  40583. * Update the current camera state depending on the inputs that have been used this frame.
  40584. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40585. */
  40586. checkInputs(): void;
  40587. }
  40588. }
  40589. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  40590. import { Nullable } from "babylonjs/types";
  40591. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40592. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40593. /**
  40594. * Manage the mouse wheel inputs to control a follow camera.
  40595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40596. */
  40597. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40598. /**
  40599. * Defines the camera the input is attached to.
  40600. */
  40601. camera: FollowCamera;
  40602. /**
  40603. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40604. */
  40605. axisControlRadius: boolean;
  40606. /**
  40607. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40608. */
  40609. axisControlHeight: boolean;
  40610. /**
  40611. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40612. */
  40613. axisControlRotation: boolean;
  40614. /**
  40615. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40616. * relation to mouseWheel events.
  40617. */
  40618. wheelPrecision: number;
  40619. /**
  40620. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40621. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40622. */
  40623. wheelDeltaPercentage: number;
  40624. private _wheel;
  40625. private _observer;
  40626. /**
  40627. * Attach the input controls to a specific dom element to get the input from.
  40628. * @param element Defines the element the controls should be listened from
  40629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40630. */
  40631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40632. /**
  40633. * Detach the current controls from the specified dom element.
  40634. * @param element Defines the element to stop listening the inputs from
  40635. */
  40636. detachControl(element: Nullable<HTMLElement>): void;
  40637. /**
  40638. * Gets the class name of the current intput.
  40639. * @returns the class name
  40640. */
  40641. getClassName(): string;
  40642. /**
  40643. * Get the friendly name associated with the input class.
  40644. * @returns the input friendly name
  40645. */
  40646. getSimpleName(): string;
  40647. }
  40648. }
  40649. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  40650. import { Nullable } from "babylonjs/types";
  40651. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40652. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40653. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40654. /**
  40655. * Manage the pointers inputs to control an follow camera.
  40656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40657. */
  40658. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40659. /**
  40660. * Defines the camera the input is attached to.
  40661. */
  40662. camera: FollowCamera;
  40663. /**
  40664. * Gets the class name of the current input.
  40665. * @returns the class name
  40666. */
  40667. getClassName(): string;
  40668. /**
  40669. * Defines the pointer angular sensibility along the X axis or how fast is
  40670. * the camera rotating.
  40671. * A negative number will reverse the axis direction.
  40672. */
  40673. angularSensibilityX: number;
  40674. /**
  40675. * Defines the pointer angular sensibility along the Y axis or how fast is
  40676. * the camera rotating.
  40677. * A negative number will reverse the axis direction.
  40678. */
  40679. angularSensibilityY: number;
  40680. /**
  40681. * Defines the pointer pinch precision or how fast is the camera zooming.
  40682. * A negative number will reverse the axis direction.
  40683. */
  40684. pinchPrecision: number;
  40685. /**
  40686. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40687. * from 0.
  40688. * It defines the percentage of current camera.radius to use as delta when
  40689. * pinch zoom is used.
  40690. */
  40691. pinchDeltaPercentage: number;
  40692. /**
  40693. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40694. */
  40695. axisXControlRadius: boolean;
  40696. /**
  40697. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40698. */
  40699. axisXControlHeight: boolean;
  40700. /**
  40701. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40702. */
  40703. axisXControlRotation: boolean;
  40704. /**
  40705. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40706. */
  40707. axisYControlRadius: boolean;
  40708. /**
  40709. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40710. */
  40711. axisYControlHeight: boolean;
  40712. /**
  40713. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40714. */
  40715. axisYControlRotation: boolean;
  40716. /**
  40717. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40718. */
  40719. axisPinchControlRadius: boolean;
  40720. /**
  40721. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40722. */
  40723. axisPinchControlHeight: boolean;
  40724. /**
  40725. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40726. */
  40727. axisPinchControlRotation: boolean;
  40728. /**
  40729. * Log error messages if basic misconfiguration has occurred.
  40730. */
  40731. warningEnable: boolean;
  40732. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40733. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40734. private _warningCounter;
  40735. private _warning;
  40736. }
  40737. }
  40738. declare module "babylonjs/Cameras/followCameraInputsManager" {
  40739. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40740. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40741. /**
  40742. * Default Inputs manager for the FollowCamera.
  40743. * It groups all the default supported inputs for ease of use.
  40744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40745. */
  40746. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40747. /**
  40748. * Instantiates a new FollowCameraInputsManager.
  40749. * @param camera Defines the camera the inputs belong to
  40750. */
  40751. constructor(camera: FollowCamera);
  40752. /**
  40753. * Add keyboard input support to the input manager.
  40754. * @returns the current input manager
  40755. */
  40756. addKeyboard(): FollowCameraInputsManager;
  40757. /**
  40758. * Add mouse wheel input support to the input manager.
  40759. * @returns the current input manager
  40760. */
  40761. addMouseWheel(): FollowCameraInputsManager;
  40762. /**
  40763. * Add pointers input support to the input manager.
  40764. * @returns the current input manager
  40765. */
  40766. addPointers(): FollowCameraInputsManager;
  40767. /**
  40768. * Add orientation input support to the input manager.
  40769. * @returns the current input manager
  40770. */
  40771. addVRDeviceOrientation(): FollowCameraInputsManager;
  40772. }
  40773. }
  40774. declare module "babylonjs/Cameras/followCamera" {
  40775. import { Nullable } from "babylonjs/types";
  40776. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40777. import { Scene } from "babylonjs/scene";
  40778. import { Vector3 } from "babylonjs/Maths/math.vector";
  40779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40780. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  40781. /**
  40782. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40783. * an arc rotate version arcFollowCamera are available.
  40784. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40785. */
  40786. export class FollowCamera extends TargetCamera {
  40787. /**
  40788. * Distance the follow camera should follow an object at
  40789. */
  40790. radius: number;
  40791. /**
  40792. * Minimum allowed distance of the camera to the axis of rotation
  40793. * (The camera can not get closer).
  40794. * This can help limiting how the Camera is able to move in the scene.
  40795. */
  40796. lowerRadiusLimit: Nullable<number>;
  40797. /**
  40798. * Maximum allowed distance of the camera to the axis of rotation
  40799. * (The camera can not get further).
  40800. * This can help limiting how the Camera is able to move in the scene.
  40801. */
  40802. upperRadiusLimit: Nullable<number>;
  40803. /**
  40804. * Define a rotation offset between the camera and the object it follows
  40805. */
  40806. rotationOffset: number;
  40807. /**
  40808. * Minimum allowed angle to camera position relative to target object.
  40809. * This can help limiting how the Camera is able to move in the scene.
  40810. */
  40811. lowerRotationOffsetLimit: Nullable<number>;
  40812. /**
  40813. * Maximum allowed angle to camera position relative to target object.
  40814. * This can help limiting how the Camera is able to move in the scene.
  40815. */
  40816. upperRotationOffsetLimit: Nullable<number>;
  40817. /**
  40818. * Define a height offset between the camera and the object it follows.
  40819. * It can help following an object from the top (like a car chaing a plane)
  40820. */
  40821. heightOffset: number;
  40822. /**
  40823. * Minimum allowed height of camera position relative to target object.
  40824. * This can help limiting how the Camera is able to move in the scene.
  40825. */
  40826. lowerHeightOffsetLimit: Nullable<number>;
  40827. /**
  40828. * Maximum allowed height of camera position relative to target object.
  40829. * This can help limiting how the Camera is able to move in the scene.
  40830. */
  40831. upperHeightOffsetLimit: Nullable<number>;
  40832. /**
  40833. * Define how fast the camera can accelerate to follow it s target.
  40834. */
  40835. cameraAcceleration: number;
  40836. /**
  40837. * Define the speed limit of the camera following an object.
  40838. */
  40839. maxCameraSpeed: number;
  40840. /**
  40841. * Define the target of the camera.
  40842. */
  40843. lockedTarget: Nullable<AbstractMesh>;
  40844. /**
  40845. * Defines the input associated with the camera.
  40846. */
  40847. inputs: FollowCameraInputsManager;
  40848. /**
  40849. * Instantiates the follow camera.
  40850. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40851. * @param name Define the name of the camera in the scene
  40852. * @param position Define the position of the camera
  40853. * @param scene Define the scene the camera belong to
  40854. * @param lockedTarget Define the target of the camera
  40855. */
  40856. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40857. private _follow;
  40858. /**
  40859. * Attached controls to the current camera.
  40860. * @param element Defines the element the controls should be listened from
  40861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40862. */
  40863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40864. /**
  40865. * Detach the current controls from the camera.
  40866. * The camera will stop reacting to inputs.
  40867. * @param element Defines the element to stop listening the inputs from
  40868. */
  40869. detachControl(element: HTMLElement): void;
  40870. /** @hidden */
  40871. _checkInputs(): void;
  40872. private _checkLimits;
  40873. /**
  40874. * Gets the camera class name.
  40875. * @returns the class name
  40876. */
  40877. getClassName(): string;
  40878. }
  40879. /**
  40880. * Arc Rotate version of the follow camera.
  40881. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40882. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40883. */
  40884. export class ArcFollowCamera extends TargetCamera {
  40885. /** The longitudinal angle of the camera */
  40886. alpha: number;
  40887. /** The latitudinal angle of the camera */
  40888. beta: number;
  40889. /** The radius of the camera from its target */
  40890. radius: number;
  40891. /** Define the camera target (the messh it should follow) */
  40892. target: Nullable<AbstractMesh>;
  40893. private _cartesianCoordinates;
  40894. /**
  40895. * Instantiates a new ArcFollowCamera
  40896. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40897. * @param name Define the name of the camera
  40898. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40899. * @param beta Define the rotation angle of the camera around the elevation axis
  40900. * @param radius Define the radius of the camera from its target point
  40901. * @param target Define the target of the camera
  40902. * @param scene Define the scene the camera belongs to
  40903. */
  40904. constructor(name: string,
  40905. /** The longitudinal angle of the camera */
  40906. alpha: number,
  40907. /** The latitudinal angle of the camera */
  40908. beta: number,
  40909. /** The radius of the camera from its target */
  40910. radius: number,
  40911. /** Define the camera target (the messh it should follow) */
  40912. target: Nullable<AbstractMesh>, scene: Scene);
  40913. private _follow;
  40914. /** @hidden */
  40915. _checkInputs(): void;
  40916. /**
  40917. * Returns the class name of the object.
  40918. * It is mostly used internally for serialization purposes.
  40919. */
  40920. getClassName(): string;
  40921. }
  40922. }
  40923. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  40924. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40925. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40926. import { Nullable } from "babylonjs/types";
  40927. /**
  40928. * Manage the keyboard inputs to control the movement of a follow camera.
  40929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40930. */
  40931. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40932. /**
  40933. * Defines the camera the input is attached to.
  40934. */
  40935. camera: FollowCamera;
  40936. /**
  40937. * Defines the list of key codes associated with the up action (increase heightOffset)
  40938. */
  40939. keysHeightOffsetIncr: number[];
  40940. /**
  40941. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40942. */
  40943. keysHeightOffsetDecr: number[];
  40944. /**
  40945. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40946. */
  40947. keysHeightOffsetModifierAlt: boolean;
  40948. /**
  40949. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40950. */
  40951. keysHeightOffsetModifierCtrl: boolean;
  40952. /**
  40953. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40954. */
  40955. keysHeightOffsetModifierShift: boolean;
  40956. /**
  40957. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40958. */
  40959. keysRotationOffsetIncr: number[];
  40960. /**
  40961. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40962. */
  40963. keysRotationOffsetDecr: number[];
  40964. /**
  40965. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40966. */
  40967. keysRotationOffsetModifierAlt: boolean;
  40968. /**
  40969. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40970. */
  40971. keysRotationOffsetModifierCtrl: boolean;
  40972. /**
  40973. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40974. */
  40975. keysRotationOffsetModifierShift: boolean;
  40976. /**
  40977. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40978. */
  40979. keysRadiusIncr: number[];
  40980. /**
  40981. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40982. */
  40983. keysRadiusDecr: number[];
  40984. /**
  40985. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40986. */
  40987. keysRadiusModifierAlt: boolean;
  40988. /**
  40989. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40990. */
  40991. keysRadiusModifierCtrl: boolean;
  40992. /**
  40993. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40994. */
  40995. keysRadiusModifierShift: boolean;
  40996. /**
  40997. * Defines the rate of change of heightOffset.
  40998. */
  40999. heightSensibility: number;
  41000. /**
  41001. * Defines the rate of change of rotationOffset.
  41002. */
  41003. rotationSensibility: number;
  41004. /**
  41005. * Defines the rate of change of radius.
  41006. */
  41007. radiusSensibility: number;
  41008. private _keys;
  41009. private _ctrlPressed;
  41010. private _altPressed;
  41011. private _shiftPressed;
  41012. private _onCanvasBlurObserver;
  41013. private _onKeyboardObserver;
  41014. private _engine;
  41015. private _scene;
  41016. /**
  41017. * Attach the input controls to a specific dom element to get the input from.
  41018. * @param element Defines the element the controls should be listened from
  41019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41020. */
  41021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41022. /**
  41023. * Detach the current controls from the specified dom element.
  41024. * @param element Defines the element to stop listening the inputs from
  41025. */
  41026. detachControl(element: Nullable<HTMLElement>): void;
  41027. /**
  41028. * Update the current camera state depending on the inputs that have been used this frame.
  41029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41030. */
  41031. checkInputs(): void;
  41032. /**
  41033. * Gets the class name of the current input.
  41034. * @returns the class name
  41035. */
  41036. getClassName(): string;
  41037. /**
  41038. * Get the friendly name associated with the input class.
  41039. * @returns the input friendly name
  41040. */
  41041. getSimpleName(): string;
  41042. /**
  41043. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41044. * allow modification of the heightOffset value.
  41045. */
  41046. private _modifierHeightOffset;
  41047. /**
  41048. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41049. * allow modification of the rotationOffset value.
  41050. */
  41051. private _modifierRotationOffset;
  41052. /**
  41053. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41054. * allow modification of the radius value.
  41055. */
  41056. private _modifierRadius;
  41057. }
  41058. }
  41059. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41060. import { Nullable } from "babylonjs/types";
  41061. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41062. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41063. import { Observable } from "babylonjs/Misc/observable";
  41064. module "babylonjs/Cameras/freeCameraInputsManager" {
  41065. interface FreeCameraInputsManager {
  41066. /**
  41067. * @hidden
  41068. */
  41069. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41070. /**
  41071. * Add orientation input support to the input manager.
  41072. * @returns the current input manager
  41073. */
  41074. addDeviceOrientation(): FreeCameraInputsManager;
  41075. }
  41076. }
  41077. /**
  41078. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41079. * Screen rotation is taken into account.
  41080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41081. */
  41082. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41083. private _camera;
  41084. private _screenOrientationAngle;
  41085. private _constantTranform;
  41086. private _screenQuaternion;
  41087. private _alpha;
  41088. private _beta;
  41089. private _gamma;
  41090. /**
  41091. * Can be used to detect if a device orientation sensor is availible on a device
  41092. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41093. * @returns a promise that will resolve on orientation change
  41094. */
  41095. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41096. /**
  41097. * @hidden
  41098. */
  41099. _onDeviceOrientationChangedObservable: Observable<void>;
  41100. /**
  41101. * Instantiates a new input
  41102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41103. */
  41104. constructor();
  41105. /**
  41106. * Define the camera controlled by the input.
  41107. */
  41108. camera: FreeCamera;
  41109. /**
  41110. * Attach the input controls to a specific dom element to get the input from.
  41111. * @param element Defines the element the controls should be listened from
  41112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41113. */
  41114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41115. private _orientationChanged;
  41116. private _deviceOrientation;
  41117. /**
  41118. * Detach the current controls from the specified dom element.
  41119. * @param element Defines the element to stop listening the inputs from
  41120. */
  41121. detachControl(element: Nullable<HTMLElement>): void;
  41122. /**
  41123. * Update the current camera state depending on the inputs that have been used this frame.
  41124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41125. */
  41126. checkInputs(): void;
  41127. /**
  41128. * Gets the class name of the current intput.
  41129. * @returns the class name
  41130. */
  41131. getClassName(): string;
  41132. /**
  41133. * Get the friendly name associated with the input class.
  41134. * @returns the input friendly name
  41135. */
  41136. getSimpleName(): string;
  41137. }
  41138. }
  41139. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41140. import { Nullable } from "babylonjs/types";
  41141. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41142. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41143. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41144. /**
  41145. * Manage the gamepad inputs to control a free camera.
  41146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41147. */
  41148. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41149. /**
  41150. * Define the camera the input is attached to.
  41151. */
  41152. camera: FreeCamera;
  41153. /**
  41154. * Define the Gamepad controlling the input
  41155. */
  41156. gamepad: Nullable<Gamepad>;
  41157. /**
  41158. * Defines the gamepad rotation sensiblity.
  41159. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41160. */
  41161. gamepadAngularSensibility: number;
  41162. /**
  41163. * Defines the gamepad move sensiblity.
  41164. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41165. */
  41166. gamepadMoveSensibility: number;
  41167. private _yAxisScale;
  41168. /**
  41169. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41170. */
  41171. invertYAxis: boolean;
  41172. private _onGamepadConnectedObserver;
  41173. private _onGamepadDisconnectedObserver;
  41174. private _cameraTransform;
  41175. private _deltaTransform;
  41176. private _vector3;
  41177. private _vector2;
  41178. /**
  41179. * Attach the input controls to a specific dom element to get the input from.
  41180. * @param element Defines the element the controls should be listened from
  41181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41182. */
  41183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41184. /**
  41185. * Detach the current controls from the specified dom element.
  41186. * @param element Defines the element to stop listening the inputs from
  41187. */
  41188. detachControl(element: Nullable<HTMLElement>): void;
  41189. /**
  41190. * Update the current camera state depending on the inputs that have been used this frame.
  41191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41192. */
  41193. checkInputs(): void;
  41194. /**
  41195. * Gets the class name of the current intput.
  41196. * @returns the class name
  41197. */
  41198. getClassName(): string;
  41199. /**
  41200. * Get the friendly name associated with the input class.
  41201. * @returns the input friendly name
  41202. */
  41203. getSimpleName(): string;
  41204. }
  41205. }
  41206. declare module "babylonjs/Misc/virtualJoystick" {
  41207. import { Nullable } from "babylonjs/types";
  41208. import { Vector3 } from "babylonjs/Maths/math.vector";
  41209. /**
  41210. * Defines the potential axis of a Joystick
  41211. */
  41212. export enum JoystickAxis {
  41213. /** X axis */
  41214. X = 0,
  41215. /** Y axis */
  41216. Y = 1,
  41217. /** Z axis */
  41218. Z = 2
  41219. }
  41220. /**
  41221. * Class used to define virtual joystick (used in touch mode)
  41222. */
  41223. export class VirtualJoystick {
  41224. /**
  41225. * Gets or sets a boolean indicating that left and right values must be inverted
  41226. */
  41227. reverseLeftRight: boolean;
  41228. /**
  41229. * Gets or sets a boolean indicating that up and down values must be inverted
  41230. */
  41231. reverseUpDown: boolean;
  41232. /**
  41233. * Gets the offset value for the position (ie. the change of the position value)
  41234. */
  41235. deltaPosition: Vector3;
  41236. /**
  41237. * Gets a boolean indicating if the virtual joystick was pressed
  41238. */
  41239. pressed: boolean;
  41240. /**
  41241. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41242. */
  41243. static Canvas: Nullable<HTMLCanvasElement>;
  41244. private static _globalJoystickIndex;
  41245. private static vjCanvasContext;
  41246. private static vjCanvasWidth;
  41247. private static vjCanvasHeight;
  41248. private static halfWidth;
  41249. private _action;
  41250. private _axisTargetedByLeftAndRight;
  41251. private _axisTargetedByUpAndDown;
  41252. private _joystickSensibility;
  41253. private _inversedSensibility;
  41254. private _joystickPointerID;
  41255. private _joystickColor;
  41256. private _joystickPointerPos;
  41257. private _joystickPreviousPointerPos;
  41258. private _joystickPointerStartPos;
  41259. private _deltaJoystickVector;
  41260. private _leftJoystick;
  41261. private _touches;
  41262. private _onPointerDownHandlerRef;
  41263. private _onPointerMoveHandlerRef;
  41264. private _onPointerUpHandlerRef;
  41265. private _onResize;
  41266. /**
  41267. * Creates a new virtual joystick
  41268. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41269. */
  41270. constructor(leftJoystick?: boolean);
  41271. /**
  41272. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41273. * @param newJoystickSensibility defines the new sensibility
  41274. */
  41275. setJoystickSensibility(newJoystickSensibility: number): void;
  41276. private _onPointerDown;
  41277. private _onPointerMove;
  41278. private _onPointerUp;
  41279. /**
  41280. * Change the color of the virtual joystick
  41281. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41282. */
  41283. setJoystickColor(newColor: string): void;
  41284. /**
  41285. * Defines a callback to call when the joystick is touched
  41286. * @param action defines the callback
  41287. */
  41288. setActionOnTouch(action: () => any): void;
  41289. /**
  41290. * Defines which axis you'd like to control for left & right
  41291. * @param axis defines the axis to use
  41292. */
  41293. setAxisForLeftRight(axis: JoystickAxis): void;
  41294. /**
  41295. * Defines which axis you'd like to control for up & down
  41296. * @param axis defines the axis to use
  41297. */
  41298. setAxisForUpDown(axis: JoystickAxis): void;
  41299. private _drawVirtualJoystick;
  41300. /**
  41301. * Release internal HTML canvas
  41302. */
  41303. releaseCanvas(): void;
  41304. }
  41305. }
  41306. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41307. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41308. import { Nullable } from "babylonjs/types";
  41309. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41310. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41311. module "babylonjs/Cameras/freeCameraInputsManager" {
  41312. interface FreeCameraInputsManager {
  41313. /**
  41314. * Add virtual joystick input support to the input manager.
  41315. * @returns the current input manager
  41316. */
  41317. addVirtualJoystick(): FreeCameraInputsManager;
  41318. }
  41319. }
  41320. /**
  41321. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41323. */
  41324. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41325. /**
  41326. * Defines the camera the input is attached to.
  41327. */
  41328. camera: FreeCamera;
  41329. private _leftjoystick;
  41330. private _rightjoystick;
  41331. /**
  41332. * Gets the left stick of the virtual joystick.
  41333. * @returns The virtual Joystick
  41334. */
  41335. getLeftJoystick(): VirtualJoystick;
  41336. /**
  41337. * Gets the right stick of the virtual joystick.
  41338. * @returns The virtual Joystick
  41339. */
  41340. getRightJoystick(): VirtualJoystick;
  41341. /**
  41342. * Update the current camera state depending on the inputs that have been used this frame.
  41343. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41344. */
  41345. checkInputs(): void;
  41346. /**
  41347. * Attach the input controls to a specific dom element to get the input from.
  41348. * @param element Defines the element the controls should be listened from
  41349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41350. */
  41351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41352. /**
  41353. * Detach the current controls from the specified dom element.
  41354. * @param element Defines the element to stop listening the inputs from
  41355. */
  41356. detachControl(element: Nullable<HTMLElement>): void;
  41357. /**
  41358. * Gets the class name of the current intput.
  41359. * @returns the class name
  41360. */
  41361. getClassName(): string;
  41362. /**
  41363. * Get the friendly name associated with the input class.
  41364. * @returns the input friendly name
  41365. */
  41366. getSimpleName(): string;
  41367. }
  41368. }
  41369. declare module "babylonjs/Cameras/Inputs/index" {
  41370. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41371. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41372. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41373. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41374. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41375. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41376. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41377. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41378. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41379. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41380. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41381. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41382. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41383. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41384. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41385. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41386. }
  41387. declare module "babylonjs/Cameras/touchCamera" {
  41388. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41389. import { Scene } from "babylonjs/scene";
  41390. import { Vector3 } from "babylonjs/Maths/math.vector";
  41391. /**
  41392. * This represents a FPS type of camera controlled by touch.
  41393. * This is like a universal camera minus the Gamepad controls.
  41394. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41395. */
  41396. export class TouchCamera extends FreeCamera {
  41397. /**
  41398. * Defines the touch sensibility for rotation.
  41399. * The higher the faster.
  41400. */
  41401. touchAngularSensibility: number;
  41402. /**
  41403. * Defines the touch sensibility for move.
  41404. * The higher the faster.
  41405. */
  41406. touchMoveSensibility: number;
  41407. /**
  41408. * Instantiates a new touch camera.
  41409. * This represents a FPS type of camera controlled by touch.
  41410. * This is like a universal camera minus the Gamepad controls.
  41411. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41412. * @param name Define the name of the camera in the scene
  41413. * @param position Define the start position of the camera in the scene
  41414. * @param scene Define the scene the camera belongs to
  41415. */
  41416. constructor(name: string, position: Vector3, scene: Scene);
  41417. /**
  41418. * Gets the current object class name.
  41419. * @return the class name
  41420. */
  41421. getClassName(): string;
  41422. /** @hidden */
  41423. _setupInputs(): void;
  41424. }
  41425. }
  41426. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41427. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41428. import { Scene } from "babylonjs/scene";
  41429. import { Vector3 } from "babylonjs/Maths/math.vector";
  41430. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41431. import { Axis } from "babylonjs/Maths/math.axis";
  41432. /**
  41433. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41434. * being tilted forward or back and left or right.
  41435. */
  41436. export class DeviceOrientationCamera extends FreeCamera {
  41437. private _initialQuaternion;
  41438. private _quaternionCache;
  41439. private _tmpDragQuaternion;
  41440. private _disablePointerInputWhenUsingDeviceOrientation;
  41441. /**
  41442. * Creates a new device orientation camera
  41443. * @param name The name of the camera
  41444. * @param position The start position camera
  41445. * @param scene The scene the camera belongs to
  41446. */
  41447. constructor(name: string, position: Vector3, scene: Scene);
  41448. /**
  41449. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41450. */
  41451. disablePointerInputWhenUsingDeviceOrientation: boolean;
  41452. private _dragFactor;
  41453. /**
  41454. * Enabled turning on the y axis when the orientation sensor is active
  41455. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41456. */
  41457. enableHorizontalDragging(dragFactor?: number): void;
  41458. /**
  41459. * Gets the current instance class name ("DeviceOrientationCamera").
  41460. * This helps avoiding instanceof at run time.
  41461. * @returns the class name
  41462. */
  41463. getClassName(): string;
  41464. /**
  41465. * @hidden
  41466. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41467. */
  41468. _checkInputs(): void;
  41469. /**
  41470. * Reset the camera to its default orientation on the specified axis only.
  41471. * @param axis The axis to reset
  41472. */
  41473. resetToCurrentRotation(axis?: Axis): void;
  41474. }
  41475. }
  41476. declare module "babylonjs/Gamepads/xboxGamepad" {
  41477. import { Observable } from "babylonjs/Misc/observable";
  41478. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41479. /**
  41480. * Defines supported buttons for XBox360 compatible gamepads
  41481. */
  41482. export enum Xbox360Button {
  41483. /** A */
  41484. A = 0,
  41485. /** B */
  41486. B = 1,
  41487. /** X */
  41488. X = 2,
  41489. /** Y */
  41490. Y = 3,
  41491. /** Start */
  41492. Start = 4,
  41493. /** Back */
  41494. Back = 5,
  41495. /** Left button */
  41496. LB = 6,
  41497. /** Right button */
  41498. RB = 7,
  41499. /** Left stick */
  41500. LeftStick = 8,
  41501. /** Right stick */
  41502. RightStick = 9
  41503. }
  41504. /** Defines values for XBox360 DPad */
  41505. export enum Xbox360Dpad {
  41506. /** Up */
  41507. Up = 0,
  41508. /** Down */
  41509. Down = 1,
  41510. /** Left */
  41511. Left = 2,
  41512. /** Right */
  41513. Right = 3
  41514. }
  41515. /**
  41516. * Defines a XBox360 gamepad
  41517. */
  41518. export class Xbox360Pad extends Gamepad {
  41519. private _leftTrigger;
  41520. private _rightTrigger;
  41521. private _onlefttriggerchanged;
  41522. private _onrighttriggerchanged;
  41523. private _onbuttondown;
  41524. private _onbuttonup;
  41525. private _ondpaddown;
  41526. private _ondpadup;
  41527. /** Observable raised when a button is pressed */
  41528. onButtonDownObservable: Observable<Xbox360Button>;
  41529. /** Observable raised when a button is released */
  41530. onButtonUpObservable: Observable<Xbox360Button>;
  41531. /** Observable raised when a pad is pressed */
  41532. onPadDownObservable: Observable<Xbox360Dpad>;
  41533. /** Observable raised when a pad is released */
  41534. onPadUpObservable: Observable<Xbox360Dpad>;
  41535. private _buttonA;
  41536. private _buttonB;
  41537. private _buttonX;
  41538. private _buttonY;
  41539. private _buttonBack;
  41540. private _buttonStart;
  41541. private _buttonLB;
  41542. private _buttonRB;
  41543. private _buttonLeftStick;
  41544. private _buttonRightStick;
  41545. private _dPadUp;
  41546. private _dPadDown;
  41547. private _dPadLeft;
  41548. private _dPadRight;
  41549. private _isXboxOnePad;
  41550. /**
  41551. * Creates a new XBox360 gamepad object
  41552. * @param id defines the id of this gamepad
  41553. * @param index defines its index
  41554. * @param gamepad defines the internal HTML gamepad object
  41555. * @param xboxOne defines if it is a XBox One gamepad
  41556. */
  41557. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41558. /**
  41559. * Defines the callback to call when left trigger is pressed
  41560. * @param callback defines the callback to use
  41561. */
  41562. onlefttriggerchanged(callback: (value: number) => void): void;
  41563. /**
  41564. * Defines the callback to call when right trigger is pressed
  41565. * @param callback defines the callback to use
  41566. */
  41567. onrighttriggerchanged(callback: (value: number) => void): void;
  41568. /**
  41569. * Gets the left trigger value
  41570. */
  41571. /**
  41572. * Sets the left trigger value
  41573. */
  41574. leftTrigger: number;
  41575. /**
  41576. * Gets the right trigger value
  41577. */
  41578. /**
  41579. * Sets the right trigger value
  41580. */
  41581. rightTrigger: number;
  41582. /**
  41583. * Defines the callback to call when a button is pressed
  41584. * @param callback defines the callback to use
  41585. */
  41586. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41587. /**
  41588. * Defines the callback to call when a button is released
  41589. * @param callback defines the callback to use
  41590. */
  41591. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41592. /**
  41593. * Defines the callback to call when a pad is pressed
  41594. * @param callback defines the callback to use
  41595. */
  41596. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41597. /**
  41598. * Defines the callback to call when a pad is released
  41599. * @param callback defines the callback to use
  41600. */
  41601. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41602. private _setButtonValue;
  41603. private _setDPadValue;
  41604. /**
  41605. * Gets the value of the `A` button
  41606. */
  41607. /**
  41608. * Sets the value of the `A` button
  41609. */
  41610. buttonA: number;
  41611. /**
  41612. * Gets the value of the `B` button
  41613. */
  41614. /**
  41615. * Sets the value of the `B` button
  41616. */
  41617. buttonB: number;
  41618. /**
  41619. * Gets the value of the `X` button
  41620. */
  41621. /**
  41622. * Sets the value of the `X` button
  41623. */
  41624. buttonX: number;
  41625. /**
  41626. * Gets the value of the `Y` button
  41627. */
  41628. /**
  41629. * Sets the value of the `Y` button
  41630. */
  41631. buttonY: number;
  41632. /**
  41633. * Gets the value of the `Start` button
  41634. */
  41635. /**
  41636. * Sets the value of the `Start` button
  41637. */
  41638. buttonStart: number;
  41639. /**
  41640. * Gets the value of the `Back` button
  41641. */
  41642. /**
  41643. * Sets the value of the `Back` button
  41644. */
  41645. buttonBack: number;
  41646. /**
  41647. * Gets the value of the `Left` button
  41648. */
  41649. /**
  41650. * Sets the value of the `Left` button
  41651. */
  41652. buttonLB: number;
  41653. /**
  41654. * Gets the value of the `Right` button
  41655. */
  41656. /**
  41657. * Sets the value of the `Right` button
  41658. */
  41659. buttonRB: number;
  41660. /**
  41661. * Gets the value of the Left joystick
  41662. */
  41663. /**
  41664. * Sets the value of the Left joystick
  41665. */
  41666. buttonLeftStick: number;
  41667. /**
  41668. * Gets the value of the Right joystick
  41669. */
  41670. /**
  41671. * Sets the value of the Right joystick
  41672. */
  41673. buttonRightStick: number;
  41674. /**
  41675. * Gets the value of D-pad up
  41676. */
  41677. /**
  41678. * Sets the value of D-pad up
  41679. */
  41680. dPadUp: number;
  41681. /**
  41682. * Gets the value of D-pad down
  41683. */
  41684. /**
  41685. * Sets the value of D-pad down
  41686. */
  41687. dPadDown: number;
  41688. /**
  41689. * Gets the value of D-pad left
  41690. */
  41691. /**
  41692. * Sets the value of D-pad left
  41693. */
  41694. dPadLeft: number;
  41695. /**
  41696. * Gets the value of D-pad right
  41697. */
  41698. /**
  41699. * Sets the value of D-pad right
  41700. */
  41701. dPadRight: number;
  41702. /**
  41703. * Force the gamepad to synchronize with device values
  41704. */
  41705. update(): void;
  41706. /**
  41707. * Disposes the gamepad
  41708. */
  41709. dispose(): void;
  41710. }
  41711. }
  41712. declare module "babylonjs/Gamepads/dualShockGamepad" {
  41713. import { Observable } from "babylonjs/Misc/observable";
  41714. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41715. /**
  41716. * Defines supported buttons for DualShock compatible gamepads
  41717. */
  41718. export enum DualShockButton {
  41719. /** Cross */
  41720. Cross = 0,
  41721. /** Circle */
  41722. Circle = 1,
  41723. /** Square */
  41724. Square = 2,
  41725. /** Triangle */
  41726. Triangle = 3,
  41727. /** Options */
  41728. Options = 4,
  41729. /** Share */
  41730. Share = 5,
  41731. /** L1 */
  41732. L1 = 6,
  41733. /** R1 */
  41734. R1 = 7,
  41735. /** Left stick */
  41736. LeftStick = 8,
  41737. /** Right stick */
  41738. RightStick = 9
  41739. }
  41740. /** Defines values for DualShock DPad */
  41741. export enum DualShockDpad {
  41742. /** Up */
  41743. Up = 0,
  41744. /** Down */
  41745. Down = 1,
  41746. /** Left */
  41747. Left = 2,
  41748. /** Right */
  41749. Right = 3
  41750. }
  41751. /**
  41752. * Defines a DualShock gamepad
  41753. */
  41754. export class DualShockPad extends Gamepad {
  41755. private _leftTrigger;
  41756. private _rightTrigger;
  41757. private _onlefttriggerchanged;
  41758. private _onrighttriggerchanged;
  41759. private _onbuttondown;
  41760. private _onbuttonup;
  41761. private _ondpaddown;
  41762. private _ondpadup;
  41763. /** Observable raised when a button is pressed */
  41764. onButtonDownObservable: Observable<DualShockButton>;
  41765. /** Observable raised when a button is released */
  41766. onButtonUpObservable: Observable<DualShockButton>;
  41767. /** Observable raised when a pad is pressed */
  41768. onPadDownObservable: Observable<DualShockDpad>;
  41769. /** Observable raised when a pad is released */
  41770. onPadUpObservable: Observable<DualShockDpad>;
  41771. private _buttonCross;
  41772. private _buttonCircle;
  41773. private _buttonSquare;
  41774. private _buttonTriangle;
  41775. private _buttonShare;
  41776. private _buttonOptions;
  41777. private _buttonL1;
  41778. private _buttonR1;
  41779. private _buttonLeftStick;
  41780. private _buttonRightStick;
  41781. private _dPadUp;
  41782. private _dPadDown;
  41783. private _dPadLeft;
  41784. private _dPadRight;
  41785. /**
  41786. * Creates a new DualShock gamepad object
  41787. * @param id defines the id of this gamepad
  41788. * @param index defines its index
  41789. * @param gamepad defines the internal HTML gamepad object
  41790. */
  41791. constructor(id: string, index: number, gamepad: any);
  41792. /**
  41793. * Defines the callback to call when left trigger is pressed
  41794. * @param callback defines the callback to use
  41795. */
  41796. onlefttriggerchanged(callback: (value: number) => void): void;
  41797. /**
  41798. * Defines the callback to call when right trigger is pressed
  41799. * @param callback defines the callback to use
  41800. */
  41801. onrighttriggerchanged(callback: (value: number) => void): void;
  41802. /**
  41803. * Gets the left trigger value
  41804. */
  41805. /**
  41806. * Sets the left trigger value
  41807. */
  41808. leftTrigger: number;
  41809. /**
  41810. * Gets the right trigger value
  41811. */
  41812. /**
  41813. * Sets the right trigger value
  41814. */
  41815. rightTrigger: number;
  41816. /**
  41817. * Defines the callback to call when a button is pressed
  41818. * @param callback defines the callback to use
  41819. */
  41820. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41821. /**
  41822. * Defines the callback to call when a button is released
  41823. * @param callback defines the callback to use
  41824. */
  41825. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41826. /**
  41827. * Defines the callback to call when a pad is pressed
  41828. * @param callback defines the callback to use
  41829. */
  41830. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41831. /**
  41832. * Defines the callback to call when a pad is released
  41833. * @param callback defines the callback to use
  41834. */
  41835. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41836. private _setButtonValue;
  41837. private _setDPadValue;
  41838. /**
  41839. * Gets the value of the `Cross` button
  41840. */
  41841. /**
  41842. * Sets the value of the `Cross` button
  41843. */
  41844. buttonCross: number;
  41845. /**
  41846. * Gets the value of the `Circle` button
  41847. */
  41848. /**
  41849. * Sets the value of the `Circle` button
  41850. */
  41851. buttonCircle: number;
  41852. /**
  41853. * Gets the value of the `Square` button
  41854. */
  41855. /**
  41856. * Sets the value of the `Square` button
  41857. */
  41858. buttonSquare: number;
  41859. /**
  41860. * Gets the value of the `Triangle` button
  41861. */
  41862. /**
  41863. * Sets the value of the `Triangle` button
  41864. */
  41865. buttonTriangle: number;
  41866. /**
  41867. * Gets the value of the `Options` button
  41868. */
  41869. /**
  41870. * Sets the value of the `Options` button
  41871. */
  41872. buttonOptions: number;
  41873. /**
  41874. * Gets the value of the `Share` button
  41875. */
  41876. /**
  41877. * Sets the value of the `Share` button
  41878. */
  41879. buttonShare: number;
  41880. /**
  41881. * Gets the value of the `L1` button
  41882. */
  41883. /**
  41884. * Sets the value of the `L1` button
  41885. */
  41886. buttonL1: number;
  41887. /**
  41888. * Gets the value of the `R1` button
  41889. */
  41890. /**
  41891. * Sets the value of the `R1` button
  41892. */
  41893. buttonR1: number;
  41894. /**
  41895. * Gets the value of the Left joystick
  41896. */
  41897. /**
  41898. * Sets the value of the Left joystick
  41899. */
  41900. buttonLeftStick: number;
  41901. /**
  41902. * Gets the value of the Right joystick
  41903. */
  41904. /**
  41905. * Sets the value of the Right joystick
  41906. */
  41907. buttonRightStick: number;
  41908. /**
  41909. * Gets the value of D-pad up
  41910. */
  41911. /**
  41912. * Sets the value of D-pad up
  41913. */
  41914. dPadUp: number;
  41915. /**
  41916. * Gets the value of D-pad down
  41917. */
  41918. /**
  41919. * Sets the value of D-pad down
  41920. */
  41921. dPadDown: number;
  41922. /**
  41923. * Gets the value of D-pad left
  41924. */
  41925. /**
  41926. * Sets the value of D-pad left
  41927. */
  41928. dPadLeft: number;
  41929. /**
  41930. * Gets the value of D-pad right
  41931. */
  41932. /**
  41933. * Sets the value of D-pad right
  41934. */
  41935. dPadRight: number;
  41936. /**
  41937. * Force the gamepad to synchronize with device values
  41938. */
  41939. update(): void;
  41940. /**
  41941. * Disposes the gamepad
  41942. */
  41943. dispose(): void;
  41944. }
  41945. }
  41946. declare module "babylonjs/Gamepads/gamepadManager" {
  41947. import { Observable } from "babylonjs/Misc/observable";
  41948. import { Nullable } from "babylonjs/types";
  41949. import { Scene } from "babylonjs/scene";
  41950. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41951. /**
  41952. * Manager for handling gamepads
  41953. */
  41954. export class GamepadManager {
  41955. private _scene?;
  41956. private _babylonGamepads;
  41957. private _oneGamepadConnected;
  41958. /** @hidden */
  41959. _isMonitoring: boolean;
  41960. private _gamepadEventSupported;
  41961. private _gamepadSupport;
  41962. /**
  41963. * observable to be triggered when the gamepad controller has been connected
  41964. */
  41965. onGamepadConnectedObservable: Observable<Gamepad>;
  41966. /**
  41967. * observable to be triggered when the gamepad controller has been disconnected
  41968. */
  41969. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41970. private _onGamepadConnectedEvent;
  41971. private _onGamepadDisconnectedEvent;
  41972. /**
  41973. * Initializes the gamepad manager
  41974. * @param _scene BabylonJS scene
  41975. */
  41976. constructor(_scene?: Scene | undefined);
  41977. /**
  41978. * The gamepads in the game pad manager
  41979. */
  41980. readonly gamepads: Gamepad[];
  41981. /**
  41982. * Get the gamepad controllers based on type
  41983. * @param type The type of gamepad controller
  41984. * @returns Nullable gamepad
  41985. */
  41986. getGamepadByType(type?: number): Nullable<Gamepad>;
  41987. /**
  41988. * Disposes the gamepad manager
  41989. */
  41990. dispose(): void;
  41991. private _addNewGamepad;
  41992. private _startMonitoringGamepads;
  41993. private _stopMonitoringGamepads;
  41994. /** @hidden */
  41995. _checkGamepadsStatus(): void;
  41996. private _updateGamepadObjects;
  41997. }
  41998. }
  41999. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42000. import { Nullable } from "babylonjs/types";
  42001. import { Scene } from "babylonjs/scene";
  42002. import { ISceneComponent } from "babylonjs/sceneComponent";
  42003. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42004. module "babylonjs/scene" {
  42005. interface Scene {
  42006. /** @hidden */
  42007. _gamepadManager: Nullable<GamepadManager>;
  42008. /**
  42009. * Gets the gamepad manager associated with the scene
  42010. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42011. */
  42012. gamepadManager: GamepadManager;
  42013. }
  42014. }
  42015. module "babylonjs/Cameras/freeCameraInputsManager" {
  42016. /**
  42017. * Interface representing a free camera inputs manager
  42018. */
  42019. interface FreeCameraInputsManager {
  42020. /**
  42021. * Adds gamepad input support to the FreeCameraInputsManager.
  42022. * @returns the FreeCameraInputsManager
  42023. */
  42024. addGamepad(): FreeCameraInputsManager;
  42025. }
  42026. }
  42027. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42028. /**
  42029. * Interface representing an arc rotate camera inputs manager
  42030. */
  42031. interface ArcRotateCameraInputsManager {
  42032. /**
  42033. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42034. * @returns the camera inputs manager
  42035. */
  42036. addGamepad(): ArcRotateCameraInputsManager;
  42037. }
  42038. }
  42039. /**
  42040. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42041. */
  42042. export class GamepadSystemSceneComponent implements ISceneComponent {
  42043. /**
  42044. * The component name helpfull to identify the component in the list of scene components.
  42045. */
  42046. readonly name: string;
  42047. /**
  42048. * The scene the component belongs to.
  42049. */
  42050. scene: Scene;
  42051. /**
  42052. * Creates a new instance of the component for the given scene
  42053. * @param scene Defines the scene to register the component in
  42054. */
  42055. constructor(scene: Scene);
  42056. /**
  42057. * Registers the component in a given scene
  42058. */
  42059. register(): void;
  42060. /**
  42061. * Rebuilds the elements related to this component in case of
  42062. * context lost for instance.
  42063. */
  42064. rebuild(): void;
  42065. /**
  42066. * Disposes the component and the associated ressources
  42067. */
  42068. dispose(): void;
  42069. private _beforeCameraUpdate;
  42070. }
  42071. }
  42072. declare module "babylonjs/Cameras/universalCamera" {
  42073. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42074. import { Scene } from "babylonjs/scene";
  42075. import { Vector3 } from "babylonjs/Maths/math.vector";
  42076. import "babylonjs/Gamepads/gamepadSceneComponent";
  42077. /**
  42078. * 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,
  42079. * which still works and will still be found in many Playgrounds.
  42080. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42081. */
  42082. export class UniversalCamera extends TouchCamera {
  42083. /**
  42084. * Defines the gamepad rotation sensiblity.
  42085. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42086. */
  42087. gamepadAngularSensibility: number;
  42088. /**
  42089. * Defines the gamepad move sensiblity.
  42090. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42091. */
  42092. gamepadMoveSensibility: number;
  42093. /**
  42094. * 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,
  42095. * which still works and will still be found in many Playgrounds.
  42096. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42097. * @param name Define the name of the camera in the scene
  42098. * @param position Define the start position of the camera in the scene
  42099. * @param scene Define the scene the camera belongs to
  42100. */
  42101. constructor(name: string, position: Vector3, scene: Scene);
  42102. /**
  42103. * Gets the current object class name.
  42104. * @return the class name
  42105. */
  42106. getClassName(): string;
  42107. }
  42108. }
  42109. declare module "babylonjs/Cameras/gamepadCamera" {
  42110. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42111. import { Scene } from "babylonjs/scene";
  42112. import { Vector3 } from "babylonjs/Maths/math.vector";
  42113. /**
  42114. * This represents a FPS type of camera. This is only here for back compat purpose.
  42115. * Please use the UniversalCamera instead as both are identical.
  42116. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42117. */
  42118. export class GamepadCamera extends UniversalCamera {
  42119. /**
  42120. * Instantiates a new Gamepad Camera
  42121. * This represents a FPS type of camera. This is only here for back compat purpose.
  42122. * Please use the UniversalCamera instead as both are identical.
  42123. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42124. * @param name Define the name of the camera in the scene
  42125. * @param position Define the start position of the camera in the scene
  42126. * @param scene Define the scene the camera belongs to
  42127. */
  42128. constructor(name: string, position: Vector3, scene: Scene);
  42129. /**
  42130. * Gets the current object class name.
  42131. * @return the class name
  42132. */
  42133. getClassName(): string;
  42134. }
  42135. }
  42136. declare module "babylonjs/Shaders/pass.fragment" {
  42137. /** @hidden */
  42138. export var passPixelShader: {
  42139. name: string;
  42140. shader: string;
  42141. };
  42142. }
  42143. declare module "babylonjs/Shaders/passCube.fragment" {
  42144. /** @hidden */
  42145. export var passCubePixelShader: {
  42146. name: string;
  42147. shader: string;
  42148. };
  42149. }
  42150. declare module "babylonjs/PostProcesses/passPostProcess" {
  42151. import { Nullable } from "babylonjs/types";
  42152. import { Camera } from "babylonjs/Cameras/camera";
  42153. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42154. import { Engine } from "babylonjs/Engines/engine";
  42155. import "babylonjs/Shaders/pass.fragment";
  42156. import "babylonjs/Shaders/passCube.fragment";
  42157. /**
  42158. * PassPostProcess which produces an output the same as it's input
  42159. */
  42160. export class PassPostProcess extends PostProcess {
  42161. /**
  42162. * Creates the PassPostProcess
  42163. * @param name The name of the effect.
  42164. * @param options The required width/height ratio to downsize to before computing the render pass.
  42165. * @param camera The camera to apply the render pass to.
  42166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42167. * @param engine The engine which the post process will be applied. (default: current engine)
  42168. * @param reusable If the post process can be reused on the same frame. (default: false)
  42169. * @param textureType The type of texture to be used when performing the post processing.
  42170. * @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)
  42171. */
  42172. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42173. }
  42174. /**
  42175. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42176. */
  42177. export class PassCubePostProcess extends PostProcess {
  42178. private _face;
  42179. /**
  42180. * Gets or sets the cube face to display.
  42181. * * 0 is +X
  42182. * * 1 is -X
  42183. * * 2 is +Y
  42184. * * 3 is -Y
  42185. * * 4 is +Z
  42186. * * 5 is -Z
  42187. */
  42188. face: number;
  42189. /**
  42190. * Creates the PassCubePostProcess
  42191. * @param name The name of the effect.
  42192. * @param options The required width/height ratio to downsize to before computing the render pass.
  42193. * @param camera The camera to apply the render pass to.
  42194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42195. * @param engine The engine which the post process will be applied. (default: current engine)
  42196. * @param reusable If the post process can be reused on the same frame. (default: false)
  42197. * @param textureType The type of texture to be used when performing the post processing.
  42198. * @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)
  42199. */
  42200. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42201. }
  42202. }
  42203. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42204. /** @hidden */
  42205. export var anaglyphPixelShader: {
  42206. name: string;
  42207. shader: string;
  42208. };
  42209. }
  42210. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42211. import { Engine } from "babylonjs/Engines/engine";
  42212. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42213. import { Camera } from "babylonjs/Cameras/camera";
  42214. import "babylonjs/Shaders/anaglyph.fragment";
  42215. /**
  42216. * Postprocess used to generate anaglyphic rendering
  42217. */
  42218. export class AnaglyphPostProcess extends PostProcess {
  42219. private _passedProcess;
  42220. /**
  42221. * Creates a new AnaglyphPostProcess
  42222. * @param name defines postprocess name
  42223. * @param options defines creation options or target ratio scale
  42224. * @param rigCameras defines cameras using this postprocess
  42225. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42226. * @param engine defines hosting engine
  42227. * @param reusable defines if the postprocess will be reused multiple times per frame
  42228. */
  42229. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42230. }
  42231. }
  42232. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42233. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42234. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42235. import { Scene } from "babylonjs/scene";
  42236. import { Vector3 } from "babylonjs/Maths/math.vector";
  42237. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42238. /**
  42239. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42240. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42241. */
  42242. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42243. /**
  42244. * Creates a new AnaglyphArcRotateCamera
  42245. * @param name defines camera name
  42246. * @param alpha defines alpha angle (in radians)
  42247. * @param beta defines beta angle (in radians)
  42248. * @param radius defines radius
  42249. * @param target defines camera target
  42250. * @param interaxialDistance defines distance between each color axis
  42251. * @param scene defines the hosting scene
  42252. */
  42253. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42254. /**
  42255. * Gets camera class name
  42256. * @returns AnaglyphArcRotateCamera
  42257. */
  42258. getClassName(): string;
  42259. }
  42260. }
  42261. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42262. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42263. import { Scene } from "babylonjs/scene";
  42264. import { Vector3 } from "babylonjs/Maths/math.vector";
  42265. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42266. /**
  42267. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42268. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42269. */
  42270. export class AnaglyphFreeCamera extends FreeCamera {
  42271. /**
  42272. * Creates a new AnaglyphFreeCamera
  42273. * @param name defines camera name
  42274. * @param position defines initial position
  42275. * @param interaxialDistance defines distance between each color axis
  42276. * @param scene defines the hosting scene
  42277. */
  42278. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42279. /**
  42280. * Gets camera class name
  42281. * @returns AnaglyphFreeCamera
  42282. */
  42283. getClassName(): string;
  42284. }
  42285. }
  42286. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42287. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42288. import { Scene } from "babylonjs/scene";
  42289. import { Vector3 } from "babylonjs/Maths/math.vector";
  42290. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42291. /**
  42292. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42293. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42294. */
  42295. export class AnaglyphGamepadCamera extends GamepadCamera {
  42296. /**
  42297. * Creates a new AnaglyphGamepadCamera
  42298. * @param name defines camera name
  42299. * @param position defines initial position
  42300. * @param interaxialDistance defines distance between each color axis
  42301. * @param scene defines the hosting scene
  42302. */
  42303. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42304. /**
  42305. * Gets camera class name
  42306. * @returns AnaglyphGamepadCamera
  42307. */
  42308. getClassName(): string;
  42309. }
  42310. }
  42311. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42312. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42313. import { Scene } from "babylonjs/scene";
  42314. import { Vector3 } from "babylonjs/Maths/math.vector";
  42315. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42316. /**
  42317. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42318. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42319. */
  42320. export class AnaglyphUniversalCamera extends UniversalCamera {
  42321. /**
  42322. * Creates a new AnaglyphUniversalCamera
  42323. * @param name defines camera name
  42324. * @param position defines initial position
  42325. * @param interaxialDistance defines distance between each color axis
  42326. * @param scene defines the hosting scene
  42327. */
  42328. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42329. /**
  42330. * Gets camera class name
  42331. * @returns AnaglyphUniversalCamera
  42332. */
  42333. getClassName(): string;
  42334. }
  42335. }
  42336. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42337. /** @hidden */
  42338. export var stereoscopicInterlacePixelShader: {
  42339. name: string;
  42340. shader: string;
  42341. };
  42342. }
  42343. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42344. import { Camera } from "babylonjs/Cameras/camera";
  42345. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42346. import { Engine } from "babylonjs/Engines/engine";
  42347. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42348. /**
  42349. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42350. */
  42351. export class StereoscopicInterlacePostProcess extends PostProcess {
  42352. private _stepSize;
  42353. private _passedProcess;
  42354. /**
  42355. * Initializes a StereoscopicInterlacePostProcess
  42356. * @param name The name of the effect.
  42357. * @param rigCameras The rig cameras to be appled to the post process
  42358. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42360. * @param engine The engine which the post process will be applied. (default: current engine)
  42361. * @param reusable If the post process can be reused on the same frame. (default: false)
  42362. */
  42363. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42364. }
  42365. }
  42366. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42367. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42368. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42369. import { Scene } from "babylonjs/scene";
  42370. import { Vector3 } from "babylonjs/Maths/math.vector";
  42371. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42372. /**
  42373. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42374. * @see http://doc.babylonjs.com/features/cameras
  42375. */
  42376. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42377. /**
  42378. * Creates a new StereoscopicArcRotateCamera
  42379. * @param name defines camera name
  42380. * @param alpha defines alpha angle (in radians)
  42381. * @param beta defines beta angle (in radians)
  42382. * @param radius defines radius
  42383. * @param target defines camera target
  42384. * @param interaxialDistance defines distance between each color axis
  42385. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42386. * @param scene defines the hosting scene
  42387. */
  42388. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42389. /**
  42390. * Gets camera class name
  42391. * @returns StereoscopicArcRotateCamera
  42392. */
  42393. getClassName(): string;
  42394. }
  42395. }
  42396. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42397. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42398. import { Scene } from "babylonjs/scene";
  42399. import { Vector3 } from "babylonjs/Maths/math.vector";
  42400. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42401. /**
  42402. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42403. * @see http://doc.babylonjs.com/features/cameras
  42404. */
  42405. export class StereoscopicFreeCamera extends FreeCamera {
  42406. /**
  42407. * Creates a new StereoscopicFreeCamera
  42408. * @param name defines camera name
  42409. * @param position defines initial position
  42410. * @param interaxialDistance defines distance between each color axis
  42411. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42412. * @param scene defines the hosting scene
  42413. */
  42414. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42415. /**
  42416. * Gets camera class name
  42417. * @returns StereoscopicFreeCamera
  42418. */
  42419. getClassName(): string;
  42420. }
  42421. }
  42422. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42423. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42424. import { Scene } from "babylonjs/scene";
  42425. import { Vector3 } from "babylonjs/Maths/math.vector";
  42426. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42427. /**
  42428. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42429. * @see http://doc.babylonjs.com/features/cameras
  42430. */
  42431. export class StereoscopicGamepadCamera extends GamepadCamera {
  42432. /**
  42433. * Creates a new StereoscopicGamepadCamera
  42434. * @param name defines camera name
  42435. * @param position defines initial position
  42436. * @param interaxialDistance defines distance between each color axis
  42437. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42438. * @param scene defines the hosting scene
  42439. */
  42440. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42441. /**
  42442. * Gets camera class name
  42443. * @returns StereoscopicGamepadCamera
  42444. */
  42445. getClassName(): string;
  42446. }
  42447. }
  42448. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42449. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42450. import { Scene } from "babylonjs/scene";
  42451. import { Vector3 } from "babylonjs/Maths/math.vector";
  42452. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42453. /**
  42454. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42455. * @see http://doc.babylonjs.com/features/cameras
  42456. */
  42457. export class StereoscopicUniversalCamera extends UniversalCamera {
  42458. /**
  42459. * Creates a new StereoscopicUniversalCamera
  42460. * @param name defines camera name
  42461. * @param position defines initial position
  42462. * @param interaxialDistance defines distance between each color axis
  42463. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42464. * @param scene defines the hosting scene
  42465. */
  42466. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42467. /**
  42468. * Gets camera class name
  42469. * @returns StereoscopicUniversalCamera
  42470. */
  42471. getClassName(): string;
  42472. }
  42473. }
  42474. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42475. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42476. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42477. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42478. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42479. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42480. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42481. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42482. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42483. }
  42484. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42485. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42486. import { Scene } from "babylonjs/scene";
  42487. import { Vector3 } from "babylonjs/Maths/math.vector";
  42488. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42489. /**
  42490. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42491. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42492. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42493. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42494. */
  42495. export class VirtualJoysticksCamera extends FreeCamera {
  42496. /**
  42497. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42498. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42499. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42500. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42501. * @param name Define the name of the camera in the scene
  42502. * @param position Define the start position of the camera in the scene
  42503. * @param scene Define the scene the camera belongs to
  42504. */
  42505. constructor(name: string, position: Vector3, scene: Scene);
  42506. /**
  42507. * Gets the current object class name.
  42508. * @return the class name
  42509. */
  42510. getClassName(): string;
  42511. }
  42512. }
  42513. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  42514. import { Matrix } from "babylonjs/Maths/math.vector";
  42515. /**
  42516. * This represents all the required metrics to create a VR camera.
  42517. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42518. */
  42519. export class VRCameraMetrics {
  42520. /**
  42521. * Define the horizontal resolution off the screen.
  42522. */
  42523. hResolution: number;
  42524. /**
  42525. * Define the vertical resolution off the screen.
  42526. */
  42527. vResolution: number;
  42528. /**
  42529. * Define the horizontal screen size.
  42530. */
  42531. hScreenSize: number;
  42532. /**
  42533. * Define the vertical screen size.
  42534. */
  42535. vScreenSize: number;
  42536. /**
  42537. * Define the vertical screen center position.
  42538. */
  42539. vScreenCenter: number;
  42540. /**
  42541. * Define the distance of the eyes to the screen.
  42542. */
  42543. eyeToScreenDistance: number;
  42544. /**
  42545. * Define the distance between both lenses
  42546. */
  42547. lensSeparationDistance: number;
  42548. /**
  42549. * Define the distance between both viewer's eyes.
  42550. */
  42551. interpupillaryDistance: number;
  42552. /**
  42553. * Define the distortion factor of the VR postprocess.
  42554. * Please, touch with care.
  42555. */
  42556. distortionK: number[];
  42557. /**
  42558. * Define the chromatic aberration correction factors for the VR post process.
  42559. */
  42560. chromaAbCorrection: number[];
  42561. /**
  42562. * Define the scale factor of the post process.
  42563. * The smaller the better but the slower.
  42564. */
  42565. postProcessScaleFactor: number;
  42566. /**
  42567. * Define an offset for the lens center.
  42568. */
  42569. lensCenterOffset: number;
  42570. /**
  42571. * Define if the current vr camera should compensate the distortion of the lense or not.
  42572. */
  42573. compensateDistortion: boolean;
  42574. /**
  42575. * Defines if multiview should be enabled when rendering (Default: false)
  42576. */
  42577. multiviewEnabled: boolean;
  42578. /**
  42579. * Gets the rendering aspect ratio based on the provided resolutions.
  42580. */
  42581. readonly aspectRatio: number;
  42582. /**
  42583. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42584. */
  42585. readonly aspectRatioFov: number;
  42586. /**
  42587. * @hidden
  42588. */
  42589. readonly leftHMatrix: Matrix;
  42590. /**
  42591. * @hidden
  42592. */
  42593. readonly rightHMatrix: Matrix;
  42594. /**
  42595. * @hidden
  42596. */
  42597. readonly leftPreViewMatrix: Matrix;
  42598. /**
  42599. * @hidden
  42600. */
  42601. readonly rightPreViewMatrix: Matrix;
  42602. /**
  42603. * Get the default VRMetrics based on the most generic setup.
  42604. * @returns the default vr metrics
  42605. */
  42606. static GetDefault(): VRCameraMetrics;
  42607. }
  42608. }
  42609. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  42610. /** @hidden */
  42611. export var vrDistortionCorrectionPixelShader: {
  42612. name: string;
  42613. shader: string;
  42614. };
  42615. }
  42616. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  42617. import { Camera } from "babylonjs/Cameras/camera";
  42618. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42619. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42620. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  42621. /**
  42622. * VRDistortionCorrectionPostProcess used for mobile VR
  42623. */
  42624. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42625. private _isRightEye;
  42626. private _distortionFactors;
  42627. private _postProcessScaleFactor;
  42628. private _lensCenterOffset;
  42629. private _scaleIn;
  42630. private _scaleFactor;
  42631. private _lensCenter;
  42632. /**
  42633. * Initializes the VRDistortionCorrectionPostProcess
  42634. * @param name The name of the effect.
  42635. * @param camera The camera to apply the render pass to.
  42636. * @param isRightEye If this is for the right eye distortion
  42637. * @param vrMetrics All the required metrics for the VR camera
  42638. */
  42639. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42640. }
  42641. }
  42642. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  42643. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  42644. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42645. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42646. import { Scene } from "babylonjs/scene";
  42647. import { Vector3 } from "babylonjs/Maths/math.vector";
  42648. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42649. import "babylonjs/Cameras/RigModes/vrRigMode";
  42650. /**
  42651. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42652. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42653. */
  42654. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42655. /**
  42656. * Creates a new VRDeviceOrientationArcRotateCamera
  42657. * @param name defines camera name
  42658. * @param alpha defines the camera rotation along the logitudinal axis
  42659. * @param beta defines the camera rotation along the latitudinal axis
  42660. * @param radius defines the camera distance from its target
  42661. * @param target defines the camera target
  42662. * @param scene defines the scene the camera belongs to
  42663. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42664. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42665. */
  42666. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42667. /**
  42668. * Gets camera class name
  42669. * @returns VRDeviceOrientationArcRotateCamera
  42670. */
  42671. getClassName(): string;
  42672. }
  42673. }
  42674. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  42675. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42676. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42677. import { Scene } from "babylonjs/scene";
  42678. import { Vector3 } from "babylonjs/Maths/math.vector";
  42679. import "babylonjs/Cameras/RigModes/vrRigMode";
  42680. /**
  42681. * Camera used to simulate VR rendering (based on FreeCamera)
  42682. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42683. */
  42684. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42685. /**
  42686. * Creates a new VRDeviceOrientationFreeCamera
  42687. * @param name defines camera name
  42688. * @param position defines the start position of the camera
  42689. * @param scene defines the scene the camera belongs to
  42690. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42691. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42692. */
  42693. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42694. /**
  42695. * Gets camera class name
  42696. * @returns VRDeviceOrientationFreeCamera
  42697. */
  42698. getClassName(): string;
  42699. }
  42700. }
  42701. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  42702. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42703. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42704. import { Scene } from "babylonjs/scene";
  42705. import { Vector3 } from "babylonjs/Maths/math.vector";
  42706. import "babylonjs/Gamepads/gamepadSceneComponent";
  42707. /**
  42708. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42709. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42710. */
  42711. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42712. /**
  42713. * Creates a new VRDeviceOrientationGamepadCamera
  42714. * @param name defines camera name
  42715. * @param position defines the start position of the camera
  42716. * @param scene defines the scene the camera belongs to
  42717. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42718. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42719. */
  42720. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42721. /**
  42722. * Gets camera class name
  42723. * @returns VRDeviceOrientationGamepadCamera
  42724. */
  42725. getClassName(): string;
  42726. }
  42727. }
  42728. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42729. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42730. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42731. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42732. /** @hidden */
  42733. export var imageProcessingPixelShader: {
  42734. name: string;
  42735. shader: string;
  42736. };
  42737. }
  42738. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42739. import { Nullable } from "babylonjs/types";
  42740. import { Color4 } from "babylonjs/Maths/math.color";
  42741. import { Camera } from "babylonjs/Cameras/camera";
  42742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42743. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42744. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42745. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42746. import { Engine } from "babylonjs/Engines/engine";
  42747. import "babylonjs/Shaders/imageProcessing.fragment";
  42748. import "babylonjs/Shaders/postprocess.vertex";
  42749. /**
  42750. * ImageProcessingPostProcess
  42751. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42752. */
  42753. export class ImageProcessingPostProcess extends PostProcess {
  42754. /**
  42755. * Default configuration related to image processing available in the PBR Material.
  42756. */
  42757. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42758. /**
  42759. * Gets the image processing configuration used either in this material.
  42760. */
  42761. /**
  42762. * Sets the Default image processing configuration used either in the this material.
  42763. *
  42764. * If sets to null, the scene one is in use.
  42765. */
  42766. imageProcessingConfiguration: ImageProcessingConfiguration;
  42767. /**
  42768. * Keep track of the image processing observer to allow dispose and replace.
  42769. */
  42770. private _imageProcessingObserver;
  42771. /**
  42772. * Attaches a new image processing configuration to the PBR Material.
  42773. * @param configuration
  42774. */
  42775. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42776. /**
  42777. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42778. */
  42779. /**
  42780. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42781. */
  42782. colorCurves: Nullable<ColorCurves>;
  42783. /**
  42784. * Gets wether the color curves effect is enabled.
  42785. */
  42786. /**
  42787. * Sets wether the color curves effect is enabled.
  42788. */
  42789. colorCurvesEnabled: boolean;
  42790. /**
  42791. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42792. */
  42793. /**
  42794. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42795. */
  42796. colorGradingTexture: Nullable<BaseTexture>;
  42797. /**
  42798. * Gets wether the color grading effect is enabled.
  42799. */
  42800. /**
  42801. * Gets wether the color grading effect is enabled.
  42802. */
  42803. colorGradingEnabled: boolean;
  42804. /**
  42805. * Gets exposure used in the effect.
  42806. */
  42807. /**
  42808. * Sets exposure used in the effect.
  42809. */
  42810. exposure: number;
  42811. /**
  42812. * Gets wether tonemapping is enabled or not.
  42813. */
  42814. /**
  42815. * Sets wether tonemapping is enabled or not
  42816. */
  42817. toneMappingEnabled: boolean;
  42818. /**
  42819. * Gets the type of tone mapping effect.
  42820. */
  42821. /**
  42822. * Sets the type of tone mapping effect.
  42823. */
  42824. toneMappingType: number;
  42825. /**
  42826. * Gets contrast used in the effect.
  42827. */
  42828. /**
  42829. * Sets contrast used in the effect.
  42830. */
  42831. contrast: number;
  42832. /**
  42833. * Gets Vignette stretch size.
  42834. */
  42835. /**
  42836. * Sets Vignette stretch size.
  42837. */
  42838. vignetteStretch: number;
  42839. /**
  42840. * Gets Vignette centre X Offset.
  42841. */
  42842. /**
  42843. * Sets Vignette centre X Offset.
  42844. */
  42845. vignetteCentreX: number;
  42846. /**
  42847. * Gets Vignette centre Y Offset.
  42848. */
  42849. /**
  42850. * Sets Vignette centre Y Offset.
  42851. */
  42852. vignetteCentreY: number;
  42853. /**
  42854. * Gets Vignette weight or intensity of the vignette effect.
  42855. */
  42856. /**
  42857. * Sets Vignette weight or intensity of the vignette effect.
  42858. */
  42859. vignetteWeight: number;
  42860. /**
  42861. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42862. * if vignetteEnabled is set to true.
  42863. */
  42864. /**
  42865. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42866. * if vignetteEnabled is set to true.
  42867. */
  42868. vignetteColor: Color4;
  42869. /**
  42870. * Gets Camera field of view used by the Vignette effect.
  42871. */
  42872. /**
  42873. * Sets Camera field of view used by the Vignette effect.
  42874. */
  42875. vignetteCameraFov: number;
  42876. /**
  42877. * Gets the vignette blend mode allowing different kind of effect.
  42878. */
  42879. /**
  42880. * Sets the vignette blend mode allowing different kind of effect.
  42881. */
  42882. vignetteBlendMode: number;
  42883. /**
  42884. * Gets wether the vignette effect is enabled.
  42885. */
  42886. /**
  42887. * Sets wether the vignette effect is enabled.
  42888. */
  42889. vignetteEnabled: boolean;
  42890. private _fromLinearSpace;
  42891. /**
  42892. * Gets wether the input of the processing is in Gamma or Linear Space.
  42893. */
  42894. /**
  42895. * Sets wether the input of the processing is in Gamma or Linear Space.
  42896. */
  42897. fromLinearSpace: boolean;
  42898. /**
  42899. * Defines cache preventing GC.
  42900. */
  42901. private _defines;
  42902. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42903. /**
  42904. * "ImageProcessingPostProcess"
  42905. * @returns "ImageProcessingPostProcess"
  42906. */
  42907. getClassName(): string;
  42908. protected _updateParameters(): void;
  42909. dispose(camera?: Camera): void;
  42910. }
  42911. }
  42912. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42913. import { Scene } from "babylonjs/scene";
  42914. import { Color3 } from "babylonjs/Maths/math.color";
  42915. import { Mesh } from "babylonjs/Meshes/mesh";
  42916. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42917. import { Nullable } from "babylonjs/types";
  42918. /**
  42919. * Class containing static functions to help procedurally build meshes
  42920. */
  42921. export class GroundBuilder {
  42922. /**
  42923. * Creates a ground mesh
  42924. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42925. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42927. * @param name defines the name of the mesh
  42928. * @param options defines the options used to create the mesh
  42929. * @param scene defines the hosting scene
  42930. * @returns the ground mesh
  42931. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42932. */
  42933. static CreateGround(name: string, options: {
  42934. width?: number;
  42935. height?: number;
  42936. subdivisions?: number;
  42937. subdivisionsX?: number;
  42938. subdivisionsY?: number;
  42939. updatable?: boolean;
  42940. }, scene: any): Mesh;
  42941. /**
  42942. * Creates a tiled ground mesh
  42943. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42944. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42945. * * 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
  42946. * * 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
  42947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42948. * @param name defines the name of the mesh
  42949. * @param options defines the options used to create the mesh
  42950. * @param scene defines the hosting scene
  42951. * @returns the tiled ground mesh
  42952. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42953. */
  42954. static CreateTiledGround(name: string, options: {
  42955. xmin: number;
  42956. zmin: number;
  42957. xmax: number;
  42958. zmax: number;
  42959. subdivisions?: {
  42960. w: number;
  42961. h: number;
  42962. };
  42963. precision?: {
  42964. w: number;
  42965. h: number;
  42966. };
  42967. updatable?: boolean;
  42968. }, scene?: Nullable<Scene>): Mesh;
  42969. /**
  42970. * Creates a ground mesh from a height map
  42971. * * The parameter `url` sets the URL of the height map image resource.
  42972. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42973. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42974. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42975. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42976. * * 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.
  42977. * * 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).
  42978. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42980. * @param name defines the name of the mesh
  42981. * @param url defines the url to the height map
  42982. * @param options defines the options used to create the mesh
  42983. * @param scene defines the hosting scene
  42984. * @returns the ground mesh
  42985. * @see https://doc.babylonjs.com/babylon101/height_map
  42986. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42987. */
  42988. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42989. width?: number;
  42990. height?: number;
  42991. subdivisions?: number;
  42992. minHeight?: number;
  42993. maxHeight?: number;
  42994. colorFilter?: Color3;
  42995. alphaFilter?: number;
  42996. updatable?: boolean;
  42997. onReady?: (mesh: GroundMesh) => void;
  42998. }, scene?: Nullable<Scene>): GroundMesh;
  42999. }
  43000. }
  43001. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43002. import { Vector4 } from "babylonjs/Maths/math.vector";
  43003. import { Mesh } from "babylonjs/Meshes/mesh";
  43004. /**
  43005. * Class containing static functions to help procedurally build meshes
  43006. */
  43007. export class TorusBuilder {
  43008. /**
  43009. * Creates a torus mesh
  43010. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43011. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43012. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43016. * @param name defines the name of the mesh
  43017. * @param options defines the options used to create the mesh
  43018. * @param scene defines the hosting scene
  43019. * @returns the torus mesh
  43020. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43021. */
  43022. static CreateTorus(name: string, options: {
  43023. diameter?: number;
  43024. thickness?: number;
  43025. tessellation?: number;
  43026. updatable?: boolean;
  43027. sideOrientation?: number;
  43028. frontUVs?: Vector4;
  43029. backUVs?: Vector4;
  43030. }, scene: any): Mesh;
  43031. }
  43032. }
  43033. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43034. import { Vector4 } from "babylonjs/Maths/math.vector";
  43035. import { Color4 } from "babylonjs/Maths/math.color";
  43036. import { Mesh } from "babylonjs/Meshes/mesh";
  43037. /**
  43038. * Class containing static functions to help procedurally build meshes
  43039. */
  43040. export class CylinderBuilder {
  43041. /**
  43042. * Creates a cylinder or a cone mesh
  43043. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43044. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43045. * * 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.
  43046. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43047. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43048. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43049. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43050. * * 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).
  43051. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43052. * * 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).
  43053. * * 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
  43054. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43055. * * 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
  43056. * * 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.
  43057. * * If `enclose` is false, a ring surface is one element.
  43058. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43059. * * 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
  43060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43063. * @param name defines the name of the mesh
  43064. * @param options defines the options used to create the mesh
  43065. * @param scene defines the hosting scene
  43066. * @returns the cylinder mesh
  43067. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43068. */
  43069. static CreateCylinder(name: string, options: {
  43070. height?: number;
  43071. diameterTop?: number;
  43072. diameterBottom?: number;
  43073. diameter?: number;
  43074. tessellation?: number;
  43075. subdivisions?: number;
  43076. arc?: number;
  43077. faceColors?: Color4[];
  43078. faceUV?: Vector4[];
  43079. updatable?: boolean;
  43080. hasRings?: boolean;
  43081. enclose?: boolean;
  43082. cap?: number;
  43083. sideOrientation?: number;
  43084. frontUVs?: Vector4;
  43085. backUVs?: Vector4;
  43086. }, scene: any): Mesh;
  43087. }
  43088. }
  43089. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43090. import { Nullable } from "babylonjs/types";
  43091. import { IDisposable } from "babylonjs/scene";
  43092. /**
  43093. * States of the webXR experience
  43094. */
  43095. export enum WebXRState {
  43096. /**
  43097. * Transitioning to being in XR mode
  43098. */
  43099. ENTERING_XR = 0,
  43100. /**
  43101. * Transitioning to non XR mode
  43102. */
  43103. EXITING_XR = 1,
  43104. /**
  43105. * In XR mode and presenting
  43106. */
  43107. IN_XR = 2,
  43108. /**
  43109. * Not entered XR mode
  43110. */
  43111. NOT_IN_XR = 3
  43112. }
  43113. /**
  43114. * Abstraction of the XR render target
  43115. */
  43116. export interface WebXRRenderTarget extends IDisposable {
  43117. /**
  43118. * xrpresent context of the canvas which can be used to display/mirror xr content
  43119. */
  43120. canvasContext: WebGLRenderingContext;
  43121. /**
  43122. * xr layer for the canvas
  43123. */
  43124. xrLayer: Nullable<XRWebGLLayer>;
  43125. /**
  43126. * Initializes the xr layer for the session
  43127. * @param xrSession xr session
  43128. * @returns a promise that will resolve once the XR Layer has been created
  43129. */
  43130. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43131. }
  43132. }
  43133. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43134. import { Nullable } from "babylonjs/types";
  43135. import { Observable } from "babylonjs/Misc/observable";
  43136. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43137. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43138. /**
  43139. * COnfiguration object for WebXR output canvas
  43140. */
  43141. export class WebXRManagedOutputCanvasOptions {
  43142. /**
  43143. * Options for this XR Layer output
  43144. */
  43145. canvasOptions: XRWebGLLayerOptions;
  43146. /**
  43147. * CSS styling for a newly created canvas (if not provided)
  43148. */
  43149. newCanvasCssStyle?: string;
  43150. /**
  43151. * Get the default values of the configuration object
  43152. * @returns default values of this configuration object
  43153. */
  43154. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43155. }
  43156. /**
  43157. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43158. */
  43159. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43160. private configuration;
  43161. private _engine;
  43162. private _canvas;
  43163. /**
  43164. * xrpresent context of the canvas which can be used to display/mirror xr content
  43165. */
  43166. canvasContext: WebGLRenderingContext;
  43167. /**
  43168. * xr layer for the canvas
  43169. */
  43170. xrLayer: Nullable<XRWebGLLayer>;
  43171. /**
  43172. * Initializes the xr layer for the session
  43173. * @param xrSession xr session
  43174. * @returns a promise that will resolve once the XR Layer has been created
  43175. */
  43176. initializeXRLayerAsync(xrSession: any): any;
  43177. /**
  43178. * Initializes the canvas to be added/removed upon entering/exiting xr
  43179. * @param engine the Babylon engine
  43180. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43181. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43182. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43183. */
  43184. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43185. /**
  43186. * Disposes of the object
  43187. */
  43188. dispose(): void;
  43189. private _setManagedOutputCanvas;
  43190. private _addCanvas;
  43191. private _removeCanvas;
  43192. }
  43193. }
  43194. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43195. import { Observable } from "babylonjs/Misc/observable";
  43196. import { Nullable } from "babylonjs/types";
  43197. import { IDisposable, Scene } from "babylonjs/scene";
  43198. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43199. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43200. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43201. /**
  43202. * Manages an XRSession to work with Babylon's engine
  43203. * @see https://doc.babylonjs.com/how_to/webxr
  43204. */
  43205. export class WebXRSessionManager implements IDisposable {
  43206. private scene;
  43207. /**
  43208. * Fires every time a new xrFrame arrives which can be used to update the camera
  43209. */
  43210. onXRFrameObservable: Observable<any>;
  43211. /**
  43212. * Fires when the xr session is ended either by the device or manually done
  43213. */
  43214. onXRSessionEnded: Observable<any>;
  43215. /**
  43216. * Underlying xr session
  43217. */
  43218. session: XRSession;
  43219. /**
  43220. * Type of reference space used when creating the session
  43221. */
  43222. referenceSpace: XRReferenceSpace;
  43223. /**
  43224. * Current XR frame
  43225. */
  43226. currentFrame: Nullable<XRFrame>;
  43227. private _xrNavigator;
  43228. private baseLayer;
  43229. private _rttProvider;
  43230. private _sessionEnded;
  43231. /**
  43232. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43233. * @param scene The scene which the session should be created for
  43234. */
  43235. constructor(scene: Scene);
  43236. /**
  43237. * Initializes the manager
  43238. * After initialization enterXR can be called to start an XR session
  43239. * @returns Promise which resolves after it is initialized
  43240. */
  43241. initializeAsync(): Promise<void>;
  43242. /**
  43243. * Initializes an xr session
  43244. * @param xrSessionMode mode to initialize
  43245. * @param optionalFeatures defines optional values to pass to the session builder
  43246. * @returns a promise which will resolve once the session has been initialized
  43247. */
  43248. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43249. /**
  43250. * Sets the reference space on the xr session
  43251. * @param referenceSpace space to set
  43252. * @returns a promise that will resolve once the reference space has been set
  43253. */
  43254. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43255. /**
  43256. * Updates the render state of the session
  43257. * @param state state to set
  43258. * @returns a promise that resolves once the render state has been updated
  43259. */
  43260. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43261. /**
  43262. * Starts rendering to the xr layer
  43263. * @returns a promise that will resolve once rendering has started
  43264. */
  43265. startRenderingToXRAsync(): Promise<void>;
  43266. /**
  43267. * Gets the correct render target texture to be rendered this frame for this eye
  43268. * @param eye the eye for which to get the render target
  43269. * @returns the render target for the specified eye
  43270. */
  43271. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43272. /**
  43273. * Stops the xrSession and restores the renderloop
  43274. * @returns Promise which resolves after it exits XR
  43275. */
  43276. exitXRAsync(): Promise<void>;
  43277. /**
  43278. * Checks if a session would be supported for the creation options specified
  43279. * @param sessionMode session mode to check if supported eg. immersive-vr
  43280. * @returns true if supported
  43281. */
  43282. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43283. /**
  43284. * Creates a WebXRRenderTarget object for the XR session
  43285. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43286. * @param options optional options to provide when creating a new render target
  43287. * @returns a WebXR render target to which the session can render
  43288. */
  43289. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43290. /**
  43291. * @hidden
  43292. * Converts the render layer of xrSession to a render target
  43293. * @param session session to create render target for
  43294. * @param scene scene the new render target should be created for
  43295. */
  43296. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43297. /**
  43298. * Disposes of the session manager
  43299. */
  43300. dispose(): void;
  43301. /**
  43302. * Gets a promise returning true when fullfiled if the given session mode is supported
  43303. * @param sessionMode defines the session to test
  43304. * @returns a promise
  43305. */
  43306. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43307. }
  43308. }
  43309. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43310. import { Scene } from "babylonjs/scene";
  43311. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43312. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43313. /**
  43314. * WebXR Camera which holds the views for the xrSession
  43315. * @see https://doc.babylonjs.com/how_to/webxr
  43316. */
  43317. export class WebXRCamera extends FreeCamera {
  43318. /**
  43319. * Is the camera in debug mode. Used when using an emulator
  43320. */
  43321. debugMode: boolean;
  43322. /**
  43323. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43324. * @param name the name of the camera
  43325. * @param scene the scene to add the camera to
  43326. */
  43327. constructor(name: string, scene: Scene);
  43328. private _updateNumberOfRigCameras;
  43329. /** @hidden */
  43330. _updateForDualEyeDebugging(): void;
  43331. /**
  43332. * Updates the cameras position from the current pose information of the XR session
  43333. * @param xrSessionManager the session containing pose information
  43334. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43335. */
  43336. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43337. }
  43338. }
  43339. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43340. import { Observable } from "babylonjs/Misc/observable";
  43341. import { IDisposable, Scene } from "babylonjs/scene";
  43342. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43344. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43345. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43346. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43347. /**
  43348. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43349. * @see https://doc.babylonjs.com/how_to/webxr
  43350. */
  43351. export class WebXRExperienceHelper implements IDisposable {
  43352. private scene;
  43353. /**
  43354. * 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
  43355. */
  43356. container: AbstractMesh;
  43357. /**
  43358. * Camera used to render xr content
  43359. */
  43360. camera: WebXRCamera;
  43361. /**
  43362. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43363. */
  43364. state: WebXRState;
  43365. private _setState;
  43366. private static _TmpVector;
  43367. /**
  43368. * Fires when the state of the experience helper has changed
  43369. */
  43370. onStateChangedObservable: Observable<WebXRState>;
  43371. /** Session manager used to keep track of xr session */
  43372. sessionManager: WebXRSessionManager;
  43373. private _nonVRCamera;
  43374. private _originalSceneAutoClear;
  43375. private _supported;
  43376. /**
  43377. * Creates the experience helper
  43378. * @param scene the scene to attach the experience helper to
  43379. * @returns a promise for the experience helper
  43380. */
  43381. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43382. /**
  43383. * Creates a WebXRExperienceHelper
  43384. * @param scene The scene the helper should be created in
  43385. */
  43386. private constructor();
  43387. /**
  43388. * Exits XR mode and returns the scene to its original state
  43389. * @returns promise that resolves after xr mode has exited
  43390. */
  43391. exitXRAsync(): Promise<void>;
  43392. /**
  43393. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43394. * @param sessionMode options for the XR session
  43395. * @param referenceSpaceType frame of reference of the XR session
  43396. * @param renderTarget the output canvas that will be used to enter XR mode
  43397. * @returns promise that resolves after xr mode has entered
  43398. */
  43399. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43400. /**
  43401. * Updates the global position of the camera by moving the camera's container
  43402. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43403. * @param position The desired global position of the camera
  43404. */
  43405. setPositionOfCameraUsingContainer(position: Vector3): void;
  43406. /**
  43407. * Rotates the xr camera by rotating the camera's container around the camera's position
  43408. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43409. * @param rotation the desired quaternion rotation to apply to the camera
  43410. */
  43411. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43412. /**
  43413. * Disposes of the experience helper
  43414. */
  43415. dispose(): void;
  43416. }
  43417. }
  43418. declare module "babylonjs/Cameras/XR/webXRController" {
  43419. import { Nullable } from "babylonjs/types";
  43420. import { Observable } from "babylonjs/Misc/observable";
  43421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43422. import { Ray } from "babylonjs/Culling/ray";
  43423. import { Scene } from "babylonjs/scene";
  43424. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43425. /**
  43426. * Represents an XR input
  43427. */
  43428. export class WebXRController {
  43429. private scene;
  43430. /** The underlying input source for the controller */
  43431. inputSource: XRInputSource;
  43432. private parentContainer;
  43433. /**
  43434. * 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
  43435. */
  43436. grip?: AbstractMesh;
  43437. /**
  43438. * Pointer which can be used to select objects or attach a visible laser to
  43439. */
  43440. pointer: AbstractMesh;
  43441. private _gamepadMode;
  43442. /**
  43443. * If available, this is the gamepad object related to this controller.
  43444. * Using this object it is possible to get click events and trackpad changes of the
  43445. * webxr controller that is currently being used.
  43446. */
  43447. gamepadController?: WebVRController;
  43448. /**
  43449. * Event that fires when the controller is removed/disposed
  43450. */
  43451. onDisposeObservable: Observable<{}>;
  43452. private _tmpQuaternion;
  43453. private _tmpVector;
  43454. /**
  43455. * Creates the controller
  43456. * @see https://doc.babylonjs.com/how_to/webxr
  43457. * @param scene the scene which the controller should be associated to
  43458. * @param inputSource the underlying input source for the controller
  43459. * @param parentContainer parent that the controller meshes should be children of
  43460. */
  43461. constructor(scene: Scene,
  43462. /** The underlying input source for the controller */
  43463. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43464. /**
  43465. * Updates the controller pose based on the given XRFrame
  43466. * @param xrFrame xr frame to update the pose with
  43467. * @param referenceSpace reference space to use
  43468. */
  43469. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43470. /**
  43471. * Gets a world space ray coming from the controller
  43472. * @param result the resulting ray
  43473. */
  43474. getWorldPointerRayToRef(result: Ray): void;
  43475. /**
  43476. * Get the scene associated with this controller
  43477. * @returns the scene object
  43478. */
  43479. getScene(): Scene;
  43480. /**
  43481. * Disposes of the object
  43482. */
  43483. dispose(): void;
  43484. }
  43485. }
  43486. declare module "babylonjs/Cameras/XR/webXRInput" {
  43487. import { Observable } from "babylonjs/Misc/observable";
  43488. import { IDisposable } from "babylonjs/scene";
  43489. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43490. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43491. /**
  43492. * XR input used to track XR inputs such as controllers/rays
  43493. */
  43494. export class WebXRInput implements IDisposable {
  43495. /**
  43496. * Base experience the input listens to
  43497. */
  43498. baseExperience: WebXRExperienceHelper;
  43499. /**
  43500. * XR controllers being tracked
  43501. */
  43502. controllers: Array<WebXRController>;
  43503. private _frameObserver;
  43504. private _stateObserver;
  43505. /**
  43506. * Event when a controller has been connected/added
  43507. */
  43508. onControllerAddedObservable: Observable<WebXRController>;
  43509. /**
  43510. * Event when a controller has been removed/disconnected
  43511. */
  43512. onControllerRemovedObservable: Observable<WebXRController>;
  43513. /**
  43514. * Initializes the WebXRInput
  43515. * @param baseExperience experience helper which the input should be created for
  43516. */
  43517. constructor(
  43518. /**
  43519. * Base experience the input listens to
  43520. */
  43521. baseExperience: WebXRExperienceHelper);
  43522. private _onInputSourcesChange;
  43523. private _addAndRemoveControllers;
  43524. /**
  43525. * Disposes of the object
  43526. */
  43527. dispose(): void;
  43528. }
  43529. }
  43530. declare module "babylonjs/Loading/sceneLoader" {
  43531. import { Observable } from "babylonjs/Misc/observable";
  43532. import { Nullable } from "babylonjs/types";
  43533. import { Scene } from "babylonjs/scene";
  43534. import { Engine } from "babylonjs/Engines/engine";
  43535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43536. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43537. import { AssetContainer } from "babylonjs/assetContainer";
  43538. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43539. import { Skeleton } from "babylonjs/Bones/skeleton";
  43540. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43541. import { WebRequest } from "babylonjs/Misc/webRequest";
  43542. /**
  43543. * Class used to represent data loading progression
  43544. */
  43545. export class SceneLoaderProgressEvent {
  43546. /** defines if data length to load can be evaluated */
  43547. readonly lengthComputable: boolean;
  43548. /** defines the loaded data length */
  43549. readonly loaded: number;
  43550. /** defines the data length to load */
  43551. readonly total: number;
  43552. /**
  43553. * Create a new progress event
  43554. * @param lengthComputable defines if data length to load can be evaluated
  43555. * @param loaded defines the loaded data length
  43556. * @param total defines the data length to load
  43557. */
  43558. constructor(
  43559. /** defines if data length to load can be evaluated */
  43560. lengthComputable: boolean,
  43561. /** defines the loaded data length */
  43562. loaded: number,
  43563. /** defines the data length to load */
  43564. total: number);
  43565. /**
  43566. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43567. * @param event defines the source event
  43568. * @returns a new SceneLoaderProgressEvent
  43569. */
  43570. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43571. }
  43572. /**
  43573. * Interface used by SceneLoader plugins to define supported file extensions
  43574. */
  43575. export interface ISceneLoaderPluginExtensions {
  43576. /**
  43577. * Defines the list of supported extensions
  43578. */
  43579. [extension: string]: {
  43580. isBinary: boolean;
  43581. };
  43582. }
  43583. /**
  43584. * Interface used by SceneLoader plugin factory
  43585. */
  43586. export interface ISceneLoaderPluginFactory {
  43587. /**
  43588. * Defines the name of the factory
  43589. */
  43590. name: string;
  43591. /**
  43592. * Function called to create a new plugin
  43593. * @return the new plugin
  43594. */
  43595. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43596. /**
  43597. * The callback that returns true if the data can be directly loaded.
  43598. * @param data string containing the file data
  43599. * @returns if the data can be loaded directly
  43600. */
  43601. canDirectLoad?(data: string): boolean;
  43602. }
  43603. /**
  43604. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43605. */
  43606. export interface ISceneLoaderPluginBase {
  43607. /**
  43608. * The friendly name of this plugin.
  43609. */
  43610. name: string;
  43611. /**
  43612. * The file extensions supported by this plugin.
  43613. */
  43614. extensions: string | ISceneLoaderPluginExtensions;
  43615. /**
  43616. * The callback called when loading from a url.
  43617. * @param scene scene loading this url
  43618. * @param url url to load
  43619. * @param onSuccess callback called when the file successfully loads
  43620. * @param onProgress callback called while file is loading (if the server supports this mode)
  43621. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43622. * @param onError callback called when the file fails to load
  43623. * @returns a file request object
  43624. */
  43625. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43626. /**
  43627. * The callback called when loading from a file object.
  43628. * @param scene scene loading this file
  43629. * @param file defines the file to load
  43630. * @param onSuccess defines the callback to call when data is loaded
  43631. * @param onProgress defines the callback to call during loading process
  43632. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43633. * @param onError defines the callback to call when an error occurs
  43634. * @returns a file request object
  43635. */
  43636. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43637. /**
  43638. * The callback that returns true if the data can be directly loaded.
  43639. * @param data string containing the file data
  43640. * @returns if the data can be loaded directly
  43641. */
  43642. canDirectLoad?(data: string): boolean;
  43643. /**
  43644. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43645. * @param scene scene loading this data
  43646. * @param data string containing the data
  43647. * @returns data to pass to the plugin
  43648. */
  43649. directLoad?(scene: Scene, data: string): any;
  43650. /**
  43651. * The callback that allows custom handling of the root url based on the response url.
  43652. * @param rootUrl the original root url
  43653. * @param responseURL the response url if available
  43654. * @returns the new root url
  43655. */
  43656. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43657. }
  43658. /**
  43659. * Interface used to define a SceneLoader plugin
  43660. */
  43661. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43662. /**
  43663. * Import meshes into a scene.
  43664. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43665. * @param scene The scene to import into
  43666. * @param data The data to import
  43667. * @param rootUrl The root url for scene and resources
  43668. * @param meshes The meshes array to import into
  43669. * @param particleSystems The particle systems array to import into
  43670. * @param skeletons The skeletons array to import into
  43671. * @param onError The callback when import fails
  43672. * @returns True if successful or false otherwise
  43673. */
  43674. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43675. /**
  43676. * Load into a scene.
  43677. * @param scene The scene to load into
  43678. * @param data The data to import
  43679. * @param rootUrl The root url for scene and resources
  43680. * @param onError The callback when import fails
  43681. * @returns True if successful or false otherwise
  43682. */
  43683. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43684. /**
  43685. * Load into an asset container.
  43686. * @param scene The scene to load into
  43687. * @param data The data to import
  43688. * @param rootUrl The root url for scene and resources
  43689. * @param onError The callback when import fails
  43690. * @returns The loaded asset container
  43691. */
  43692. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43693. }
  43694. /**
  43695. * Interface used to define an async SceneLoader plugin
  43696. */
  43697. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43698. /**
  43699. * Import meshes into a scene.
  43700. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43701. * @param scene The scene to import into
  43702. * @param data The data to import
  43703. * @param rootUrl The root url for scene and resources
  43704. * @param onProgress The callback when the load progresses
  43705. * @param fileName Defines the name of the file to load
  43706. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43707. */
  43708. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43709. meshes: AbstractMesh[];
  43710. particleSystems: IParticleSystem[];
  43711. skeletons: Skeleton[];
  43712. animationGroups: AnimationGroup[];
  43713. }>;
  43714. /**
  43715. * Load into a scene.
  43716. * @param scene The scene to load into
  43717. * @param data The data to import
  43718. * @param rootUrl The root url for scene and resources
  43719. * @param onProgress The callback when the load progresses
  43720. * @param fileName Defines the name of the file to load
  43721. * @returns Nothing
  43722. */
  43723. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43724. /**
  43725. * Load into an asset container.
  43726. * @param scene The scene to load into
  43727. * @param data The data to import
  43728. * @param rootUrl The root url for scene and resources
  43729. * @param onProgress The callback when the load progresses
  43730. * @param fileName Defines the name of the file to load
  43731. * @returns The loaded asset container
  43732. */
  43733. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43734. }
  43735. /**
  43736. * Class used to load scene from various file formats using registered plugins
  43737. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43738. */
  43739. export class SceneLoader {
  43740. /**
  43741. * No logging while loading
  43742. */
  43743. static readonly NO_LOGGING: number;
  43744. /**
  43745. * Minimal logging while loading
  43746. */
  43747. static readonly MINIMAL_LOGGING: number;
  43748. /**
  43749. * Summary logging while loading
  43750. */
  43751. static readonly SUMMARY_LOGGING: number;
  43752. /**
  43753. * Detailled logging while loading
  43754. */
  43755. static readonly DETAILED_LOGGING: number;
  43756. /**
  43757. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43758. */
  43759. static ForceFullSceneLoadingForIncremental: boolean;
  43760. /**
  43761. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43762. */
  43763. static ShowLoadingScreen: boolean;
  43764. /**
  43765. * Defines the current logging level (while loading the scene)
  43766. * @ignorenaming
  43767. */
  43768. static loggingLevel: number;
  43769. /**
  43770. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43771. */
  43772. static CleanBoneMatrixWeights: boolean;
  43773. /**
  43774. * Event raised when a plugin is used to load a scene
  43775. */
  43776. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43777. private static _registeredPlugins;
  43778. private static _getDefaultPlugin;
  43779. private static _getPluginForExtension;
  43780. private static _getPluginForDirectLoad;
  43781. private static _getPluginForFilename;
  43782. private static _getDirectLoad;
  43783. private static _loadData;
  43784. private static _getFileInfo;
  43785. /**
  43786. * Gets a plugin that can load the given extension
  43787. * @param extension defines the extension to load
  43788. * @returns a plugin or null if none works
  43789. */
  43790. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43791. /**
  43792. * Gets a boolean indicating that the given extension can be loaded
  43793. * @param extension defines the extension to load
  43794. * @returns true if the extension is supported
  43795. */
  43796. static IsPluginForExtensionAvailable(extension: string): boolean;
  43797. /**
  43798. * Adds a new plugin to the list of registered plugins
  43799. * @param plugin defines the plugin to add
  43800. */
  43801. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43802. /**
  43803. * Import meshes into a scene
  43804. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43805. * @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)
  43806. * @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)
  43807. * @param scene the instance of BABYLON.Scene to append to
  43808. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43809. * @param onProgress a callback with a progress event for each file being loaded
  43810. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43811. * @param pluginExtension the extension used to determine the plugin
  43812. * @returns The loaded plugin
  43813. */
  43814. 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>;
  43815. /**
  43816. * Import meshes into a scene
  43817. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43818. * @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)
  43819. * @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)
  43820. * @param scene the instance of BABYLON.Scene to append to
  43821. * @param onProgress a callback with a progress event for each file being loaded
  43822. * @param pluginExtension the extension used to determine the plugin
  43823. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43824. */
  43825. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43826. meshes: AbstractMesh[];
  43827. particleSystems: IParticleSystem[];
  43828. skeletons: Skeleton[];
  43829. animationGroups: AnimationGroup[];
  43830. }>;
  43831. /**
  43832. * Load a scene
  43833. * @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)
  43834. * @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)
  43835. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43836. * @param onSuccess a callback with the scene when import succeeds
  43837. * @param onProgress a callback with a progress event for each file being loaded
  43838. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43839. * @param pluginExtension the extension used to determine the plugin
  43840. * @returns The loaded plugin
  43841. */
  43842. 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>;
  43843. /**
  43844. * Load a scene
  43845. * @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)
  43846. * @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)
  43847. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43848. * @param onProgress a callback with a progress event for each file being loaded
  43849. * @param pluginExtension the extension used to determine the plugin
  43850. * @returns The loaded scene
  43851. */
  43852. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43853. /**
  43854. * Append a scene
  43855. * @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)
  43856. * @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)
  43857. * @param scene is the instance of BABYLON.Scene to append to
  43858. * @param onSuccess a callback with the scene when import succeeds
  43859. * @param onProgress a callback with a progress event for each file being loaded
  43860. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43861. * @param pluginExtension the extension used to determine the plugin
  43862. * @returns The loaded plugin
  43863. */
  43864. 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>;
  43865. /**
  43866. * Append a scene
  43867. * @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)
  43868. * @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)
  43869. * @param scene is the instance of BABYLON.Scene to append to
  43870. * @param onProgress a callback with a progress event for each file being loaded
  43871. * @param pluginExtension the extension used to determine the plugin
  43872. * @returns The given scene
  43873. */
  43874. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43875. /**
  43876. * Load a scene into an asset container
  43877. * @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)
  43878. * @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)
  43879. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43880. * @param onSuccess a callback with the scene when import succeeds
  43881. * @param onProgress a callback with a progress event for each file being loaded
  43882. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43883. * @param pluginExtension the extension used to determine the plugin
  43884. * @returns The loaded plugin
  43885. */
  43886. 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>;
  43887. /**
  43888. * Load a scene into an asset container
  43889. * @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)
  43890. * @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)
  43891. * @param scene is the instance of Scene to append to
  43892. * @param onProgress a callback with a progress event for each file being loaded
  43893. * @param pluginExtension the extension used to determine the plugin
  43894. * @returns The loaded asset container
  43895. */
  43896. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43897. }
  43898. }
  43899. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43900. import { Scene } from "babylonjs/scene";
  43901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43902. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43903. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43904. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43905. /**
  43906. * Generic Controller
  43907. */
  43908. export class GenericController extends WebVRController {
  43909. /**
  43910. * Base Url for the controller model.
  43911. */
  43912. static readonly MODEL_BASE_URL: string;
  43913. /**
  43914. * File name for the controller model.
  43915. */
  43916. static readonly MODEL_FILENAME: string;
  43917. /**
  43918. * Creates a new GenericController from a gamepad
  43919. * @param vrGamepad the gamepad that the controller should be created from
  43920. */
  43921. constructor(vrGamepad: any);
  43922. /**
  43923. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43924. * @param scene scene in which to add meshes
  43925. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43926. */
  43927. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43928. /**
  43929. * Called once for each button that changed state since the last frame
  43930. * @param buttonIdx Which button index changed
  43931. * @param state New state of the button
  43932. * @param changes Which properties on the state changed since last frame
  43933. */
  43934. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43935. }
  43936. }
  43937. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43938. import { Observable } from "babylonjs/Misc/observable";
  43939. import { Scene } from "babylonjs/scene";
  43940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43941. import { Ray } from "babylonjs/Culling/ray";
  43942. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43943. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43944. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43945. /**
  43946. * Defines the WindowsMotionController object that the state of the windows motion controller
  43947. */
  43948. export class WindowsMotionController extends WebVRController {
  43949. /**
  43950. * The base url used to load the left and right controller models
  43951. */
  43952. static MODEL_BASE_URL: string;
  43953. /**
  43954. * The name of the left controller model file
  43955. */
  43956. static MODEL_LEFT_FILENAME: string;
  43957. /**
  43958. * The name of the right controller model file
  43959. */
  43960. static MODEL_RIGHT_FILENAME: string;
  43961. /**
  43962. * The controller name prefix for this controller type
  43963. */
  43964. static readonly GAMEPAD_ID_PREFIX: string;
  43965. /**
  43966. * The controller id pattern for this controller type
  43967. */
  43968. private static readonly GAMEPAD_ID_PATTERN;
  43969. private _loadedMeshInfo;
  43970. protected readonly _mapping: {
  43971. buttons: string[];
  43972. buttonMeshNames: {
  43973. 'trigger': string;
  43974. 'menu': string;
  43975. 'grip': string;
  43976. 'thumbstick': string;
  43977. 'trackpad': string;
  43978. };
  43979. buttonObservableNames: {
  43980. 'trigger': string;
  43981. 'menu': string;
  43982. 'grip': string;
  43983. 'thumbstick': string;
  43984. 'trackpad': string;
  43985. };
  43986. axisMeshNames: string[];
  43987. pointingPoseMeshName: string;
  43988. };
  43989. /**
  43990. * Fired when the trackpad on this controller is clicked
  43991. */
  43992. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43993. /**
  43994. * Fired when the trackpad on this controller is modified
  43995. */
  43996. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43997. /**
  43998. * The current x and y values of this controller's trackpad
  43999. */
  44000. trackpad: StickValues;
  44001. /**
  44002. * Creates a new WindowsMotionController from a gamepad
  44003. * @param vrGamepad the gamepad that the controller should be created from
  44004. */
  44005. constructor(vrGamepad: any);
  44006. /**
  44007. * Fired when the trigger on this controller is modified
  44008. */
  44009. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44010. /**
  44011. * Fired when the menu button on this controller is modified
  44012. */
  44013. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44014. /**
  44015. * Fired when the grip button on this controller is modified
  44016. */
  44017. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44018. /**
  44019. * Fired when the thumbstick button on this controller is modified
  44020. */
  44021. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44022. /**
  44023. * Fired when the touchpad button on this controller is modified
  44024. */
  44025. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44026. /**
  44027. * Fired when the touchpad values on this controller are modified
  44028. */
  44029. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44030. protected _updateTrackpad(): void;
  44031. /**
  44032. * Called once per frame by the engine.
  44033. */
  44034. update(): void;
  44035. /**
  44036. * Called once for each button that changed state since the last frame
  44037. * @param buttonIdx Which button index changed
  44038. * @param state New state of the button
  44039. * @param changes Which properties on the state changed since last frame
  44040. */
  44041. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44042. /**
  44043. * Moves the buttons on the controller mesh based on their current state
  44044. * @param buttonName the name of the button to move
  44045. * @param buttonValue the value of the button which determines the buttons new position
  44046. */
  44047. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44048. /**
  44049. * Moves the axis on the controller mesh based on its current state
  44050. * @param axis the index of the axis
  44051. * @param axisValue the value of the axis which determines the meshes new position
  44052. * @hidden
  44053. */
  44054. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44055. /**
  44056. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44057. * @param scene scene in which to add meshes
  44058. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44059. */
  44060. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44061. /**
  44062. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44063. * can be transformed by button presses and axes values, based on this._mapping.
  44064. *
  44065. * @param scene scene in which the meshes exist
  44066. * @param meshes list of meshes that make up the controller model to process
  44067. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44068. */
  44069. private processModel;
  44070. private createMeshInfo;
  44071. /**
  44072. * Gets the ray of the controller in the direction the controller is pointing
  44073. * @param length the length the resulting ray should be
  44074. * @returns a ray in the direction the controller is pointing
  44075. */
  44076. getForwardRay(length?: number): Ray;
  44077. /**
  44078. * Disposes of the controller
  44079. */
  44080. dispose(): void;
  44081. }
  44082. /**
  44083. * This class represents a new windows motion controller in XR.
  44084. */
  44085. export class XRWindowsMotionController extends WindowsMotionController {
  44086. /**
  44087. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44088. */
  44089. protected readonly _mapping: {
  44090. buttons: string[];
  44091. buttonMeshNames: {
  44092. 'trigger': string;
  44093. 'menu': string;
  44094. 'grip': string;
  44095. 'thumbstick': string;
  44096. 'trackpad': string;
  44097. };
  44098. buttonObservableNames: {
  44099. 'trigger': string;
  44100. 'menu': string;
  44101. 'grip': string;
  44102. 'thumbstick': string;
  44103. 'trackpad': string;
  44104. };
  44105. axisMeshNames: string[];
  44106. pointingPoseMeshName: string;
  44107. };
  44108. /**
  44109. * Construct a new XR-Based windows motion controller
  44110. *
  44111. * @param gamepadInfo the gamepad object from the browser
  44112. */
  44113. constructor(gamepadInfo: any);
  44114. /**
  44115. * holds the thumbstick values (X,Y)
  44116. */
  44117. readonly thumbstickValues: StickValues;
  44118. /**
  44119. * Fired when the thumbstick on this controller is clicked
  44120. */
  44121. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44122. /**
  44123. * Fired when the thumbstick on this controller is modified
  44124. */
  44125. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44126. /**
  44127. * Fired when the touchpad button on this controller is modified
  44128. */
  44129. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44130. /**
  44131. * Fired when the touchpad values on this controller are modified
  44132. */
  44133. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44134. /**
  44135. * Fired when the thumbstick button on this controller is modified
  44136. * here to prevent breaking changes
  44137. */
  44138. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44139. /**
  44140. * updating the thumbstick(!) and not the trackpad.
  44141. * This is named this way due to the difference between WebVR and XR and to avoid
  44142. * changing the parent class.
  44143. */
  44144. protected _updateTrackpad(): void;
  44145. /**
  44146. * Disposes the class with joy
  44147. */
  44148. dispose(): void;
  44149. }
  44150. }
  44151. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44152. import { Observable } from "babylonjs/Misc/observable";
  44153. import { Scene } from "babylonjs/scene";
  44154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44155. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44156. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44157. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44158. /**
  44159. * Oculus Touch Controller
  44160. */
  44161. export class OculusTouchController extends WebVRController {
  44162. /**
  44163. * Base Url for the controller model.
  44164. */
  44165. static MODEL_BASE_URL: string;
  44166. /**
  44167. * File name for the left controller model.
  44168. */
  44169. static MODEL_LEFT_FILENAME: string;
  44170. /**
  44171. * File name for the right controller model.
  44172. */
  44173. static MODEL_RIGHT_FILENAME: string;
  44174. /**
  44175. * Base Url for the Quest controller model.
  44176. */
  44177. static QUEST_MODEL_BASE_URL: string;
  44178. /**
  44179. * @hidden
  44180. * If the controllers are running on a device that needs the updated Quest controller models
  44181. */
  44182. static _IsQuest: boolean;
  44183. /**
  44184. * Fired when the secondary trigger on this controller is modified
  44185. */
  44186. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44187. /**
  44188. * Fired when the thumb rest on this controller is modified
  44189. */
  44190. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44191. /**
  44192. * Creates a new OculusTouchController from a gamepad
  44193. * @param vrGamepad the gamepad that the controller should be created from
  44194. */
  44195. constructor(vrGamepad: any);
  44196. /**
  44197. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44198. * @param scene scene in which to add meshes
  44199. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44200. */
  44201. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44202. /**
  44203. * Fired when the A button on this controller is modified
  44204. */
  44205. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44206. /**
  44207. * Fired when the B button on this controller is modified
  44208. */
  44209. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44210. /**
  44211. * Fired when the X button on this controller is modified
  44212. */
  44213. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44214. /**
  44215. * Fired when the Y button on this controller is modified
  44216. */
  44217. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44218. /**
  44219. * Called once for each button that changed state since the last frame
  44220. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44221. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44222. * 2) secondary trigger (same)
  44223. * 3) A (right) X (left), touch, pressed = value
  44224. * 4) B / Y
  44225. * 5) thumb rest
  44226. * @param buttonIdx Which button index changed
  44227. * @param state New state of the button
  44228. * @param changes Which properties on the state changed since last frame
  44229. */
  44230. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44231. }
  44232. }
  44233. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44234. import { Scene } from "babylonjs/scene";
  44235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44236. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44237. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44238. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44239. import { Observable } from "babylonjs/Misc/observable";
  44240. /**
  44241. * Vive Controller
  44242. */
  44243. export class ViveController extends WebVRController {
  44244. /**
  44245. * Base Url for the controller model.
  44246. */
  44247. static MODEL_BASE_URL: string;
  44248. /**
  44249. * File name for the controller model.
  44250. */
  44251. static MODEL_FILENAME: string;
  44252. /**
  44253. * Creates a new ViveController from a gamepad
  44254. * @param vrGamepad the gamepad that the controller should be created from
  44255. */
  44256. constructor(vrGamepad: any);
  44257. /**
  44258. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44259. * @param scene scene in which to add meshes
  44260. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44261. */
  44262. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44263. /**
  44264. * Fired when the left button on this controller is modified
  44265. */
  44266. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44267. /**
  44268. * Fired when the right button on this controller is modified
  44269. */
  44270. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44271. /**
  44272. * Fired when the menu button on this controller is modified
  44273. */
  44274. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44275. /**
  44276. * Called once for each button that changed state since the last frame
  44277. * Vive mapping:
  44278. * 0: touchpad
  44279. * 1: trigger
  44280. * 2: left AND right buttons
  44281. * 3: menu button
  44282. * @param buttonIdx Which button index changed
  44283. * @param state New state of the button
  44284. * @param changes Which properties on the state changed since last frame
  44285. */
  44286. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44287. }
  44288. }
  44289. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44290. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44291. import { Observable } from "babylonjs/Misc/observable";
  44292. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44293. /**
  44294. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44295. */
  44296. export class WebXRControllerModelLoader {
  44297. /**
  44298. * an observable that triggers when a new model (the mesh itself) was initialized.
  44299. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44300. */
  44301. onControllerModelLoaded: Observable<WebXRController>;
  44302. /**
  44303. * Creates the WebXRControllerModelLoader
  44304. * @param input xr input that creates the controllers
  44305. */
  44306. constructor(input: WebXRInput);
  44307. }
  44308. }
  44309. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  44310. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44311. /**
  44312. * Handles pointer input automatically for the pointer of XR controllers
  44313. */
  44314. export class WebXRControllerPointerSelection {
  44315. private static _idCounter;
  44316. private _tmpRay;
  44317. /**
  44318. * Creates a WebXRControllerPointerSelection
  44319. * @param input input manager to setup pointer selection
  44320. */
  44321. constructor(input: WebXRInput);
  44322. private _convertNormalToDirectionOfRay;
  44323. private _updatePointerDistance;
  44324. }
  44325. }
  44326. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  44327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44328. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44329. /**
  44330. * Enables teleportation
  44331. */
  44332. export class WebXRControllerTeleportation {
  44333. private _teleportationFillColor;
  44334. private _teleportationBorderColor;
  44335. private _tmpRay;
  44336. private _tmpVector;
  44337. /**
  44338. * Creates a WebXRControllerTeleportation
  44339. * @param input input manager to add teleportation to
  44340. * @param floorMeshes floormeshes which can be teleported to
  44341. */
  44342. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  44343. }
  44344. }
  44345. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  44346. import { Nullable } from "babylonjs/types";
  44347. import { Observable } from "babylonjs/Misc/observable";
  44348. import { IDisposable, Scene } from "babylonjs/scene";
  44349. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44350. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44351. /**
  44352. * Button which can be used to enter a different mode of XR
  44353. */
  44354. export class WebXREnterExitUIButton {
  44355. /** button element */
  44356. element: HTMLElement;
  44357. /** XR initialization options for the button */
  44358. sessionMode: XRSessionMode;
  44359. /** Reference space type */
  44360. referenceSpaceType: XRReferenceSpaceType;
  44361. /**
  44362. * Creates a WebXREnterExitUIButton
  44363. * @param element button element
  44364. * @param sessionMode XR initialization session mode
  44365. * @param referenceSpaceType the type of reference space to be used
  44366. */
  44367. constructor(
  44368. /** button element */
  44369. element: HTMLElement,
  44370. /** XR initialization options for the button */
  44371. sessionMode: XRSessionMode,
  44372. /** Reference space type */
  44373. referenceSpaceType: XRReferenceSpaceType);
  44374. /**
  44375. * Overwritable function which can be used to update the button's visuals when the state changes
  44376. * @param activeButton the current active button in the UI
  44377. */
  44378. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44379. }
  44380. /**
  44381. * Options to create the webXR UI
  44382. */
  44383. export class WebXREnterExitUIOptions {
  44384. /**
  44385. * Context to enter xr with
  44386. */
  44387. renderTarget?: Nullable<WebXRRenderTarget>;
  44388. /**
  44389. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44390. */
  44391. customButtons?: Array<WebXREnterExitUIButton>;
  44392. /**
  44393. * A session mode to use when creating the default button.
  44394. * Default is immersive-vr
  44395. */
  44396. sessionMode?: XRSessionMode;
  44397. /**
  44398. * A reference space type to use when creating the default button.
  44399. * Default is local-floor
  44400. */
  44401. referenceSpaceType?: XRReferenceSpaceType;
  44402. }
  44403. /**
  44404. * UI to allow the user to enter/exit XR mode
  44405. */
  44406. export class WebXREnterExitUI implements IDisposable {
  44407. private scene;
  44408. private _overlay;
  44409. private _buttons;
  44410. private _activeButton;
  44411. /**
  44412. * Fired every time the active button is changed.
  44413. *
  44414. * When xr is entered via a button that launches xr that button will be the callback parameter
  44415. *
  44416. * When exiting xr the callback parameter will be null)
  44417. */
  44418. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44419. /**
  44420. * Creates UI to allow the user to enter/exit XR mode
  44421. * @param scene the scene to add the ui to
  44422. * @param helper the xr experience helper to enter/exit xr with
  44423. * @param options options to configure the UI
  44424. * @returns the created ui
  44425. */
  44426. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44427. private constructor();
  44428. private _updateButtons;
  44429. /**
  44430. * Disposes of the object
  44431. */
  44432. dispose(): void;
  44433. }
  44434. }
  44435. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44436. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44437. import { Scene } from "babylonjs/scene";
  44438. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44439. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44440. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44441. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44442. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44443. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44445. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44446. /**
  44447. * Options for the default xr helper
  44448. */
  44449. export class WebXRDefaultExperienceOptions {
  44450. /**
  44451. * Floor meshes that should be used for teleporting
  44452. */
  44453. floorMeshes: Array<AbstractMesh>;
  44454. /**
  44455. * Enable or disable default UI to enter XR
  44456. */
  44457. disableDefaultUI?: boolean;
  44458. /**
  44459. * optional configuration for the output canvas
  44460. */
  44461. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44462. }
  44463. /**
  44464. * Default experience which provides a similar setup to the previous webVRExperience
  44465. */
  44466. export class WebXRDefaultExperience {
  44467. /**
  44468. * Base experience
  44469. */
  44470. baseExperience: WebXRExperienceHelper;
  44471. /**
  44472. * Input experience extension
  44473. */
  44474. input: WebXRInput;
  44475. /**
  44476. * Loads the controller models
  44477. */
  44478. controllerModelLoader: WebXRControllerModelLoader;
  44479. /**
  44480. * Enables laser pointer and selection
  44481. */
  44482. pointerSelection: WebXRControllerPointerSelection;
  44483. /**
  44484. * Enables teleportation
  44485. */
  44486. teleportation: WebXRControllerTeleportation;
  44487. /**
  44488. * Enables ui for enetering/exiting xr
  44489. */
  44490. enterExitUI: WebXREnterExitUI;
  44491. /**
  44492. * Default target xr should render to
  44493. */
  44494. renderTarget: WebXRRenderTarget;
  44495. /**
  44496. * Creates the default xr experience
  44497. * @param scene scene
  44498. * @param options options for basic configuration
  44499. * @returns resulting WebXRDefaultExperience
  44500. */
  44501. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44502. private constructor();
  44503. /**
  44504. * DIsposes of the experience helper
  44505. */
  44506. dispose(): void;
  44507. }
  44508. }
  44509. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  44510. import { Observable } from "babylonjs/Misc/observable";
  44511. import { Nullable } from "babylonjs/types";
  44512. import { Camera } from "babylonjs/Cameras/camera";
  44513. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44514. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44515. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  44516. import { Scene } from "babylonjs/scene";
  44517. import { Vector3 } from "babylonjs/Maths/math.vector";
  44518. import { Color3 } from "babylonjs/Maths/math.color";
  44519. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44521. import { Mesh } from "babylonjs/Meshes/mesh";
  44522. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44523. import { EasingFunction } from "babylonjs/Animations/easing";
  44524. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44525. import "babylonjs/Meshes/Builders/groundBuilder";
  44526. import "babylonjs/Meshes/Builders/torusBuilder";
  44527. import "babylonjs/Meshes/Builders/cylinderBuilder";
  44528. import "babylonjs/Gamepads/gamepadSceneComponent";
  44529. import "babylonjs/Animations/animatable";
  44530. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44531. /**
  44532. * Options to modify the vr teleportation behavior.
  44533. */
  44534. export interface VRTeleportationOptions {
  44535. /**
  44536. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44537. */
  44538. floorMeshName?: string;
  44539. /**
  44540. * A list of meshes to be used as the teleportation floor. (default: empty)
  44541. */
  44542. floorMeshes?: Mesh[];
  44543. /**
  44544. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44545. */
  44546. teleportationMode?: number;
  44547. /**
  44548. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44549. */
  44550. teleportationTime?: number;
  44551. /**
  44552. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44553. */
  44554. teleportationSpeed?: number;
  44555. /**
  44556. * The easing function used in the animation or null for Linear. (default CircleEase)
  44557. */
  44558. easingFunction?: EasingFunction;
  44559. }
  44560. /**
  44561. * Options to modify the vr experience helper's behavior.
  44562. */
  44563. export interface VRExperienceHelperOptions extends WebVROptions {
  44564. /**
  44565. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44566. */
  44567. createDeviceOrientationCamera?: boolean;
  44568. /**
  44569. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44570. */
  44571. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44572. /**
  44573. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44574. */
  44575. laserToggle?: boolean;
  44576. /**
  44577. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44578. */
  44579. floorMeshes?: Mesh[];
  44580. /**
  44581. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44582. */
  44583. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44584. /**
  44585. * Defines if WebXR should be used instead of WebVR (if available)
  44586. */
  44587. useXR?: boolean;
  44588. }
  44589. /**
  44590. * Event containing information after VR has been entered
  44591. */
  44592. export class OnAfterEnteringVRObservableEvent {
  44593. /**
  44594. * If entering vr was successful
  44595. */
  44596. success: boolean;
  44597. }
  44598. /**
  44599. * Helps to quickly add VR support to an existing scene.
  44600. * See http://doc.babylonjs.com/how_to/webvr_helper
  44601. */
  44602. export class VRExperienceHelper {
  44603. /** Options to modify the vr experience helper's behavior. */
  44604. webVROptions: VRExperienceHelperOptions;
  44605. private _scene;
  44606. private _position;
  44607. private _btnVR;
  44608. private _btnVRDisplayed;
  44609. private _webVRsupported;
  44610. private _webVRready;
  44611. private _webVRrequesting;
  44612. private _webVRpresenting;
  44613. private _hasEnteredVR;
  44614. private _fullscreenVRpresenting;
  44615. private _inputElement;
  44616. private _webVRCamera;
  44617. private _vrDeviceOrientationCamera;
  44618. private _deviceOrientationCamera;
  44619. private _existingCamera;
  44620. private _onKeyDown;
  44621. private _onVrDisplayPresentChange;
  44622. private _onVRDisplayChanged;
  44623. private _onVRRequestPresentStart;
  44624. private _onVRRequestPresentComplete;
  44625. /**
  44626. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  44627. */
  44628. enableGazeEvenWhenNoPointerLock: boolean;
  44629. /**
  44630. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44631. */
  44632. exitVROnDoubleTap: boolean;
  44633. /**
  44634. * Observable raised right before entering VR.
  44635. */
  44636. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44637. /**
  44638. * Observable raised when entering VR has completed.
  44639. */
  44640. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44641. /**
  44642. * Observable raised when exiting VR.
  44643. */
  44644. onExitingVRObservable: Observable<VRExperienceHelper>;
  44645. /**
  44646. * Observable raised when controller mesh is loaded.
  44647. */
  44648. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44649. /** Return this.onEnteringVRObservable
  44650. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44651. */
  44652. readonly onEnteringVR: Observable<VRExperienceHelper>;
  44653. /** Return this.onExitingVRObservable
  44654. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44655. */
  44656. readonly onExitingVR: Observable<VRExperienceHelper>;
  44657. /** Return this.onControllerMeshLoadedObservable
  44658. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44659. */
  44660. readonly onControllerMeshLoaded: Observable<WebVRController>;
  44661. private _rayLength;
  44662. private _useCustomVRButton;
  44663. private _teleportationRequested;
  44664. private _teleportActive;
  44665. private _floorMeshName;
  44666. private _floorMeshesCollection;
  44667. private _teleportationMode;
  44668. private _teleportationTime;
  44669. private _teleportationSpeed;
  44670. private _teleportationEasing;
  44671. private _rotationAllowed;
  44672. private _teleportBackwardsVector;
  44673. private _teleportationTarget;
  44674. private _isDefaultTeleportationTarget;
  44675. private _postProcessMove;
  44676. private _teleportationFillColor;
  44677. private _teleportationBorderColor;
  44678. private _rotationAngle;
  44679. private _haloCenter;
  44680. private _cameraGazer;
  44681. private _padSensibilityUp;
  44682. private _padSensibilityDown;
  44683. private _leftController;
  44684. private _rightController;
  44685. /**
  44686. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44687. */
  44688. onNewMeshSelected: Observable<AbstractMesh>;
  44689. /**
  44690. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44691. * This observable will provide the mesh and the controller used to select the mesh
  44692. */
  44693. onMeshSelectedWithController: Observable<{
  44694. mesh: AbstractMesh;
  44695. controller: WebVRController;
  44696. }>;
  44697. /**
  44698. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44699. */
  44700. onNewMeshPicked: Observable<PickingInfo>;
  44701. private _circleEase;
  44702. /**
  44703. * Observable raised before camera teleportation
  44704. */
  44705. onBeforeCameraTeleport: Observable<Vector3>;
  44706. /**
  44707. * Observable raised after camera teleportation
  44708. */
  44709. onAfterCameraTeleport: Observable<Vector3>;
  44710. /**
  44711. * Observable raised when current selected mesh gets unselected
  44712. */
  44713. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44714. private _raySelectionPredicate;
  44715. /**
  44716. * To be optionaly changed by user to define custom ray selection
  44717. */
  44718. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44719. /**
  44720. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44721. */
  44722. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44723. /**
  44724. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44725. */
  44726. teleportationEnabled: boolean;
  44727. private _defaultHeight;
  44728. private _teleportationInitialized;
  44729. private _interactionsEnabled;
  44730. private _interactionsRequested;
  44731. private _displayGaze;
  44732. private _displayLaserPointer;
  44733. /**
  44734. * The mesh used to display where the user is going to teleport.
  44735. */
  44736. /**
  44737. * Sets the mesh to be used to display where the user is going to teleport.
  44738. */
  44739. teleportationTarget: Mesh;
  44740. /**
  44741. * 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
  44742. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44743. * See http://doc.babylonjs.com/resources/baking_transformations
  44744. */
  44745. gazeTrackerMesh: Mesh;
  44746. /**
  44747. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44748. */
  44749. updateGazeTrackerScale: boolean;
  44750. /**
  44751. * If the gaze trackers color should be updated when selecting meshes
  44752. */
  44753. updateGazeTrackerColor: boolean;
  44754. /**
  44755. * If the controller laser color should be updated when selecting meshes
  44756. */
  44757. updateControllerLaserColor: boolean;
  44758. /**
  44759. * The gaze tracking mesh corresponding to the left controller
  44760. */
  44761. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  44762. /**
  44763. * The gaze tracking mesh corresponding to the right controller
  44764. */
  44765. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  44766. /**
  44767. * If the ray of the gaze should be displayed.
  44768. */
  44769. /**
  44770. * Sets if the ray of the gaze should be displayed.
  44771. */
  44772. displayGaze: boolean;
  44773. /**
  44774. * If the ray of the LaserPointer should be displayed.
  44775. */
  44776. /**
  44777. * Sets if the ray of the LaserPointer should be displayed.
  44778. */
  44779. displayLaserPointer: boolean;
  44780. /**
  44781. * The deviceOrientationCamera used as the camera when not in VR.
  44782. */
  44783. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  44784. /**
  44785. * Based on the current WebVR support, returns the current VR camera used.
  44786. */
  44787. readonly currentVRCamera: Nullable<Camera>;
  44788. /**
  44789. * The webVRCamera which is used when in VR.
  44790. */
  44791. readonly webVRCamera: WebVRFreeCamera;
  44792. /**
  44793. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44794. */
  44795. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  44796. /**
  44797. * The html button that is used to trigger entering into VR.
  44798. */
  44799. readonly vrButton: Nullable<HTMLButtonElement>;
  44800. private readonly _teleportationRequestInitiated;
  44801. /**
  44802. * Defines wether or not Pointer lock should be requested when switching to
  44803. * full screen.
  44804. */
  44805. requestPointerLockOnFullScreen: boolean;
  44806. /**
  44807. * If asking to force XR, this will be populated with the default xr experience
  44808. */
  44809. xr: WebXRDefaultExperience;
  44810. /**
  44811. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44812. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44813. */
  44814. xrTestDone: boolean;
  44815. /**
  44816. * Instantiates a VRExperienceHelper.
  44817. * Helps to quickly add VR support to an existing scene.
  44818. * @param scene The scene the VRExperienceHelper belongs to.
  44819. * @param webVROptions Options to modify the vr experience helper's behavior.
  44820. */
  44821. constructor(scene: Scene,
  44822. /** Options to modify the vr experience helper's behavior. */
  44823. webVROptions?: VRExperienceHelperOptions);
  44824. private completeVRInit;
  44825. private _onDefaultMeshLoaded;
  44826. private _onResize;
  44827. private _onFullscreenChange;
  44828. /**
  44829. * Gets a value indicating if we are currently in VR mode.
  44830. */
  44831. readonly isInVRMode: boolean;
  44832. private onVrDisplayPresentChange;
  44833. private onVRDisplayChanged;
  44834. private moveButtonToBottomRight;
  44835. private displayVRButton;
  44836. private updateButtonVisibility;
  44837. private _cachedAngularSensibility;
  44838. /**
  44839. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44840. * Otherwise, will use the fullscreen API.
  44841. */
  44842. enterVR(): void;
  44843. /**
  44844. * Attempt to exit VR, or fullscreen.
  44845. */
  44846. exitVR(): void;
  44847. /**
  44848. * The position of the vr experience helper.
  44849. */
  44850. /**
  44851. * Sets the position of the vr experience helper.
  44852. */
  44853. position: Vector3;
  44854. /**
  44855. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44856. */
  44857. enableInteractions(): void;
  44858. private readonly _noControllerIsActive;
  44859. private beforeRender;
  44860. private _isTeleportationFloor;
  44861. /**
  44862. * Adds a floor mesh to be used for teleportation.
  44863. * @param floorMesh the mesh to be used for teleportation.
  44864. */
  44865. addFloorMesh(floorMesh: Mesh): void;
  44866. /**
  44867. * Removes a floor mesh from being used for teleportation.
  44868. * @param floorMesh the mesh to be removed.
  44869. */
  44870. removeFloorMesh(floorMesh: Mesh): void;
  44871. /**
  44872. * Enables interactions and teleportation using the VR controllers and gaze.
  44873. * @param vrTeleportationOptions options to modify teleportation behavior.
  44874. */
  44875. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44876. private _onNewGamepadConnected;
  44877. private _tryEnableInteractionOnController;
  44878. private _onNewGamepadDisconnected;
  44879. private _enableInteractionOnController;
  44880. private _checkTeleportWithRay;
  44881. private _checkRotate;
  44882. private _checkTeleportBackwards;
  44883. private _enableTeleportationOnController;
  44884. private _createTeleportationCircles;
  44885. private _displayTeleportationTarget;
  44886. private _hideTeleportationTarget;
  44887. private _rotateCamera;
  44888. private _moveTeleportationSelectorTo;
  44889. private _workingVector;
  44890. private _workingQuaternion;
  44891. private _workingMatrix;
  44892. /**
  44893. * Time Constant Teleportation Mode
  44894. */
  44895. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44896. /**
  44897. * Speed Constant Teleportation Mode
  44898. */
  44899. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44900. /**
  44901. * Teleports the users feet to the desired location
  44902. * @param location The location where the user's feet should be placed
  44903. */
  44904. teleportCamera(location: Vector3): void;
  44905. private _convertNormalToDirectionOfRay;
  44906. private _castRayAndSelectObject;
  44907. private _notifySelectedMeshUnselected;
  44908. /**
  44909. * Sets the color of the laser ray from the vr controllers.
  44910. * @param color new color for the ray.
  44911. */
  44912. changeLaserColor(color: Color3): void;
  44913. /**
  44914. * Sets the color of the ray from the vr headsets gaze.
  44915. * @param color new color for the ray.
  44916. */
  44917. changeGazeColor(color: Color3): void;
  44918. /**
  44919. * Exits VR and disposes of the vr experience helper
  44920. */
  44921. dispose(): void;
  44922. /**
  44923. * Gets the name of the VRExperienceHelper class
  44924. * @returns "VRExperienceHelper"
  44925. */
  44926. getClassName(): string;
  44927. }
  44928. }
  44929. declare module "babylonjs/Cameras/VR/index" {
  44930. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  44931. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  44932. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44933. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  44934. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  44935. export * from "babylonjs/Cameras/VR/webVRCamera";
  44936. }
  44937. declare module "babylonjs/Cameras/XR/index" {
  44938. export * from "babylonjs/Cameras/XR/webXRCamera";
  44939. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44940. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44941. export * from "babylonjs/Cameras/XR/webXRInput";
  44942. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44943. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44944. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44945. export * from "babylonjs/Cameras/XR/webXRController";
  44946. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44947. export * from "babylonjs/Cameras/XR/webXRTypes";
  44948. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44949. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44950. }
  44951. declare module "babylonjs/Cameras/RigModes/index" {
  44952. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44953. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44954. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44955. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44956. }
  44957. declare module "babylonjs/Cameras/index" {
  44958. export * from "babylonjs/Cameras/Inputs/index";
  44959. export * from "babylonjs/Cameras/cameraInputsManager";
  44960. export * from "babylonjs/Cameras/camera";
  44961. export * from "babylonjs/Cameras/targetCamera";
  44962. export * from "babylonjs/Cameras/freeCamera";
  44963. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44964. export * from "babylonjs/Cameras/touchCamera";
  44965. export * from "babylonjs/Cameras/arcRotateCamera";
  44966. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44967. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44968. export * from "babylonjs/Cameras/flyCamera";
  44969. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44970. export * from "babylonjs/Cameras/followCamera";
  44971. export * from "babylonjs/Cameras/followCameraInputsManager";
  44972. export * from "babylonjs/Cameras/gamepadCamera";
  44973. export * from "babylonjs/Cameras/Stereoscopic/index";
  44974. export * from "babylonjs/Cameras/universalCamera";
  44975. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44976. export * from "babylonjs/Cameras/VR/index";
  44977. export * from "babylonjs/Cameras/XR/index";
  44978. export * from "babylonjs/Cameras/RigModes/index";
  44979. }
  44980. declare module "babylonjs/Collisions/index" {
  44981. export * from "babylonjs/Collisions/collider";
  44982. export * from "babylonjs/Collisions/collisionCoordinator";
  44983. export * from "babylonjs/Collisions/pickingInfo";
  44984. export * from "babylonjs/Collisions/intersectionInfo";
  44985. export * from "babylonjs/Collisions/meshCollisionData";
  44986. }
  44987. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44988. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44989. import { Vector3 } from "babylonjs/Maths/math.vector";
  44990. import { Ray } from "babylonjs/Culling/ray";
  44991. import { Plane } from "babylonjs/Maths/math.plane";
  44992. /**
  44993. * Contains an array of blocks representing the octree
  44994. */
  44995. export interface IOctreeContainer<T> {
  44996. /**
  44997. * Blocks within the octree
  44998. */
  44999. blocks: Array<OctreeBlock<T>>;
  45000. }
  45001. /**
  45002. * Class used to store a cell in an octree
  45003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45004. */
  45005. export class OctreeBlock<T> {
  45006. /**
  45007. * Gets the content of the current block
  45008. */
  45009. entries: T[];
  45010. /**
  45011. * Gets the list of block children
  45012. */
  45013. blocks: Array<OctreeBlock<T>>;
  45014. private _depth;
  45015. private _maxDepth;
  45016. private _capacity;
  45017. private _minPoint;
  45018. private _maxPoint;
  45019. private _boundingVectors;
  45020. private _creationFunc;
  45021. /**
  45022. * Creates a new block
  45023. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45024. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45025. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45026. * @param depth defines the current depth of this block in the octree
  45027. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45028. * @param creationFunc defines a callback to call when an element is added to the block
  45029. */
  45030. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45031. /**
  45032. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45033. */
  45034. readonly capacity: number;
  45035. /**
  45036. * Gets the minimum vector (in world space) of the block's bounding box
  45037. */
  45038. readonly minPoint: Vector3;
  45039. /**
  45040. * Gets the maximum vector (in world space) of the block's bounding box
  45041. */
  45042. readonly maxPoint: Vector3;
  45043. /**
  45044. * Add a new element to this block
  45045. * @param entry defines the element to add
  45046. */
  45047. addEntry(entry: T): void;
  45048. /**
  45049. * Remove an element from this block
  45050. * @param entry defines the element to remove
  45051. */
  45052. removeEntry(entry: T): void;
  45053. /**
  45054. * Add an array of elements to this block
  45055. * @param entries defines the array of elements to add
  45056. */
  45057. addEntries(entries: T[]): void;
  45058. /**
  45059. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45060. * @param frustumPlanes defines the frustum planes to test
  45061. * @param selection defines the array to store current content if selection is positive
  45062. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45063. */
  45064. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45065. /**
  45066. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45067. * @param sphereCenter defines the bounding sphere center
  45068. * @param sphereRadius defines the bounding sphere radius
  45069. * @param selection defines the array to store current content if selection is positive
  45070. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45071. */
  45072. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45073. /**
  45074. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45075. * @param ray defines the ray to test with
  45076. * @param selection defines the array to store current content if selection is positive
  45077. */
  45078. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45079. /**
  45080. * Subdivide the content into child blocks (this block will then be empty)
  45081. */
  45082. createInnerBlocks(): void;
  45083. /**
  45084. * @hidden
  45085. */
  45086. 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;
  45087. }
  45088. }
  45089. declare module "babylonjs/Culling/Octrees/octree" {
  45090. import { SmartArray } from "babylonjs/Misc/smartArray";
  45091. import { Vector3 } from "babylonjs/Maths/math.vector";
  45092. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45094. import { Ray } from "babylonjs/Culling/ray";
  45095. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  45096. import { Plane } from "babylonjs/Maths/math.plane";
  45097. /**
  45098. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45099. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45100. */
  45101. export class Octree<T> {
  45102. /** 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.) */
  45103. maxDepth: number;
  45104. /**
  45105. * Blocks within the octree containing objects
  45106. */
  45107. blocks: Array<OctreeBlock<T>>;
  45108. /**
  45109. * Content stored in the octree
  45110. */
  45111. dynamicContent: T[];
  45112. private _maxBlockCapacity;
  45113. private _selectionContent;
  45114. private _creationFunc;
  45115. /**
  45116. * Creates a octree
  45117. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45118. * @param creationFunc function to be used to instatiate the octree
  45119. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45120. * @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.)
  45121. */
  45122. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45123. /** 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.) */
  45124. maxDepth?: number);
  45125. /**
  45126. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45127. * @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);
  45128. * @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);
  45129. * @param entries meshes to be added to the octree blocks
  45130. */
  45131. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45132. /**
  45133. * Adds a mesh to the octree
  45134. * @param entry Mesh to add to the octree
  45135. */
  45136. addMesh(entry: T): void;
  45137. /**
  45138. * Remove an element from the octree
  45139. * @param entry defines the element to remove
  45140. */
  45141. removeMesh(entry: T): void;
  45142. /**
  45143. * Selects an array of meshes within the frustum
  45144. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45145. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45146. * @returns array of meshes within the frustum
  45147. */
  45148. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45149. /**
  45150. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45151. * @param sphereCenter defines the bounding sphere center
  45152. * @param sphereRadius defines the bounding sphere radius
  45153. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45154. * @returns an array of objects that intersect the sphere
  45155. */
  45156. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45157. /**
  45158. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45159. * @param ray defines the ray to test with
  45160. * @returns array of intersected objects
  45161. */
  45162. intersectsRay(ray: Ray): SmartArray<T>;
  45163. /**
  45164. * Adds a mesh into the octree block if it intersects the block
  45165. */
  45166. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45167. /**
  45168. * Adds a submesh into the octree block if it intersects the block
  45169. */
  45170. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45171. }
  45172. }
  45173. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  45174. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  45175. import { Scene } from "babylonjs/scene";
  45176. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45178. import { Ray } from "babylonjs/Culling/ray";
  45179. import { Octree } from "babylonjs/Culling/Octrees/octree";
  45180. import { Collider } from "babylonjs/Collisions/collider";
  45181. module "babylonjs/scene" {
  45182. interface Scene {
  45183. /**
  45184. * @hidden
  45185. * Backing Filed
  45186. */
  45187. _selectionOctree: Octree<AbstractMesh>;
  45188. /**
  45189. * Gets the octree used to boost mesh selection (picking)
  45190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45191. */
  45192. selectionOctree: Octree<AbstractMesh>;
  45193. /**
  45194. * Creates or updates the octree used to boost selection (picking)
  45195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45196. * @param maxCapacity defines the maximum capacity per leaf
  45197. * @param maxDepth defines the maximum depth of the octree
  45198. * @returns an octree of AbstractMesh
  45199. */
  45200. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45201. }
  45202. }
  45203. module "babylonjs/Meshes/abstractMesh" {
  45204. interface AbstractMesh {
  45205. /**
  45206. * @hidden
  45207. * Backing Field
  45208. */
  45209. _submeshesOctree: Octree<SubMesh>;
  45210. /**
  45211. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45212. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45213. * @param maxCapacity defines the maximum size of each block (64 by default)
  45214. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45215. * @returns the new octree
  45216. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45218. */
  45219. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45220. }
  45221. }
  45222. /**
  45223. * Defines the octree scene component responsible to manage any octrees
  45224. * in a given scene.
  45225. */
  45226. export class OctreeSceneComponent {
  45227. /**
  45228. * The component name help to identify the component in the list of scene components.
  45229. */
  45230. readonly name: string;
  45231. /**
  45232. * The scene the component belongs to.
  45233. */
  45234. scene: Scene;
  45235. /**
  45236. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45237. */
  45238. readonly checksIsEnabled: boolean;
  45239. /**
  45240. * Creates a new instance of the component for the given scene
  45241. * @param scene Defines the scene to register the component in
  45242. */
  45243. constructor(scene: Scene);
  45244. /**
  45245. * Registers the component in a given scene
  45246. */
  45247. register(): void;
  45248. /**
  45249. * Return the list of active meshes
  45250. * @returns the list of active meshes
  45251. */
  45252. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45253. /**
  45254. * Return the list of active sub meshes
  45255. * @param mesh The mesh to get the candidates sub meshes from
  45256. * @returns the list of active sub meshes
  45257. */
  45258. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45259. private _tempRay;
  45260. /**
  45261. * Return the list of sub meshes intersecting with a given local ray
  45262. * @param mesh defines the mesh to find the submesh for
  45263. * @param localRay defines the ray in local space
  45264. * @returns the list of intersecting sub meshes
  45265. */
  45266. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45267. /**
  45268. * Return the list of sub meshes colliding with a collider
  45269. * @param mesh defines the mesh to find the submesh for
  45270. * @param collider defines the collider to evaluate the collision against
  45271. * @returns the list of colliding sub meshes
  45272. */
  45273. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45274. /**
  45275. * Rebuilds the elements related to this component in case of
  45276. * context lost for instance.
  45277. */
  45278. rebuild(): void;
  45279. /**
  45280. * Disposes the component and the associated ressources.
  45281. */
  45282. dispose(): void;
  45283. }
  45284. }
  45285. declare module "babylonjs/Culling/Octrees/index" {
  45286. export * from "babylonjs/Culling/Octrees/octree";
  45287. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45288. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45289. }
  45290. declare module "babylonjs/Culling/index" {
  45291. export * from "babylonjs/Culling/boundingBox";
  45292. export * from "babylonjs/Culling/boundingInfo";
  45293. export * from "babylonjs/Culling/boundingSphere";
  45294. export * from "babylonjs/Culling/Octrees/index";
  45295. export * from "babylonjs/Culling/ray";
  45296. }
  45297. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45298. import { IDisposable, Scene } from "babylonjs/scene";
  45299. import { Nullable } from "babylonjs/types";
  45300. import { Observable } from "babylonjs/Misc/observable";
  45301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45302. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45303. import { Camera } from "babylonjs/Cameras/camera";
  45304. /**
  45305. * Renders a layer on top of an existing scene
  45306. */
  45307. export class UtilityLayerRenderer implements IDisposable {
  45308. /** the original scene that will be rendered on top of */
  45309. originalScene: Scene;
  45310. private _pointerCaptures;
  45311. private _lastPointerEvents;
  45312. private static _DefaultUtilityLayer;
  45313. private static _DefaultKeepDepthUtilityLayer;
  45314. private _sharedGizmoLight;
  45315. private _renderCamera;
  45316. /**
  45317. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45318. * @returns the camera that is used when rendering the utility layer
  45319. */
  45320. getRenderCamera(): Nullable<Camera>;
  45321. /**
  45322. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45323. * @param cam the camera that should be used when rendering the utility layer
  45324. */
  45325. setRenderCamera(cam: Nullable<Camera>): void;
  45326. /**
  45327. * @hidden
  45328. * Light which used by gizmos to get light shading
  45329. */
  45330. _getSharedGizmoLight(): HemisphericLight;
  45331. /**
  45332. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45333. */
  45334. pickUtilitySceneFirst: boolean;
  45335. /**
  45336. * 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)
  45337. */
  45338. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45339. /**
  45340. * 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)
  45341. */
  45342. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45343. /**
  45344. * The scene that is rendered on top of the original scene
  45345. */
  45346. utilityLayerScene: Scene;
  45347. /**
  45348. * If the utility layer should automatically be rendered on top of existing scene
  45349. */
  45350. shouldRender: boolean;
  45351. /**
  45352. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45353. */
  45354. onlyCheckPointerDownEvents: boolean;
  45355. /**
  45356. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45357. */
  45358. processAllEvents: boolean;
  45359. /**
  45360. * Observable raised when the pointer move from the utility layer scene to the main scene
  45361. */
  45362. onPointerOutObservable: Observable<number>;
  45363. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45364. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45365. private _afterRenderObserver;
  45366. private _sceneDisposeObserver;
  45367. private _originalPointerObserver;
  45368. /**
  45369. * Instantiates a UtilityLayerRenderer
  45370. * @param originalScene the original scene that will be rendered on top of
  45371. * @param handleEvents boolean indicating if the utility layer should handle events
  45372. */
  45373. constructor(
  45374. /** the original scene that will be rendered on top of */
  45375. originalScene: Scene, handleEvents?: boolean);
  45376. private _notifyObservers;
  45377. /**
  45378. * Renders the utility layers scene on top of the original scene
  45379. */
  45380. render(): void;
  45381. /**
  45382. * Disposes of the renderer
  45383. */
  45384. dispose(): void;
  45385. private _updateCamera;
  45386. }
  45387. }
  45388. declare module "babylonjs/Gizmos/gizmo" {
  45389. import { Nullable } from "babylonjs/types";
  45390. import { IDisposable } from "babylonjs/scene";
  45391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45392. import { Mesh } from "babylonjs/Meshes/mesh";
  45393. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45394. /**
  45395. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45396. */
  45397. export class Gizmo implements IDisposable {
  45398. /** The utility layer the gizmo will be added to */
  45399. gizmoLayer: UtilityLayerRenderer;
  45400. /**
  45401. * The root mesh of the gizmo
  45402. */
  45403. _rootMesh: Mesh;
  45404. private _attachedMesh;
  45405. /**
  45406. * Ratio for the scale of the gizmo (Default: 1)
  45407. */
  45408. scaleRatio: number;
  45409. /**
  45410. * If a custom mesh has been set (Default: false)
  45411. */
  45412. protected _customMeshSet: boolean;
  45413. /**
  45414. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45415. * * When set, interactions will be enabled
  45416. */
  45417. attachedMesh: Nullable<AbstractMesh>;
  45418. /**
  45419. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45420. * @param mesh The mesh to replace the default mesh of the gizmo
  45421. */
  45422. setCustomMesh(mesh: Mesh): void;
  45423. /**
  45424. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45425. */
  45426. updateGizmoRotationToMatchAttachedMesh: boolean;
  45427. /**
  45428. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45429. */
  45430. updateGizmoPositionToMatchAttachedMesh: boolean;
  45431. /**
  45432. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45433. */
  45434. updateScale: boolean;
  45435. protected _interactionsEnabled: boolean;
  45436. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45437. private _beforeRenderObserver;
  45438. private _tempVector;
  45439. /**
  45440. * Creates a gizmo
  45441. * @param gizmoLayer The utility layer the gizmo will be added to
  45442. */
  45443. constructor(
  45444. /** The utility layer the gizmo will be added to */
  45445. gizmoLayer?: UtilityLayerRenderer);
  45446. /**
  45447. * Updates the gizmo to match the attached mesh's position/rotation
  45448. */
  45449. protected _update(): void;
  45450. /**
  45451. * Disposes of the gizmo
  45452. */
  45453. dispose(): void;
  45454. }
  45455. }
  45456. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45457. import { Observable } from "babylonjs/Misc/observable";
  45458. import { Nullable } from "babylonjs/types";
  45459. import { Vector3 } from "babylonjs/Maths/math.vector";
  45460. import { Color3 } from "babylonjs/Maths/math.color";
  45461. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45463. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45464. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45465. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45466. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45467. import { Scene } from "babylonjs/scene";
  45468. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45469. /**
  45470. * Single plane drag gizmo
  45471. */
  45472. export class PlaneDragGizmo extends Gizmo {
  45473. /**
  45474. * Drag behavior responsible for the gizmos dragging interactions
  45475. */
  45476. dragBehavior: PointerDragBehavior;
  45477. private _pointerObserver;
  45478. /**
  45479. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45480. */
  45481. snapDistance: number;
  45482. /**
  45483. * Event that fires each time the gizmo snaps to a new location.
  45484. * * snapDistance is the the change in distance
  45485. */
  45486. onSnapObservable: Observable<{
  45487. snapDistance: number;
  45488. }>;
  45489. private _plane;
  45490. private _coloredMaterial;
  45491. private _hoverMaterial;
  45492. private _isEnabled;
  45493. private _parent;
  45494. /** @hidden */
  45495. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45496. /** @hidden */
  45497. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45498. /**
  45499. * Creates a PlaneDragGizmo
  45500. * @param gizmoLayer The utility layer the gizmo will be added to
  45501. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45502. * @param color The color of the gizmo
  45503. */
  45504. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45505. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45506. /**
  45507. * If the gizmo is enabled
  45508. */
  45509. isEnabled: boolean;
  45510. /**
  45511. * Disposes of the gizmo
  45512. */
  45513. dispose(): void;
  45514. }
  45515. }
  45516. declare module "babylonjs/Gizmos/positionGizmo" {
  45517. import { Observable } from "babylonjs/Misc/observable";
  45518. import { Nullable } from "babylonjs/types";
  45519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45520. import { Mesh } from "babylonjs/Meshes/mesh";
  45521. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45522. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45523. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45524. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45525. /**
  45526. * Gizmo that enables dragging a mesh along 3 axis
  45527. */
  45528. export class PositionGizmo extends Gizmo {
  45529. /**
  45530. * Internal gizmo used for interactions on the x axis
  45531. */
  45532. xGizmo: AxisDragGizmo;
  45533. /**
  45534. * Internal gizmo used for interactions on the y axis
  45535. */
  45536. yGizmo: AxisDragGizmo;
  45537. /**
  45538. * Internal gizmo used for interactions on the z axis
  45539. */
  45540. zGizmo: AxisDragGizmo;
  45541. /**
  45542. * Internal gizmo used for interactions on the yz plane
  45543. */
  45544. xPlaneGizmo: PlaneDragGizmo;
  45545. /**
  45546. * Internal gizmo used for interactions on the xz plane
  45547. */
  45548. yPlaneGizmo: PlaneDragGizmo;
  45549. /**
  45550. * Internal gizmo used for interactions on the xy plane
  45551. */
  45552. zPlaneGizmo: PlaneDragGizmo;
  45553. /**
  45554. * private variables
  45555. */
  45556. private _meshAttached;
  45557. private _updateGizmoRotationToMatchAttachedMesh;
  45558. private _snapDistance;
  45559. private _scaleRatio;
  45560. /** Fires an event when any of it's sub gizmos are dragged */
  45561. onDragStartObservable: Observable<unknown>;
  45562. /** Fires an event when any of it's sub gizmos are released from dragging */
  45563. onDragEndObservable: Observable<unknown>;
  45564. /**
  45565. * If set to true, planar drag is enabled
  45566. */
  45567. private _planarGizmoEnabled;
  45568. attachedMesh: Nullable<AbstractMesh>;
  45569. /**
  45570. * Creates a PositionGizmo
  45571. * @param gizmoLayer The utility layer the gizmo will be added to
  45572. */
  45573. constructor(gizmoLayer?: UtilityLayerRenderer);
  45574. /**
  45575. * If the planar drag gizmo is enabled
  45576. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45577. */
  45578. planarGizmoEnabled: boolean;
  45579. updateGizmoRotationToMatchAttachedMesh: boolean;
  45580. /**
  45581. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45582. */
  45583. snapDistance: number;
  45584. /**
  45585. * Ratio for the scale of the gizmo (Default: 1)
  45586. */
  45587. scaleRatio: number;
  45588. /**
  45589. * Disposes of the gizmo
  45590. */
  45591. dispose(): void;
  45592. /**
  45593. * CustomMeshes are not supported by this gizmo
  45594. * @param mesh The mesh to replace the default mesh of the gizmo
  45595. */
  45596. setCustomMesh(mesh: Mesh): void;
  45597. }
  45598. }
  45599. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45600. import { Observable } from "babylonjs/Misc/observable";
  45601. import { Nullable } from "babylonjs/types";
  45602. import { Vector3 } from "babylonjs/Maths/math.vector";
  45603. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45605. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45606. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45607. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45608. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45609. import { Scene } from "babylonjs/scene";
  45610. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45611. import { Color3 } from "babylonjs/Maths/math.color";
  45612. /**
  45613. * Single axis drag gizmo
  45614. */
  45615. export class AxisDragGizmo extends Gizmo {
  45616. /**
  45617. * Drag behavior responsible for the gizmos dragging interactions
  45618. */
  45619. dragBehavior: PointerDragBehavior;
  45620. private _pointerObserver;
  45621. /**
  45622. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45623. */
  45624. snapDistance: number;
  45625. /**
  45626. * Event that fires each time the gizmo snaps to a new location.
  45627. * * snapDistance is the the change in distance
  45628. */
  45629. onSnapObservable: Observable<{
  45630. snapDistance: number;
  45631. }>;
  45632. private _isEnabled;
  45633. private _parent;
  45634. private _arrow;
  45635. private _coloredMaterial;
  45636. private _hoverMaterial;
  45637. /** @hidden */
  45638. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45639. /** @hidden */
  45640. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45641. /**
  45642. * Creates an AxisDragGizmo
  45643. * @param gizmoLayer The utility layer the gizmo will be added to
  45644. * @param dragAxis The axis which the gizmo will be able to drag on
  45645. * @param color The color of the gizmo
  45646. */
  45647. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45648. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45649. /**
  45650. * If the gizmo is enabled
  45651. */
  45652. isEnabled: boolean;
  45653. /**
  45654. * Disposes of the gizmo
  45655. */
  45656. dispose(): void;
  45657. }
  45658. }
  45659. declare module "babylonjs/Debug/axesViewer" {
  45660. import { Vector3 } from "babylonjs/Maths/math.vector";
  45661. import { Nullable } from "babylonjs/types";
  45662. import { Scene } from "babylonjs/scene";
  45663. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45664. /**
  45665. * The Axes viewer will show 3 axes in a specific point in space
  45666. */
  45667. export class AxesViewer {
  45668. private _xAxis;
  45669. private _yAxis;
  45670. private _zAxis;
  45671. private _scaleLinesFactor;
  45672. private _instanced;
  45673. /**
  45674. * Gets the hosting scene
  45675. */
  45676. scene: Scene;
  45677. /**
  45678. * Gets or sets a number used to scale line length
  45679. */
  45680. scaleLines: number;
  45681. /** Gets the node hierarchy used to render x-axis */
  45682. readonly xAxis: TransformNode;
  45683. /** Gets the node hierarchy used to render y-axis */
  45684. readonly yAxis: TransformNode;
  45685. /** Gets the node hierarchy used to render z-axis */
  45686. readonly zAxis: TransformNode;
  45687. /**
  45688. * Creates a new AxesViewer
  45689. * @param scene defines the hosting scene
  45690. * @param scaleLines defines a number used to scale line length (1 by default)
  45691. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45692. * @param xAxis defines the node hierarchy used to render the x-axis
  45693. * @param yAxis defines the node hierarchy used to render the y-axis
  45694. * @param zAxis defines the node hierarchy used to render the z-axis
  45695. */
  45696. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45697. /**
  45698. * Force the viewer to update
  45699. * @param position defines the position of the viewer
  45700. * @param xaxis defines the x axis of the viewer
  45701. * @param yaxis defines the y axis of the viewer
  45702. * @param zaxis defines the z axis of the viewer
  45703. */
  45704. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45705. /**
  45706. * Creates an instance of this axes viewer.
  45707. * @returns a new axes viewer with instanced meshes
  45708. */
  45709. createInstance(): AxesViewer;
  45710. /** Releases resources */
  45711. dispose(): void;
  45712. private static _SetRenderingGroupId;
  45713. }
  45714. }
  45715. declare module "babylonjs/Debug/boneAxesViewer" {
  45716. import { Nullable } from "babylonjs/types";
  45717. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45718. import { Vector3 } from "babylonjs/Maths/math.vector";
  45719. import { Mesh } from "babylonjs/Meshes/mesh";
  45720. import { Bone } from "babylonjs/Bones/bone";
  45721. import { Scene } from "babylonjs/scene";
  45722. /**
  45723. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45724. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45725. */
  45726. export class BoneAxesViewer extends AxesViewer {
  45727. /**
  45728. * Gets or sets the target mesh where to display the axes viewer
  45729. */
  45730. mesh: Nullable<Mesh>;
  45731. /**
  45732. * Gets or sets the target bone where to display the axes viewer
  45733. */
  45734. bone: Nullable<Bone>;
  45735. /** Gets current position */
  45736. pos: Vector3;
  45737. /** Gets direction of X axis */
  45738. xaxis: Vector3;
  45739. /** Gets direction of Y axis */
  45740. yaxis: Vector3;
  45741. /** Gets direction of Z axis */
  45742. zaxis: Vector3;
  45743. /**
  45744. * Creates a new BoneAxesViewer
  45745. * @param scene defines the hosting scene
  45746. * @param bone defines the target bone
  45747. * @param mesh defines the target mesh
  45748. * @param scaleLines defines a scaling factor for line length (1 by default)
  45749. */
  45750. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45751. /**
  45752. * Force the viewer to update
  45753. */
  45754. update(): void;
  45755. /** Releases resources */
  45756. dispose(): void;
  45757. }
  45758. }
  45759. declare module "babylonjs/Debug/debugLayer" {
  45760. import { Scene } from "babylonjs/scene";
  45761. /**
  45762. * Interface used to define scene explorer extensibility option
  45763. */
  45764. export interface IExplorerExtensibilityOption {
  45765. /**
  45766. * Define the option label
  45767. */
  45768. label: string;
  45769. /**
  45770. * Defines the action to execute on click
  45771. */
  45772. action: (entity: any) => void;
  45773. }
  45774. /**
  45775. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45776. */
  45777. export interface IExplorerExtensibilityGroup {
  45778. /**
  45779. * Defines a predicate to test if a given type mut be extended
  45780. */
  45781. predicate: (entity: any) => boolean;
  45782. /**
  45783. * Gets the list of options added to a type
  45784. */
  45785. entries: IExplorerExtensibilityOption[];
  45786. }
  45787. /**
  45788. * Interface used to define the options to use to create the Inspector
  45789. */
  45790. export interface IInspectorOptions {
  45791. /**
  45792. * Display in overlay mode (default: false)
  45793. */
  45794. overlay?: boolean;
  45795. /**
  45796. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45797. */
  45798. globalRoot?: HTMLElement;
  45799. /**
  45800. * Display the Scene explorer
  45801. */
  45802. showExplorer?: boolean;
  45803. /**
  45804. * Display the property inspector
  45805. */
  45806. showInspector?: boolean;
  45807. /**
  45808. * Display in embed mode (both panes on the right)
  45809. */
  45810. embedMode?: boolean;
  45811. /**
  45812. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45813. */
  45814. handleResize?: boolean;
  45815. /**
  45816. * Allow the panes to popup (default: true)
  45817. */
  45818. enablePopup?: boolean;
  45819. /**
  45820. * Allow the panes to be closed by users (default: true)
  45821. */
  45822. enableClose?: boolean;
  45823. /**
  45824. * Optional list of extensibility entries
  45825. */
  45826. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45827. /**
  45828. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45829. */
  45830. inspectorURL?: string;
  45831. }
  45832. module "babylonjs/scene" {
  45833. interface Scene {
  45834. /**
  45835. * @hidden
  45836. * Backing field
  45837. */
  45838. _debugLayer: DebugLayer;
  45839. /**
  45840. * Gets the debug layer (aka Inspector) associated with the scene
  45841. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45842. */
  45843. debugLayer: DebugLayer;
  45844. }
  45845. }
  45846. /**
  45847. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45848. * what is happening in your scene
  45849. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45850. */
  45851. export class DebugLayer {
  45852. /**
  45853. * Define the url to get the inspector script from.
  45854. * By default it uses the babylonjs CDN.
  45855. * @ignoreNaming
  45856. */
  45857. static InspectorURL: string;
  45858. private _scene;
  45859. private BJSINSPECTOR;
  45860. private _onPropertyChangedObservable?;
  45861. /**
  45862. * Observable triggered when a property is changed through the inspector.
  45863. */
  45864. readonly onPropertyChangedObservable: any;
  45865. /**
  45866. * Instantiates a new debug layer.
  45867. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45868. * what is happening in your scene
  45869. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45870. * @param scene Defines the scene to inspect
  45871. */
  45872. constructor(scene: Scene);
  45873. /** Creates the inspector window. */
  45874. private _createInspector;
  45875. /**
  45876. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45877. * @param entity defines the entity to select
  45878. * @param lineContainerTitle defines the specific block to highlight
  45879. */
  45880. select(entity: any, lineContainerTitle?: string): void;
  45881. /** Get the inspector from bundle or global */
  45882. private _getGlobalInspector;
  45883. /**
  45884. * Get if the inspector is visible or not.
  45885. * @returns true if visible otherwise, false
  45886. */
  45887. isVisible(): boolean;
  45888. /**
  45889. * Hide the inspector and close its window.
  45890. */
  45891. hide(): void;
  45892. /**
  45893. * Launch the debugLayer.
  45894. * @param config Define the configuration of the inspector
  45895. * @return a promise fulfilled when the debug layer is visible
  45896. */
  45897. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45898. }
  45899. }
  45900. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45901. import { Nullable } from "babylonjs/types";
  45902. import { Scene } from "babylonjs/scene";
  45903. import { Vector4 } from "babylonjs/Maths/math.vector";
  45904. import { Color4 } from "babylonjs/Maths/math.color";
  45905. import { Mesh } from "babylonjs/Meshes/mesh";
  45906. /**
  45907. * Class containing static functions to help procedurally build meshes
  45908. */
  45909. export class BoxBuilder {
  45910. /**
  45911. * Creates a box mesh
  45912. * * The parameter `size` sets the size (float) of each box side (default 1)
  45913. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45914. * * 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)
  45915. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45919. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45920. * @param name defines the name of the mesh
  45921. * @param options defines the options used to create the mesh
  45922. * @param scene defines the hosting scene
  45923. * @returns the box mesh
  45924. */
  45925. static CreateBox(name: string, options: {
  45926. size?: number;
  45927. width?: number;
  45928. height?: number;
  45929. depth?: number;
  45930. faceUV?: Vector4[];
  45931. faceColors?: Color4[];
  45932. sideOrientation?: number;
  45933. frontUVs?: Vector4;
  45934. backUVs?: Vector4;
  45935. wrap?: boolean;
  45936. topBaseAt?: number;
  45937. bottomBaseAt?: number;
  45938. updatable?: boolean;
  45939. }, scene?: Nullable<Scene>): Mesh;
  45940. }
  45941. }
  45942. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45943. import { Vector4 } from "babylonjs/Maths/math.vector";
  45944. import { Mesh } from "babylonjs/Meshes/mesh";
  45945. import { Scene } from "babylonjs/scene";
  45946. import { Nullable } from "babylonjs/types";
  45947. /**
  45948. * Class containing static functions to help procedurally build meshes
  45949. */
  45950. export class SphereBuilder {
  45951. /**
  45952. * Creates a sphere mesh
  45953. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45954. * * 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`)
  45955. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45956. * * 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
  45957. * * 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)
  45958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45961. * @param name defines the name of the mesh
  45962. * @param options defines the options used to create the mesh
  45963. * @param scene defines the hosting scene
  45964. * @returns the sphere mesh
  45965. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45966. */
  45967. static CreateSphere(name: string, options: {
  45968. segments?: number;
  45969. diameter?: number;
  45970. diameterX?: number;
  45971. diameterY?: number;
  45972. diameterZ?: number;
  45973. arc?: number;
  45974. slice?: number;
  45975. sideOrientation?: number;
  45976. frontUVs?: Vector4;
  45977. backUVs?: Vector4;
  45978. updatable?: boolean;
  45979. }, scene?: Nullable<Scene>): Mesh;
  45980. }
  45981. }
  45982. declare module "babylonjs/Debug/physicsViewer" {
  45983. import { Nullable } from "babylonjs/types";
  45984. import { Scene } from "babylonjs/scene";
  45985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45986. import { Mesh } from "babylonjs/Meshes/mesh";
  45987. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45988. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45989. /**
  45990. * Used to show the physics impostor around the specific mesh
  45991. */
  45992. export class PhysicsViewer {
  45993. /** @hidden */
  45994. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45995. /** @hidden */
  45996. protected _meshes: Array<Nullable<AbstractMesh>>;
  45997. /** @hidden */
  45998. protected _scene: Nullable<Scene>;
  45999. /** @hidden */
  46000. protected _numMeshes: number;
  46001. /** @hidden */
  46002. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46003. private _renderFunction;
  46004. private _utilityLayer;
  46005. private _debugBoxMesh;
  46006. private _debugSphereMesh;
  46007. private _debugCylinderMesh;
  46008. private _debugMaterial;
  46009. private _debugMeshMeshes;
  46010. /**
  46011. * Creates a new PhysicsViewer
  46012. * @param scene defines the hosting scene
  46013. */
  46014. constructor(scene: Scene);
  46015. /** @hidden */
  46016. protected _updateDebugMeshes(): void;
  46017. /**
  46018. * Renders a specified physic impostor
  46019. * @param impostor defines the impostor to render
  46020. * @param targetMesh defines the mesh represented by the impostor
  46021. * @returns the new debug mesh used to render the impostor
  46022. */
  46023. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46024. /**
  46025. * Hides a specified physic impostor
  46026. * @param impostor defines the impostor to hide
  46027. */
  46028. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46029. private _getDebugMaterial;
  46030. private _getDebugBoxMesh;
  46031. private _getDebugSphereMesh;
  46032. private _getDebugCylinderMesh;
  46033. private _getDebugMeshMesh;
  46034. private _getDebugMesh;
  46035. /** Releases all resources */
  46036. dispose(): void;
  46037. }
  46038. }
  46039. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46040. import { Vector3 } from "babylonjs/Maths/math.vector";
  46041. import { Color4 } from "babylonjs/Maths/math.color";
  46042. import { Nullable } from "babylonjs/types";
  46043. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46044. import { Scene } from "babylonjs/scene";
  46045. /**
  46046. * Class containing static functions to help procedurally build meshes
  46047. */
  46048. export class LinesBuilder {
  46049. /**
  46050. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46051. * * 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
  46052. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46053. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46054. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46055. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46056. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46057. * * 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
  46058. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46061. * @param name defines the name of the new line system
  46062. * @param options defines the options used to create the line system
  46063. * @param scene defines the hosting scene
  46064. * @returns a new line system mesh
  46065. */
  46066. static CreateLineSystem(name: string, options: {
  46067. lines: Vector3[][];
  46068. updatable?: boolean;
  46069. instance?: Nullable<LinesMesh>;
  46070. colors?: Nullable<Color4[][]>;
  46071. useVertexAlpha?: boolean;
  46072. }, scene: Nullable<Scene>): LinesMesh;
  46073. /**
  46074. * Creates a line mesh
  46075. * 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
  46076. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46077. * * The parameter `points` is an array successive Vector3
  46078. * * 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
  46079. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46080. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46081. * * When updating an instance, remember that only point positions can change, not the number of points
  46082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46084. * @param name defines the name of the new line system
  46085. * @param options defines the options used to create the line system
  46086. * @param scene defines the hosting scene
  46087. * @returns a new line mesh
  46088. */
  46089. static CreateLines(name: string, options: {
  46090. points: Vector3[];
  46091. updatable?: boolean;
  46092. instance?: Nullable<LinesMesh>;
  46093. colors?: Color4[];
  46094. useVertexAlpha?: boolean;
  46095. }, scene?: Nullable<Scene>): LinesMesh;
  46096. /**
  46097. * Creates a dashed line mesh
  46098. * * 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
  46099. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46100. * * The parameter `points` is an array successive Vector3
  46101. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46102. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46103. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46104. * * 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
  46105. * * When updating an instance, remember that only point positions can change, not the number of points
  46106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46107. * @param name defines the name of the mesh
  46108. * @param options defines the options used to create the mesh
  46109. * @param scene defines the hosting scene
  46110. * @returns the dashed line mesh
  46111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46112. */
  46113. static CreateDashedLines(name: string, options: {
  46114. points: Vector3[];
  46115. dashSize?: number;
  46116. gapSize?: number;
  46117. dashNb?: number;
  46118. updatable?: boolean;
  46119. instance?: LinesMesh;
  46120. }, scene?: Nullable<Scene>): LinesMesh;
  46121. }
  46122. }
  46123. declare module "babylonjs/Debug/rayHelper" {
  46124. import { Nullable } from "babylonjs/types";
  46125. import { Ray } from "babylonjs/Culling/ray";
  46126. import { Vector3 } from "babylonjs/Maths/math.vector";
  46127. import { Color3 } from "babylonjs/Maths/math.color";
  46128. import { Scene } from "babylonjs/scene";
  46129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46130. import "babylonjs/Meshes/Builders/linesBuilder";
  46131. /**
  46132. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46133. * in order to better appreciate the issue one might have.
  46134. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46135. */
  46136. export class RayHelper {
  46137. /**
  46138. * Defines the ray we are currently tryin to visualize.
  46139. */
  46140. ray: Nullable<Ray>;
  46141. private _renderPoints;
  46142. private _renderLine;
  46143. private _renderFunction;
  46144. private _scene;
  46145. private _updateToMeshFunction;
  46146. private _attachedToMesh;
  46147. private _meshSpaceDirection;
  46148. private _meshSpaceOrigin;
  46149. /**
  46150. * Helper function to create a colored helper in a scene in one line.
  46151. * @param ray Defines the ray we are currently tryin to visualize
  46152. * @param scene Defines the scene the ray is used in
  46153. * @param color Defines the color we want to see the ray in
  46154. * @returns The newly created ray helper.
  46155. */
  46156. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46157. /**
  46158. * Instantiate a new ray helper.
  46159. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46160. * in order to better appreciate the issue one might have.
  46161. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46162. * @param ray Defines the ray we are currently tryin to visualize
  46163. */
  46164. constructor(ray: Ray);
  46165. /**
  46166. * Shows the ray we are willing to debug.
  46167. * @param scene Defines the scene the ray needs to be rendered in
  46168. * @param color Defines the color the ray needs to be rendered in
  46169. */
  46170. show(scene: Scene, color?: Color3): void;
  46171. /**
  46172. * Hides the ray we are debugging.
  46173. */
  46174. hide(): void;
  46175. private _render;
  46176. /**
  46177. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46178. * @param mesh Defines the mesh we want the helper attached to
  46179. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46180. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46181. * @param length Defines the length of the ray
  46182. */
  46183. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46184. /**
  46185. * Detach the ray helper from the mesh it has previously been attached to.
  46186. */
  46187. detachFromMesh(): void;
  46188. private _updateToMesh;
  46189. /**
  46190. * Dispose the helper and release its associated resources.
  46191. */
  46192. dispose(): void;
  46193. }
  46194. }
  46195. declare module "babylonjs/Debug/skeletonViewer" {
  46196. import { Color3 } from "babylonjs/Maths/math.color";
  46197. import { Scene } from "babylonjs/scene";
  46198. import { Nullable } from "babylonjs/types";
  46199. import { Skeleton } from "babylonjs/Bones/skeleton";
  46200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46201. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46202. /**
  46203. * Class used to render a debug view of a given skeleton
  46204. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46205. */
  46206. export class SkeletonViewer {
  46207. /** defines the skeleton to render */
  46208. skeleton: Skeleton;
  46209. /** defines the mesh attached to the skeleton */
  46210. mesh: AbstractMesh;
  46211. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46212. autoUpdateBonesMatrices: boolean;
  46213. /** defines the rendering group id to use with the viewer */
  46214. renderingGroupId: number;
  46215. /** Gets or sets the color used to render the skeleton */
  46216. color: Color3;
  46217. private _scene;
  46218. private _debugLines;
  46219. private _debugMesh;
  46220. private _isEnabled;
  46221. private _renderFunction;
  46222. private _utilityLayer;
  46223. /**
  46224. * Returns the mesh used to render the bones
  46225. */
  46226. readonly debugMesh: Nullable<LinesMesh>;
  46227. /**
  46228. * Creates a new SkeletonViewer
  46229. * @param skeleton defines the skeleton to render
  46230. * @param mesh defines the mesh attached to the skeleton
  46231. * @param scene defines the hosting scene
  46232. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46233. * @param renderingGroupId defines the rendering group id to use with the viewer
  46234. */
  46235. constructor(
  46236. /** defines the skeleton to render */
  46237. skeleton: Skeleton,
  46238. /** defines the mesh attached to the skeleton */
  46239. mesh: AbstractMesh, scene: Scene,
  46240. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46241. autoUpdateBonesMatrices?: boolean,
  46242. /** defines the rendering group id to use with the viewer */
  46243. renderingGroupId?: number);
  46244. /** Gets or sets a boolean indicating if the viewer is enabled */
  46245. isEnabled: boolean;
  46246. private _getBonePosition;
  46247. private _getLinesForBonesWithLength;
  46248. private _getLinesForBonesNoLength;
  46249. /** Update the viewer to sync with current skeleton state */
  46250. update(): void;
  46251. /** Release associated resources */
  46252. dispose(): void;
  46253. }
  46254. }
  46255. declare module "babylonjs/Debug/index" {
  46256. export * from "babylonjs/Debug/axesViewer";
  46257. export * from "babylonjs/Debug/boneAxesViewer";
  46258. export * from "babylonjs/Debug/debugLayer";
  46259. export * from "babylonjs/Debug/physicsViewer";
  46260. export * from "babylonjs/Debug/rayHelper";
  46261. export * from "babylonjs/Debug/skeletonViewer";
  46262. }
  46263. declare module "babylonjs/Engines/nullEngine" {
  46264. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46265. import { Scene } from "babylonjs/scene";
  46266. import { Engine } from "babylonjs/Engines/engine";
  46267. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46268. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46269. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46270. import { Effect } from "babylonjs/Materials/effect";
  46271. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46272. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46273. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46274. /**
  46275. * Options to create the null engine
  46276. */
  46277. export class NullEngineOptions {
  46278. /**
  46279. * Render width (Default: 512)
  46280. */
  46281. renderWidth: number;
  46282. /**
  46283. * Render height (Default: 256)
  46284. */
  46285. renderHeight: number;
  46286. /**
  46287. * Texture size (Default: 512)
  46288. */
  46289. textureSize: number;
  46290. /**
  46291. * If delta time between frames should be constant
  46292. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46293. */
  46294. deterministicLockstep: boolean;
  46295. /**
  46296. * Maximum about of steps between frames (Default: 4)
  46297. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46298. */
  46299. lockstepMaxSteps: number;
  46300. }
  46301. /**
  46302. * The null engine class provides support for headless version of babylon.js.
  46303. * This can be used in server side scenario or for testing purposes
  46304. */
  46305. export class NullEngine extends Engine {
  46306. private _options;
  46307. /**
  46308. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46309. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46310. * @returns true if engine is in deterministic lock step mode
  46311. */
  46312. isDeterministicLockStep(): boolean;
  46313. /**
  46314. * Gets the max steps when engine is running in deterministic lock step
  46315. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46316. * @returns the max steps
  46317. */
  46318. getLockstepMaxSteps(): number;
  46319. /**
  46320. * Gets the current hardware scaling level.
  46321. * By default the hardware scaling level is computed from the window device ratio.
  46322. * 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.
  46323. * @returns a number indicating the current hardware scaling level
  46324. */
  46325. getHardwareScalingLevel(): number;
  46326. constructor(options?: NullEngineOptions);
  46327. /**
  46328. * Creates a vertex buffer
  46329. * @param vertices the data for the vertex buffer
  46330. * @returns the new WebGL static buffer
  46331. */
  46332. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46333. /**
  46334. * Creates a new index buffer
  46335. * @param indices defines the content of the index buffer
  46336. * @param updatable defines if the index buffer must be updatable
  46337. * @returns a new webGL buffer
  46338. */
  46339. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46340. /**
  46341. * Clear the current render buffer or the current render target (if any is set up)
  46342. * @param color defines the color to use
  46343. * @param backBuffer defines if the back buffer must be cleared
  46344. * @param depth defines if the depth buffer must be cleared
  46345. * @param stencil defines if the stencil buffer must be cleared
  46346. */
  46347. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46348. /**
  46349. * Gets the current render width
  46350. * @param useScreen defines if screen size must be used (or the current render target if any)
  46351. * @returns a number defining the current render width
  46352. */
  46353. getRenderWidth(useScreen?: boolean): number;
  46354. /**
  46355. * Gets the current render height
  46356. * @param useScreen defines if screen size must be used (or the current render target if any)
  46357. * @returns a number defining the current render height
  46358. */
  46359. getRenderHeight(useScreen?: boolean): number;
  46360. /**
  46361. * Set the WebGL's viewport
  46362. * @param viewport defines the viewport element to be used
  46363. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46364. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46365. */
  46366. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46367. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46368. /**
  46369. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46370. * @param pipelineContext defines the pipeline context to use
  46371. * @param uniformsNames defines the list of uniform names
  46372. * @returns an array of webGL uniform locations
  46373. */
  46374. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46375. /**
  46376. * Gets the lsit of active attributes for a given webGL program
  46377. * @param pipelineContext defines the pipeline context to use
  46378. * @param attributesNames defines the list of attribute names to get
  46379. * @returns an array of indices indicating the offset of each attribute
  46380. */
  46381. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46382. /**
  46383. * Binds an effect to the webGL context
  46384. * @param effect defines the effect to bind
  46385. */
  46386. bindSamplers(effect: Effect): void;
  46387. /**
  46388. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46389. * @param effect defines the effect to activate
  46390. */
  46391. enableEffect(effect: Effect): void;
  46392. /**
  46393. * Set various states to the webGL context
  46394. * @param culling defines backface culling state
  46395. * @param zOffset defines the value to apply to zOffset (0 by default)
  46396. * @param force defines if states must be applied even if cache is up to date
  46397. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46398. */
  46399. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46400. /**
  46401. * Set the value of an uniform to an array of int32
  46402. * @param uniform defines the webGL uniform location where to store the value
  46403. * @param array defines the array of int32 to store
  46404. */
  46405. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46406. /**
  46407. * Set the value of an uniform to an array of int32 (stored as vec2)
  46408. * @param uniform defines the webGL uniform location where to store the value
  46409. * @param array defines the array of int32 to store
  46410. */
  46411. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46412. /**
  46413. * Set the value of an uniform to an array of int32 (stored as vec3)
  46414. * @param uniform defines the webGL uniform location where to store the value
  46415. * @param array defines the array of int32 to store
  46416. */
  46417. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46418. /**
  46419. * Set the value of an uniform to an array of int32 (stored as vec4)
  46420. * @param uniform defines the webGL uniform location where to store the value
  46421. * @param array defines the array of int32 to store
  46422. */
  46423. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46424. /**
  46425. * Set the value of an uniform to an array of float32
  46426. * @param uniform defines the webGL uniform location where to store the value
  46427. * @param array defines the array of float32 to store
  46428. */
  46429. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46430. /**
  46431. * Set the value of an uniform to an array of float32 (stored as vec2)
  46432. * @param uniform defines the webGL uniform location where to store the value
  46433. * @param array defines the array of float32 to store
  46434. */
  46435. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46436. /**
  46437. * Set the value of an uniform to an array of float32 (stored as vec3)
  46438. * @param uniform defines the webGL uniform location where to store the value
  46439. * @param array defines the array of float32 to store
  46440. */
  46441. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46442. /**
  46443. * Set the value of an uniform to an array of float32 (stored as vec4)
  46444. * @param uniform defines the webGL uniform location where to store the value
  46445. * @param array defines the array of float32 to store
  46446. */
  46447. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46448. /**
  46449. * Set the value of an uniform to an array of number
  46450. * @param uniform defines the webGL uniform location where to store the value
  46451. * @param array defines the array of number to store
  46452. */
  46453. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46454. /**
  46455. * Set the value of an uniform to an array of number (stored as vec2)
  46456. * @param uniform defines the webGL uniform location where to store the value
  46457. * @param array defines the array of number to store
  46458. */
  46459. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46460. /**
  46461. * Set the value of an uniform to an array of number (stored as vec3)
  46462. * @param uniform defines the webGL uniform location where to store the value
  46463. * @param array defines the array of number to store
  46464. */
  46465. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46466. /**
  46467. * Set the value of an uniform to an array of number (stored as vec4)
  46468. * @param uniform defines the webGL uniform location where to store the value
  46469. * @param array defines the array of number to store
  46470. */
  46471. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46472. /**
  46473. * Set the value of an uniform to an array of float32 (stored as matrices)
  46474. * @param uniform defines the webGL uniform location where to store the value
  46475. * @param matrices defines the array of float32 to store
  46476. */
  46477. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46478. /**
  46479. * Set the value of an uniform to a matrix (3x3)
  46480. * @param uniform defines the webGL uniform location where to store the value
  46481. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46482. */
  46483. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46484. /**
  46485. * Set the value of an uniform to a matrix (2x2)
  46486. * @param uniform defines the webGL uniform location where to store the value
  46487. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46488. */
  46489. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46490. /**
  46491. * Set the value of an uniform to a number (float)
  46492. * @param uniform defines the webGL uniform location where to store the value
  46493. * @param value defines the float number to store
  46494. */
  46495. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46496. /**
  46497. * Set the value of an uniform to a vec2
  46498. * @param uniform defines the webGL uniform location where to store the value
  46499. * @param x defines the 1st component of the value
  46500. * @param y defines the 2nd component of the value
  46501. */
  46502. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46503. /**
  46504. * Set the value of an uniform to a vec3
  46505. * @param uniform defines the webGL uniform location where to store the value
  46506. * @param x defines the 1st component of the value
  46507. * @param y defines the 2nd component of the value
  46508. * @param z defines the 3rd component of the value
  46509. */
  46510. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46511. /**
  46512. * Set the value of an uniform to a boolean
  46513. * @param uniform defines the webGL uniform location where to store the value
  46514. * @param bool defines the boolean to store
  46515. */
  46516. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46517. /**
  46518. * Set the value of an uniform to a vec4
  46519. * @param uniform defines the webGL uniform location where to store the value
  46520. * @param x defines the 1st component of the value
  46521. * @param y defines the 2nd component of the value
  46522. * @param z defines the 3rd component of the value
  46523. * @param w defines the 4th component of the value
  46524. */
  46525. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46526. /**
  46527. * Sets the current alpha mode
  46528. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46529. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46530. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46531. */
  46532. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46533. /**
  46534. * Bind webGl buffers directly to the webGL context
  46535. * @param vertexBuffers defines the vertex buffer to bind
  46536. * @param indexBuffer defines the index buffer to bind
  46537. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46538. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46539. * @param effect defines the effect associated with the vertex buffer
  46540. */
  46541. bindBuffers(vertexBuffers: {
  46542. [key: string]: VertexBuffer;
  46543. }, indexBuffer: DataBuffer, effect: Effect): void;
  46544. /**
  46545. * Force the entire cache to be cleared
  46546. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46547. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46548. */
  46549. wipeCaches(bruteForce?: boolean): void;
  46550. /**
  46551. * Send a draw order
  46552. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46553. * @param indexStart defines the starting index
  46554. * @param indexCount defines the number of index to draw
  46555. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46556. */
  46557. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46558. /**
  46559. * Draw a list of indexed primitives
  46560. * @param fillMode defines the primitive to use
  46561. * @param indexStart defines the starting index
  46562. * @param indexCount defines the number of index to draw
  46563. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46564. */
  46565. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46566. /**
  46567. * Draw a list of unindexed primitives
  46568. * @param fillMode defines the primitive to use
  46569. * @param verticesStart defines the index of first vertex to draw
  46570. * @param verticesCount defines the count of vertices to draw
  46571. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46572. */
  46573. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46574. /** @hidden */
  46575. _createTexture(): WebGLTexture;
  46576. /** @hidden */
  46577. _releaseTexture(texture: InternalTexture): void;
  46578. /**
  46579. * Usually called from Texture.ts.
  46580. * Passed information to create a WebGLTexture
  46581. * @param urlArg defines a value which contains one of the following:
  46582. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46583. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46584. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46585. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46586. * @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)
  46587. * @param scene needed for loading to the correct scene
  46588. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46589. * @param onLoad optional callback to be called upon successful completion
  46590. * @param onError optional callback to be called upon failure
  46591. * @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
  46592. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46593. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46594. * @param forcedExtension defines the extension to use to pick the right loader
  46595. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46596. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46597. */
  46598. 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;
  46599. /**
  46600. * Creates a new render target texture
  46601. * @param size defines the size of the texture
  46602. * @param options defines the options used to create the texture
  46603. * @returns a new render target texture stored in an InternalTexture
  46604. */
  46605. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46606. /**
  46607. * Update the sampling mode of a given texture
  46608. * @param samplingMode defines the required sampling mode
  46609. * @param texture defines the texture to update
  46610. */
  46611. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46612. /**
  46613. * Binds the frame buffer to the specified texture.
  46614. * @param texture The texture to render to or null for the default canvas
  46615. * @param faceIndex The face of the texture to render to in case of cube texture
  46616. * @param requiredWidth The width of the target to render to
  46617. * @param requiredHeight The height of the target to render to
  46618. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46619. * @param depthStencilTexture The depth stencil texture to use to render
  46620. * @param lodLevel defines le lod level to bind to the frame buffer
  46621. */
  46622. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46623. /**
  46624. * Unbind the current render target texture from the webGL context
  46625. * @param texture defines the render target texture to unbind
  46626. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46627. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46628. */
  46629. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46630. /**
  46631. * Creates a dynamic vertex buffer
  46632. * @param vertices the data for the dynamic vertex buffer
  46633. * @returns the new WebGL dynamic buffer
  46634. */
  46635. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46636. /**
  46637. * Update the content of a dynamic texture
  46638. * @param texture defines the texture to update
  46639. * @param canvas defines the canvas containing the source
  46640. * @param invertY defines if data must be stored with Y axis inverted
  46641. * @param premulAlpha defines if alpha is stored as premultiplied
  46642. * @param format defines the format of the data
  46643. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46644. */
  46645. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46646. /**
  46647. * Gets a boolean indicating if all created effects are ready
  46648. * @returns true if all effects are ready
  46649. */
  46650. areAllEffectsReady(): boolean;
  46651. /**
  46652. * @hidden
  46653. * Get the current error code of the webGL context
  46654. * @returns the error code
  46655. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46656. */
  46657. getError(): number;
  46658. /** @hidden */
  46659. _getUnpackAlignement(): number;
  46660. /** @hidden */
  46661. _unpackFlipY(value: boolean): void;
  46662. /**
  46663. * Update a dynamic index buffer
  46664. * @param indexBuffer defines the target index buffer
  46665. * @param indices defines the data to update
  46666. * @param offset defines the offset in the target index buffer where update should start
  46667. */
  46668. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46669. /**
  46670. * Updates a dynamic vertex buffer.
  46671. * @param vertexBuffer the vertex buffer to update
  46672. * @param vertices the data used to update the vertex buffer
  46673. * @param byteOffset the byte offset of the data (optional)
  46674. * @param byteLength the byte length of the data (optional)
  46675. */
  46676. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46677. /** @hidden */
  46678. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46679. /** @hidden */
  46680. _bindTexture(channel: number, texture: InternalTexture): void;
  46681. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46682. /**
  46683. * 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
  46684. */
  46685. releaseEffects(): void;
  46686. displayLoadingUI(): void;
  46687. hideLoadingUI(): void;
  46688. /** @hidden */
  46689. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46690. /** @hidden */
  46691. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46692. /** @hidden */
  46693. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46694. /** @hidden */
  46695. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46696. }
  46697. }
  46698. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46699. import { Nullable, int } from "babylonjs/types";
  46700. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46701. /** @hidden */
  46702. export class _OcclusionDataStorage {
  46703. /** @hidden */
  46704. occlusionInternalRetryCounter: number;
  46705. /** @hidden */
  46706. isOcclusionQueryInProgress: boolean;
  46707. /** @hidden */
  46708. isOccluded: boolean;
  46709. /** @hidden */
  46710. occlusionRetryCount: number;
  46711. /** @hidden */
  46712. occlusionType: number;
  46713. /** @hidden */
  46714. occlusionQueryAlgorithmType: number;
  46715. }
  46716. module "babylonjs/Engines/engine" {
  46717. interface Engine {
  46718. /**
  46719. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46720. * @return the new query
  46721. */
  46722. createQuery(): WebGLQuery;
  46723. /**
  46724. * Delete and release a webGL query
  46725. * @param query defines the query to delete
  46726. * @return the current engine
  46727. */
  46728. deleteQuery(query: WebGLQuery): Engine;
  46729. /**
  46730. * Check if a given query has resolved and got its value
  46731. * @param query defines the query to check
  46732. * @returns true if the query got its value
  46733. */
  46734. isQueryResultAvailable(query: WebGLQuery): boolean;
  46735. /**
  46736. * Gets the value of a given query
  46737. * @param query defines the query to check
  46738. * @returns the value of the query
  46739. */
  46740. getQueryResult(query: WebGLQuery): number;
  46741. /**
  46742. * Initiates an occlusion query
  46743. * @param algorithmType defines the algorithm to use
  46744. * @param query defines the query to use
  46745. * @returns the current engine
  46746. * @see http://doc.babylonjs.com/features/occlusionquery
  46747. */
  46748. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46749. /**
  46750. * Ends an occlusion query
  46751. * @see http://doc.babylonjs.com/features/occlusionquery
  46752. * @param algorithmType defines the algorithm to use
  46753. * @returns the current engine
  46754. */
  46755. endOcclusionQuery(algorithmType: number): Engine;
  46756. /**
  46757. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46758. * Please note that only one query can be issued at a time
  46759. * @returns a time token used to track the time span
  46760. */
  46761. startTimeQuery(): Nullable<_TimeToken>;
  46762. /**
  46763. * Ends a time query
  46764. * @param token defines the token used to measure the time span
  46765. * @returns the time spent (in ns)
  46766. */
  46767. endTimeQuery(token: _TimeToken): int;
  46768. /** @hidden */
  46769. _currentNonTimestampToken: Nullable<_TimeToken>;
  46770. /** @hidden */
  46771. _createTimeQuery(): WebGLQuery;
  46772. /** @hidden */
  46773. _deleteTimeQuery(query: WebGLQuery): void;
  46774. /** @hidden */
  46775. _getGlAlgorithmType(algorithmType: number): number;
  46776. /** @hidden */
  46777. _getTimeQueryResult(query: WebGLQuery): any;
  46778. /** @hidden */
  46779. _getTimeQueryAvailability(query: WebGLQuery): any;
  46780. }
  46781. }
  46782. module "babylonjs/Meshes/abstractMesh" {
  46783. interface AbstractMesh {
  46784. /**
  46785. * Backing filed
  46786. * @hidden
  46787. */
  46788. __occlusionDataStorage: _OcclusionDataStorage;
  46789. /**
  46790. * Access property
  46791. * @hidden
  46792. */
  46793. _occlusionDataStorage: _OcclusionDataStorage;
  46794. /**
  46795. * 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.
  46796. * The default value is -1 which means don't break the query and wait till the result
  46797. * @see http://doc.babylonjs.com/features/occlusionquery
  46798. */
  46799. occlusionRetryCount: number;
  46800. /**
  46801. * 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:
  46802. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46803. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46804. * * 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.
  46805. * @see http://doc.babylonjs.com/features/occlusionquery
  46806. */
  46807. occlusionType: number;
  46808. /**
  46809. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46810. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46811. * * 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.
  46812. * @see http://doc.babylonjs.com/features/occlusionquery
  46813. */
  46814. occlusionQueryAlgorithmType: number;
  46815. /**
  46816. * 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
  46817. * @see http://doc.babylonjs.com/features/occlusionquery
  46818. */
  46819. isOccluded: boolean;
  46820. /**
  46821. * Flag to check the progress status of the query
  46822. * @see http://doc.babylonjs.com/features/occlusionquery
  46823. */
  46824. isOcclusionQueryInProgress: boolean;
  46825. }
  46826. }
  46827. }
  46828. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46829. import { Nullable } from "babylonjs/types";
  46830. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46831. /** @hidden */
  46832. export var _forceTransformFeedbackToBundle: boolean;
  46833. module "babylonjs/Engines/engine" {
  46834. interface Engine {
  46835. /**
  46836. * Creates a webGL transform feedback object
  46837. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46838. * @returns the webGL transform feedback object
  46839. */
  46840. createTransformFeedback(): WebGLTransformFeedback;
  46841. /**
  46842. * Delete a webGL transform feedback object
  46843. * @param value defines the webGL transform feedback object to delete
  46844. */
  46845. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46846. /**
  46847. * Bind a webGL transform feedback object to the webgl context
  46848. * @param value defines the webGL transform feedback object to bind
  46849. */
  46850. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46851. /**
  46852. * Begins a transform feedback operation
  46853. * @param usePoints defines if points or triangles must be used
  46854. */
  46855. beginTransformFeedback(usePoints: boolean): void;
  46856. /**
  46857. * Ends a transform feedback operation
  46858. */
  46859. endTransformFeedback(): void;
  46860. /**
  46861. * Specify the varyings to use with transform feedback
  46862. * @param program defines the associated webGL program
  46863. * @param value defines the list of strings representing the varying names
  46864. */
  46865. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46866. /**
  46867. * Bind a webGL buffer for a transform feedback operation
  46868. * @param value defines the webGL buffer to bind
  46869. */
  46870. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46871. }
  46872. }
  46873. }
  46874. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46875. import { Scene } from "babylonjs/scene";
  46876. import { Engine } from "babylonjs/Engines/engine";
  46877. import { Texture } from "babylonjs/Materials/Textures/texture";
  46878. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46879. import "babylonjs/Engines/Extensions/engine.multiRender";
  46880. /**
  46881. * Creation options of the multi render target texture.
  46882. */
  46883. export interface IMultiRenderTargetOptions {
  46884. /**
  46885. * Define if the texture needs to create mip maps after render.
  46886. */
  46887. generateMipMaps?: boolean;
  46888. /**
  46889. * Define the types of all the draw buffers we want to create
  46890. */
  46891. types?: number[];
  46892. /**
  46893. * Define the sampling modes of all the draw buffers we want to create
  46894. */
  46895. samplingModes?: number[];
  46896. /**
  46897. * Define if a depth buffer is required
  46898. */
  46899. generateDepthBuffer?: boolean;
  46900. /**
  46901. * Define if a stencil buffer is required
  46902. */
  46903. generateStencilBuffer?: boolean;
  46904. /**
  46905. * Define if a depth texture is required instead of a depth buffer
  46906. */
  46907. generateDepthTexture?: boolean;
  46908. /**
  46909. * Define the number of desired draw buffers
  46910. */
  46911. textureCount?: number;
  46912. /**
  46913. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46914. */
  46915. doNotChangeAspectRatio?: boolean;
  46916. /**
  46917. * Define the default type of the buffers we are creating
  46918. */
  46919. defaultType?: number;
  46920. }
  46921. /**
  46922. * A multi render target, like a render target provides the ability to render to a texture.
  46923. * Unlike the render target, it can render to several draw buffers in one draw.
  46924. * This is specially interesting in deferred rendering or for any effects requiring more than
  46925. * just one color from a single pass.
  46926. */
  46927. export class MultiRenderTarget extends RenderTargetTexture {
  46928. private _internalTextures;
  46929. private _textures;
  46930. private _multiRenderTargetOptions;
  46931. /**
  46932. * Get if draw buffers are currently supported by the used hardware and browser.
  46933. */
  46934. readonly isSupported: boolean;
  46935. /**
  46936. * Get the list of textures generated by the multi render target.
  46937. */
  46938. readonly textures: Texture[];
  46939. /**
  46940. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46941. */
  46942. readonly depthTexture: Texture;
  46943. /**
  46944. * Set the wrapping mode on U of all the textures we are rendering to.
  46945. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46946. */
  46947. wrapU: number;
  46948. /**
  46949. * Set the wrapping mode on V of all the textures we are rendering to.
  46950. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46951. */
  46952. wrapV: number;
  46953. /**
  46954. * Instantiate a new multi render target texture.
  46955. * A multi render target, like a render target provides the ability to render to a texture.
  46956. * Unlike the render target, it can render to several draw buffers in one draw.
  46957. * This is specially interesting in deferred rendering or for any effects requiring more than
  46958. * just one color from a single pass.
  46959. * @param name Define the name of the texture
  46960. * @param size Define the size of the buffers to render to
  46961. * @param count Define the number of target we are rendering into
  46962. * @param scene Define the scene the texture belongs to
  46963. * @param options Define the options used to create the multi render target
  46964. */
  46965. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46966. /** @hidden */
  46967. _rebuild(): void;
  46968. private _createInternalTextures;
  46969. private _createTextures;
  46970. /**
  46971. * Define the number of samples used if MSAA is enabled.
  46972. */
  46973. samples: number;
  46974. /**
  46975. * Resize all the textures in the multi render target.
  46976. * Be carrefull as it will recreate all the data in the new texture.
  46977. * @param size Define the new size
  46978. */
  46979. resize(size: any): void;
  46980. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46981. /**
  46982. * Dispose the render targets and their associated resources
  46983. */
  46984. dispose(): void;
  46985. /**
  46986. * Release all the underlying texture used as draw buffers.
  46987. */
  46988. releaseInternalTextures(): void;
  46989. }
  46990. }
  46991. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46992. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46993. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46994. import { Nullable } from "babylonjs/types";
  46995. module "babylonjs/Engines/thinEngine" {
  46996. interface ThinEngine {
  46997. /**
  46998. * Unbind a list of render target textures from the webGL context
  46999. * This is used only when drawBuffer extension or webGL2 are active
  47000. * @param textures defines the render target textures to unbind
  47001. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47002. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47003. */
  47004. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47005. /**
  47006. * Create a multi render target texture
  47007. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47008. * @param size defines the size of the texture
  47009. * @param options defines the creation options
  47010. * @returns the cube texture as an InternalTexture
  47011. */
  47012. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47013. /**
  47014. * Update the sample count for a given multiple render target texture
  47015. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47016. * @param textures defines the textures to update
  47017. * @param samples defines the sample count to set
  47018. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47019. */
  47020. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47021. }
  47022. }
  47023. }
  47024. declare module "babylonjs/Engines/Extensions/engine.views" {
  47025. import { Camera } from "babylonjs/Cameras/camera";
  47026. import { Nullable } from "babylonjs/types";
  47027. /**
  47028. * Class used to define an additional view for the engine
  47029. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47030. */
  47031. export class EngineView {
  47032. /** Defines the canvas where to render the view */
  47033. target: HTMLCanvasElement;
  47034. /** Defines an optional camera used to render the view (will use active camera else) */
  47035. camera?: Camera;
  47036. }
  47037. module "babylonjs/Engines/engine" {
  47038. interface Engine {
  47039. /**
  47040. * Gets or sets the HTML element to use for attaching events
  47041. */
  47042. inputElement: Nullable<HTMLElement>;
  47043. /**
  47044. * Gets the current engine view
  47045. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47046. */
  47047. activeView: Nullable<EngineView>;
  47048. /** Gets or sets the list of views */
  47049. views: EngineView[];
  47050. /**
  47051. * Register a new child canvas
  47052. * @param canvas defines the canvas to register
  47053. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47054. * @returns the associated view
  47055. */
  47056. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47057. /**
  47058. * Remove a registered child canvas
  47059. * @param canvas defines the canvas to remove
  47060. * @returns the current engine
  47061. */
  47062. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47063. }
  47064. }
  47065. }
  47066. declare module "babylonjs/Engines/Extensions/index" {
  47067. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  47068. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  47069. export * from "babylonjs/Engines/Extensions/engine.multiview";
  47070. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  47071. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47072. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  47073. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  47074. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  47075. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  47076. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47077. export * from "babylonjs/Engines/Extensions/engine.webVR";
  47078. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  47079. export * from "babylonjs/Engines/Extensions/engine.views";
  47080. }
  47081. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  47082. import { Nullable } from "babylonjs/types";
  47083. /**
  47084. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47085. */
  47086. export interface CubeMapInfo {
  47087. /**
  47088. * The pixel array for the front face.
  47089. * This is stored in format, left to right, up to down format.
  47090. */
  47091. front: Nullable<ArrayBufferView>;
  47092. /**
  47093. * The pixel array for the back face.
  47094. * This is stored in format, left to right, up to down format.
  47095. */
  47096. back: Nullable<ArrayBufferView>;
  47097. /**
  47098. * The pixel array for the left face.
  47099. * This is stored in format, left to right, up to down format.
  47100. */
  47101. left: Nullable<ArrayBufferView>;
  47102. /**
  47103. * The pixel array for the right face.
  47104. * This is stored in format, left to right, up to down format.
  47105. */
  47106. right: Nullable<ArrayBufferView>;
  47107. /**
  47108. * The pixel array for the up face.
  47109. * This is stored in format, left to right, up to down format.
  47110. */
  47111. up: Nullable<ArrayBufferView>;
  47112. /**
  47113. * The pixel array for the down face.
  47114. * This is stored in format, left to right, up to down format.
  47115. */
  47116. down: Nullable<ArrayBufferView>;
  47117. /**
  47118. * The size of the cubemap stored.
  47119. *
  47120. * Each faces will be size * size pixels.
  47121. */
  47122. size: number;
  47123. /**
  47124. * The format of the texture.
  47125. *
  47126. * RGBA, RGB.
  47127. */
  47128. format: number;
  47129. /**
  47130. * The type of the texture data.
  47131. *
  47132. * UNSIGNED_INT, FLOAT.
  47133. */
  47134. type: number;
  47135. /**
  47136. * Specifies whether the texture is in gamma space.
  47137. */
  47138. gammaSpace: boolean;
  47139. }
  47140. /**
  47141. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47142. */
  47143. export class PanoramaToCubeMapTools {
  47144. private static FACE_FRONT;
  47145. private static FACE_BACK;
  47146. private static FACE_RIGHT;
  47147. private static FACE_LEFT;
  47148. private static FACE_DOWN;
  47149. private static FACE_UP;
  47150. /**
  47151. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47152. *
  47153. * @param float32Array The source data.
  47154. * @param inputWidth The width of the input panorama.
  47155. * @param inputHeight The height of the input panorama.
  47156. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47157. * @return The cubemap data
  47158. */
  47159. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47160. private static CreateCubemapTexture;
  47161. private static CalcProjectionSpherical;
  47162. }
  47163. }
  47164. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  47165. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47166. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47167. import { Nullable } from "babylonjs/types";
  47168. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47169. /**
  47170. * Helper class dealing with the extraction of spherical polynomial dataArray
  47171. * from a cube map.
  47172. */
  47173. export class CubeMapToSphericalPolynomialTools {
  47174. private static FileFaces;
  47175. /**
  47176. * Converts a texture to the according Spherical Polynomial data.
  47177. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47178. *
  47179. * @param texture The texture to extract the information from.
  47180. * @return The Spherical Polynomial data.
  47181. */
  47182. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47183. /**
  47184. * Converts a cubemap to the according Spherical Polynomial data.
  47185. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47186. *
  47187. * @param cubeInfo The Cube map to extract the information from.
  47188. * @return The Spherical Polynomial data.
  47189. */
  47190. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47191. }
  47192. }
  47193. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  47194. import { Nullable } from "babylonjs/types";
  47195. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47196. module "babylonjs/Materials/Textures/baseTexture" {
  47197. interface BaseTexture {
  47198. /**
  47199. * Get the polynomial representation of the texture data.
  47200. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47201. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47202. */
  47203. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47204. }
  47205. }
  47206. }
  47207. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47209. /** @hidden */
  47210. export var rgbdEncodePixelShader: {
  47211. name: string;
  47212. shader: string;
  47213. };
  47214. }
  47215. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47216. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47217. /** @hidden */
  47218. export var rgbdDecodePixelShader: {
  47219. name: string;
  47220. shader: string;
  47221. };
  47222. }
  47223. declare module "babylonjs/Misc/environmentTextureTools" {
  47224. import { Nullable } from "babylonjs/types";
  47225. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47226. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47227. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47228. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47229. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  47230. import "babylonjs/Shaders/rgbdEncode.fragment";
  47231. import "babylonjs/Shaders/rgbdDecode.fragment";
  47232. /**
  47233. * Raw texture data and descriptor sufficient for WebGL texture upload
  47234. */
  47235. export interface EnvironmentTextureInfo {
  47236. /**
  47237. * Version of the environment map
  47238. */
  47239. version: number;
  47240. /**
  47241. * Width of image
  47242. */
  47243. width: number;
  47244. /**
  47245. * Irradiance information stored in the file.
  47246. */
  47247. irradiance: any;
  47248. /**
  47249. * Specular information stored in the file.
  47250. */
  47251. specular: any;
  47252. }
  47253. /**
  47254. * Defines One Image in the file. It requires only the position in the file
  47255. * as well as the length.
  47256. */
  47257. interface BufferImageData {
  47258. /**
  47259. * Length of the image data.
  47260. */
  47261. length: number;
  47262. /**
  47263. * Position of the data from the null terminator delimiting the end of the JSON.
  47264. */
  47265. position: number;
  47266. }
  47267. /**
  47268. * Defines the specular data enclosed in the file.
  47269. * This corresponds to the version 1 of the data.
  47270. */
  47271. export interface EnvironmentTextureSpecularInfoV1 {
  47272. /**
  47273. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47274. */
  47275. specularDataPosition?: number;
  47276. /**
  47277. * This contains all the images data needed to reconstruct the cubemap.
  47278. */
  47279. mipmaps: Array<BufferImageData>;
  47280. /**
  47281. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47282. */
  47283. lodGenerationScale: number;
  47284. }
  47285. /**
  47286. * Sets of helpers addressing the serialization and deserialization of environment texture
  47287. * stored in a BabylonJS env file.
  47288. * Those files are usually stored as .env files.
  47289. */
  47290. export class EnvironmentTextureTools {
  47291. /**
  47292. * Magic number identifying the env file.
  47293. */
  47294. private static _MagicBytes;
  47295. /**
  47296. * Gets the environment info from an env file.
  47297. * @param data The array buffer containing the .env bytes.
  47298. * @returns the environment file info (the json header) if successfully parsed.
  47299. */
  47300. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47301. /**
  47302. * Creates an environment texture from a loaded cube texture.
  47303. * @param texture defines the cube texture to convert in env file
  47304. * @return a promise containing the environment data if succesfull.
  47305. */
  47306. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47307. /**
  47308. * Creates a JSON representation of the spherical data.
  47309. * @param texture defines the texture containing the polynomials
  47310. * @return the JSON representation of the spherical info
  47311. */
  47312. private static _CreateEnvTextureIrradiance;
  47313. /**
  47314. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47315. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47316. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47317. * @return the views described by info providing access to the underlying buffer
  47318. */
  47319. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47320. /**
  47321. * Uploads the texture info contained in the env file to the GPU.
  47322. * @param texture defines the internal texture to upload to
  47323. * @param arrayBuffer defines the buffer cotaining the data to load
  47324. * @param info defines the texture info retrieved through the GetEnvInfo method
  47325. * @returns a promise
  47326. */
  47327. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47328. private static _OnImageReadyAsync;
  47329. /**
  47330. * Uploads the levels of image data to the GPU.
  47331. * @param texture defines the internal texture to upload to
  47332. * @param imageData defines the array buffer views of image data [mipmap][face]
  47333. * @returns a promise
  47334. */
  47335. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47336. /**
  47337. * Uploads spherical polynomials information to the texture.
  47338. * @param texture defines the texture we are trying to upload the information to
  47339. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47340. */
  47341. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47342. /** @hidden */
  47343. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47344. }
  47345. }
  47346. declare module "babylonjs/Maths/math.vertexFormat" {
  47347. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47348. /**
  47349. * Contains position and normal vectors for a vertex
  47350. */
  47351. export class PositionNormalVertex {
  47352. /** the position of the vertex (defaut: 0,0,0) */
  47353. position: Vector3;
  47354. /** the normal of the vertex (defaut: 0,1,0) */
  47355. normal: Vector3;
  47356. /**
  47357. * Creates a PositionNormalVertex
  47358. * @param position the position of the vertex (defaut: 0,0,0)
  47359. * @param normal the normal of the vertex (defaut: 0,1,0)
  47360. */
  47361. constructor(
  47362. /** the position of the vertex (defaut: 0,0,0) */
  47363. position?: Vector3,
  47364. /** the normal of the vertex (defaut: 0,1,0) */
  47365. normal?: Vector3);
  47366. /**
  47367. * Clones the PositionNormalVertex
  47368. * @returns the cloned PositionNormalVertex
  47369. */
  47370. clone(): PositionNormalVertex;
  47371. }
  47372. /**
  47373. * Contains position, normal and uv vectors for a vertex
  47374. */
  47375. export class PositionNormalTextureVertex {
  47376. /** the position of the vertex (defaut: 0,0,0) */
  47377. position: Vector3;
  47378. /** the normal of the vertex (defaut: 0,1,0) */
  47379. normal: Vector3;
  47380. /** the uv of the vertex (default: 0,0) */
  47381. uv: Vector2;
  47382. /**
  47383. * Creates a PositionNormalTextureVertex
  47384. * @param position the position of the vertex (defaut: 0,0,0)
  47385. * @param normal the normal of the vertex (defaut: 0,1,0)
  47386. * @param uv the uv of the vertex (default: 0,0)
  47387. */
  47388. constructor(
  47389. /** the position of the vertex (defaut: 0,0,0) */
  47390. position?: Vector3,
  47391. /** the normal of the vertex (defaut: 0,1,0) */
  47392. normal?: Vector3,
  47393. /** the uv of the vertex (default: 0,0) */
  47394. uv?: Vector2);
  47395. /**
  47396. * Clones the PositionNormalTextureVertex
  47397. * @returns the cloned PositionNormalTextureVertex
  47398. */
  47399. clone(): PositionNormalTextureVertex;
  47400. }
  47401. }
  47402. declare module "babylonjs/Maths/math" {
  47403. export * from "babylonjs/Maths/math.axis";
  47404. export * from "babylonjs/Maths/math.color";
  47405. export * from "babylonjs/Maths/math.constants";
  47406. export * from "babylonjs/Maths/math.frustum";
  47407. export * from "babylonjs/Maths/math.path";
  47408. export * from "babylonjs/Maths/math.plane";
  47409. export * from "babylonjs/Maths/math.size";
  47410. export * from "babylonjs/Maths/math.vector";
  47411. export * from "babylonjs/Maths/math.vertexFormat";
  47412. export * from "babylonjs/Maths/math.viewport";
  47413. }
  47414. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47415. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47416. /** @hidden */
  47417. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47418. private _genericAttributeLocation;
  47419. private _varyingLocationCount;
  47420. private _varyingLocationMap;
  47421. private _replacements;
  47422. private _textureCount;
  47423. private _uniforms;
  47424. lineProcessor(line: string): string;
  47425. attributeProcessor(attribute: string): string;
  47426. varyingProcessor(varying: string, isFragment: boolean): string;
  47427. uniformProcessor(uniform: string): string;
  47428. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47429. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47430. }
  47431. }
  47432. declare module "babylonjs/Engines/nativeEngine" {
  47433. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47434. import { Engine } from "babylonjs/Engines/engine";
  47435. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47436. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47437. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47438. import { Effect } from "babylonjs/Materials/effect";
  47439. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47440. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47441. import { IColor4Like } from "babylonjs/Maths/math.like";
  47442. import { Scene } from "babylonjs/scene";
  47443. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47444. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47445. /**
  47446. * Container for accessors for natively-stored mesh data buffers.
  47447. */
  47448. class NativeDataBuffer extends DataBuffer {
  47449. /**
  47450. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47451. */
  47452. nativeIndexBuffer?: any;
  47453. /**
  47454. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47455. */
  47456. nativeVertexBuffer?: any;
  47457. }
  47458. /** @hidden */
  47459. class NativeTexture extends InternalTexture {
  47460. getInternalTexture(): InternalTexture;
  47461. getViewCount(): number;
  47462. }
  47463. /** @hidden */
  47464. export class NativeEngine extends Engine {
  47465. private readonly _native;
  47466. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47467. private readonly INVALID_HANDLE;
  47468. getHardwareScalingLevel(): number;
  47469. constructor();
  47470. /**
  47471. * Can be used to override the current requestAnimationFrame requester.
  47472. * @hidden
  47473. */
  47474. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47475. /**
  47476. * Override default engine behavior.
  47477. * @param color
  47478. * @param backBuffer
  47479. * @param depth
  47480. * @param stencil
  47481. */
  47482. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47483. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47484. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47485. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47486. recordVertexArrayObject(vertexBuffers: {
  47487. [key: string]: VertexBuffer;
  47488. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47489. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47490. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47491. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47492. /**
  47493. * Draw a list of indexed primitives
  47494. * @param fillMode defines the primitive to use
  47495. * @param indexStart defines the starting index
  47496. * @param indexCount defines the number of index to draw
  47497. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47498. */
  47499. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47500. /**
  47501. * Draw a list of unindexed primitives
  47502. * @param fillMode defines the primitive to use
  47503. * @param verticesStart defines the index of first vertex to draw
  47504. * @param verticesCount defines the count of vertices to draw
  47505. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47506. */
  47507. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47508. createPipelineContext(): IPipelineContext;
  47509. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47510. /** @hidden */
  47511. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47512. /** @hidden */
  47513. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47514. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47515. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47516. protected _setProgram(program: WebGLProgram): void;
  47517. _releaseEffect(effect: Effect): void;
  47518. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47519. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47520. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47521. bindSamplers(effect: Effect): void;
  47522. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47523. getRenderWidth(useScreen?: boolean): number;
  47524. getRenderHeight(useScreen?: boolean): number;
  47525. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47526. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47527. /**
  47528. * Set the z offset to apply to current rendering
  47529. * @param value defines the offset to apply
  47530. */
  47531. setZOffset(value: number): void;
  47532. /**
  47533. * Gets the current value of the zOffset
  47534. * @returns the current zOffset state
  47535. */
  47536. getZOffset(): number;
  47537. /**
  47538. * Enable or disable depth buffering
  47539. * @param enable defines the state to set
  47540. */
  47541. setDepthBuffer(enable: boolean): void;
  47542. /**
  47543. * Gets a boolean indicating if depth writing is enabled
  47544. * @returns the current depth writing state
  47545. */
  47546. getDepthWrite(): boolean;
  47547. /**
  47548. * Enable or disable depth writing
  47549. * @param enable defines the state to set
  47550. */
  47551. setDepthWrite(enable: boolean): void;
  47552. /**
  47553. * Enable or disable color writing
  47554. * @param enable defines the state to set
  47555. */
  47556. setColorWrite(enable: boolean): void;
  47557. /**
  47558. * Gets a boolean indicating if color writing is enabled
  47559. * @returns the current color writing state
  47560. */
  47561. getColorWrite(): boolean;
  47562. /**
  47563. * Sets alpha constants used by some alpha blending modes
  47564. * @param r defines the red component
  47565. * @param g defines the green component
  47566. * @param b defines the blue component
  47567. * @param a defines the alpha component
  47568. */
  47569. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47570. /**
  47571. * Sets the current alpha mode
  47572. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47573. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47574. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47575. */
  47576. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47577. /**
  47578. * Gets the current alpha mode
  47579. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47580. * @returns the current alpha mode
  47581. */
  47582. getAlphaMode(): number;
  47583. setInt(uniform: WebGLUniformLocation, int: number): void;
  47584. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47585. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47586. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47587. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47588. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47589. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47590. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47591. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47592. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47593. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47594. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47595. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47596. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47597. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47598. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47599. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47600. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47601. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47602. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47603. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47604. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47605. wipeCaches(bruteForce?: boolean): void;
  47606. _createTexture(): WebGLTexture;
  47607. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47608. /**
  47609. * Usually called from BABYLON.Texture.ts.
  47610. * Passed information to create a WebGLTexture
  47611. * @param urlArg defines a value which contains one of the following:
  47612. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47613. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47614. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47615. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47616. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47617. * @param scene needed for loading to the correct scene
  47618. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47619. * @param onLoad optional callback to be called upon successful completion
  47620. * @param onError optional callback to be called upon failure
  47621. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47622. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47623. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47624. * @param forcedExtension defines the extension to use to pick the right loader
  47625. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47626. */
  47627. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  47628. /**
  47629. * Creates a cube texture
  47630. * @param rootUrl defines the url where the files to load is located
  47631. * @param scene defines the current scene
  47632. * @param files defines the list of files to load (1 per face)
  47633. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47634. * @param onLoad defines an optional callback raised when the texture is loaded
  47635. * @param onError defines an optional callback raised if there is an issue to load the texture
  47636. * @param format defines the format of the data
  47637. * @param forcedExtension defines the extension to use to pick the right loader
  47638. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47639. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47640. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47641. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47642. * @returns the cube texture as an InternalTexture
  47643. */
  47644. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  47645. private _getSamplingFilter;
  47646. private static _GetNativeTextureFormat;
  47647. createRenderTargetTexture(size: number | {
  47648. width: number;
  47649. height: number;
  47650. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47651. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47652. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47653. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47654. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47655. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47656. /**
  47657. * Updates a dynamic vertex buffer.
  47658. * @param vertexBuffer the vertex buffer to update
  47659. * @param data the data used to update the vertex buffer
  47660. * @param byteOffset the byte offset of the data (optional)
  47661. * @param byteLength the byte length of the data (optional)
  47662. */
  47663. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47664. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47665. private _updateAnisotropicLevel;
  47666. private _getAddressMode;
  47667. /** @hidden */
  47668. _bindTexture(channel: number, texture: InternalTexture): void;
  47669. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47670. releaseEffects(): void;
  47671. /** @hidden */
  47672. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47673. /** @hidden */
  47674. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47675. /** @hidden */
  47676. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47677. /** @hidden */
  47678. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47679. }
  47680. }
  47681. declare module "babylonjs/Engines/index" {
  47682. export * from "babylonjs/Engines/constants";
  47683. export * from "babylonjs/Engines/engineCapabilities";
  47684. export * from "babylonjs/Engines/instancingAttributeInfo";
  47685. export * from "babylonjs/Engines/thinEngine";
  47686. export * from "babylonjs/Engines/engine";
  47687. export * from "babylonjs/Engines/engineStore";
  47688. export * from "babylonjs/Engines/nullEngine";
  47689. export * from "babylonjs/Engines/Extensions/index";
  47690. export * from "babylonjs/Engines/IPipelineContext";
  47691. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47692. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47693. export * from "babylonjs/Engines/nativeEngine";
  47694. }
  47695. declare module "babylonjs/Events/clipboardEvents" {
  47696. /**
  47697. * Gather the list of clipboard event types as constants.
  47698. */
  47699. export class ClipboardEventTypes {
  47700. /**
  47701. * The clipboard event is fired when a copy command is active (pressed).
  47702. */
  47703. static readonly COPY: number;
  47704. /**
  47705. * The clipboard event is fired when a cut command is active (pressed).
  47706. */
  47707. static readonly CUT: number;
  47708. /**
  47709. * The clipboard event is fired when a paste command is active (pressed).
  47710. */
  47711. static readonly PASTE: number;
  47712. }
  47713. /**
  47714. * This class is used to store clipboard related info for the onClipboardObservable event.
  47715. */
  47716. export class ClipboardInfo {
  47717. /**
  47718. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47719. */
  47720. type: number;
  47721. /**
  47722. * Defines the related dom event
  47723. */
  47724. event: ClipboardEvent;
  47725. /**
  47726. *Creates an instance of ClipboardInfo.
  47727. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47728. * @param event Defines the related dom event
  47729. */
  47730. constructor(
  47731. /**
  47732. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47733. */
  47734. type: number,
  47735. /**
  47736. * Defines the related dom event
  47737. */
  47738. event: ClipboardEvent);
  47739. /**
  47740. * Get the clipboard event's type from the keycode.
  47741. * @param keyCode Defines the keyCode for the current keyboard event.
  47742. * @return {number}
  47743. */
  47744. static GetTypeFromCharacter(keyCode: number): number;
  47745. }
  47746. }
  47747. declare module "babylonjs/Events/index" {
  47748. export * from "babylonjs/Events/keyboardEvents";
  47749. export * from "babylonjs/Events/pointerEvents";
  47750. export * from "babylonjs/Events/clipboardEvents";
  47751. }
  47752. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47753. import { Scene } from "babylonjs/scene";
  47754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47755. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47756. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47757. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47758. /**
  47759. * Google Daydream controller
  47760. */
  47761. export class DaydreamController extends WebVRController {
  47762. /**
  47763. * Base Url for the controller model.
  47764. */
  47765. static MODEL_BASE_URL: string;
  47766. /**
  47767. * File name for the controller model.
  47768. */
  47769. static MODEL_FILENAME: string;
  47770. /**
  47771. * Gamepad Id prefix used to identify Daydream Controller.
  47772. */
  47773. static readonly GAMEPAD_ID_PREFIX: string;
  47774. /**
  47775. * Creates a new DaydreamController from a gamepad
  47776. * @param vrGamepad the gamepad that the controller should be created from
  47777. */
  47778. constructor(vrGamepad: any);
  47779. /**
  47780. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47781. * @param scene scene in which to add meshes
  47782. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47783. */
  47784. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47785. /**
  47786. * Called once for each button that changed state since the last frame
  47787. * @param buttonIdx Which button index changed
  47788. * @param state New state of the button
  47789. * @param changes Which properties on the state changed since last frame
  47790. */
  47791. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47792. }
  47793. }
  47794. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47795. import { Scene } from "babylonjs/scene";
  47796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47797. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47798. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47799. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47800. /**
  47801. * Gear VR Controller
  47802. */
  47803. export class GearVRController extends WebVRController {
  47804. /**
  47805. * Base Url for the controller model.
  47806. */
  47807. static MODEL_BASE_URL: string;
  47808. /**
  47809. * File name for the controller model.
  47810. */
  47811. static MODEL_FILENAME: string;
  47812. /**
  47813. * Gamepad Id prefix used to identify this controller.
  47814. */
  47815. static readonly GAMEPAD_ID_PREFIX: string;
  47816. private readonly _buttonIndexToObservableNameMap;
  47817. /**
  47818. * Creates a new GearVRController from a gamepad
  47819. * @param vrGamepad the gamepad that the controller should be created from
  47820. */
  47821. constructor(vrGamepad: any);
  47822. /**
  47823. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47824. * @param scene scene in which to add meshes
  47825. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47826. */
  47827. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47828. /**
  47829. * Called once for each button that changed state since the last frame
  47830. * @param buttonIdx Which button index changed
  47831. * @param state New state of the button
  47832. * @param changes Which properties on the state changed since last frame
  47833. */
  47834. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47835. }
  47836. }
  47837. declare module "babylonjs/Gamepads/Controllers/index" {
  47838. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47839. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47840. export * from "babylonjs/Gamepads/Controllers/genericController";
  47841. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47842. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47843. export * from "babylonjs/Gamepads/Controllers/viveController";
  47844. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47845. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47846. }
  47847. declare module "babylonjs/Gamepads/index" {
  47848. export * from "babylonjs/Gamepads/Controllers/index";
  47849. export * from "babylonjs/Gamepads/gamepad";
  47850. export * from "babylonjs/Gamepads/gamepadManager";
  47851. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47852. export * from "babylonjs/Gamepads/xboxGamepad";
  47853. export * from "babylonjs/Gamepads/dualShockGamepad";
  47854. }
  47855. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47856. import { Scene } from "babylonjs/scene";
  47857. import { Vector4 } from "babylonjs/Maths/math.vector";
  47858. import { Color4 } from "babylonjs/Maths/math.color";
  47859. import { Mesh } from "babylonjs/Meshes/mesh";
  47860. import { Nullable } from "babylonjs/types";
  47861. /**
  47862. * Class containing static functions to help procedurally build meshes
  47863. */
  47864. export class PolyhedronBuilder {
  47865. /**
  47866. * Creates a polyhedron mesh
  47867. * * 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
  47868. * * The parameter `size` (positive float, default 1) sets the polygon size
  47869. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47870. * * 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`
  47871. * * 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
  47872. * * 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)`)
  47873. * * 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
  47874. * * 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
  47875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47878. * @param name defines the name of the mesh
  47879. * @param options defines the options used to create the mesh
  47880. * @param scene defines the hosting scene
  47881. * @returns the polyhedron mesh
  47882. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47883. */
  47884. static CreatePolyhedron(name: string, options: {
  47885. type?: number;
  47886. size?: number;
  47887. sizeX?: number;
  47888. sizeY?: number;
  47889. sizeZ?: number;
  47890. custom?: any;
  47891. faceUV?: Vector4[];
  47892. faceColors?: Color4[];
  47893. flat?: boolean;
  47894. updatable?: boolean;
  47895. sideOrientation?: number;
  47896. frontUVs?: Vector4;
  47897. backUVs?: Vector4;
  47898. }, scene?: Nullable<Scene>): Mesh;
  47899. }
  47900. }
  47901. declare module "babylonjs/Gizmos/scaleGizmo" {
  47902. import { Observable } from "babylonjs/Misc/observable";
  47903. import { Nullable } from "babylonjs/types";
  47904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47905. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47906. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47907. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47908. /**
  47909. * Gizmo that enables scaling a mesh along 3 axis
  47910. */
  47911. export class ScaleGizmo extends Gizmo {
  47912. /**
  47913. * Internal gizmo used for interactions on the x axis
  47914. */
  47915. xGizmo: AxisScaleGizmo;
  47916. /**
  47917. * Internal gizmo used for interactions on the y axis
  47918. */
  47919. yGizmo: AxisScaleGizmo;
  47920. /**
  47921. * Internal gizmo used for interactions on the z axis
  47922. */
  47923. zGizmo: AxisScaleGizmo;
  47924. /**
  47925. * Internal gizmo used to scale all axis equally
  47926. */
  47927. uniformScaleGizmo: AxisScaleGizmo;
  47928. private _meshAttached;
  47929. private _updateGizmoRotationToMatchAttachedMesh;
  47930. private _snapDistance;
  47931. private _scaleRatio;
  47932. private _uniformScalingMesh;
  47933. private _octahedron;
  47934. private _sensitivity;
  47935. /** Fires an event when any of it's sub gizmos are dragged */
  47936. onDragStartObservable: Observable<unknown>;
  47937. /** Fires an event when any of it's sub gizmos are released from dragging */
  47938. onDragEndObservable: Observable<unknown>;
  47939. attachedMesh: Nullable<AbstractMesh>;
  47940. /**
  47941. * Creates a ScaleGizmo
  47942. * @param gizmoLayer The utility layer the gizmo will be added to
  47943. */
  47944. constructor(gizmoLayer?: UtilityLayerRenderer);
  47945. updateGizmoRotationToMatchAttachedMesh: boolean;
  47946. /**
  47947. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47948. */
  47949. snapDistance: number;
  47950. /**
  47951. * Ratio for the scale of the gizmo (Default: 1)
  47952. */
  47953. scaleRatio: number;
  47954. /**
  47955. * Sensitivity factor for dragging (Default: 1)
  47956. */
  47957. sensitivity: number;
  47958. /**
  47959. * Disposes of the gizmo
  47960. */
  47961. dispose(): void;
  47962. }
  47963. }
  47964. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47965. import { Observable } from "babylonjs/Misc/observable";
  47966. import { Nullable } from "babylonjs/types";
  47967. import { Vector3 } from "babylonjs/Maths/math.vector";
  47968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47969. import { Mesh } from "babylonjs/Meshes/mesh";
  47970. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47971. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47972. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47973. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47974. import { Color3 } from "babylonjs/Maths/math.color";
  47975. /**
  47976. * Single axis scale gizmo
  47977. */
  47978. export class AxisScaleGizmo extends Gizmo {
  47979. /**
  47980. * Drag behavior responsible for the gizmos dragging interactions
  47981. */
  47982. dragBehavior: PointerDragBehavior;
  47983. private _pointerObserver;
  47984. /**
  47985. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47986. */
  47987. snapDistance: number;
  47988. /**
  47989. * Event that fires each time the gizmo snaps to a new location.
  47990. * * snapDistance is the the change in distance
  47991. */
  47992. onSnapObservable: Observable<{
  47993. snapDistance: number;
  47994. }>;
  47995. /**
  47996. * If the scaling operation should be done on all axis (default: false)
  47997. */
  47998. uniformScaling: boolean;
  47999. /**
  48000. * Custom sensitivity value for the drag strength
  48001. */
  48002. sensitivity: number;
  48003. private _isEnabled;
  48004. private _parent;
  48005. private _arrow;
  48006. private _coloredMaterial;
  48007. private _hoverMaterial;
  48008. /**
  48009. * Creates an AxisScaleGizmo
  48010. * @param gizmoLayer The utility layer the gizmo will be added to
  48011. * @param dragAxis The axis which the gizmo will be able to scale on
  48012. * @param color The color of the gizmo
  48013. */
  48014. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48015. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48016. /**
  48017. * If the gizmo is enabled
  48018. */
  48019. isEnabled: boolean;
  48020. /**
  48021. * Disposes of the gizmo
  48022. */
  48023. dispose(): void;
  48024. /**
  48025. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48026. * @param mesh The mesh to replace the default mesh of the gizmo
  48027. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48028. */
  48029. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48030. }
  48031. }
  48032. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  48033. import { Observable } from "babylonjs/Misc/observable";
  48034. import { Nullable } from "babylonjs/types";
  48035. import { Vector3 } from "babylonjs/Maths/math.vector";
  48036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48037. import { Mesh } from "babylonjs/Meshes/mesh";
  48038. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48039. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48040. import { Color3 } from "babylonjs/Maths/math.color";
  48041. import "babylonjs/Meshes/Builders/boxBuilder";
  48042. /**
  48043. * Bounding box gizmo
  48044. */
  48045. export class BoundingBoxGizmo extends Gizmo {
  48046. private _lineBoundingBox;
  48047. private _rotateSpheresParent;
  48048. private _scaleBoxesParent;
  48049. private _boundingDimensions;
  48050. private _renderObserver;
  48051. private _pointerObserver;
  48052. private _scaleDragSpeed;
  48053. private _tmpQuaternion;
  48054. private _tmpVector;
  48055. private _tmpRotationMatrix;
  48056. /**
  48057. * 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)
  48058. */
  48059. ignoreChildren: boolean;
  48060. /**
  48061. * 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)
  48062. */
  48063. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48064. /**
  48065. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48066. */
  48067. rotationSphereSize: number;
  48068. /**
  48069. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48070. */
  48071. scaleBoxSize: number;
  48072. /**
  48073. * 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)
  48074. */
  48075. fixedDragMeshScreenSize: boolean;
  48076. /**
  48077. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48078. */
  48079. fixedDragMeshScreenSizeDistanceFactor: number;
  48080. /**
  48081. * Fired when a rotation sphere or scale box is dragged
  48082. */
  48083. onDragStartObservable: Observable<{}>;
  48084. /**
  48085. * Fired when a scale box is dragged
  48086. */
  48087. onScaleBoxDragObservable: Observable<{}>;
  48088. /**
  48089. * Fired when a scale box drag is ended
  48090. */
  48091. onScaleBoxDragEndObservable: Observable<{}>;
  48092. /**
  48093. * Fired when a rotation sphere is dragged
  48094. */
  48095. onRotationSphereDragObservable: Observable<{}>;
  48096. /**
  48097. * Fired when a rotation sphere drag is ended
  48098. */
  48099. onRotationSphereDragEndObservable: Observable<{}>;
  48100. /**
  48101. * 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)
  48102. */
  48103. scalePivot: Nullable<Vector3>;
  48104. /**
  48105. * Mesh used as a pivot to rotate the attached mesh
  48106. */
  48107. private _anchorMesh;
  48108. private _existingMeshScale;
  48109. private _dragMesh;
  48110. private pointerDragBehavior;
  48111. private coloredMaterial;
  48112. private hoverColoredMaterial;
  48113. /**
  48114. * Sets the color of the bounding box gizmo
  48115. * @param color the color to set
  48116. */
  48117. setColor(color: Color3): void;
  48118. /**
  48119. * Creates an BoundingBoxGizmo
  48120. * @param gizmoLayer The utility layer the gizmo will be added to
  48121. * @param color The color of the gizmo
  48122. */
  48123. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48124. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48125. private _selectNode;
  48126. /**
  48127. * Updates the bounding box information for the Gizmo
  48128. */
  48129. updateBoundingBox(): void;
  48130. private _updateRotationSpheres;
  48131. private _updateScaleBoxes;
  48132. /**
  48133. * Enables rotation on the specified axis and disables rotation on the others
  48134. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48135. */
  48136. setEnabledRotationAxis(axis: string): void;
  48137. /**
  48138. * Enables/disables scaling
  48139. * @param enable if scaling should be enabled
  48140. */
  48141. setEnabledScaling(enable: boolean): void;
  48142. private _updateDummy;
  48143. /**
  48144. * Enables a pointer drag behavior on the bounding box of the gizmo
  48145. */
  48146. enableDragBehavior(): void;
  48147. /**
  48148. * Disposes of the gizmo
  48149. */
  48150. dispose(): void;
  48151. /**
  48152. * 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)
  48153. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48154. * @returns the bounding box mesh with the passed in mesh as a child
  48155. */
  48156. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48157. /**
  48158. * CustomMeshes are not supported by this gizmo
  48159. * @param mesh The mesh to replace the default mesh of the gizmo
  48160. */
  48161. setCustomMesh(mesh: Mesh): void;
  48162. }
  48163. }
  48164. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  48165. import { Observable } from "babylonjs/Misc/observable";
  48166. import { Nullable } from "babylonjs/types";
  48167. import { Vector3 } from "babylonjs/Maths/math.vector";
  48168. import { Color3 } from "babylonjs/Maths/math.color";
  48169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48170. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48171. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48172. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48173. import "babylonjs/Meshes/Builders/linesBuilder";
  48174. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48175. /**
  48176. * Single plane rotation gizmo
  48177. */
  48178. export class PlaneRotationGizmo extends Gizmo {
  48179. /**
  48180. * Drag behavior responsible for the gizmos dragging interactions
  48181. */
  48182. dragBehavior: PointerDragBehavior;
  48183. private _pointerObserver;
  48184. /**
  48185. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48186. */
  48187. snapDistance: number;
  48188. /**
  48189. * Event that fires each time the gizmo snaps to a new location.
  48190. * * snapDistance is the the change in distance
  48191. */
  48192. onSnapObservable: Observable<{
  48193. snapDistance: number;
  48194. }>;
  48195. private _isEnabled;
  48196. private _parent;
  48197. /**
  48198. * Creates a PlaneRotationGizmo
  48199. * @param gizmoLayer The utility layer the gizmo will be added to
  48200. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48201. * @param color The color of the gizmo
  48202. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48203. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48204. */
  48205. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48206. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48207. /**
  48208. * If the gizmo is enabled
  48209. */
  48210. isEnabled: boolean;
  48211. /**
  48212. * Disposes of the gizmo
  48213. */
  48214. dispose(): void;
  48215. }
  48216. }
  48217. declare module "babylonjs/Gizmos/rotationGizmo" {
  48218. import { Observable } from "babylonjs/Misc/observable";
  48219. import { Nullable } from "babylonjs/types";
  48220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48221. import { Mesh } from "babylonjs/Meshes/mesh";
  48222. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48223. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  48224. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48225. /**
  48226. * Gizmo that enables rotating a mesh along 3 axis
  48227. */
  48228. export class RotationGizmo extends Gizmo {
  48229. /**
  48230. * Internal gizmo used for interactions on the x axis
  48231. */
  48232. xGizmo: PlaneRotationGizmo;
  48233. /**
  48234. * Internal gizmo used for interactions on the y axis
  48235. */
  48236. yGizmo: PlaneRotationGizmo;
  48237. /**
  48238. * Internal gizmo used for interactions on the z axis
  48239. */
  48240. zGizmo: PlaneRotationGizmo;
  48241. /** Fires an event when any of it's sub gizmos are dragged */
  48242. onDragStartObservable: Observable<unknown>;
  48243. /** Fires an event when any of it's sub gizmos are released from dragging */
  48244. onDragEndObservable: Observable<unknown>;
  48245. private _meshAttached;
  48246. attachedMesh: Nullable<AbstractMesh>;
  48247. /**
  48248. * Creates a RotationGizmo
  48249. * @param gizmoLayer The utility layer the gizmo will be added to
  48250. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48251. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48252. */
  48253. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48254. updateGizmoRotationToMatchAttachedMesh: boolean;
  48255. /**
  48256. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48257. */
  48258. snapDistance: number;
  48259. /**
  48260. * Ratio for the scale of the gizmo (Default: 1)
  48261. */
  48262. scaleRatio: number;
  48263. /**
  48264. * Disposes of the gizmo
  48265. */
  48266. dispose(): void;
  48267. /**
  48268. * CustomMeshes are not supported by this gizmo
  48269. * @param mesh The mesh to replace the default mesh of the gizmo
  48270. */
  48271. setCustomMesh(mesh: Mesh): void;
  48272. }
  48273. }
  48274. declare module "babylonjs/Gizmos/gizmoManager" {
  48275. import { Observable } from "babylonjs/Misc/observable";
  48276. import { Nullable } from "babylonjs/types";
  48277. import { Scene, IDisposable } from "babylonjs/scene";
  48278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48279. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48280. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48281. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48282. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48283. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48284. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48285. /**
  48286. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48287. */
  48288. export class GizmoManager implements IDisposable {
  48289. private scene;
  48290. /**
  48291. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48292. */
  48293. gizmos: {
  48294. positionGizmo: Nullable<PositionGizmo>;
  48295. rotationGizmo: Nullable<RotationGizmo>;
  48296. scaleGizmo: Nullable<ScaleGizmo>;
  48297. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48298. };
  48299. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48300. clearGizmoOnEmptyPointerEvent: boolean;
  48301. /** Fires an event when the manager is attached to a mesh */
  48302. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48303. private _gizmosEnabled;
  48304. private _pointerObserver;
  48305. private _attachedMesh;
  48306. private _boundingBoxColor;
  48307. private _defaultUtilityLayer;
  48308. private _defaultKeepDepthUtilityLayer;
  48309. /**
  48310. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48311. */
  48312. boundingBoxDragBehavior: SixDofDragBehavior;
  48313. /**
  48314. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48315. */
  48316. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48317. /**
  48318. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48319. */
  48320. usePointerToAttachGizmos: boolean;
  48321. /**
  48322. * Utility layer that the bounding box gizmo belongs to
  48323. */
  48324. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48325. /**
  48326. * Utility layer that all gizmos besides bounding box belong to
  48327. */
  48328. readonly utilityLayer: UtilityLayerRenderer;
  48329. /**
  48330. * Instatiates a gizmo manager
  48331. * @param scene the scene to overlay the gizmos on top of
  48332. */
  48333. constructor(scene: Scene);
  48334. /**
  48335. * Attaches a set of gizmos to the specified mesh
  48336. * @param mesh The mesh the gizmo's should be attached to
  48337. */
  48338. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48339. /**
  48340. * If the position gizmo is enabled
  48341. */
  48342. positionGizmoEnabled: boolean;
  48343. /**
  48344. * If the rotation gizmo is enabled
  48345. */
  48346. rotationGizmoEnabled: boolean;
  48347. /**
  48348. * If the scale gizmo is enabled
  48349. */
  48350. scaleGizmoEnabled: boolean;
  48351. /**
  48352. * If the boundingBox gizmo is enabled
  48353. */
  48354. boundingBoxGizmoEnabled: boolean;
  48355. /**
  48356. * Disposes of the gizmo manager
  48357. */
  48358. dispose(): void;
  48359. }
  48360. }
  48361. declare module "babylonjs/Lights/directionalLight" {
  48362. import { Camera } from "babylonjs/Cameras/camera";
  48363. import { Scene } from "babylonjs/scene";
  48364. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48366. import { Light } from "babylonjs/Lights/light";
  48367. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48368. import { Effect } from "babylonjs/Materials/effect";
  48369. /**
  48370. * A directional light is defined by a direction (what a surprise!).
  48371. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48372. * 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.
  48373. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48374. */
  48375. export class DirectionalLight extends ShadowLight {
  48376. private _shadowFrustumSize;
  48377. /**
  48378. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48379. */
  48380. /**
  48381. * Specifies a fix frustum size for the shadow generation.
  48382. */
  48383. shadowFrustumSize: number;
  48384. private _shadowOrthoScale;
  48385. /**
  48386. * Gets the shadow projection scale against the optimal computed one.
  48387. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48388. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48389. */
  48390. /**
  48391. * Sets the shadow projection scale against the optimal computed one.
  48392. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48393. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48394. */
  48395. shadowOrthoScale: number;
  48396. /**
  48397. * Automatically compute the projection matrix to best fit (including all the casters)
  48398. * on each frame.
  48399. */
  48400. autoUpdateExtends: boolean;
  48401. private _orthoLeft;
  48402. private _orthoRight;
  48403. private _orthoTop;
  48404. private _orthoBottom;
  48405. /**
  48406. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48407. * The directional light is emitted from everywhere in the given direction.
  48408. * It can cast shadows.
  48409. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48410. * @param name The friendly name of the light
  48411. * @param direction The direction of the light
  48412. * @param scene The scene the light belongs to
  48413. */
  48414. constructor(name: string, direction: Vector3, scene: Scene);
  48415. /**
  48416. * Returns the string "DirectionalLight".
  48417. * @return The class name
  48418. */
  48419. getClassName(): string;
  48420. /**
  48421. * Returns the integer 1.
  48422. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48423. */
  48424. getTypeID(): number;
  48425. /**
  48426. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48427. * Returns the DirectionalLight Shadow projection matrix.
  48428. */
  48429. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48430. /**
  48431. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48432. * Returns the DirectionalLight Shadow projection matrix.
  48433. */
  48434. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48435. /**
  48436. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48437. * Returns the DirectionalLight Shadow projection matrix.
  48438. */
  48439. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48440. protected _buildUniformLayout(): void;
  48441. /**
  48442. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48443. * @param effect The effect to update
  48444. * @param lightIndex The index of the light in the effect to update
  48445. * @returns The directional light
  48446. */
  48447. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48448. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48449. /**
  48450. * Gets the minZ used for shadow according to both the scene and the light.
  48451. *
  48452. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48453. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48454. * @param activeCamera The camera we are returning the min for
  48455. * @returns the depth min z
  48456. */
  48457. getDepthMinZ(activeCamera: Camera): number;
  48458. /**
  48459. * Gets the maxZ used for shadow according to both the scene and the light.
  48460. *
  48461. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48462. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48463. * @param activeCamera The camera we are returning the max for
  48464. * @returns the depth max z
  48465. */
  48466. getDepthMaxZ(activeCamera: Camera): number;
  48467. /**
  48468. * Prepares the list of defines specific to the light type.
  48469. * @param defines the list of defines
  48470. * @param lightIndex defines the index of the light for the effect
  48471. */
  48472. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48473. }
  48474. }
  48475. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48476. import { Mesh } from "babylonjs/Meshes/mesh";
  48477. /**
  48478. * Class containing static functions to help procedurally build meshes
  48479. */
  48480. export class HemisphereBuilder {
  48481. /**
  48482. * Creates a hemisphere mesh
  48483. * @param name defines the name of the mesh
  48484. * @param options defines the options used to create the mesh
  48485. * @param scene defines the hosting scene
  48486. * @returns the hemisphere mesh
  48487. */
  48488. static CreateHemisphere(name: string, options: {
  48489. segments?: number;
  48490. diameter?: number;
  48491. sideOrientation?: number;
  48492. }, scene: any): Mesh;
  48493. }
  48494. }
  48495. declare module "babylonjs/Lights/spotLight" {
  48496. import { Nullable } from "babylonjs/types";
  48497. import { Scene } from "babylonjs/scene";
  48498. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48500. import { Effect } from "babylonjs/Materials/effect";
  48501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48502. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48503. /**
  48504. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48505. * These values define a cone of light starting from the position, emitting toward the direction.
  48506. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48507. * and the exponent defines the speed of the decay of the light with distance (reach).
  48508. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48509. */
  48510. export class SpotLight extends ShadowLight {
  48511. private _angle;
  48512. private _innerAngle;
  48513. private _cosHalfAngle;
  48514. private _lightAngleScale;
  48515. private _lightAngleOffset;
  48516. /**
  48517. * Gets the cone angle of the spot light in Radians.
  48518. */
  48519. /**
  48520. * Sets the cone angle of the spot light in Radians.
  48521. */
  48522. angle: number;
  48523. /**
  48524. * Only used in gltf falloff mode, this defines the angle where
  48525. * the directional falloff will start before cutting at angle which could be seen
  48526. * as outer angle.
  48527. */
  48528. /**
  48529. * Only used in gltf falloff mode, this defines the angle where
  48530. * the directional falloff will start before cutting at angle which could be seen
  48531. * as outer angle.
  48532. */
  48533. innerAngle: number;
  48534. private _shadowAngleScale;
  48535. /**
  48536. * Allows scaling the angle of the light for shadow generation only.
  48537. */
  48538. /**
  48539. * Allows scaling the angle of the light for shadow generation only.
  48540. */
  48541. shadowAngleScale: number;
  48542. /**
  48543. * The light decay speed with the distance from the emission spot.
  48544. */
  48545. exponent: number;
  48546. private _projectionTextureMatrix;
  48547. /**
  48548. * Allows reading the projecton texture
  48549. */
  48550. readonly projectionTextureMatrix: Matrix;
  48551. protected _projectionTextureLightNear: number;
  48552. /**
  48553. * Gets the near clip of the Spotlight for texture projection.
  48554. */
  48555. /**
  48556. * Sets the near clip of the Spotlight for texture projection.
  48557. */
  48558. projectionTextureLightNear: number;
  48559. protected _projectionTextureLightFar: number;
  48560. /**
  48561. * Gets the far clip of the Spotlight for texture projection.
  48562. */
  48563. /**
  48564. * Sets the far clip of the Spotlight for texture projection.
  48565. */
  48566. projectionTextureLightFar: number;
  48567. protected _projectionTextureUpDirection: Vector3;
  48568. /**
  48569. * Gets the Up vector of the Spotlight for texture projection.
  48570. */
  48571. /**
  48572. * Sets the Up vector of the Spotlight for texture projection.
  48573. */
  48574. projectionTextureUpDirection: Vector3;
  48575. private _projectionTexture;
  48576. /**
  48577. * Gets the projection texture of the light.
  48578. */
  48579. /**
  48580. * Sets the projection texture of the light.
  48581. */
  48582. projectionTexture: Nullable<BaseTexture>;
  48583. private _projectionTextureViewLightDirty;
  48584. private _projectionTextureProjectionLightDirty;
  48585. private _projectionTextureDirty;
  48586. private _projectionTextureViewTargetVector;
  48587. private _projectionTextureViewLightMatrix;
  48588. private _projectionTextureProjectionLightMatrix;
  48589. private _projectionTextureScalingMatrix;
  48590. /**
  48591. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48592. * It can cast shadows.
  48593. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48594. * @param name The light friendly name
  48595. * @param position The position of the spot light in the scene
  48596. * @param direction The direction of the light in the scene
  48597. * @param angle The cone angle of the light in Radians
  48598. * @param exponent The light decay speed with the distance from the emission spot
  48599. * @param scene The scene the lights belongs to
  48600. */
  48601. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48602. /**
  48603. * Returns the string "SpotLight".
  48604. * @returns the class name
  48605. */
  48606. getClassName(): string;
  48607. /**
  48608. * Returns the integer 2.
  48609. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48610. */
  48611. getTypeID(): number;
  48612. /**
  48613. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48614. */
  48615. protected _setDirection(value: Vector3): void;
  48616. /**
  48617. * Overrides the position setter to recompute the projection texture view light Matrix.
  48618. */
  48619. protected _setPosition(value: Vector3): void;
  48620. /**
  48621. * 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.
  48622. * Returns the SpotLight.
  48623. */
  48624. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48625. protected _computeProjectionTextureViewLightMatrix(): void;
  48626. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48627. /**
  48628. * Main function for light texture projection matrix computing.
  48629. */
  48630. protected _computeProjectionTextureMatrix(): void;
  48631. protected _buildUniformLayout(): void;
  48632. private _computeAngleValues;
  48633. /**
  48634. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48635. * @param effect The effect to update
  48636. * @param lightIndex The index of the light in the effect to update
  48637. * @returns The spot light
  48638. */
  48639. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48640. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48641. /**
  48642. * Disposes the light and the associated resources.
  48643. */
  48644. dispose(): void;
  48645. /**
  48646. * Prepares the list of defines specific to the light type.
  48647. * @param defines the list of defines
  48648. * @param lightIndex defines the index of the light for the effect
  48649. */
  48650. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48651. }
  48652. }
  48653. declare module "babylonjs/Gizmos/lightGizmo" {
  48654. import { Nullable } from "babylonjs/types";
  48655. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48656. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48657. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48658. import { Light } from "babylonjs/Lights/light";
  48659. /**
  48660. * Gizmo that enables viewing a light
  48661. */
  48662. export class LightGizmo extends Gizmo {
  48663. private _lightMesh;
  48664. private _material;
  48665. private _cachedPosition;
  48666. private _cachedForward;
  48667. private _attachedMeshParent;
  48668. /**
  48669. * Creates a LightGizmo
  48670. * @param gizmoLayer The utility layer the gizmo will be added to
  48671. */
  48672. constructor(gizmoLayer?: UtilityLayerRenderer);
  48673. private _light;
  48674. /**
  48675. * The light that the gizmo is attached to
  48676. */
  48677. light: Nullable<Light>;
  48678. /**
  48679. * Gets the material used to render the light gizmo
  48680. */
  48681. readonly material: StandardMaterial;
  48682. /**
  48683. * @hidden
  48684. * Updates the gizmo to match the attached mesh's position/rotation
  48685. */
  48686. protected _update(): void;
  48687. private static _Scale;
  48688. /**
  48689. * Creates the lines for a light mesh
  48690. */
  48691. private static _CreateLightLines;
  48692. /**
  48693. * Disposes of the light gizmo
  48694. */
  48695. dispose(): void;
  48696. private static _CreateHemisphericLightMesh;
  48697. private static _CreatePointLightMesh;
  48698. private static _CreateSpotLightMesh;
  48699. private static _CreateDirectionalLightMesh;
  48700. }
  48701. }
  48702. declare module "babylonjs/Gizmos/index" {
  48703. export * from "babylonjs/Gizmos/axisDragGizmo";
  48704. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48705. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48706. export * from "babylonjs/Gizmos/gizmo";
  48707. export * from "babylonjs/Gizmos/gizmoManager";
  48708. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48709. export * from "babylonjs/Gizmos/positionGizmo";
  48710. export * from "babylonjs/Gizmos/rotationGizmo";
  48711. export * from "babylonjs/Gizmos/scaleGizmo";
  48712. export * from "babylonjs/Gizmos/lightGizmo";
  48713. export * from "babylonjs/Gizmos/planeDragGizmo";
  48714. }
  48715. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48716. /** @hidden */
  48717. export var backgroundFragmentDeclaration: {
  48718. name: string;
  48719. shader: string;
  48720. };
  48721. }
  48722. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48723. /** @hidden */
  48724. export var backgroundUboDeclaration: {
  48725. name: string;
  48726. shader: string;
  48727. };
  48728. }
  48729. declare module "babylonjs/Shaders/background.fragment" {
  48730. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48731. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48732. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48733. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48734. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48735. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48736. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48737. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48738. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48739. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48740. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48741. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48742. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48743. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48744. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48745. /** @hidden */
  48746. export var backgroundPixelShader: {
  48747. name: string;
  48748. shader: string;
  48749. };
  48750. }
  48751. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48752. /** @hidden */
  48753. export var backgroundVertexDeclaration: {
  48754. name: string;
  48755. shader: string;
  48756. };
  48757. }
  48758. declare module "babylonjs/Shaders/background.vertex" {
  48759. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48760. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48761. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48762. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48763. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48764. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48765. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48766. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48767. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48768. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48769. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48770. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48771. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48772. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48773. /** @hidden */
  48774. export var backgroundVertexShader: {
  48775. name: string;
  48776. shader: string;
  48777. };
  48778. }
  48779. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48780. import { Nullable, int, float } from "babylonjs/types";
  48781. import { Scene } from "babylonjs/scene";
  48782. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48783. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48785. import { Mesh } from "babylonjs/Meshes/mesh";
  48786. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48787. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48788. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48790. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48791. import { Color3 } from "babylonjs/Maths/math.color";
  48792. import "babylonjs/Shaders/background.fragment";
  48793. import "babylonjs/Shaders/background.vertex";
  48794. /**
  48795. * Background material used to create an efficient environement around your scene.
  48796. */
  48797. export class BackgroundMaterial extends PushMaterial {
  48798. /**
  48799. * Standard reflectance value at parallel view angle.
  48800. */
  48801. static StandardReflectance0: number;
  48802. /**
  48803. * Standard reflectance value at grazing angle.
  48804. */
  48805. static StandardReflectance90: number;
  48806. protected _primaryColor: Color3;
  48807. /**
  48808. * Key light Color (multiply against the environement texture)
  48809. */
  48810. primaryColor: Color3;
  48811. protected __perceptualColor: Nullable<Color3>;
  48812. /**
  48813. * Experimental Internal Use Only.
  48814. *
  48815. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48816. * This acts as a helper to set the primary color to a more "human friendly" value.
  48817. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48818. * output color as close as possible from the chosen value.
  48819. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48820. * part of lighting setup.)
  48821. */
  48822. _perceptualColor: Nullable<Color3>;
  48823. protected _primaryColorShadowLevel: float;
  48824. /**
  48825. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48826. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48827. */
  48828. primaryColorShadowLevel: float;
  48829. protected _primaryColorHighlightLevel: float;
  48830. /**
  48831. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48832. * The primary color is used at the level chosen to define what the white area would look.
  48833. */
  48834. primaryColorHighlightLevel: float;
  48835. protected _reflectionTexture: Nullable<BaseTexture>;
  48836. /**
  48837. * Reflection Texture used in the material.
  48838. * Should be author in a specific way for the best result (refer to the documentation).
  48839. */
  48840. reflectionTexture: Nullable<BaseTexture>;
  48841. protected _reflectionBlur: float;
  48842. /**
  48843. * Reflection Texture level of blur.
  48844. *
  48845. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48846. * texture twice.
  48847. */
  48848. reflectionBlur: float;
  48849. protected _diffuseTexture: Nullable<BaseTexture>;
  48850. /**
  48851. * Diffuse Texture used in the material.
  48852. * Should be author in a specific way for the best result (refer to the documentation).
  48853. */
  48854. diffuseTexture: Nullable<BaseTexture>;
  48855. protected _shadowLights: Nullable<IShadowLight[]>;
  48856. /**
  48857. * Specify the list of lights casting shadow on the material.
  48858. * All scene shadow lights will be included if null.
  48859. */
  48860. shadowLights: Nullable<IShadowLight[]>;
  48861. protected _shadowLevel: float;
  48862. /**
  48863. * Helps adjusting the shadow to a softer level if required.
  48864. * 0 means black shadows and 1 means no shadows.
  48865. */
  48866. shadowLevel: float;
  48867. protected _sceneCenter: Vector3;
  48868. /**
  48869. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48870. * It is usually zero but might be interesting to modify according to your setup.
  48871. */
  48872. sceneCenter: Vector3;
  48873. protected _opacityFresnel: boolean;
  48874. /**
  48875. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48876. * This helps ensuring a nice transition when the camera goes under the ground.
  48877. */
  48878. opacityFresnel: boolean;
  48879. protected _reflectionFresnel: boolean;
  48880. /**
  48881. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48882. * This helps adding a mirror texture on the ground.
  48883. */
  48884. reflectionFresnel: boolean;
  48885. protected _reflectionFalloffDistance: number;
  48886. /**
  48887. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48888. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48889. */
  48890. reflectionFalloffDistance: number;
  48891. protected _reflectionAmount: number;
  48892. /**
  48893. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48894. */
  48895. reflectionAmount: number;
  48896. protected _reflectionReflectance0: number;
  48897. /**
  48898. * This specifies the weight of the reflection at grazing angle.
  48899. */
  48900. reflectionReflectance0: number;
  48901. protected _reflectionReflectance90: number;
  48902. /**
  48903. * This specifies the weight of the reflection at a perpendicular point of view.
  48904. */
  48905. reflectionReflectance90: number;
  48906. /**
  48907. * Sets the reflection reflectance fresnel values according to the default standard
  48908. * empirically know to work well :-)
  48909. */
  48910. reflectionStandardFresnelWeight: number;
  48911. protected _useRGBColor: boolean;
  48912. /**
  48913. * Helps to directly use the maps channels instead of their level.
  48914. */
  48915. useRGBColor: boolean;
  48916. protected _enableNoise: boolean;
  48917. /**
  48918. * This helps reducing the banding effect that could occur on the background.
  48919. */
  48920. enableNoise: boolean;
  48921. /**
  48922. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48923. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48924. * Recommended to be keep at 1.0 except for special cases.
  48925. */
  48926. fovMultiplier: number;
  48927. private _fovMultiplier;
  48928. /**
  48929. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48930. */
  48931. useEquirectangularFOV: boolean;
  48932. private _maxSimultaneousLights;
  48933. /**
  48934. * Number of Simultaneous lights allowed on the material.
  48935. */
  48936. maxSimultaneousLights: int;
  48937. /**
  48938. * Default configuration related to image processing available in the Background Material.
  48939. */
  48940. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48941. /**
  48942. * Keep track of the image processing observer to allow dispose and replace.
  48943. */
  48944. private _imageProcessingObserver;
  48945. /**
  48946. * Attaches a new image processing configuration to the PBR Material.
  48947. * @param configuration (if null the scene configuration will be use)
  48948. */
  48949. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48950. /**
  48951. * Gets the image processing configuration used either in this material.
  48952. */
  48953. /**
  48954. * Sets the Default image processing configuration used either in the this material.
  48955. *
  48956. * If sets to null, the scene one is in use.
  48957. */
  48958. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48959. /**
  48960. * Gets wether the color curves effect is enabled.
  48961. */
  48962. /**
  48963. * Sets wether the color curves effect is enabled.
  48964. */
  48965. cameraColorCurvesEnabled: boolean;
  48966. /**
  48967. * Gets wether the color grading effect is enabled.
  48968. */
  48969. /**
  48970. * Gets wether the color grading effect is enabled.
  48971. */
  48972. cameraColorGradingEnabled: boolean;
  48973. /**
  48974. * Gets wether tonemapping is enabled or not.
  48975. */
  48976. /**
  48977. * Sets wether tonemapping is enabled or not
  48978. */
  48979. cameraToneMappingEnabled: boolean;
  48980. /**
  48981. * The camera exposure used on this material.
  48982. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48983. * This corresponds to a photographic exposure.
  48984. */
  48985. /**
  48986. * The camera exposure used on this material.
  48987. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48988. * This corresponds to a photographic exposure.
  48989. */
  48990. cameraExposure: float;
  48991. /**
  48992. * Gets The camera contrast used on this material.
  48993. */
  48994. /**
  48995. * Sets The camera contrast used on this material.
  48996. */
  48997. cameraContrast: float;
  48998. /**
  48999. * Gets the Color Grading 2D Lookup Texture.
  49000. */
  49001. /**
  49002. * Sets the Color Grading 2D Lookup Texture.
  49003. */
  49004. cameraColorGradingTexture: Nullable<BaseTexture>;
  49005. /**
  49006. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49007. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49008. * 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;
  49009. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49010. */
  49011. /**
  49012. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49013. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49014. * 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;
  49015. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49016. */
  49017. cameraColorCurves: Nullable<ColorCurves>;
  49018. /**
  49019. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49020. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49021. */
  49022. switchToBGR: boolean;
  49023. private _renderTargets;
  49024. private _reflectionControls;
  49025. private _white;
  49026. private _primaryShadowColor;
  49027. private _primaryHighlightColor;
  49028. /**
  49029. * Instantiates a Background Material in the given scene
  49030. * @param name The friendly name of the material
  49031. * @param scene The scene to add the material to
  49032. */
  49033. constructor(name: string, scene: Scene);
  49034. /**
  49035. * Gets a boolean indicating that current material needs to register RTT
  49036. */
  49037. readonly hasRenderTargetTextures: boolean;
  49038. /**
  49039. * The entire material has been created in order to prevent overdraw.
  49040. * @returns false
  49041. */
  49042. needAlphaTesting(): boolean;
  49043. /**
  49044. * The entire material has been created in order to prevent overdraw.
  49045. * @returns true if blending is enable
  49046. */
  49047. needAlphaBlending(): boolean;
  49048. /**
  49049. * Checks wether the material is ready to be rendered for a given mesh.
  49050. * @param mesh The mesh to render
  49051. * @param subMesh The submesh to check against
  49052. * @param useInstances Specify wether or not the material is used with instances
  49053. * @returns true if all the dependencies are ready (Textures, Effects...)
  49054. */
  49055. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49056. /**
  49057. * Compute the primary color according to the chosen perceptual color.
  49058. */
  49059. private _computePrimaryColorFromPerceptualColor;
  49060. /**
  49061. * Compute the highlights and shadow colors according to their chosen levels.
  49062. */
  49063. private _computePrimaryColors;
  49064. /**
  49065. * Build the uniform buffer used in the material.
  49066. */
  49067. buildUniformLayout(): void;
  49068. /**
  49069. * Unbind the material.
  49070. */
  49071. unbind(): void;
  49072. /**
  49073. * Bind only the world matrix to the material.
  49074. * @param world The world matrix to bind.
  49075. */
  49076. bindOnlyWorldMatrix(world: Matrix): void;
  49077. /**
  49078. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49079. * @param world The world matrix to bind.
  49080. * @param subMesh The submesh to bind for.
  49081. */
  49082. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49083. /**
  49084. * Checks to see if a texture is used in the material.
  49085. * @param texture - Base texture to use.
  49086. * @returns - Boolean specifying if a texture is used in the material.
  49087. */
  49088. hasTexture(texture: BaseTexture): boolean;
  49089. /**
  49090. * Dispose the material.
  49091. * @param forceDisposeEffect Force disposal of the associated effect.
  49092. * @param forceDisposeTextures Force disposal of the associated textures.
  49093. */
  49094. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49095. /**
  49096. * Clones the material.
  49097. * @param name The cloned name.
  49098. * @returns The cloned material.
  49099. */
  49100. clone(name: string): BackgroundMaterial;
  49101. /**
  49102. * Serializes the current material to its JSON representation.
  49103. * @returns The JSON representation.
  49104. */
  49105. serialize(): any;
  49106. /**
  49107. * Gets the class name of the material
  49108. * @returns "BackgroundMaterial"
  49109. */
  49110. getClassName(): string;
  49111. /**
  49112. * Parse a JSON input to create back a background material.
  49113. * @param source The JSON data to parse
  49114. * @param scene The scene to create the parsed material in
  49115. * @param rootUrl The root url of the assets the material depends upon
  49116. * @returns the instantiated BackgroundMaterial.
  49117. */
  49118. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49119. }
  49120. }
  49121. declare module "babylonjs/Helpers/environmentHelper" {
  49122. import { Observable } from "babylonjs/Misc/observable";
  49123. import { Nullable } from "babylonjs/types";
  49124. import { Scene } from "babylonjs/scene";
  49125. import { Vector3 } from "babylonjs/Maths/math.vector";
  49126. import { Color3 } from "babylonjs/Maths/math.color";
  49127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49128. import { Mesh } from "babylonjs/Meshes/mesh";
  49129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49130. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  49131. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49132. import "babylonjs/Meshes/Builders/planeBuilder";
  49133. import "babylonjs/Meshes/Builders/boxBuilder";
  49134. /**
  49135. * Represents the different options available during the creation of
  49136. * a Environment helper.
  49137. *
  49138. * This can control the default ground, skybox and image processing setup of your scene.
  49139. */
  49140. export interface IEnvironmentHelperOptions {
  49141. /**
  49142. * Specifies wether or not to create a ground.
  49143. * True by default.
  49144. */
  49145. createGround: boolean;
  49146. /**
  49147. * Specifies the ground size.
  49148. * 15 by default.
  49149. */
  49150. groundSize: number;
  49151. /**
  49152. * The texture used on the ground for the main color.
  49153. * Comes from the BabylonJS CDN by default.
  49154. *
  49155. * Remarks: Can be either a texture or a url.
  49156. */
  49157. groundTexture: string | BaseTexture;
  49158. /**
  49159. * The color mixed in the ground texture by default.
  49160. * BabylonJS clearColor by default.
  49161. */
  49162. groundColor: Color3;
  49163. /**
  49164. * Specifies the ground opacity.
  49165. * 1 by default.
  49166. */
  49167. groundOpacity: number;
  49168. /**
  49169. * Enables the ground to receive shadows.
  49170. * True by default.
  49171. */
  49172. enableGroundShadow: boolean;
  49173. /**
  49174. * Helps preventing the shadow to be fully black on the ground.
  49175. * 0.5 by default.
  49176. */
  49177. groundShadowLevel: number;
  49178. /**
  49179. * Creates a mirror texture attach to the ground.
  49180. * false by default.
  49181. */
  49182. enableGroundMirror: boolean;
  49183. /**
  49184. * Specifies the ground mirror size ratio.
  49185. * 0.3 by default as the default kernel is 64.
  49186. */
  49187. groundMirrorSizeRatio: number;
  49188. /**
  49189. * Specifies the ground mirror blur kernel size.
  49190. * 64 by default.
  49191. */
  49192. groundMirrorBlurKernel: number;
  49193. /**
  49194. * Specifies the ground mirror visibility amount.
  49195. * 1 by default
  49196. */
  49197. groundMirrorAmount: number;
  49198. /**
  49199. * Specifies the ground mirror reflectance weight.
  49200. * This uses the standard weight of the background material to setup the fresnel effect
  49201. * of the mirror.
  49202. * 1 by default.
  49203. */
  49204. groundMirrorFresnelWeight: number;
  49205. /**
  49206. * Specifies the ground mirror Falloff distance.
  49207. * This can helps reducing the size of the reflection.
  49208. * 0 by Default.
  49209. */
  49210. groundMirrorFallOffDistance: number;
  49211. /**
  49212. * Specifies the ground mirror texture type.
  49213. * Unsigned Int by Default.
  49214. */
  49215. groundMirrorTextureType: number;
  49216. /**
  49217. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49218. * the shown objects.
  49219. */
  49220. groundYBias: number;
  49221. /**
  49222. * Specifies wether or not to create a skybox.
  49223. * True by default.
  49224. */
  49225. createSkybox: boolean;
  49226. /**
  49227. * Specifies the skybox size.
  49228. * 20 by default.
  49229. */
  49230. skyboxSize: number;
  49231. /**
  49232. * The texture used on the skybox for the main color.
  49233. * Comes from the BabylonJS CDN by default.
  49234. *
  49235. * Remarks: Can be either a texture or a url.
  49236. */
  49237. skyboxTexture: string | BaseTexture;
  49238. /**
  49239. * The color mixed in the skybox texture by default.
  49240. * BabylonJS clearColor by default.
  49241. */
  49242. skyboxColor: Color3;
  49243. /**
  49244. * The background rotation around the Y axis of the scene.
  49245. * This helps aligning the key lights of your scene with the background.
  49246. * 0 by default.
  49247. */
  49248. backgroundYRotation: number;
  49249. /**
  49250. * Compute automatically the size of the elements to best fit with the scene.
  49251. */
  49252. sizeAuto: boolean;
  49253. /**
  49254. * Default position of the rootMesh if autoSize is not true.
  49255. */
  49256. rootPosition: Vector3;
  49257. /**
  49258. * Sets up the image processing in the scene.
  49259. * true by default.
  49260. */
  49261. setupImageProcessing: boolean;
  49262. /**
  49263. * The texture used as your environment texture in the scene.
  49264. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49265. *
  49266. * Remarks: Can be either a texture or a url.
  49267. */
  49268. environmentTexture: string | BaseTexture;
  49269. /**
  49270. * The value of the exposure to apply to the scene.
  49271. * 0.6 by default if setupImageProcessing is true.
  49272. */
  49273. cameraExposure: number;
  49274. /**
  49275. * The value of the contrast to apply to the scene.
  49276. * 1.6 by default if setupImageProcessing is true.
  49277. */
  49278. cameraContrast: number;
  49279. /**
  49280. * Specifies wether or not tonemapping should be enabled in the scene.
  49281. * true by default if setupImageProcessing is true.
  49282. */
  49283. toneMappingEnabled: boolean;
  49284. }
  49285. /**
  49286. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49287. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49288. * It also helps with the default setup of your imageProcessing configuration.
  49289. */
  49290. export class EnvironmentHelper {
  49291. /**
  49292. * Default ground texture URL.
  49293. */
  49294. private static _groundTextureCDNUrl;
  49295. /**
  49296. * Default skybox texture URL.
  49297. */
  49298. private static _skyboxTextureCDNUrl;
  49299. /**
  49300. * Default environment texture URL.
  49301. */
  49302. private static _environmentTextureCDNUrl;
  49303. /**
  49304. * Creates the default options for the helper.
  49305. */
  49306. private static _getDefaultOptions;
  49307. private _rootMesh;
  49308. /**
  49309. * Gets the root mesh created by the helper.
  49310. */
  49311. readonly rootMesh: Mesh;
  49312. private _skybox;
  49313. /**
  49314. * Gets the skybox created by the helper.
  49315. */
  49316. readonly skybox: Nullable<Mesh>;
  49317. private _skyboxTexture;
  49318. /**
  49319. * Gets the skybox texture created by the helper.
  49320. */
  49321. readonly skyboxTexture: Nullable<BaseTexture>;
  49322. private _skyboxMaterial;
  49323. /**
  49324. * Gets the skybox material created by the helper.
  49325. */
  49326. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49327. private _ground;
  49328. /**
  49329. * Gets the ground mesh created by the helper.
  49330. */
  49331. readonly ground: Nullable<Mesh>;
  49332. private _groundTexture;
  49333. /**
  49334. * Gets the ground texture created by the helper.
  49335. */
  49336. readonly groundTexture: Nullable<BaseTexture>;
  49337. private _groundMirror;
  49338. /**
  49339. * Gets the ground mirror created by the helper.
  49340. */
  49341. readonly groundMirror: Nullable<MirrorTexture>;
  49342. /**
  49343. * Gets the ground mirror render list to helps pushing the meshes
  49344. * you wish in the ground reflection.
  49345. */
  49346. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49347. private _groundMaterial;
  49348. /**
  49349. * Gets the ground material created by the helper.
  49350. */
  49351. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49352. /**
  49353. * Stores the creation options.
  49354. */
  49355. private readonly _scene;
  49356. private _options;
  49357. /**
  49358. * This observable will be notified with any error during the creation of the environment,
  49359. * mainly texture creation errors.
  49360. */
  49361. onErrorObservable: Observable<{
  49362. message?: string;
  49363. exception?: any;
  49364. }>;
  49365. /**
  49366. * constructor
  49367. * @param options Defines the options we want to customize the helper
  49368. * @param scene The scene to add the material to
  49369. */
  49370. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49371. /**
  49372. * Updates the background according to the new options
  49373. * @param options
  49374. */
  49375. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49376. /**
  49377. * Sets the primary color of all the available elements.
  49378. * @param color the main color to affect to the ground and the background
  49379. */
  49380. setMainColor(color: Color3): void;
  49381. /**
  49382. * Setup the image processing according to the specified options.
  49383. */
  49384. private _setupImageProcessing;
  49385. /**
  49386. * Setup the environment texture according to the specified options.
  49387. */
  49388. private _setupEnvironmentTexture;
  49389. /**
  49390. * Setup the background according to the specified options.
  49391. */
  49392. private _setupBackground;
  49393. /**
  49394. * Get the scene sizes according to the setup.
  49395. */
  49396. private _getSceneSize;
  49397. /**
  49398. * Setup the ground according to the specified options.
  49399. */
  49400. private _setupGround;
  49401. /**
  49402. * Setup the ground material according to the specified options.
  49403. */
  49404. private _setupGroundMaterial;
  49405. /**
  49406. * Setup the ground diffuse texture according to the specified options.
  49407. */
  49408. private _setupGroundDiffuseTexture;
  49409. /**
  49410. * Setup the ground mirror texture according to the specified options.
  49411. */
  49412. private _setupGroundMirrorTexture;
  49413. /**
  49414. * Setup the ground to receive the mirror texture.
  49415. */
  49416. private _setupMirrorInGroundMaterial;
  49417. /**
  49418. * Setup the skybox according to the specified options.
  49419. */
  49420. private _setupSkybox;
  49421. /**
  49422. * Setup the skybox material according to the specified options.
  49423. */
  49424. private _setupSkyboxMaterial;
  49425. /**
  49426. * Setup the skybox reflection texture according to the specified options.
  49427. */
  49428. private _setupSkyboxReflectionTexture;
  49429. private _errorHandler;
  49430. /**
  49431. * Dispose all the elements created by the Helper.
  49432. */
  49433. dispose(): void;
  49434. }
  49435. }
  49436. declare module "babylonjs/Helpers/photoDome" {
  49437. import { Observable } from "babylonjs/Misc/observable";
  49438. import { Nullable } from "babylonjs/types";
  49439. import { Scene } from "babylonjs/scene";
  49440. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49441. import { Mesh } from "babylonjs/Meshes/mesh";
  49442. import { Texture } from "babylonjs/Materials/Textures/texture";
  49443. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49444. import "babylonjs/Meshes/Builders/sphereBuilder";
  49445. /**
  49446. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49447. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49448. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49449. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49450. */
  49451. export class PhotoDome extends TransformNode {
  49452. /**
  49453. * Define the image as a Monoscopic panoramic 360 image.
  49454. */
  49455. static readonly MODE_MONOSCOPIC: number;
  49456. /**
  49457. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49458. */
  49459. static readonly MODE_TOPBOTTOM: number;
  49460. /**
  49461. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49462. */
  49463. static readonly MODE_SIDEBYSIDE: number;
  49464. private _useDirectMapping;
  49465. /**
  49466. * The texture being displayed on the sphere
  49467. */
  49468. protected _photoTexture: Texture;
  49469. /**
  49470. * Gets or sets the texture being displayed on the sphere
  49471. */
  49472. photoTexture: Texture;
  49473. /**
  49474. * Observable raised when an error occured while loading the 360 image
  49475. */
  49476. onLoadErrorObservable: Observable<string>;
  49477. /**
  49478. * The skybox material
  49479. */
  49480. protected _material: BackgroundMaterial;
  49481. /**
  49482. * The surface used for the skybox
  49483. */
  49484. protected _mesh: Mesh;
  49485. /**
  49486. * Gets the mesh used for the skybox.
  49487. */
  49488. readonly mesh: Mesh;
  49489. /**
  49490. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49491. * Also see the options.resolution property.
  49492. */
  49493. fovMultiplier: number;
  49494. private _imageMode;
  49495. /**
  49496. * Gets or set the current video mode for the video. It can be:
  49497. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49498. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49499. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49500. */
  49501. imageMode: number;
  49502. /**
  49503. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49504. * @param name Element's name, child elements will append suffixes for their own names.
  49505. * @param urlsOfPhoto defines the url of the photo to display
  49506. * @param options defines an object containing optional or exposed sub element properties
  49507. * @param onError defines a callback called when an error occured while loading the texture
  49508. */
  49509. constructor(name: string, urlOfPhoto: string, options: {
  49510. resolution?: number;
  49511. size?: number;
  49512. useDirectMapping?: boolean;
  49513. faceForward?: boolean;
  49514. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49515. private _onBeforeCameraRenderObserver;
  49516. private _changeImageMode;
  49517. /**
  49518. * Releases resources associated with this node.
  49519. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49520. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49521. */
  49522. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49523. }
  49524. }
  49525. declare module "babylonjs/Misc/rgbdTextureTools" {
  49526. import "babylonjs/Shaders/rgbdDecode.fragment";
  49527. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49528. import { Texture } from "babylonjs/Materials/Textures/texture";
  49529. /**
  49530. * Class used to host RGBD texture specific utilities
  49531. */
  49532. export class RGBDTextureTools {
  49533. /**
  49534. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49535. * @param texture the texture to expand.
  49536. */
  49537. static ExpandRGBDTexture(texture: Texture): void;
  49538. }
  49539. }
  49540. declare module "babylonjs/Misc/brdfTextureTools" {
  49541. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49542. import { Scene } from "babylonjs/scene";
  49543. /**
  49544. * Class used to host texture specific utilities
  49545. */
  49546. export class BRDFTextureTools {
  49547. /**
  49548. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49549. * @param scene defines the hosting scene
  49550. * @returns the environment BRDF texture
  49551. */
  49552. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49553. private static _environmentBRDFBase64Texture;
  49554. }
  49555. }
  49556. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49557. import { Nullable } from "babylonjs/types";
  49558. import { Color3 } from "babylonjs/Maths/math.color";
  49559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49560. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49561. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49562. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49563. import { Engine } from "babylonjs/Engines/engine";
  49564. import { Scene } from "babylonjs/scene";
  49565. /**
  49566. * @hidden
  49567. */
  49568. export interface IMaterialClearCoatDefines {
  49569. CLEARCOAT: boolean;
  49570. CLEARCOAT_DEFAULTIOR: boolean;
  49571. CLEARCOAT_TEXTURE: boolean;
  49572. CLEARCOAT_TEXTUREDIRECTUV: number;
  49573. CLEARCOAT_BUMP: boolean;
  49574. CLEARCOAT_BUMPDIRECTUV: number;
  49575. CLEARCOAT_TINT: boolean;
  49576. CLEARCOAT_TINT_TEXTURE: boolean;
  49577. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49578. /** @hidden */
  49579. _areTexturesDirty: boolean;
  49580. }
  49581. /**
  49582. * Define the code related to the clear coat parameters of the pbr material.
  49583. */
  49584. export class PBRClearCoatConfiguration {
  49585. /**
  49586. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49587. * The default fits with a polyurethane material.
  49588. */
  49589. private static readonly _DefaultIndexOfRefraction;
  49590. private _isEnabled;
  49591. /**
  49592. * Defines if the clear coat is enabled in the material.
  49593. */
  49594. isEnabled: boolean;
  49595. /**
  49596. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49597. */
  49598. intensity: number;
  49599. /**
  49600. * Defines the clear coat layer roughness.
  49601. */
  49602. roughness: number;
  49603. private _indexOfRefraction;
  49604. /**
  49605. * Defines the index of refraction of the clear coat.
  49606. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49607. * The default fits with a polyurethane material.
  49608. * Changing the default value is more performance intensive.
  49609. */
  49610. indexOfRefraction: number;
  49611. private _texture;
  49612. /**
  49613. * Stores the clear coat values in a texture.
  49614. */
  49615. texture: Nullable<BaseTexture>;
  49616. private _bumpTexture;
  49617. /**
  49618. * Define the clear coat specific bump texture.
  49619. */
  49620. bumpTexture: Nullable<BaseTexture>;
  49621. private _isTintEnabled;
  49622. /**
  49623. * Defines if the clear coat tint is enabled in the material.
  49624. */
  49625. isTintEnabled: boolean;
  49626. /**
  49627. * Defines the clear coat tint of the material.
  49628. * This is only use if tint is enabled
  49629. */
  49630. tintColor: Color3;
  49631. /**
  49632. * Defines the distance at which the tint color should be found in the
  49633. * clear coat media.
  49634. * This is only use if tint is enabled
  49635. */
  49636. tintColorAtDistance: number;
  49637. /**
  49638. * Defines the clear coat layer thickness.
  49639. * This is only use if tint is enabled
  49640. */
  49641. tintThickness: number;
  49642. private _tintTexture;
  49643. /**
  49644. * Stores the clear tint values in a texture.
  49645. * rgb is tint
  49646. * a is a thickness factor
  49647. */
  49648. tintTexture: Nullable<BaseTexture>;
  49649. /** @hidden */
  49650. private _internalMarkAllSubMeshesAsTexturesDirty;
  49651. /** @hidden */
  49652. _markAllSubMeshesAsTexturesDirty(): void;
  49653. /**
  49654. * Instantiate a new istance of clear coat configuration.
  49655. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49656. */
  49657. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49658. /**
  49659. * Gets wehter the submesh is ready to be used or not.
  49660. * @param defines the list of "defines" to update.
  49661. * @param scene defines the scene the material belongs to.
  49662. * @param engine defines the engine the material belongs to.
  49663. * @param disableBumpMap defines wether the material disables bump or not.
  49664. * @returns - boolean indicating that the submesh is ready or not.
  49665. */
  49666. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49667. /**
  49668. * Checks to see if a texture is used in the material.
  49669. * @param defines the list of "defines" to update.
  49670. * @param scene defines the scene to the material belongs to.
  49671. */
  49672. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49673. /**
  49674. * Binds the material data.
  49675. * @param uniformBuffer defines the Uniform buffer to fill in.
  49676. * @param scene defines the scene the material belongs to.
  49677. * @param engine defines the engine the material belongs to.
  49678. * @param disableBumpMap defines wether the material disables bump or not.
  49679. * @param isFrozen defines wether the material is frozen or not.
  49680. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49681. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49682. */
  49683. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49684. /**
  49685. * Checks to see if a texture is used in the material.
  49686. * @param texture - Base texture to use.
  49687. * @returns - Boolean specifying if a texture is used in the material.
  49688. */
  49689. hasTexture(texture: BaseTexture): boolean;
  49690. /**
  49691. * Returns an array of the actively used textures.
  49692. * @param activeTextures Array of BaseTextures
  49693. */
  49694. getActiveTextures(activeTextures: BaseTexture[]): void;
  49695. /**
  49696. * Returns the animatable textures.
  49697. * @param animatables Array of animatable textures.
  49698. */
  49699. getAnimatables(animatables: IAnimatable[]): void;
  49700. /**
  49701. * Disposes the resources of the material.
  49702. * @param forceDisposeTextures - Forces the disposal of all textures.
  49703. */
  49704. dispose(forceDisposeTextures?: boolean): void;
  49705. /**
  49706. * Get the current class name of the texture useful for serialization or dynamic coding.
  49707. * @returns "PBRClearCoatConfiguration"
  49708. */
  49709. getClassName(): string;
  49710. /**
  49711. * Add fallbacks to the effect fallbacks list.
  49712. * @param defines defines the Base texture to use.
  49713. * @param fallbacks defines the current fallback list.
  49714. * @param currentRank defines the current fallback rank.
  49715. * @returns the new fallback rank.
  49716. */
  49717. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49718. /**
  49719. * Add the required uniforms to the current list.
  49720. * @param uniforms defines the current uniform list.
  49721. */
  49722. static AddUniforms(uniforms: string[]): void;
  49723. /**
  49724. * Add the required samplers to the current list.
  49725. * @param samplers defines the current sampler list.
  49726. */
  49727. static AddSamplers(samplers: string[]): void;
  49728. /**
  49729. * Add the required uniforms to the current buffer.
  49730. * @param uniformBuffer defines the current uniform buffer.
  49731. */
  49732. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49733. /**
  49734. * Makes a duplicate of the current configuration into another one.
  49735. * @param clearCoatConfiguration define the config where to copy the info
  49736. */
  49737. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49738. /**
  49739. * Serializes this clear coat configuration.
  49740. * @returns - An object with the serialized config.
  49741. */
  49742. serialize(): any;
  49743. /**
  49744. * Parses a anisotropy Configuration from a serialized object.
  49745. * @param source - Serialized object.
  49746. * @param scene Defines the scene we are parsing for
  49747. * @param rootUrl Defines the rootUrl to load from
  49748. */
  49749. parse(source: any, scene: Scene, rootUrl: string): void;
  49750. }
  49751. }
  49752. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49753. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49755. import { Vector2 } from "babylonjs/Maths/math.vector";
  49756. import { Scene } from "babylonjs/scene";
  49757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49758. import { Nullable } from "babylonjs/types";
  49759. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49760. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49761. /**
  49762. * @hidden
  49763. */
  49764. export interface IMaterialAnisotropicDefines {
  49765. ANISOTROPIC: boolean;
  49766. ANISOTROPIC_TEXTURE: boolean;
  49767. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49768. MAINUV1: boolean;
  49769. _areTexturesDirty: boolean;
  49770. _needUVs: boolean;
  49771. }
  49772. /**
  49773. * Define the code related to the anisotropic parameters of the pbr material.
  49774. */
  49775. export class PBRAnisotropicConfiguration {
  49776. private _isEnabled;
  49777. /**
  49778. * Defines if the anisotropy is enabled in the material.
  49779. */
  49780. isEnabled: boolean;
  49781. /**
  49782. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49783. */
  49784. intensity: number;
  49785. /**
  49786. * Defines if the effect is along the tangents, bitangents or in between.
  49787. * By default, the effect is "strectching" the highlights along the tangents.
  49788. */
  49789. direction: Vector2;
  49790. private _texture;
  49791. /**
  49792. * Stores the anisotropy values in a texture.
  49793. * rg is direction (like normal from -1 to 1)
  49794. * b is a intensity
  49795. */
  49796. texture: Nullable<BaseTexture>;
  49797. /** @hidden */
  49798. private _internalMarkAllSubMeshesAsTexturesDirty;
  49799. /** @hidden */
  49800. _markAllSubMeshesAsTexturesDirty(): void;
  49801. /**
  49802. * Instantiate a new istance of anisotropy configuration.
  49803. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49804. */
  49805. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49806. /**
  49807. * Specifies that the submesh is ready to be used.
  49808. * @param defines the list of "defines" to update.
  49809. * @param scene defines the scene the material belongs to.
  49810. * @returns - boolean indicating that the submesh is ready or not.
  49811. */
  49812. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49813. /**
  49814. * Checks to see if a texture is used in the material.
  49815. * @param defines the list of "defines" to update.
  49816. * @param mesh the mesh we are preparing the defines for.
  49817. * @param scene defines the scene the material belongs to.
  49818. */
  49819. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49820. /**
  49821. * Binds the material data.
  49822. * @param uniformBuffer defines the Uniform buffer to fill in.
  49823. * @param scene defines the scene the material belongs to.
  49824. * @param isFrozen defines wether the material is frozen or not.
  49825. */
  49826. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49827. /**
  49828. * Checks to see if a texture is used in the material.
  49829. * @param texture - Base texture to use.
  49830. * @returns - Boolean specifying if a texture is used in the material.
  49831. */
  49832. hasTexture(texture: BaseTexture): boolean;
  49833. /**
  49834. * Returns an array of the actively used textures.
  49835. * @param activeTextures Array of BaseTextures
  49836. */
  49837. getActiveTextures(activeTextures: BaseTexture[]): void;
  49838. /**
  49839. * Returns the animatable textures.
  49840. * @param animatables Array of animatable textures.
  49841. */
  49842. getAnimatables(animatables: IAnimatable[]): void;
  49843. /**
  49844. * Disposes the resources of the material.
  49845. * @param forceDisposeTextures - Forces the disposal of all textures.
  49846. */
  49847. dispose(forceDisposeTextures?: boolean): void;
  49848. /**
  49849. * Get the current class name of the texture useful for serialization or dynamic coding.
  49850. * @returns "PBRAnisotropicConfiguration"
  49851. */
  49852. getClassName(): string;
  49853. /**
  49854. * Add fallbacks to the effect fallbacks list.
  49855. * @param defines defines the Base texture to use.
  49856. * @param fallbacks defines the current fallback list.
  49857. * @param currentRank defines the current fallback rank.
  49858. * @returns the new fallback rank.
  49859. */
  49860. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49861. /**
  49862. * Add the required uniforms to the current list.
  49863. * @param uniforms defines the current uniform list.
  49864. */
  49865. static AddUniforms(uniforms: string[]): void;
  49866. /**
  49867. * Add the required uniforms to the current buffer.
  49868. * @param uniformBuffer defines the current uniform buffer.
  49869. */
  49870. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49871. /**
  49872. * Add the required samplers to the current list.
  49873. * @param samplers defines the current sampler list.
  49874. */
  49875. static AddSamplers(samplers: string[]): void;
  49876. /**
  49877. * Makes a duplicate of the current configuration into another one.
  49878. * @param anisotropicConfiguration define the config where to copy the info
  49879. */
  49880. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49881. /**
  49882. * Serializes this anisotropy configuration.
  49883. * @returns - An object with the serialized config.
  49884. */
  49885. serialize(): any;
  49886. /**
  49887. * Parses a anisotropy Configuration from a serialized object.
  49888. * @param source - Serialized object.
  49889. * @param scene Defines the scene we are parsing for
  49890. * @param rootUrl Defines the rootUrl to load from
  49891. */
  49892. parse(source: any, scene: Scene, rootUrl: string): void;
  49893. }
  49894. }
  49895. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49896. import { Scene } from "babylonjs/scene";
  49897. /**
  49898. * @hidden
  49899. */
  49900. export interface IMaterialBRDFDefines {
  49901. BRDF_V_HEIGHT_CORRELATED: boolean;
  49902. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49903. SPHERICAL_HARMONICS: boolean;
  49904. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49905. /** @hidden */
  49906. _areMiscDirty: boolean;
  49907. }
  49908. /**
  49909. * Define the code related to the BRDF parameters of the pbr material.
  49910. */
  49911. export class PBRBRDFConfiguration {
  49912. /**
  49913. * Default value used for the energy conservation.
  49914. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49915. */
  49916. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49917. /**
  49918. * Default value used for the Smith Visibility Height Correlated mode.
  49919. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49920. */
  49921. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49922. /**
  49923. * Default value used for the IBL diffuse part.
  49924. * This can help switching back to the polynomials mode globally which is a tiny bit
  49925. * less GPU intensive at the drawback of a lower quality.
  49926. */
  49927. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49928. /**
  49929. * Default value used for activating energy conservation for the specular workflow.
  49930. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49931. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49932. */
  49933. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49934. private _useEnergyConservation;
  49935. /**
  49936. * Defines if the material uses energy conservation.
  49937. */
  49938. useEnergyConservation: boolean;
  49939. private _useSmithVisibilityHeightCorrelated;
  49940. /**
  49941. * LEGACY Mode set to false
  49942. * Defines if the material uses height smith correlated visibility term.
  49943. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49944. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49945. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49946. * Not relying on height correlated will also disable energy conservation.
  49947. */
  49948. useSmithVisibilityHeightCorrelated: boolean;
  49949. private _useSphericalHarmonics;
  49950. /**
  49951. * LEGACY Mode set to false
  49952. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49953. * diffuse part of the IBL.
  49954. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49955. * to the ground truth.
  49956. */
  49957. useSphericalHarmonics: boolean;
  49958. private _useSpecularGlossinessInputEnergyConservation;
  49959. /**
  49960. * Defines if the material uses energy conservation, when the specular workflow is active.
  49961. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49962. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49963. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49964. */
  49965. useSpecularGlossinessInputEnergyConservation: boolean;
  49966. /** @hidden */
  49967. private _internalMarkAllSubMeshesAsMiscDirty;
  49968. /** @hidden */
  49969. _markAllSubMeshesAsMiscDirty(): void;
  49970. /**
  49971. * Instantiate a new istance of clear coat configuration.
  49972. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49973. */
  49974. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49975. /**
  49976. * Checks to see if a texture is used in the material.
  49977. * @param defines the list of "defines" to update.
  49978. */
  49979. prepareDefines(defines: IMaterialBRDFDefines): void;
  49980. /**
  49981. * Get the current class name of the texture useful for serialization or dynamic coding.
  49982. * @returns "PBRClearCoatConfiguration"
  49983. */
  49984. getClassName(): string;
  49985. /**
  49986. * Makes a duplicate of the current configuration into another one.
  49987. * @param brdfConfiguration define the config where to copy the info
  49988. */
  49989. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49990. /**
  49991. * Serializes this BRDF configuration.
  49992. * @returns - An object with the serialized config.
  49993. */
  49994. serialize(): any;
  49995. /**
  49996. * Parses a anisotropy Configuration from a serialized object.
  49997. * @param source - Serialized object.
  49998. * @param scene Defines the scene we are parsing for
  49999. * @param rootUrl Defines the rootUrl to load from
  50000. */
  50001. parse(source: any, scene: Scene, rootUrl: string): void;
  50002. }
  50003. }
  50004. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  50005. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50006. import { Color3 } from "babylonjs/Maths/math.color";
  50007. import { Scene } from "babylonjs/scene";
  50008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50009. import { Nullable } from "babylonjs/types";
  50010. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50011. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50012. /**
  50013. * @hidden
  50014. */
  50015. export interface IMaterialSheenDefines {
  50016. SHEEN: boolean;
  50017. SHEEN_TEXTURE: boolean;
  50018. SHEEN_TEXTUREDIRECTUV: number;
  50019. SHEEN_LINKWITHALBEDO: boolean;
  50020. /** @hidden */
  50021. _areTexturesDirty: boolean;
  50022. }
  50023. /**
  50024. * Define the code related to the Sheen parameters of the pbr material.
  50025. */
  50026. export class PBRSheenConfiguration {
  50027. private _isEnabled;
  50028. /**
  50029. * Defines if the material uses sheen.
  50030. */
  50031. isEnabled: boolean;
  50032. private _linkSheenWithAlbedo;
  50033. /**
  50034. * Defines if the sheen is linked to the sheen color.
  50035. */
  50036. linkSheenWithAlbedo: boolean;
  50037. /**
  50038. * Defines the sheen intensity.
  50039. */
  50040. intensity: number;
  50041. /**
  50042. * Defines the sheen color.
  50043. */
  50044. color: Color3;
  50045. private _texture;
  50046. /**
  50047. * Stores the sheen tint values in a texture.
  50048. * rgb is tint
  50049. * a is a intensity
  50050. */
  50051. texture: Nullable<BaseTexture>;
  50052. /** @hidden */
  50053. private _internalMarkAllSubMeshesAsTexturesDirty;
  50054. /** @hidden */
  50055. _markAllSubMeshesAsTexturesDirty(): void;
  50056. /**
  50057. * Instantiate a new istance of clear coat configuration.
  50058. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50059. */
  50060. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50061. /**
  50062. * Specifies that the submesh is ready to be used.
  50063. * @param defines the list of "defines" to update.
  50064. * @param scene defines the scene the material belongs to.
  50065. * @returns - boolean indicating that the submesh is ready or not.
  50066. */
  50067. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50068. /**
  50069. * Checks to see if a texture is used in the material.
  50070. * @param defines the list of "defines" to update.
  50071. * @param scene defines the scene the material belongs to.
  50072. */
  50073. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50074. /**
  50075. * Binds the material data.
  50076. * @param uniformBuffer defines the Uniform buffer to fill in.
  50077. * @param scene defines the scene the material belongs to.
  50078. * @param isFrozen defines wether the material is frozen or not.
  50079. */
  50080. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50081. /**
  50082. * Checks to see if a texture is used in the material.
  50083. * @param texture - Base texture to use.
  50084. * @returns - Boolean specifying if a texture is used in the material.
  50085. */
  50086. hasTexture(texture: BaseTexture): boolean;
  50087. /**
  50088. * Returns an array of the actively used textures.
  50089. * @param activeTextures Array of BaseTextures
  50090. */
  50091. getActiveTextures(activeTextures: BaseTexture[]): void;
  50092. /**
  50093. * Returns the animatable textures.
  50094. * @param animatables Array of animatable textures.
  50095. */
  50096. getAnimatables(animatables: IAnimatable[]): void;
  50097. /**
  50098. * Disposes the resources of the material.
  50099. * @param forceDisposeTextures - Forces the disposal of all textures.
  50100. */
  50101. dispose(forceDisposeTextures?: boolean): void;
  50102. /**
  50103. * Get the current class name of the texture useful for serialization or dynamic coding.
  50104. * @returns "PBRSheenConfiguration"
  50105. */
  50106. getClassName(): string;
  50107. /**
  50108. * Add fallbacks to the effect fallbacks list.
  50109. * @param defines defines the Base texture to use.
  50110. * @param fallbacks defines the current fallback list.
  50111. * @param currentRank defines the current fallback rank.
  50112. * @returns the new fallback rank.
  50113. */
  50114. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50115. /**
  50116. * Add the required uniforms to the current list.
  50117. * @param uniforms defines the current uniform list.
  50118. */
  50119. static AddUniforms(uniforms: string[]): void;
  50120. /**
  50121. * Add the required uniforms to the current buffer.
  50122. * @param uniformBuffer defines the current uniform buffer.
  50123. */
  50124. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50125. /**
  50126. * Add the required samplers to the current list.
  50127. * @param samplers defines the current sampler list.
  50128. */
  50129. static AddSamplers(samplers: string[]): void;
  50130. /**
  50131. * Makes a duplicate of the current configuration into another one.
  50132. * @param sheenConfiguration define the config where to copy the info
  50133. */
  50134. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50135. /**
  50136. * Serializes this BRDF configuration.
  50137. * @returns - An object with the serialized config.
  50138. */
  50139. serialize(): any;
  50140. /**
  50141. * Parses a anisotropy Configuration from a serialized object.
  50142. * @param source - Serialized object.
  50143. * @param scene Defines the scene we are parsing for
  50144. * @param rootUrl Defines the rootUrl to load from
  50145. */
  50146. parse(source: any, scene: Scene, rootUrl: string): void;
  50147. }
  50148. }
  50149. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  50150. import { Nullable } from "babylonjs/types";
  50151. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50152. import { Color3 } from "babylonjs/Maths/math.color";
  50153. import { SmartArray } from "babylonjs/Misc/smartArray";
  50154. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50155. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50156. import { Effect } from "babylonjs/Materials/effect";
  50157. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50158. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50159. import { Engine } from "babylonjs/Engines/engine";
  50160. import { Scene } from "babylonjs/scene";
  50161. /**
  50162. * @hidden
  50163. */
  50164. export interface IMaterialSubSurfaceDefines {
  50165. SUBSURFACE: boolean;
  50166. SS_REFRACTION: boolean;
  50167. SS_TRANSLUCENCY: boolean;
  50168. SS_SCATERRING: boolean;
  50169. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50170. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50171. SS_REFRACTIONMAP_3D: boolean;
  50172. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50173. SS_LODINREFRACTIONALPHA: boolean;
  50174. SS_GAMMAREFRACTION: boolean;
  50175. SS_RGBDREFRACTION: boolean;
  50176. SS_LINEARSPECULARREFRACTION: boolean;
  50177. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50178. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50179. /** @hidden */
  50180. _areTexturesDirty: boolean;
  50181. }
  50182. /**
  50183. * Define the code related to the sub surface parameters of the pbr material.
  50184. */
  50185. export class PBRSubSurfaceConfiguration {
  50186. private _isRefractionEnabled;
  50187. /**
  50188. * Defines if the refraction is enabled in the material.
  50189. */
  50190. isRefractionEnabled: boolean;
  50191. private _isTranslucencyEnabled;
  50192. /**
  50193. * Defines if the translucency is enabled in the material.
  50194. */
  50195. isTranslucencyEnabled: boolean;
  50196. private _isScatteringEnabled;
  50197. /**
  50198. * Defines the refraction intensity of the material.
  50199. * The refraction when enabled replaces the Diffuse part of the material.
  50200. * The intensity helps transitionning between diffuse and refraction.
  50201. */
  50202. refractionIntensity: number;
  50203. /**
  50204. * Defines the translucency intensity of the material.
  50205. * When translucency has been enabled, this defines how much of the "translucency"
  50206. * is addded to the diffuse part of the material.
  50207. */
  50208. translucencyIntensity: number;
  50209. /**
  50210. * Defines the scattering intensity of the material.
  50211. * When scattering has been enabled, this defines how much of the "scattered light"
  50212. * is addded to the diffuse part of the material.
  50213. */
  50214. scatteringIntensity: number;
  50215. private _thicknessTexture;
  50216. /**
  50217. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50218. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50219. * 0 would mean minimumThickness
  50220. * 1 would mean maximumThickness
  50221. * The other channels might be use as a mask to vary the different effects intensity.
  50222. */
  50223. thicknessTexture: Nullable<BaseTexture>;
  50224. private _refractionTexture;
  50225. /**
  50226. * Defines the texture to use for refraction.
  50227. */
  50228. refractionTexture: Nullable<BaseTexture>;
  50229. private _indexOfRefraction;
  50230. /**
  50231. * Defines the index of refraction used in the material.
  50232. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50233. */
  50234. indexOfRefraction: number;
  50235. private _invertRefractionY;
  50236. /**
  50237. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50238. */
  50239. invertRefractionY: boolean;
  50240. private _linkRefractionWithTransparency;
  50241. /**
  50242. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50243. * Materials half opaque for instance using refraction could benefit from this control.
  50244. */
  50245. linkRefractionWithTransparency: boolean;
  50246. /**
  50247. * Defines the minimum thickness stored in the thickness map.
  50248. * If no thickness map is defined, this value will be used to simulate thickness.
  50249. */
  50250. minimumThickness: number;
  50251. /**
  50252. * Defines the maximum thickness stored in the thickness map.
  50253. */
  50254. maximumThickness: number;
  50255. /**
  50256. * Defines the volume tint of the material.
  50257. * This is used for both translucency and scattering.
  50258. */
  50259. tintColor: Color3;
  50260. /**
  50261. * Defines the distance at which the tint color should be found in the media.
  50262. * This is used for refraction only.
  50263. */
  50264. tintColorAtDistance: number;
  50265. /**
  50266. * Defines how far each channel transmit through the media.
  50267. * It is defined as a color to simplify it selection.
  50268. */
  50269. diffusionDistance: Color3;
  50270. private _useMaskFromThicknessTexture;
  50271. /**
  50272. * Stores the intensity of the different subsurface effects in the thickness texture.
  50273. * * the green channel is the translucency intensity.
  50274. * * the blue channel is the scattering intensity.
  50275. * * the alpha channel is the refraction intensity.
  50276. */
  50277. useMaskFromThicknessTexture: boolean;
  50278. /** @hidden */
  50279. private _internalMarkAllSubMeshesAsTexturesDirty;
  50280. /** @hidden */
  50281. _markAllSubMeshesAsTexturesDirty(): void;
  50282. /**
  50283. * Instantiate a new istance of sub surface configuration.
  50284. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50285. */
  50286. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50287. /**
  50288. * Gets wehter the submesh is ready to be used or not.
  50289. * @param defines the list of "defines" to update.
  50290. * @param scene defines the scene the material belongs to.
  50291. * @returns - boolean indicating that the submesh is ready or not.
  50292. */
  50293. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50294. /**
  50295. * Checks to see if a texture is used in the material.
  50296. * @param defines the list of "defines" to update.
  50297. * @param scene defines the scene to the material belongs to.
  50298. */
  50299. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50300. /**
  50301. * Binds the material data.
  50302. * @param uniformBuffer defines the Uniform buffer to fill in.
  50303. * @param scene defines the scene the material belongs to.
  50304. * @param engine defines the engine the material belongs to.
  50305. * @param isFrozen defines wether the material is frozen or not.
  50306. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50307. */
  50308. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50309. /**
  50310. * Unbinds the material from the mesh.
  50311. * @param activeEffect defines the effect that should be unbound from.
  50312. * @returns true if unbound, otherwise false
  50313. */
  50314. unbind(activeEffect: Effect): boolean;
  50315. /**
  50316. * Returns the texture used for refraction or null if none is used.
  50317. * @param scene defines the scene the material belongs to.
  50318. * @returns - Refraction texture if present. If no refraction texture and refraction
  50319. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50320. */
  50321. private _getRefractionTexture;
  50322. /**
  50323. * Returns true if alpha blending should be disabled.
  50324. */
  50325. readonly disableAlphaBlending: boolean;
  50326. /**
  50327. * Fills the list of render target textures.
  50328. * @param renderTargets the list of render targets to update
  50329. */
  50330. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50331. /**
  50332. * Checks to see if a texture is used in the material.
  50333. * @param texture - Base texture to use.
  50334. * @returns - Boolean specifying if a texture is used in the material.
  50335. */
  50336. hasTexture(texture: BaseTexture): boolean;
  50337. /**
  50338. * Gets a boolean indicating that current material needs to register RTT
  50339. * @returns true if this uses a render target otherwise false.
  50340. */
  50341. hasRenderTargetTextures(): boolean;
  50342. /**
  50343. * Returns an array of the actively used textures.
  50344. * @param activeTextures Array of BaseTextures
  50345. */
  50346. getActiveTextures(activeTextures: BaseTexture[]): void;
  50347. /**
  50348. * Returns the animatable textures.
  50349. * @param animatables Array of animatable textures.
  50350. */
  50351. getAnimatables(animatables: IAnimatable[]): void;
  50352. /**
  50353. * Disposes the resources of the material.
  50354. * @param forceDisposeTextures - Forces the disposal of all textures.
  50355. */
  50356. dispose(forceDisposeTextures?: boolean): void;
  50357. /**
  50358. * Get the current class name of the texture useful for serialization or dynamic coding.
  50359. * @returns "PBRSubSurfaceConfiguration"
  50360. */
  50361. getClassName(): string;
  50362. /**
  50363. * Add fallbacks to the effect fallbacks list.
  50364. * @param defines defines the Base texture to use.
  50365. * @param fallbacks defines the current fallback list.
  50366. * @param currentRank defines the current fallback rank.
  50367. * @returns the new fallback rank.
  50368. */
  50369. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50370. /**
  50371. * Add the required uniforms to the current list.
  50372. * @param uniforms defines the current uniform list.
  50373. */
  50374. static AddUniforms(uniforms: string[]): void;
  50375. /**
  50376. * Add the required samplers to the current list.
  50377. * @param samplers defines the current sampler list.
  50378. */
  50379. static AddSamplers(samplers: string[]): void;
  50380. /**
  50381. * Add the required uniforms to the current buffer.
  50382. * @param uniformBuffer defines the current uniform buffer.
  50383. */
  50384. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50385. /**
  50386. * Makes a duplicate of the current configuration into another one.
  50387. * @param configuration define the config where to copy the info
  50388. */
  50389. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50390. /**
  50391. * Serializes this Sub Surface configuration.
  50392. * @returns - An object with the serialized config.
  50393. */
  50394. serialize(): any;
  50395. /**
  50396. * Parses a anisotropy Configuration from a serialized object.
  50397. * @param source - Serialized object.
  50398. * @param scene Defines the scene we are parsing for
  50399. * @param rootUrl Defines the rootUrl to load from
  50400. */
  50401. parse(source: any, scene: Scene, rootUrl: string): void;
  50402. }
  50403. }
  50404. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50405. /** @hidden */
  50406. export var pbrFragmentDeclaration: {
  50407. name: string;
  50408. shader: string;
  50409. };
  50410. }
  50411. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50412. /** @hidden */
  50413. export var pbrUboDeclaration: {
  50414. name: string;
  50415. shader: string;
  50416. };
  50417. }
  50418. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50419. /** @hidden */
  50420. export var pbrFragmentExtraDeclaration: {
  50421. name: string;
  50422. shader: string;
  50423. };
  50424. }
  50425. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50426. /** @hidden */
  50427. export var pbrFragmentSamplersDeclaration: {
  50428. name: string;
  50429. shader: string;
  50430. };
  50431. }
  50432. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50433. /** @hidden */
  50434. export var pbrHelperFunctions: {
  50435. name: string;
  50436. shader: string;
  50437. };
  50438. }
  50439. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50440. /** @hidden */
  50441. export var harmonicsFunctions: {
  50442. name: string;
  50443. shader: string;
  50444. };
  50445. }
  50446. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50447. /** @hidden */
  50448. export var pbrDirectLightingSetupFunctions: {
  50449. name: string;
  50450. shader: string;
  50451. };
  50452. }
  50453. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50454. /** @hidden */
  50455. export var pbrDirectLightingFalloffFunctions: {
  50456. name: string;
  50457. shader: string;
  50458. };
  50459. }
  50460. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50461. /** @hidden */
  50462. export var pbrBRDFFunctions: {
  50463. name: string;
  50464. shader: string;
  50465. };
  50466. }
  50467. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50468. /** @hidden */
  50469. export var pbrDirectLightingFunctions: {
  50470. name: string;
  50471. shader: string;
  50472. };
  50473. }
  50474. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50475. /** @hidden */
  50476. export var pbrIBLFunctions: {
  50477. name: string;
  50478. shader: string;
  50479. };
  50480. }
  50481. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50482. /** @hidden */
  50483. export var pbrDebug: {
  50484. name: string;
  50485. shader: string;
  50486. };
  50487. }
  50488. declare module "babylonjs/Shaders/pbr.fragment" {
  50489. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50490. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50491. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50492. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50493. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50494. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50495. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50496. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50497. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50498. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50499. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50500. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50501. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50502. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50503. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50504. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50505. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50506. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50507. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50508. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50509. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50510. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50511. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50512. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50513. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50514. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50515. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50516. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50517. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50518. /** @hidden */
  50519. export var pbrPixelShader: {
  50520. name: string;
  50521. shader: string;
  50522. };
  50523. }
  50524. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50525. /** @hidden */
  50526. export var pbrVertexDeclaration: {
  50527. name: string;
  50528. shader: string;
  50529. };
  50530. }
  50531. declare module "babylonjs/Shaders/pbr.vertex" {
  50532. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50533. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50534. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50535. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50536. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50537. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50538. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50539. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50540. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50541. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50542. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50543. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50545. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50547. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50548. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50549. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50550. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50551. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50552. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50553. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50554. /** @hidden */
  50555. export var pbrVertexShader: {
  50556. name: string;
  50557. shader: string;
  50558. };
  50559. }
  50560. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50561. import { Nullable } from "babylonjs/types";
  50562. import { Scene } from "babylonjs/scene";
  50563. import { Matrix } from "babylonjs/Maths/math.vector";
  50564. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50566. import { Mesh } from "babylonjs/Meshes/mesh";
  50567. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50568. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50569. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50570. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50571. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50572. import { Color3 } from "babylonjs/Maths/math.color";
  50573. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50574. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50575. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50576. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50578. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50579. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50580. import "babylonjs/Shaders/pbr.fragment";
  50581. import "babylonjs/Shaders/pbr.vertex";
  50582. /**
  50583. * Manages the defines for the PBR Material.
  50584. * @hidden
  50585. */
  50586. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50587. PBR: boolean;
  50588. MAINUV1: boolean;
  50589. MAINUV2: boolean;
  50590. UV1: boolean;
  50591. UV2: boolean;
  50592. ALBEDO: boolean;
  50593. ALBEDODIRECTUV: number;
  50594. VERTEXCOLOR: boolean;
  50595. AMBIENT: boolean;
  50596. AMBIENTDIRECTUV: number;
  50597. AMBIENTINGRAYSCALE: boolean;
  50598. OPACITY: boolean;
  50599. VERTEXALPHA: boolean;
  50600. OPACITYDIRECTUV: number;
  50601. OPACITYRGB: boolean;
  50602. ALPHATEST: boolean;
  50603. DEPTHPREPASS: boolean;
  50604. ALPHABLEND: boolean;
  50605. ALPHAFROMALBEDO: boolean;
  50606. ALPHATESTVALUE: string;
  50607. SPECULAROVERALPHA: boolean;
  50608. RADIANCEOVERALPHA: boolean;
  50609. ALPHAFRESNEL: boolean;
  50610. LINEARALPHAFRESNEL: boolean;
  50611. PREMULTIPLYALPHA: boolean;
  50612. EMISSIVE: boolean;
  50613. EMISSIVEDIRECTUV: number;
  50614. REFLECTIVITY: boolean;
  50615. REFLECTIVITYDIRECTUV: number;
  50616. SPECULARTERM: boolean;
  50617. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50618. MICROSURFACEAUTOMATIC: boolean;
  50619. LODBASEDMICROSFURACE: boolean;
  50620. MICROSURFACEMAP: boolean;
  50621. MICROSURFACEMAPDIRECTUV: number;
  50622. METALLICWORKFLOW: boolean;
  50623. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50624. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50625. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50626. AOSTOREINMETALMAPRED: boolean;
  50627. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50628. ENVIRONMENTBRDF: boolean;
  50629. ENVIRONMENTBRDF_RGBD: boolean;
  50630. NORMAL: boolean;
  50631. TANGENT: boolean;
  50632. BUMP: boolean;
  50633. BUMPDIRECTUV: number;
  50634. OBJECTSPACE_NORMALMAP: boolean;
  50635. PARALLAX: boolean;
  50636. PARALLAXOCCLUSION: boolean;
  50637. NORMALXYSCALE: boolean;
  50638. LIGHTMAP: boolean;
  50639. LIGHTMAPDIRECTUV: number;
  50640. USELIGHTMAPASSHADOWMAP: boolean;
  50641. GAMMALIGHTMAP: boolean;
  50642. RGBDLIGHTMAP: boolean;
  50643. REFLECTION: boolean;
  50644. REFLECTIONMAP_3D: boolean;
  50645. REFLECTIONMAP_SPHERICAL: boolean;
  50646. REFLECTIONMAP_PLANAR: boolean;
  50647. REFLECTIONMAP_CUBIC: boolean;
  50648. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50649. REFLECTIONMAP_PROJECTION: boolean;
  50650. REFLECTIONMAP_SKYBOX: boolean;
  50651. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50652. REFLECTIONMAP_EXPLICIT: boolean;
  50653. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50654. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50655. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50656. INVERTCUBICMAP: boolean;
  50657. USESPHERICALFROMREFLECTIONMAP: boolean;
  50658. USEIRRADIANCEMAP: boolean;
  50659. SPHERICAL_HARMONICS: boolean;
  50660. USESPHERICALINVERTEX: boolean;
  50661. REFLECTIONMAP_OPPOSITEZ: boolean;
  50662. LODINREFLECTIONALPHA: boolean;
  50663. GAMMAREFLECTION: boolean;
  50664. RGBDREFLECTION: boolean;
  50665. LINEARSPECULARREFLECTION: boolean;
  50666. RADIANCEOCCLUSION: boolean;
  50667. HORIZONOCCLUSION: boolean;
  50668. INSTANCES: boolean;
  50669. NUM_BONE_INFLUENCERS: number;
  50670. BonesPerMesh: number;
  50671. BONETEXTURE: boolean;
  50672. NONUNIFORMSCALING: boolean;
  50673. MORPHTARGETS: boolean;
  50674. MORPHTARGETS_NORMAL: boolean;
  50675. MORPHTARGETS_TANGENT: boolean;
  50676. MORPHTARGETS_UV: boolean;
  50677. NUM_MORPH_INFLUENCERS: number;
  50678. IMAGEPROCESSING: boolean;
  50679. VIGNETTE: boolean;
  50680. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50681. VIGNETTEBLENDMODEOPAQUE: boolean;
  50682. TONEMAPPING: boolean;
  50683. TONEMAPPING_ACES: boolean;
  50684. CONTRAST: boolean;
  50685. COLORCURVES: boolean;
  50686. COLORGRADING: boolean;
  50687. COLORGRADING3D: boolean;
  50688. SAMPLER3DGREENDEPTH: boolean;
  50689. SAMPLER3DBGRMAP: boolean;
  50690. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50691. EXPOSURE: boolean;
  50692. MULTIVIEW: boolean;
  50693. USEPHYSICALLIGHTFALLOFF: boolean;
  50694. USEGLTFLIGHTFALLOFF: boolean;
  50695. TWOSIDEDLIGHTING: boolean;
  50696. SHADOWFLOAT: boolean;
  50697. CLIPPLANE: boolean;
  50698. CLIPPLANE2: boolean;
  50699. CLIPPLANE3: boolean;
  50700. CLIPPLANE4: boolean;
  50701. POINTSIZE: boolean;
  50702. FOG: boolean;
  50703. LOGARITHMICDEPTH: boolean;
  50704. FORCENORMALFORWARD: boolean;
  50705. SPECULARAA: boolean;
  50706. CLEARCOAT: boolean;
  50707. CLEARCOAT_DEFAULTIOR: boolean;
  50708. CLEARCOAT_TEXTURE: boolean;
  50709. CLEARCOAT_TEXTUREDIRECTUV: number;
  50710. CLEARCOAT_BUMP: boolean;
  50711. CLEARCOAT_BUMPDIRECTUV: number;
  50712. CLEARCOAT_TINT: boolean;
  50713. CLEARCOAT_TINT_TEXTURE: boolean;
  50714. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50715. ANISOTROPIC: boolean;
  50716. ANISOTROPIC_TEXTURE: boolean;
  50717. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50718. BRDF_V_HEIGHT_CORRELATED: boolean;
  50719. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50720. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50721. SHEEN: boolean;
  50722. SHEEN_TEXTURE: boolean;
  50723. SHEEN_TEXTUREDIRECTUV: number;
  50724. SHEEN_LINKWITHALBEDO: boolean;
  50725. SUBSURFACE: boolean;
  50726. SS_REFRACTION: boolean;
  50727. SS_TRANSLUCENCY: boolean;
  50728. SS_SCATERRING: boolean;
  50729. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50730. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50731. SS_REFRACTIONMAP_3D: boolean;
  50732. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50733. SS_LODINREFRACTIONALPHA: boolean;
  50734. SS_GAMMAREFRACTION: boolean;
  50735. SS_RGBDREFRACTION: boolean;
  50736. SS_LINEARSPECULARREFRACTION: boolean;
  50737. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50738. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50739. UNLIT: boolean;
  50740. DEBUGMODE: number;
  50741. /**
  50742. * Initializes the PBR Material defines.
  50743. */
  50744. constructor();
  50745. /**
  50746. * Resets the PBR Material defines.
  50747. */
  50748. reset(): void;
  50749. }
  50750. /**
  50751. * The Physically based material base class of BJS.
  50752. *
  50753. * This offers the main features of a standard PBR material.
  50754. * For more information, please refer to the documentation :
  50755. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50756. */
  50757. export abstract class PBRBaseMaterial extends PushMaterial {
  50758. /**
  50759. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50760. */
  50761. static readonly PBRMATERIAL_OPAQUE: number;
  50762. /**
  50763. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50764. */
  50765. static readonly PBRMATERIAL_ALPHATEST: number;
  50766. /**
  50767. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50768. */
  50769. static readonly PBRMATERIAL_ALPHABLEND: number;
  50770. /**
  50771. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50772. * They are also discarded below the alpha cutoff threshold to improve performances.
  50773. */
  50774. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50775. /**
  50776. * Defines the default value of how much AO map is occluding the analytical lights
  50777. * (point spot...).
  50778. */
  50779. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50780. /**
  50781. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50782. */
  50783. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50784. /**
  50785. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50786. * to enhance interoperability with other engines.
  50787. */
  50788. static readonly LIGHTFALLOFF_GLTF: number;
  50789. /**
  50790. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50791. * to enhance interoperability with other materials.
  50792. */
  50793. static readonly LIGHTFALLOFF_STANDARD: number;
  50794. /**
  50795. * Intensity of the direct lights e.g. the four lights available in your scene.
  50796. * This impacts both the direct diffuse and specular highlights.
  50797. */
  50798. protected _directIntensity: number;
  50799. /**
  50800. * Intensity of the emissive part of the material.
  50801. * This helps controlling the emissive effect without modifying the emissive color.
  50802. */
  50803. protected _emissiveIntensity: number;
  50804. /**
  50805. * Intensity of the environment e.g. how much the environment will light the object
  50806. * either through harmonics for rough material or through the refelction for shiny ones.
  50807. */
  50808. protected _environmentIntensity: number;
  50809. /**
  50810. * This is a special control allowing the reduction of the specular highlights coming from the
  50811. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50812. */
  50813. protected _specularIntensity: number;
  50814. /**
  50815. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50816. */
  50817. private _lightingInfos;
  50818. /**
  50819. * Debug Control allowing disabling the bump map on this material.
  50820. */
  50821. protected _disableBumpMap: boolean;
  50822. /**
  50823. * AKA Diffuse Texture in standard nomenclature.
  50824. */
  50825. protected _albedoTexture: Nullable<BaseTexture>;
  50826. /**
  50827. * AKA Occlusion Texture in other nomenclature.
  50828. */
  50829. protected _ambientTexture: Nullable<BaseTexture>;
  50830. /**
  50831. * AKA Occlusion Texture Intensity in other nomenclature.
  50832. */
  50833. protected _ambientTextureStrength: number;
  50834. /**
  50835. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50836. * 1 means it completely occludes it
  50837. * 0 mean it has no impact
  50838. */
  50839. protected _ambientTextureImpactOnAnalyticalLights: number;
  50840. /**
  50841. * Stores the alpha values in a texture.
  50842. */
  50843. protected _opacityTexture: Nullable<BaseTexture>;
  50844. /**
  50845. * Stores the reflection values in a texture.
  50846. */
  50847. protected _reflectionTexture: Nullable<BaseTexture>;
  50848. /**
  50849. * Stores the emissive values in a texture.
  50850. */
  50851. protected _emissiveTexture: Nullable<BaseTexture>;
  50852. /**
  50853. * AKA Specular texture in other nomenclature.
  50854. */
  50855. protected _reflectivityTexture: Nullable<BaseTexture>;
  50856. /**
  50857. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50858. */
  50859. protected _metallicTexture: Nullable<BaseTexture>;
  50860. /**
  50861. * Specifies the metallic scalar of the metallic/roughness workflow.
  50862. * Can also be used to scale the metalness values of the metallic texture.
  50863. */
  50864. protected _metallic: Nullable<number>;
  50865. /**
  50866. * Specifies the roughness scalar of the metallic/roughness workflow.
  50867. * Can also be used to scale the roughness values of the metallic texture.
  50868. */
  50869. protected _roughness: Nullable<number>;
  50870. /**
  50871. * Specifies the an F0 factor to help configuring the material F0.
  50872. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50873. * to 0.5 the previously hard coded value stays the same.
  50874. * Can also be used to scale the F0 values of the metallic texture.
  50875. */
  50876. protected _metallicF0Factor: number;
  50877. /**
  50878. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50879. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50880. * your expectation as it multiplies with the texture data.
  50881. */
  50882. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50883. /**
  50884. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50885. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50886. */
  50887. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50888. /**
  50889. * Stores surface normal data used to displace a mesh in a texture.
  50890. */
  50891. protected _bumpTexture: Nullable<BaseTexture>;
  50892. /**
  50893. * Stores the pre-calculated light information of a mesh in a texture.
  50894. */
  50895. protected _lightmapTexture: Nullable<BaseTexture>;
  50896. /**
  50897. * The color of a material in ambient lighting.
  50898. */
  50899. protected _ambientColor: Color3;
  50900. /**
  50901. * AKA Diffuse Color in other nomenclature.
  50902. */
  50903. protected _albedoColor: Color3;
  50904. /**
  50905. * AKA Specular Color in other nomenclature.
  50906. */
  50907. protected _reflectivityColor: Color3;
  50908. /**
  50909. * The color applied when light is reflected from a material.
  50910. */
  50911. protected _reflectionColor: Color3;
  50912. /**
  50913. * The color applied when light is emitted from a material.
  50914. */
  50915. protected _emissiveColor: Color3;
  50916. /**
  50917. * AKA Glossiness in other nomenclature.
  50918. */
  50919. protected _microSurface: number;
  50920. /**
  50921. * Specifies that the material will use the light map as a show map.
  50922. */
  50923. protected _useLightmapAsShadowmap: boolean;
  50924. /**
  50925. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50926. * makes the reflect vector face the model (under horizon).
  50927. */
  50928. protected _useHorizonOcclusion: boolean;
  50929. /**
  50930. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50931. * too much the area relying on ambient texture to define their ambient occlusion.
  50932. */
  50933. protected _useRadianceOcclusion: boolean;
  50934. /**
  50935. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50936. */
  50937. protected _useAlphaFromAlbedoTexture: boolean;
  50938. /**
  50939. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50940. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50941. */
  50942. protected _useSpecularOverAlpha: boolean;
  50943. /**
  50944. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50945. */
  50946. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50947. /**
  50948. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50949. */
  50950. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50951. /**
  50952. * Specifies if the metallic texture contains the roughness information in its green channel.
  50953. */
  50954. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50955. /**
  50956. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50957. */
  50958. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50959. /**
  50960. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50961. */
  50962. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50963. /**
  50964. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50965. */
  50966. protected _useAmbientInGrayScale: boolean;
  50967. /**
  50968. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50969. * The material will try to infer what glossiness each pixel should be.
  50970. */
  50971. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50972. /**
  50973. * Defines the falloff type used in this material.
  50974. * It by default is Physical.
  50975. */
  50976. protected _lightFalloff: number;
  50977. /**
  50978. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50979. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50980. */
  50981. protected _useRadianceOverAlpha: boolean;
  50982. /**
  50983. * Allows using an object space normal map (instead of tangent space).
  50984. */
  50985. protected _useObjectSpaceNormalMap: boolean;
  50986. /**
  50987. * Allows using the bump map in parallax mode.
  50988. */
  50989. protected _useParallax: boolean;
  50990. /**
  50991. * Allows using the bump map in parallax occlusion mode.
  50992. */
  50993. protected _useParallaxOcclusion: boolean;
  50994. /**
  50995. * Controls the scale bias of the parallax mode.
  50996. */
  50997. protected _parallaxScaleBias: number;
  50998. /**
  50999. * If sets to true, disables all the lights affecting the material.
  51000. */
  51001. protected _disableLighting: boolean;
  51002. /**
  51003. * Number of Simultaneous lights allowed on the material.
  51004. */
  51005. protected _maxSimultaneousLights: number;
  51006. /**
  51007. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51008. */
  51009. protected _invertNormalMapX: boolean;
  51010. /**
  51011. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51012. */
  51013. protected _invertNormalMapY: boolean;
  51014. /**
  51015. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51016. */
  51017. protected _twoSidedLighting: boolean;
  51018. /**
  51019. * Defines the alpha limits in alpha test mode.
  51020. */
  51021. protected _alphaCutOff: number;
  51022. /**
  51023. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51024. */
  51025. protected _forceAlphaTest: boolean;
  51026. /**
  51027. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51028. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51029. */
  51030. protected _useAlphaFresnel: boolean;
  51031. /**
  51032. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51033. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51034. */
  51035. protected _useLinearAlphaFresnel: boolean;
  51036. /**
  51037. * The transparency mode of the material.
  51038. */
  51039. protected _transparencyMode: Nullable<number>;
  51040. /**
  51041. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51042. * from cos thetav and roughness:
  51043. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51044. */
  51045. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51046. /**
  51047. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51048. */
  51049. protected _forceIrradianceInFragment: boolean;
  51050. /**
  51051. * Force normal to face away from face.
  51052. */
  51053. protected _forceNormalForward: boolean;
  51054. /**
  51055. * Enables specular anti aliasing in the PBR shader.
  51056. * It will both interacts on the Geometry for analytical and IBL lighting.
  51057. * It also prefilter the roughness map based on the bump values.
  51058. */
  51059. protected _enableSpecularAntiAliasing: boolean;
  51060. /**
  51061. * Default configuration related to image processing available in the PBR Material.
  51062. */
  51063. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51064. /**
  51065. * Keep track of the image processing observer to allow dispose and replace.
  51066. */
  51067. private _imageProcessingObserver;
  51068. /**
  51069. * Attaches a new image processing configuration to the PBR Material.
  51070. * @param configuration
  51071. */
  51072. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51073. /**
  51074. * Stores the available render targets.
  51075. */
  51076. private _renderTargets;
  51077. /**
  51078. * Sets the global ambient color for the material used in lighting calculations.
  51079. */
  51080. private _globalAmbientColor;
  51081. /**
  51082. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51083. */
  51084. private _useLogarithmicDepth;
  51085. /**
  51086. * If set to true, no lighting calculations will be applied.
  51087. */
  51088. private _unlit;
  51089. private _debugMode;
  51090. /**
  51091. * @hidden
  51092. * This is reserved for the inspector.
  51093. * Defines the material debug mode.
  51094. * It helps seeing only some components of the material while troubleshooting.
  51095. */
  51096. debugMode: number;
  51097. /**
  51098. * @hidden
  51099. * This is reserved for the inspector.
  51100. * Specify from where on screen the debug mode should start.
  51101. * The value goes from -1 (full screen) to 1 (not visible)
  51102. * It helps with side by side comparison against the final render
  51103. * This defaults to -1
  51104. */
  51105. private debugLimit;
  51106. /**
  51107. * @hidden
  51108. * This is reserved for the inspector.
  51109. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51110. * You can use the factor to better multiply the final value.
  51111. */
  51112. private debugFactor;
  51113. /**
  51114. * Defines the clear coat layer parameters for the material.
  51115. */
  51116. readonly clearCoat: PBRClearCoatConfiguration;
  51117. /**
  51118. * Defines the anisotropic parameters for the material.
  51119. */
  51120. readonly anisotropy: PBRAnisotropicConfiguration;
  51121. /**
  51122. * Defines the BRDF parameters for the material.
  51123. */
  51124. readonly brdf: PBRBRDFConfiguration;
  51125. /**
  51126. * Defines the Sheen parameters for the material.
  51127. */
  51128. readonly sheen: PBRSheenConfiguration;
  51129. /**
  51130. * Defines the SubSurface parameters for the material.
  51131. */
  51132. readonly subSurface: PBRSubSurfaceConfiguration;
  51133. /**
  51134. * Custom callback helping to override the default shader used in the material.
  51135. */
  51136. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51137. protected _rebuildInParallel: boolean;
  51138. /**
  51139. * Instantiates a new PBRMaterial instance.
  51140. *
  51141. * @param name The material name
  51142. * @param scene The scene the material will be use in.
  51143. */
  51144. constructor(name: string, scene: Scene);
  51145. /**
  51146. * Gets a boolean indicating that current material needs to register RTT
  51147. */
  51148. readonly hasRenderTargetTextures: boolean;
  51149. /**
  51150. * Gets the name of the material class.
  51151. */
  51152. getClassName(): string;
  51153. /**
  51154. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51155. */
  51156. /**
  51157. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51158. */
  51159. useLogarithmicDepth: boolean;
  51160. /**
  51161. * Gets the current transparency mode.
  51162. */
  51163. /**
  51164. * Sets the transparency mode of the material.
  51165. *
  51166. * | Value | Type | Description |
  51167. * | ----- | ----------------------------------- | ----------- |
  51168. * | 0 | OPAQUE | |
  51169. * | 1 | ALPHATEST | |
  51170. * | 2 | ALPHABLEND | |
  51171. * | 3 | ALPHATESTANDBLEND | |
  51172. *
  51173. */
  51174. transparencyMode: Nullable<number>;
  51175. /**
  51176. * Returns true if alpha blending should be disabled.
  51177. */
  51178. private readonly _disableAlphaBlending;
  51179. /**
  51180. * Specifies whether or not this material should be rendered in alpha blend mode.
  51181. */
  51182. needAlphaBlending(): boolean;
  51183. /**
  51184. * Specifies if the mesh will require alpha blending.
  51185. * @param mesh - BJS mesh.
  51186. */
  51187. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51188. /**
  51189. * Specifies whether or not this material should be rendered in alpha test mode.
  51190. */
  51191. needAlphaTesting(): boolean;
  51192. /**
  51193. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51194. */
  51195. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51196. /**
  51197. * Gets the texture used for the alpha test.
  51198. */
  51199. getAlphaTestTexture(): Nullable<BaseTexture>;
  51200. /**
  51201. * Specifies that the submesh is ready to be used.
  51202. * @param mesh - BJS mesh.
  51203. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51204. * @param useInstances - Specifies that instances should be used.
  51205. * @returns - boolean indicating that the submesh is ready or not.
  51206. */
  51207. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51208. /**
  51209. * Specifies if the material uses metallic roughness workflow.
  51210. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51211. */
  51212. isMetallicWorkflow(): boolean;
  51213. private _prepareEffect;
  51214. private _prepareDefines;
  51215. /**
  51216. * Force shader compilation
  51217. */
  51218. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51219. /**
  51220. * Initializes the uniform buffer layout for the shader.
  51221. */
  51222. buildUniformLayout(): void;
  51223. /**
  51224. * Unbinds the material from the mesh
  51225. */
  51226. unbind(): void;
  51227. /**
  51228. * Binds the submesh data.
  51229. * @param world - The world matrix.
  51230. * @param mesh - The BJS mesh.
  51231. * @param subMesh - A submesh of the BJS mesh.
  51232. */
  51233. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51234. /**
  51235. * Returns the animatable textures.
  51236. * @returns - Array of animatable textures.
  51237. */
  51238. getAnimatables(): IAnimatable[];
  51239. /**
  51240. * Returns the texture used for reflections.
  51241. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51242. */
  51243. private _getReflectionTexture;
  51244. /**
  51245. * Returns an array of the actively used textures.
  51246. * @returns - Array of BaseTextures
  51247. */
  51248. getActiveTextures(): BaseTexture[];
  51249. /**
  51250. * Checks to see if a texture is used in the material.
  51251. * @param texture - Base texture to use.
  51252. * @returns - Boolean specifying if a texture is used in the material.
  51253. */
  51254. hasTexture(texture: BaseTexture): boolean;
  51255. /**
  51256. * Disposes the resources of the material.
  51257. * @param forceDisposeEffect - Forces the disposal of effects.
  51258. * @param forceDisposeTextures - Forces the disposal of all textures.
  51259. */
  51260. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51261. }
  51262. }
  51263. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51264. import { Nullable } from "babylonjs/types";
  51265. import { Scene } from "babylonjs/scene";
  51266. import { Color3 } from "babylonjs/Maths/math.color";
  51267. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51268. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51269. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51270. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51271. /**
  51272. * The Physically based material of BJS.
  51273. *
  51274. * This offers the main features of a standard PBR material.
  51275. * For more information, please refer to the documentation :
  51276. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51277. */
  51278. export class PBRMaterial extends PBRBaseMaterial {
  51279. /**
  51280. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51281. */
  51282. static readonly PBRMATERIAL_OPAQUE: number;
  51283. /**
  51284. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51285. */
  51286. static readonly PBRMATERIAL_ALPHATEST: number;
  51287. /**
  51288. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51289. */
  51290. static readonly PBRMATERIAL_ALPHABLEND: number;
  51291. /**
  51292. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51293. * They are also discarded below the alpha cutoff threshold to improve performances.
  51294. */
  51295. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51296. /**
  51297. * Defines the default value of how much AO map is occluding the analytical lights
  51298. * (point spot...).
  51299. */
  51300. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51301. /**
  51302. * Intensity of the direct lights e.g. the four lights available in your scene.
  51303. * This impacts both the direct diffuse and specular highlights.
  51304. */
  51305. directIntensity: number;
  51306. /**
  51307. * Intensity of the emissive part of the material.
  51308. * This helps controlling the emissive effect without modifying the emissive color.
  51309. */
  51310. emissiveIntensity: number;
  51311. /**
  51312. * Intensity of the environment e.g. how much the environment will light the object
  51313. * either through harmonics for rough material or through the refelction for shiny ones.
  51314. */
  51315. environmentIntensity: number;
  51316. /**
  51317. * This is a special control allowing the reduction of the specular highlights coming from the
  51318. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51319. */
  51320. specularIntensity: number;
  51321. /**
  51322. * Debug Control allowing disabling the bump map on this material.
  51323. */
  51324. disableBumpMap: boolean;
  51325. /**
  51326. * AKA Diffuse Texture in standard nomenclature.
  51327. */
  51328. albedoTexture: BaseTexture;
  51329. /**
  51330. * AKA Occlusion Texture in other nomenclature.
  51331. */
  51332. ambientTexture: BaseTexture;
  51333. /**
  51334. * AKA Occlusion Texture Intensity in other nomenclature.
  51335. */
  51336. ambientTextureStrength: number;
  51337. /**
  51338. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51339. * 1 means it completely occludes it
  51340. * 0 mean it has no impact
  51341. */
  51342. ambientTextureImpactOnAnalyticalLights: number;
  51343. /**
  51344. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51345. */
  51346. opacityTexture: BaseTexture;
  51347. /**
  51348. * Stores the reflection values in a texture.
  51349. */
  51350. reflectionTexture: Nullable<BaseTexture>;
  51351. /**
  51352. * Stores the emissive values in a texture.
  51353. */
  51354. emissiveTexture: BaseTexture;
  51355. /**
  51356. * AKA Specular texture in other nomenclature.
  51357. */
  51358. reflectivityTexture: BaseTexture;
  51359. /**
  51360. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51361. */
  51362. metallicTexture: BaseTexture;
  51363. /**
  51364. * Specifies the metallic scalar of the metallic/roughness workflow.
  51365. * Can also be used to scale the metalness values of the metallic texture.
  51366. */
  51367. metallic: Nullable<number>;
  51368. /**
  51369. * Specifies the roughness scalar of the metallic/roughness workflow.
  51370. * Can also be used to scale the roughness values of the metallic texture.
  51371. */
  51372. roughness: Nullable<number>;
  51373. /**
  51374. * Specifies the an F0 factor to help configuring the material F0.
  51375. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51376. * to 0.5 the previously hard coded value stays the same.
  51377. * Can also be used to scale the F0 values of the metallic texture.
  51378. */
  51379. metallicF0Factor: number;
  51380. /**
  51381. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51382. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51383. * your expectation as it multiplies with the texture data.
  51384. */
  51385. useMetallicF0FactorFromMetallicTexture: boolean;
  51386. /**
  51387. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51388. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51389. */
  51390. microSurfaceTexture: BaseTexture;
  51391. /**
  51392. * Stores surface normal data used to displace a mesh in a texture.
  51393. */
  51394. bumpTexture: BaseTexture;
  51395. /**
  51396. * Stores the pre-calculated light information of a mesh in a texture.
  51397. */
  51398. lightmapTexture: BaseTexture;
  51399. /**
  51400. * Stores the refracted light information in a texture.
  51401. */
  51402. refractionTexture: Nullable<BaseTexture>;
  51403. /**
  51404. * The color of a material in ambient lighting.
  51405. */
  51406. ambientColor: Color3;
  51407. /**
  51408. * AKA Diffuse Color in other nomenclature.
  51409. */
  51410. albedoColor: Color3;
  51411. /**
  51412. * AKA Specular Color in other nomenclature.
  51413. */
  51414. reflectivityColor: Color3;
  51415. /**
  51416. * The color reflected from the material.
  51417. */
  51418. reflectionColor: Color3;
  51419. /**
  51420. * The color emitted from the material.
  51421. */
  51422. emissiveColor: Color3;
  51423. /**
  51424. * AKA Glossiness in other nomenclature.
  51425. */
  51426. microSurface: number;
  51427. /**
  51428. * source material index of refraction (IOR)' / 'destination material IOR.
  51429. */
  51430. indexOfRefraction: number;
  51431. /**
  51432. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51433. */
  51434. invertRefractionY: boolean;
  51435. /**
  51436. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51437. * Materials half opaque for instance using refraction could benefit from this control.
  51438. */
  51439. linkRefractionWithTransparency: boolean;
  51440. /**
  51441. * If true, the light map contains occlusion information instead of lighting info.
  51442. */
  51443. useLightmapAsShadowmap: boolean;
  51444. /**
  51445. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51446. */
  51447. useAlphaFromAlbedoTexture: boolean;
  51448. /**
  51449. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51450. */
  51451. forceAlphaTest: boolean;
  51452. /**
  51453. * Defines the alpha limits in alpha test mode.
  51454. */
  51455. alphaCutOff: number;
  51456. /**
  51457. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51458. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51459. */
  51460. useSpecularOverAlpha: boolean;
  51461. /**
  51462. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51463. */
  51464. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51465. /**
  51466. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51467. */
  51468. useRoughnessFromMetallicTextureAlpha: boolean;
  51469. /**
  51470. * Specifies if the metallic texture contains the roughness information in its green channel.
  51471. */
  51472. useRoughnessFromMetallicTextureGreen: boolean;
  51473. /**
  51474. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51475. */
  51476. useMetallnessFromMetallicTextureBlue: boolean;
  51477. /**
  51478. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51479. */
  51480. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51481. /**
  51482. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51483. */
  51484. useAmbientInGrayScale: boolean;
  51485. /**
  51486. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51487. * The material will try to infer what glossiness each pixel should be.
  51488. */
  51489. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51490. /**
  51491. * BJS is using an harcoded light falloff based on a manually sets up range.
  51492. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51493. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51494. */
  51495. /**
  51496. * BJS is using an harcoded light falloff based on a manually sets up range.
  51497. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51498. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51499. */
  51500. usePhysicalLightFalloff: boolean;
  51501. /**
  51502. * In order to support the falloff compatibility with gltf, a special mode has been added
  51503. * to reproduce the gltf light falloff.
  51504. */
  51505. /**
  51506. * In order to support the falloff compatibility with gltf, a special mode has been added
  51507. * to reproduce the gltf light falloff.
  51508. */
  51509. useGLTFLightFalloff: boolean;
  51510. /**
  51511. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51512. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51513. */
  51514. useRadianceOverAlpha: boolean;
  51515. /**
  51516. * Allows using an object space normal map (instead of tangent space).
  51517. */
  51518. useObjectSpaceNormalMap: boolean;
  51519. /**
  51520. * Allows using the bump map in parallax mode.
  51521. */
  51522. useParallax: boolean;
  51523. /**
  51524. * Allows using the bump map in parallax occlusion mode.
  51525. */
  51526. useParallaxOcclusion: boolean;
  51527. /**
  51528. * Controls the scale bias of the parallax mode.
  51529. */
  51530. parallaxScaleBias: number;
  51531. /**
  51532. * If sets to true, disables all the lights affecting the material.
  51533. */
  51534. disableLighting: boolean;
  51535. /**
  51536. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51537. */
  51538. forceIrradianceInFragment: boolean;
  51539. /**
  51540. * Number of Simultaneous lights allowed on the material.
  51541. */
  51542. maxSimultaneousLights: number;
  51543. /**
  51544. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51545. */
  51546. invertNormalMapX: boolean;
  51547. /**
  51548. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51549. */
  51550. invertNormalMapY: boolean;
  51551. /**
  51552. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51553. */
  51554. twoSidedLighting: boolean;
  51555. /**
  51556. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51557. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51558. */
  51559. useAlphaFresnel: boolean;
  51560. /**
  51561. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51562. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51563. */
  51564. useLinearAlphaFresnel: boolean;
  51565. /**
  51566. * Let user defines the brdf lookup texture used for IBL.
  51567. * A default 8bit version is embedded but you could point at :
  51568. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51569. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51570. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51571. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51572. */
  51573. environmentBRDFTexture: Nullable<BaseTexture>;
  51574. /**
  51575. * Force normal to face away from face.
  51576. */
  51577. forceNormalForward: boolean;
  51578. /**
  51579. * Enables specular anti aliasing in the PBR shader.
  51580. * It will both interacts on the Geometry for analytical and IBL lighting.
  51581. * It also prefilter the roughness map based on the bump values.
  51582. */
  51583. enableSpecularAntiAliasing: boolean;
  51584. /**
  51585. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51586. * makes the reflect vector face the model (under horizon).
  51587. */
  51588. useHorizonOcclusion: boolean;
  51589. /**
  51590. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51591. * too much the area relying on ambient texture to define their ambient occlusion.
  51592. */
  51593. useRadianceOcclusion: boolean;
  51594. /**
  51595. * If set to true, no lighting calculations will be applied.
  51596. */
  51597. unlit: boolean;
  51598. /**
  51599. * Gets the image processing configuration used either in this material.
  51600. */
  51601. /**
  51602. * Sets the Default image processing configuration used either in the this material.
  51603. *
  51604. * If sets to null, the scene one is in use.
  51605. */
  51606. imageProcessingConfiguration: ImageProcessingConfiguration;
  51607. /**
  51608. * Gets wether the color curves effect is enabled.
  51609. */
  51610. /**
  51611. * Sets wether the color curves effect is enabled.
  51612. */
  51613. cameraColorCurvesEnabled: boolean;
  51614. /**
  51615. * Gets wether the color grading effect is enabled.
  51616. */
  51617. /**
  51618. * Gets wether the color grading effect is enabled.
  51619. */
  51620. cameraColorGradingEnabled: boolean;
  51621. /**
  51622. * Gets wether tonemapping is enabled or not.
  51623. */
  51624. /**
  51625. * Sets wether tonemapping is enabled or not
  51626. */
  51627. cameraToneMappingEnabled: boolean;
  51628. /**
  51629. * The camera exposure used on this material.
  51630. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51631. * This corresponds to a photographic exposure.
  51632. */
  51633. /**
  51634. * The camera exposure used on this material.
  51635. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51636. * This corresponds to a photographic exposure.
  51637. */
  51638. cameraExposure: number;
  51639. /**
  51640. * Gets The camera contrast used on this material.
  51641. */
  51642. /**
  51643. * Sets The camera contrast used on this material.
  51644. */
  51645. cameraContrast: number;
  51646. /**
  51647. * Gets the Color Grading 2D Lookup Texture.
  51648. */
  51649. /**
  51650. * Sets the Color Grading 2D Lookup Texture.
  51651. */
  51652. cameraColorGradingTexture: Nullable<BaseTexture>;
  51653. /**
  51654. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51655. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51656. * 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;
  51657. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51658. */
  51659. /**
  51660. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51661. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51662. * 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;
  51663. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51664. */
  51665. cameraColorCurves: Nullable<ColorCurves>;
  51666. /**
  51667. * Instantiates a new PBRMaterial instance.
  51668. *
  51669. * @param name The material name
  51670. * @param scene The scene the material will be use in.
  51671. */
  51672. constructor(name: string, scene: Scene);
  51673. /**
  51674. * Returns the name of this material class.
  51675. */
  51676. getClassName(): string;
  51677. /**
  51678. * Makes a duplicate of the current material.
  51679. * @param name - name to use for the new material.
  51680. */
  51681. clone(name: string): PBRMaterial;
  51682. /**
  51683. * Serializes this PBR Material.
  51684. * @returns - An object with the serialized material.
  51685. */
  51686. serialize(): any;
  51687. /**
  51688. * Parses a PBR Material from a serialized object.
  51689. * @param source - Serialized object.
  51690. * @param scene - BJS scene instance.
  51691. * @param rootUrl - url for the scene object
  51692. * @returns - PBRMaterial
  51693. */
  51694. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51695. }
  51696. }
  51697. declare module "babylonjs/Misc/dds" {
  51698. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51699. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51700. import { Nullable } from "babylonjs/types";
  51701. import { Scene } from "babylonjs/scene";
  51702. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51703. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51704. /**
  51705. * Direct draw surface info
  51706. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51707. */
  51708. export interface DDSInfo {
  51709. /**
  51710. * Width of the texture
  51711. */
  51712. width: number;
  51713. /**
  51714. * Width of the texture
  51715. */
  51716. height: number;
  51717. /**
  51718. * Number of Mipmaps for the texture
  51719. * @see https://en.wikipedia.org/wiki/Mipmap
  51720. */
  51721. mipmapCount: number;
  51722. /**
  51723. * If the textures format is a known fourCC format
  51724. * @see https://www.fourcc.org/
  51725. */
  51726. isFourCC: boolean;
  51727. /**
  51728. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51729. */
  51730. isRGB: boolean;
  51731. /**
  51732. * If the texture is a lumincance format
  51733. */
  51734. isLuminance: boolean;
  51735. /**
  51736. * If this is a cube texture
  51737. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51738. */
  51739. isCube: boolean;
  51740. /**
  51741. * If the texture is a compressed format eg. FOURCC_DXT1
  51742. */
  51743. isCompressed: boolean;
  51744. /**
  51745. * The dxgiFormat of the texture
  51746. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51747. */
  51748. dxgiFormat: number;
  51749. /**
  51750. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51751. */
  51752. textureType: number;
  51753. /**
  51754. * Sphericle polynomial created for the dds texture
  51755. */
  51756. sphericalPolynomial?: SphericalPolynomial;
  51757. }
  51758. /**
  51759. * Class used to provide DDS decompression tools
  51760. */
  51761. export class DDSTools {
  51762. /**
  51763. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51764. */
  51765. static StoreLODInAlphaChannel: boolean;
  51766. /**
  51767. * Gets DDS information from an array buffer
  51768. * @param arrayBuffer defines the array buffer to read data from
  51769. * @returns the DDS information
  51770. */
  51771. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51772. private static _FloatView;
  51773. private static _Int32View;
  51774. private static _ToHalfFloat;
  51775. private static _FromHalfFloat;
  51776. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51777. private static _GetHalfFloatRGBAArrayBuffer;
  51778. private static _GetFloatRGBAArrayBuffer;
  51779. private static _GetFloatAsUIntRGBAArrayBuffer;
  51780. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51781. private static _GetRGBAArrayBuffer;
  51782. private static _ExtractLongWordOrder;
  51783. private static _GetRGBArrayBuffer;
  51784. private static _GetLuminanceArrayBuffer;
  51785. /**
  51786. * Uploads DDS Levels to a Babylon Texture
  51787. * @hidden
  51788. */
  51789. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51790. }
  51791. module "babylonjs/Engines/thinEngine" {
  51792. interface ThinEngine {
  51793. /**
  51794. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51795. * @param rootUrl defines the url where the file to load is located
  51796. * @param scene defines the current scene
  51797. * @param lodScale defines scale to apply to the mip map selection
  51798. * @param lodOffset defines offset to apply to the mip map selection
  51799. * @param onLoad defines an optional callback raised when the texture is loaded
  51800. * @param onError defines an optional callback raised if there is an issue to load the texture
  51801. * @param format defines the format of the data
  51802. * @param forcedExtension defines the extension to use to pick the right loader
  51803. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51804. * @returns the cube texture as an InternalTexture
  51805. */
  51806. 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;
  51807. }
  51808. }
  51809. }
  51810. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51811. import { Nullable } from "babylonjs/types";
  51812. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51813. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51814. /**
  51815. * Implementation of the DDS Texture Loader.
  51816. * @hidden
  51817. */
  51818. export class _DDSTextureLoader implements IInternalTextureLoader {
  51819. /**
  51820. * Defines wether the loader supports cascade loading the different faces.
  51821. */
  51822. readonly supportCascades: boolean;
  51823. /**
  51824. * This returns if the loader support the current file information.
  51825. * @param extension defines the file extension of the file being loaded
  51826. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51827. * @param fallback defines the fallback internal texture if any
  51828. * @param isBase64 defines whether the texture is encoded as a base64
  51829. * @param isBuffer defines whether the texture data are stored as a buffer
  51830. * @returns true if the loader can load the specified file
  51831. */
  51832. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51833. /**
  51834. * Transform the url before loading if required.
  51835. * @param rootUrl the url of the texture
  51836. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51837. * @returns the transformed texture
  51838. */
  51839. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51840. /**
  51841. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51842. * @param rootUrl the url of the texture
  51843. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51844. * @returns the fallback texture
  51845. */
  51846. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51847. /**
  51848. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51849. * @param data contains the texture data
  51850. * @param texture defines the BabylonJS internal texture
  51851. * @param createPolynomials will be true if polynomials have been requested
  51852. * @param onLoad defines the callback to trigger once the texture is ready
  51853. * @param onError defines the callback to trigger in case of error
  51854. */
  51855. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51856. /**
  51857. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51858. * @param data contains the texture data
  51859. * @param texture defines the BabylonJS internal texture
  51860. * @param callback defines the method to call once ready to upload
  51861. */
  51862. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51863. }
  51864. }
  51865. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51866. import { Nullable } from "babylonjs/types";
  51867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51868. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51869. /**
  51870. * Implementation of the ENV Texture Loader.
  51871. * @hidden
  51872. */
  51873. export class _ENVTextureLoader implements IInternalTextureLoader {
  51874. /**
  51875. * Defines wether the loader supports cascade loading the different faces.
  51876. */
  51877. readonly supportCascades: boolean;
  51878. /**
  51879. * This returns if the loader support the current file information.
  51880. * @param extension defines the file extension of the file being loaded
  51881. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51882. * @param fallback defines the fallback internal texture if any
  51883. * @param isBase64 defines whether the texture is encoded as a base64
  51884. * @param isBuffer defines whether the texture data are stored as a buffer
  51885. * @returns true if the loader can load the specified file
  51886. */
  51887. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51888. /**
  51889. * Transform the url before loading if required.
  51890. * @param rootUrl the url of the texture
  51891. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51892. * @returns the transformed texture
  51893. */
  51894. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51895. /**
  51896. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51897. * @param rootUrl the url of the texture
  51898. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51899. * @returns the fallback texture
  51900. */
  51901. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51902. /**
  51903. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51904. * @param data contains the texture data
  51905. * @param texture defines the BabylonJS internal texture
  51906. * @param createPolynomials will be true if polynomials have been requested
  51907. * @param onLoad defines the callback to trigger once the texture is ready
  51908. * @param onError defines the callback to trigger in case of error
  51909. */
  51910. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51911. /**
  51912. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51913. * @param data contains the texture data
  51914. * @param texture defines the BabylonJS internal texture
  51915. * @param callback defines the method to call once ready to upload
  51916. */
  51917. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51918. }
  51919. }
  51920. declare module "babylonjs/Misc/khronosTextureContainer" {
  51921. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51922. /**
  51923. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51924. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51925. */
  51926. export class KhronosTextureContainer {
  51927. /** contents of the KTX container file */
  51928. arrayBuffer: any;
  51929. private static HEADER_LEN;
  51930. private static COMPRESSED_2D;
  51931. private static COMPRESSED_3D;
  51932. private static TEX_2D;
  51933. private static TEX_3D;
  51934. /**
  51935. * Gets the openGL type
  51936. */
  51937. glType: number;
  51938. /**
  51939. * Gets the openGL type size
  51940. */
  51941. glTypeSize: number;
  51942. /**
  51943. * Gets the openGL format
  51944. */
  51945. glFormat: number;
  51946. /**
  51947. * Gets the openGL internal format
  51948. */
  51949. glInternalFormat: number;
  51950. /**
  51951. * Gets the base internal format
  51952. */
  51953. glBaseInternalFormat: number;
  51954. /**
  51955. * Gets image width in pixel
  51956. */
  51957. pixelWidth: number;
  51958. /**
  51959. * Gets image height in pixel
  51960. */
  51961. pixelHeight: number;
  51962. /**
  51963. * Gets image depth in pixels
  51964. */
  51965. pixelDepth: number;
  51966. /**
  51967. * Gets the number of array elements
  51968. */
  51969. numberOfArrayElements: number;
  51970. /**
  51971. * Gets the number of faces
  51972. */
  51973. numberOfFaces: number;
  51974. /**
  51975. * Gets the number of mipmap levels
  51976. */
  51977. numberOfMipmapLevels: number;
  51978. /**
  51979. * Gets the bytes of key value data
  51980. */
  51981. bytesOfKeyValueData: number;
  51982. /**
  51983. * Gets the load type
  51984. */
  51985. loadType: number;
  51986. /**
  51987. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51988. */
  51989. isInvalid: boolean;
  51990. /**
  51991. * Creates a new KhronosTextureContainer
  51992. * @param arrayBuffer contents of the KTX container file
  51993. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51994. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51995. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51996. */
  51997. constructor(
  51998. /** contents of the KTX container file */
  51999. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52000. /**
  52001. * Uploads KTX content to a Babylon Texture.
  52002. * It is assumed that the texture has already been created & is currently bound
  52003. * @hidden
  52004. */
  52005. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52006. private _upload2DCompressedLevels;
  52007. }
  52008. }
  52009. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  52010. import { Nullable } from "babylonjs/types";
  52011. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52012. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52013. /**
  52014. * Implementation of the KTX Texture Loader.
  52015. * @hidden
  52016. */
  52017. export class _KTXTextureLoader implements IInternalTextureLoader {
  52018. /**
  52019. * Defines wether the loader supports cascade loading the different faces.
  52020. */
  52021. readonly supportCascades: boolean;
  52022. /**
  52023. * This returns if the loader support the current file information.
  52024. * @param extension defines the file extension of the file being loaded
  52025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52026. * @param fallback defines the fallback internal texture if any
  52027. * @param isBase64 defines whether the texture is encoded as a base64
  52028. * @param isBuffer defines whether the texture data are stored as a buffer
  52029. * @returns true if the loader can load the specified file
  52030. */
  52031. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52032. /**
  52033. * Transform the url before loading if required.
  52034. * @param rootUrl the url of the texture
  52035. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52036. * @returns the transformed texture
  52037. */
  52038. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52039. /**
  52040. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52041. * @param rootUrl the url of the texture
  52042. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52043. * @returns the fallback texture
  52044. */
  52045. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52046. /**
  52047. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52048. * @param data contains the texture data
  52049. * @param texture defines the BabylonJS internal texture
  52050. * @param createPolynomials will be true if polynomials have been requested
  52051. * @param onLoad defines the callback to trigger once the texture is ready
  52052. * @param onError defines the callback to trigger in case of error
  52053. */
  52054. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52055. /**
  52056. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52057. * @param data contains the texture data
  52058. * @param texture defines the BabylonJS internal texture
  52059. * @param callback defines the method to call once ready to upload
  52060. */
  52061. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52062. }
  52063. }
  52064. declare module "babylonjs/Helpers/sceneHelpers" {
  52065. import { Nullable } from "babylonjs/types";
  52066. import { Mesh } from "babylonjs/Meshes/mesh";
  52067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52068. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  52069. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  52070. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52071. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52072. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52073. import "babylonjs/Meshes/Builders/boxBuilder";
  52074. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  52075. /** @hidden */
  52076. export var _forceSceneHelpersToBundle: boolean;
  52077. module "babylonjs/scene" {
  52078. interface Scene {
  52079. /**
  52080. * Creates a default light for the scene.
  52081. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52082. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52083. */
  52084. createDefaultLight(replace?: boolean): void;
  52085. /**
  52086. * Creates a default camera for the scene.
  52087. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52088. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52089. * @param replace has default false, when true replaces the active camera in the scene
  52090. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52091. */
  52092. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52093. /**
  52094. * Creates a default camera and a default light.
  52095. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52096. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52097. * @param replace has the default false, when true replaces the active camera/light in the scene
  52098. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52099. */
  52100. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52101. /**
  52102. * Creates a new sky box
  52103. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52104. * @param environmentTexture defines the texture to use as environment texture
  52105. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52106. * @param scale defines the overall scale of the skybox
  52107. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52108. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52109. * @returns a new mesh holding the sky box
  52110. */
  52111. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52112. /**
  52113. * Creates a new environment
  52114. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52115. * @param options defines the options you can use to configure the environment
  52116. * @returns the new EnvironmentHelper
  52117. */
  52118. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52119. /**
  52120. * Creates a new VREXperienceHelper
  52121. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52122. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52123. * @returns a new VREXperienceHelper
  52124. */
  52125. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52126. /**
  52127. * Creates a new WebXRDefaultExperience
  52128. * @see http://doc.babylonjs.com/how_to/webxr
  52129. * @param options experience options
  52130. * @returns a promise for a new WebXRDefaultExperience
  52131. */
  52132. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52133. }
  52134. }
  52135. }
  52136. declare module "babylonjs/Helpers/videoDome" {
  52137. import { Scene } from "babylonjs/scene";
  52138. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52139. import { Mesh } from "babylonjs/Meshes/mesh";
  52140. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  52141. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52142. import "babylonjs/Meshes/Builders/sphereBuilder";
  52143. /**
  52144. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52145. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52146. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52147. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52148. */
  52149. export class VideoDome extends TransformNode {
  52150. /**
  52151. * Define the video source as a Monoscopic panoramic 360 video.
  52152. */
  52153. static readonly MODE_MONOSCOPIC: number;
  52154. /**
  52155. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52156. */
  52157. static readonly MODE_TOPBOTTOM: number;
  52158. /**
  52159. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52160. */
  52161. static readonly MODE_SIDEBYSIDE: number;
  52162. private _halfDome;
  52163. private _useDirectMapping;
  52164. /**
  52165. * The video texture being displayed on the sphere
  52166. */
  52167. protected _videoTexture: VideoTexture;
  52168. /**
  52169. * Gets the video texture being displayed on the sphere
  52170. */
  52171. readonly videoTexture: VideoTexture;
  52172. /**
  52173. * The skybox material
  52174. */
  52175. protected _material: BackgroundMaterial;
  52176. /**
  52177. * The surface used for the skybox
  52178. */
  52179. protected _mesh: Mesh;
  52180. /**
  52181. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52182. */
  52183. private _halfDomeMask;
  52184. /**
  52185. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52186. * Also see the options.resolution property.
  52187. */
  52188. fovMultiplier: number;
  52189. private _videoMode;
  52190. /**
  52191. * Gets or set the current video mode for the video. It can be:
  52192. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52193. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52194. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52195. */
  52196. videoMode: number;
  52197. /**
  52198. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52199. *
  52200. */
  52201. /**
  52202. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52203. */
  52204. halfDome: boolean;
  52205. /**
  52206. * Oberserver used in Stereoscopic VR Mode.
  52207. */
  52208. private _onBeforeCameraRenderObserver;
  52209. /**
  52210. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52211. * @param name Element's name, child elements will append suffixes for their own names.
  52212. * @param urlsOrVideo defines the url(s) or the video element to use
  52213. * @param options An object containing optional or exposed sub element properties
  52214. */
  52215. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52216. resolution?: number;
  52217. clickToPlay?: boolean;
  52218. autoPlay?: boolean;
  52219. loop?: boolean;
  52220. size?: number;
  52221. poster?: string;
  52222. faceForward?: boolean;
  52223. useDirectMapping?: boolean;
  52224. halfDomeMode?: boolean;
  52225. }, scene: Scene);
  52226. private _changeVideoMode;
  52227. /**
  52228. * Releases resources associated with this node.
  52229. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52230. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52231. */
  52232. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52233. }
  52234. }
  52235. declare module "babylonjs/Helpers/index" {
  52236. export * from "babylonjs/Helpers/environmentHelper";
  52237. export * from "babylonjs/Helpers/photoDome";
  52238. export * from "babylonjs/Helpers/sceneHelpers";
  52239. export * from "babylonjs/Helpers/videoDome";
  52240. }
  52241. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  52242. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52243. import { IDisposable } from "babylonjs/scene";
  52244. import { Engine } from "babylonjs/Engines/engine";
  52245. /**
  52246. * This class can be used to get instrumentation data from a Babylon engine
  52247. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52248. */
  52249. export class EngineInstrumentation implements IDisposable {
  52250. /**
  52251. * Define the instrumented engine.
  52252. */
  52253. engine: Engine;
  52254. private _captureGPUFrameTime;
  52255. private _gpuFrameTimeToken;
  52256. private _gpuFrameTime;
  52257. private _captureShaderCompilationTime;
  52258. private _shaderCompilationTime;
  52259. private _onBeginFrameObserver;
  52260. private _onEndFrameObserver;
  52261. private _onBeforeShaderCompilationObserver;
  52262. private _onAfterShaderCompilationObserver;
  52263. /**
  52264. * Gets the perf counter used for GPU frame time
  52265. */
  52266. readonly gpuFrameTimeCounter: PerfCounter;
  52267. /**
  52268. * Gets the GPU frame time capture status
  52269. */
  52270. /**
  52271. * Enable or disable the GPU frame time capture
  52272. */
  52273. captureGPUFrameTime: boolean;
  52274. /**
  52275. * Gets the perf counter used for shader compilation time
  52276. */
  52277. readonly shaderCompilationTimeCounter: PerfCounter;
  52278. /**
  52279. * Gets the shader compilation time capture status
  52280. */
  52281. /**
  52282. * Enable or disable the shader compilation time capture
  52283. */
  52284. captureShaderCompilationTime: boolean;
  52285. /**
  52286. * Instantiates a new engine instrumentation.
  52287. * This class can be used to get instrumentation data from a Babylon engine
  52288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52289. * @param engine Defines the engine to instrument
  52290. */
  52291. constructor(
  52292. /**
  52293. * Define the instrumented engine.
  52294. */
  52295. engine: Engine);
  52296. /**
  52297. * Dispose and release associated resources.
  52298. */
  52299. dispose(): void;
  52300. }
  52301. }
  52302. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52303. import { Scene, IDisposable } from "babylonjs/scene";
  52304. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52305. /**
  52306. * This class can be used to get instrumentation data from a Babylon engine
  52307. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52308. */
  52309. export class SceneInstrumentation implements IDisposable {
  52310. /**
  52311. * Defines the scene to instrument
  52312. */
  52313. scene: Scene;
  52314. private _captureActiveMeshesEvaluationTime;
  52315. private _activeMeshesEvaluationTime;
  52316. private _captureRenderTargetsRenderTime;
  52317. private _renderTargetsRenderTime;
  52318. private _captureFrameTime;
  52319. private _frameTime;
  52320. private _captureRenderTime;
  52321. private _renderTime;
  52322. private _captureInterFrameTime;
  52323. private _interFrameTime;
  52324. private _captureParticlesRenderTime;
  52325. private _particlesRenderTime;
  52326. private _captureSpritesRenderTime;
  52327. private _spritesRenderTime;
  52328. private _capturePhysicsTime;
  52329. private _physicsTime;
  52330. private _captureAnimationsTime;
  52331. private _animationsTime;
  52332. private _captureCameraRenderTime;
  52333. private _cameraRenderTime;
  52334. private _onBeforeActiveMeshesEvaluationObserver;
  52335. private _onAfterActiveMeshesEvaluationObserver;
  52336. private _onBeforeRenderTargetsRenderObserver;
  52337. private _onAfterRenderTargetsRenderObserver;
  52338. private _onAfterRenderObserver;
  52339. private _onBeforeDrawPhaseObserver;
  52340. private _onAfterDrawPhaseObserver;
  52341. private _onBeforeAnimationsObserver;
  52342. private _onBeforeParticlesRenderingObserver;
  52343. private _onAfterParticlesRenderingObserver;
  52344. private _onBeforeSpritesRenderingObserver;
  52345. private _onAfterSpritesRenderingObserver;
  52346. private _onBeforePhysicsObserver;
  52347. private _onAfterPhysicsObserver;
  52348. private _onAfterAnimationsObserver;
  52349. private _onBeforeCameraRenderObserver;
  52350. private _onAfterCameraRenderObserver;
  52351. /**
  52352. * Gets the perf counter used for active meshes evaluation time
  52353. */
  52354. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52355. /**
  52356. * Gets the active meshes evaluation time capture status
  52357. */
  52358. /**
  52359. * Enable or disable the active meshes evaluation time capture
  52360. */
  52361. captureActiveMeshesEvaluationTime: boolean;
  52362. /**
  52363. * Gets the perf counter used for render targets render time
  52364. */
  52365. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52366. /**
  52367. * Gets the render targets render time capture status
  52368. */
  52369. /**
  52370. * Enable or disable the render targets render time capture
  52371. */
  52372. captureRenderTargetsRenderTime: boolean;
  52373. /**
  52374. * Gets the perf counter used for particles render time
  52375. */
  52376. readonly particlesRenderTimeCounter: PerfCounter;
  52377. /**
  52378. * Gets the particles render time capture status
  52379. */
  52380. /**
  52381. * Enable or disable the particles render time capture
  52382. */
  52383. captureParticlesRenderTime: boolean;
  52384. /**
  52385. * Gets the perf counter used for sprites render time
  52386. */
  52387. readonly spritesRenderTimeCounter: PerfCounter;
  52388. /**
  52389. * Gets the sprites render time capture status
  52390. */
  52391. /**
  52392. * Enable or disable the sprites render time capture
  52393. */
  52394. captureSpritesRenderTime: boolean;
  52395. /**
  52396. * Gets the perf counter used for physics time
  52397. */
  52398. readonly physicsTimeCounter: PerfCounter;
  52399. /**
  52400. * Gets the physics time capture status
  52401. */
  52402. /**
  52403. * Enable or disable the physics time capture
  52404. */
  52405. capturePhysicsTime: boolean;
  52406. /**
  52407. * Gets the perf counter used for animations time
  52408. */
  52409. readonly animationsTimeCounter: PerfCounter;
  52410. /**
  52411. * Gets the animations time capture status
  52412. */
  52413. /**
  52414. * Enable or disable the animations time capture
  52415. */
  52416. captureAnimationsTime: boolean;
  52417. /**
  52418. * Gets the perf counter used for frame time capture
  52419. */
  52420. readonly frameTimeCounter: PerfCounter;
  52421. /**
  52422. * Gets the frame time capture status
  52423. */
  52424. /**
  52425. * Enable or disable the frame time capture
  52426. */
  52427. captureFrameTime: boolean;
  52428. /**
  52429. * Gets the perf counter used for inter-frames time capture
  52430. */
  52431. readonly interFrameTimeCounter: PerfCounter;
  52432. /**
  52433. * Gets the inter-frames time capture status
  52434. */
  52435. /**
  52436. * Enable or disable the inter-frames time capture
  52437. */
  52438. captureInterFrameTime: boolean;
  52439. /**
  52440. * Gets the perf counter used for render time capture
  52441. */
  52442. readonly renderTimeCounter: PerfCounter;
  52443. /**
  52444. * Gets the render time capture status
  52445. */
  52446. /**
  52447. * Enable or disable the render time capture
  52448. */
  52449. captureRenderTime: boolean;
  52450. /**
  52451. * Gets the perf counter used for camera render time capture
  52452. */
  52453. readonly cameraRenderTimeCounter: PerfCounter;
  52454. /**
  52455. * Gets the camera render time capture status
  52456. */
  52457. /**
  52458. * Enable or disable the camera render time capture
  52459. */
  52460. captureCameraRenderTime: boolean;
  52461. /**
  52462. * Gets the perf counter used for draw calls
  52463. */
  52464. readonly drawCallsCounter: PerfCounter;
  52465. /**
  52466. * Instantiates a new scene instrumentation.
  52467. * This class can be used to get instrumentation data from a Babylon engine
  52468. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52469. * @param scene Defines the scene to instrument
  52470. */
  52471. constructor(
  52472. /**
  52473. * Defines the scene to instrument
  52474. */
  52475. scene: Scene);
  52476. /**
  52477. * Dispose and release associated resources.
  52478. */
  52479. dispose(): void;
  52480. }
  52481. }
  52482. declare module "babylonjs/Instrumentation/index" {
  52483. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52484. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52485. export * from "babylonjs/Instrumentation/timeToken";
  52486. }
  52487. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52488. /** @hidden */
  52489. export var glowMapGenerationPixelShader: {
  52490. name: string;
  52491. shader: string;
  52492. };
  52493. }
  52494. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52495. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52496. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52497. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52498. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52499. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52500. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52501. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52502. /** @hidden */
  52503. export var glowMapGenerationVertexShader: {
  52504. name: string;
  52505. shader: string;
  52506. };
  52507. }
  52508. declare module "babylonjs/Layers/effectLayer" {
  52509. import { Observable } from "babylonjs/Misc/observable";
  52510. import { Nullable } from "babylonjs/types";
  52511. import { Camera } from "babylonjs/Cameras/camera";
  52512. import { Scene } from "babylonjs/scene";
  52513. import { ISize } from "babylonjs/Maths/math.size";
  52514. import { Color4 } from "babylonjs/Maths/math.color";
  52515. import { Engine } from "babylonjs/Engines/engine";
  52516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52518. import { Mesh } from "babylonjs/Meshes/mesh";
  52519. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52521. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52522. import { Effect } from "babylonjs/Materials/effect";
  52523. import { Material } from "babylonjs/Materials/material";
  52524. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52525. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52526. /**
  52527. * Effect layer options. This helps customizing the behaviour
  52528. * of the effect layer.
  52529. */
  52530. export interface IEffectLayerOptions {
  52531. /**
  52532. * Multiplication factor apply to the canvas size to compute the render target size
  52533. * used to generated the objects (the smaller the faster).
  52534. */
  52535. mainTextureRatio: number;
  52536. /**
  52537. * Enforces a fixed size texture to ensure effect stability across devices.
  52538. */
  52539. mainTextureFixedSize?: number;
  52540. /**
  52541. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52542. */
  52543. alphaBlendingMode: number;
  52544. /**
  52545. * The camera attached to the layer.
  52546. */
  52547. camera: Nullable<Camera>;
  52548. /**
  52549. * The rendering group to draw the layer in.
  52550. */
  52551. renderingGroupId: number;
  52552. }
  52553. /**
  52554. * The effect layer Helps adding post process effect blended with the main pass.
  52555. *
  52556. * This can be for instance use to generate glow or higlight effects on the scene.
  52557. *
  52558. * The effect layer class can not be used directly and is intented to inherited from to be
  52559. * customized per effects.
  52560. */
  52561. export abstract class EffectLayer {
  52562. private _vertexBuffers;
  52563. private _indexBuffer;
  52564. private _cachedDefines;
  52565. private _effectLayerMapGenerationEffect;
  52566. private _effectLayerOptions;
  52567. private _mergeEffect;
  52568. protected _scene: Scene;
  52569. protected _engine: Engine;
  52570. protected _maxSize: number;
  52571. protected _mainTextureDesiredSize: ISize;
  52572. protected _mainTexture: RenderTargetTexture;
  52573. protected _shouldRender: boolean;
  52574. protected _postProcesses: PostProcess[];
  52575. protected _textures: BaseTexture[];
  52576. protected _emissiveTextureAndColor: {
  52577. texture: Nullable<BaseTexture>;
  52578. color: Color4;
  52579. };
  52580. /**
  52581. * The name of the layer
  52582. */
  52583. name: string;
  52584. /**
  52585. * The clear color of the texture used to generate the glow map.
  52586. */
  52587. neutralColor: Color4;
  52588. /**
  52589. * Specifies wether the highlight layer is enabled or not.
  52590. */
  52591. isEnabled: boolean;
  52592. /**
  52593. * Gets the camera attached to the layer.
  52594. */
  52595. readonly camera: Nullable<Camera>;
  52596. /**
  52597. * Gets the rendering group id the layer should render in.
  52598. */
  52599. renderingGroupId: number;
  52600. /**
  52601. * An event triggered when the effect layer has been disposed.
  52602. */
  52603. onDisposeObservable: Observable<EffectLayer>;
  52604. /**
  52605. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52606. */
  52607. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52608. /**
  52609. * An event triggered when the generated texture is being merged in the scene.
  52610. */
  52611. onBeforeComposeObservable: Observable<EffectLayer>;
  52612. /**
  52613. * An event triggered when the mesh is rendered into the effect render target.
  52614. */
  52615. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52616. /**
  52617. * An event triggered after the mesh has been rendered into the effect render target.
  52618. */
  52619. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52620. /**
  52621. * An event triggered when the generated texture has been merged in the scene.
  52622. */
  52623. onAfterComposeObservable: Observable<EffectLayer>;
  52624. /**
  52625. * An event triggered when the efffect layer changes its size.
  52626. */
  52627. onSizeChangedObservable: Observable<EffectLayer>;
  52628. /** @hidden */
  52629. static _SceneComponentInitialization: (scene: Scene) => void;
  52630. /**
  52631. * Instantiates a new effect Layer and references it in the scene.
  52632. * @param name The name of the layer
  52633. * @param scene The scene to use the layer in
  52634. */
  52635. constructor(
  52636. /** The Friendly of the effect in the scene */
  52637. name: string, scene: Scene);
  52638. /**
  52639. * Get the effect name of the layer.
  52640. * @return The effect name
  52641. */
  52642. abstract getEffectName(): string;
  52643. /**
  52644. * Checks for the readiness of the element composing the layer.
  52645. * @param subMesh the mesh to check for
  52646. * @param useInstances specify wether or not to use instances to render the mesh
  52647. * @return true if ready otherwise, false
  52648. */
  52649. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52650. /**
  52651. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52652. * @returns true if the effect requires stencil during the main canvas render pass.
  52653. */
  52654. abstract needStencil(): boolean;
  52655. /**
  52656. * Create the merge effect. This is the shader use to blit the information back
  52657. * to the main canvas at the end of the scene rendering.
  52658. * @returns The effect containing the shader used to merge the effect on the main canvas
  52659. */
  52660. protected abstract _createMergeEffect(): Effect;
  52661. /**
  52662. * Creates the render target textures and post processes used in the effect layer.
  52663. */
  52664. protected abstract _createTextureAndPostProcesses(): void;
  52665. /**
  52666. * Implementation specific of rendering the generating effect on the main canvas.
  52667. * @param effect The effect used to render through
  52668. */
  52669. protected abstract _internalRender(effect: Effect): void;
  52670. /**
  52671. * Sets the required values for both the emissive texture and and the main color.
  52672. */
  52673. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52674. /**
  52675. * Free any resources and references associated to a mesh.
  52676. * Internal use
  52677. * @param mesh The mesh to free.
  52678. */
  52679. abstract _disposeMesh(mesh: Mesh): void;
  52680. /**
  52681. * Serializes this layer (Glow or Highlight for example)
  52682. * @returns a serialized layer object
  52683. */
  52684. abstract serialize?(): any;
  52685. /**
  52686. * Initializes the effect layer with the required options.
  52687. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52688. */
  52689. protected _init(options: Partial<IEffectLayerOptions>): void;
  52690. /**
  52691. * Generates the index buffer of the full screen quad blending to the main canvas.
  52692. */
  52693. private _generateIndexBuffer;
  52694. /**
  52695. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52696. */
  52697. private _generateVertexBuffer;
  52698. /**
  52699. * Sets the main texture desired size which is the closest power of two
  52700. * of the engine canvas size.
  52701. */
  52702. private _setMainTextureSize;
  52703. /**
  52704. * Creates the main texture for the effect layer.
  52705. */
  52706. protected _createMainTexture(): void;
  52707. /**
  52708. * Adds specific effects defines.
  52709. * @param defines The defines to add specifics to.
  52710. */
  52711. protected _addCustomEffectDefines(defines: string[]): void;
  52712. /**
  52713. * Checks for the readiness of the element composing the layer.
  52714. * @param subMesh the mesh to check for
  52715. * @param useInstances specify wether or not to use instances to render the mesh
  52716. * @param emissiveTexture the associated emissive texture used to generate the glow
  52717. * @return true if ready otherwise, false
  52718. */
  52719. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52720. /**
  52721. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52722. */
  52723. render(): void;
  52724. /**
  52725. * Determine if a given mesh will be used in the current effect.
  52726. * @param mesh mesh to test
  52727. * @returns true if the mesh will be used
  52728. */
  52729. hasMesh(mesh: AbstractMesh): boolean;
  52730. /**
  52731. * Returns true if the layer contains information to display, otherwise false.
  52732. * @returns true if the glow layer should be rendered
  52733. */
  52734. shouldRender(): boolean;
  52735. /**
  52736. * Returns true if the mesh should render, otherwise false.
  52737. * @param mesh The mesh to render
  52738. * @returns true if it should render otherwise false
  52739. */
  52740. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52741. /**
  52742. * Returns true if the mesh can be rendered, otherwise false.
  52743. * @param mesh The mesh to render
  52744. * @param material The material used on the mesh
  52745. * @returns true if it can be rendered otherwise false
  52746. */
  52747. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52748. /**
  52749. * Returns true if the mesh should render, otherwise false.
  52750. * @param mesh The mesh to render
  52751. * @returns true if it should render otherwise false
  52752. */
  52753. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52754. /**
  52755. * Renders the submesh passed in parameter to the generation map.
  52756. */
  52757. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52758. /**
  52759. * Defines wether the current material of the mesh should be use to render the effect.
  52760. * @param mesh defines the current mesh to render
  52761. */
  52762. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52763. /**
  52764. * Rebuild the required buffers.
  52765. * @hidden Internal use only.
  52766. */
  52767. _rebuild(): void;
  52768. /**
  52769. * Dispose only the render target textures and post process.
  52770. */
  52771. private _disposeTextureAndPostProcesses;
  52772. /**
  52773. * Dispose the highlight layer and free resources.
  52774. */
  52775. dispose(): void;
  52776. /**
  52777. * Gets the class name of the effect layer
  52778. * @returns the string with the class name of the effect layer
  52779. */
  52780. getClassName(): string;
  52781. /**
  52782. * Creates an effect layer from parsed effect layer data
  52783. * @param parsedEffectLayer defines effect layer data
  52784. * @param scene defines the current scene
  52785. * @param rootUrl defines the root URL containing the effect layer information
  52786. * @returns a parsed effect Layer
  52787. */
  52788. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52789. }
  52790. }
  52791. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52792. import { Scene } from "babylonjs/scene";
  52793. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52794. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52795. import { AbstractScene } from "babylonjs/abstractScene";
  52796. module "babylonjs/abstractScene" {
  52797. interface AbstractScene {
  52798. /**
  52799. * The list of effect layers (highlights/glow) added to the scene
  52800. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52801. * @see http://doc.babylonjs.com/how_to/glow_layer
  52802. */
  52803. effectLayers: Array<EffectLayer>;
  52804. /**
  52805. * Removes the given effect layer from this scene.
  52806. * @param toRemove defines the effect layer to remove
  52807. * @returns the index of the removed effect layer
  52808. */
  52809. removeEffectLayer(toRemove: EffectLayer): number;
  52810. /**
  52811. * Adds the given effect layer to this scene
  52812. * @param newEffectLayer defines the effect layer to add
  52813. */
  52814. addEffectLayer(newEffectLayer: EffectLayer): void;
  52815. }
  52816. }
  52817. /**
  52818. * Defines the layer scene component responsible to manage any effect layers
  52819. * in a given scene.
  52820. */
  52821. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52822. /**
  52823. * The component name helpfull to identify the component in the list of scene components.
  52824. */
  52825. readonly name: string;
  52826. /**
  52827. * The scene the component belongs to.
  52828. */
  52829. scene: Scene;
  52830. private _engine;
  52831. private _renderEffects;
  52832. private _needStencil;
  52833. private _previousStencilState;
  52834. /**
  52835. * Creates a new instance of the component for the given scene
  52836. * @param scene Defines the scene to register the component in
  52837. */
  52838. constructor(scene: Scene);
  52839. /**
  52840. * Registers the component in a given scene
  52841. */
  52842. register(): void;
  52843. /**
  52844. * Rebuilds the elements related to this component in case of
  52845. * context lost for instance.
  52846. */
  52847. rebuild(): void;
  52848. /**
  52849. * Serializes the component data to the specified json object
  52850. * @param serializationObject The object to serialize to
  52851. */
  52852. serialize(serializationObject: any): void;
  52853. /**
  52854. * Adds all the elements from the container to the scene
  52855. * @param container the container holding the elements
  52856. */
  52857. addFromContainer(container: AbstractScene): void;
  52858. /**
  52859. * Removes all the elements in the container from the scene
  52860. * @param container contains the elements to remove
  52861. * @param dispose if the removed element should be disposed (default: false)
  52862. */
  52863. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52864. /**
  52865. * Disposes the component and the associated ressources.
  52866. */
  52867. dispose(): void;
  52868. private _isReadyForMesh;
  52869. private _renderMainTexture;
  52870. private _setStencil;
  52871. private _setStencilBack;
  52872. private _draw;
  52873. private _drawCamera;
  52874. private _drawRenderingGroup;
  52875. }
  52876. }
  52877. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52878. /** @hidden */
  52879. export var glowMapMergePixelShader: {
  52880. name: string;
  52881. shader: string;
  52882. };
  52883. }
  52884. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52885. /** @hidden */
  52886. export var glowMapMergeVertexShader: {
  52887. name: string;
  52888. shader: string;
  52889. };
  52890. }
  52891. declare module "babylonjs/Layers/glowLayer" {
  52892. import { Nullable } from "babylonjs/types";
  52893. import { Camera } from "babylonjs/Cameras/camera";
  52894. import { Scene } from "babylonjs/scene";
  52895. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52897. import { Mesh } from "babylonjs/Meshes/mesh";
  52898. import { Texture } from "babylonjs/Materials/Textures/texture";
  52899. import { Effect } from "babylonjs/Materials/effect";
  52900. import { Material } from "babylonjs/Materials/material";
  52901. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52902. import { Color4 } from "babylonjs/Maths/math.color";
  52903. import "babylonjs/Shaders/glowMapMerge.fragment";
  52904. import "babylonjs/Shaders/glowMapMerge.vertex";
  52905. import "babylonjs/Layers/effectLayerSceneComponent";
  52906. module "babylonjs/abstractScene" {
  52907. interface AbstractScene {
  52908. /**
  52909. * Return a the first highlight layer of the scene with a given name.
  52910. * @param name The name of the highlight layer to look for.
  52911. * @return The highlight layer if found otherwise null.
  52912. */
  52913. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52914. }
  52915. }
  52916. /**
  52917. * Glow layer options. This helps customizing the behaviour
  52918. * of the glow layer.
  52919. */
  52920. export interface IGlowLayerOptions {
  52921. /**
  52922. * Multiplication factor apply to the canvas size to compute the render target size
  52923. * used to generated the glowing objects (the smaller the faster).
  52924. */
  52925. mainTextureRatio: number;
  52926. /**
  52927. * Enforces a fixed size texture to ensure resize independant blur.
  52928. */
  52929. mainTextureFixedSize?: number;
  52930. /**
  52931. * How big is the kernel of the blur texture.
  52932. */
  52933. blurKernelSize: number;
  52934. /**
  52935. * The camera attached to the layer.
  52936. */
  52937. camera: Nullable<Camera>;
  52938. /**
  52939. * Enable MSAA by chosing the number of samples.
  52940. */
  52941. mainTextureSamples?: number;
  52942. /**
  52943. * The rendering group to draw the layer in.
  52944. */
  52945. renderingGroupId: number;
  52946. }
  52947. /**
  52948. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52949. *
  52950. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52951. *
  52952. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52953. */
  52954. export class GlowLayer extends EffectLayer {
  52955. /**
  52956. * Effect Name of the layer.
  52957. */
  52958. static readonly EffectName: string;
  52959. /**
  52960. * The default blur kernel size used for the glow.
  52961. */
  52962. static DefaultBlurKernelSize: number;
  52963. /**
  52964. * The default texture size ratio used for the glow.
  52965. */
  52966. static DefaultTextureRatio: number;
  52967. /**
  52968. * Sets the kernel size of the blur.
  52969. */
  52970. /**
  52971. * Gets the kernel size of the blur.
  52972. */
  52973. blurKernelSize: number;
  52974. /**
  52975. * Sets the glow intensity.
  52976. */
  52977. /**
  52978. * Gets the glow intensity.
  52979. */
  52980. intensity: number;
  52981. private _options;
  52982. private _intensity;
  52983. private _horizontalBlurPostprocess1;
  52984. private _verticalBlurPostprocess1;
  52985. private _horizontalBlurPostprocess2;
  52986. private _verticalBlurPostprocess2;
  52987. private _blurTexture1;
  52988. private _blurTexture2;
  52989. private _postProcesses1;
  52990. private _postProcesses2;
  52991. private _includedOnlyMeshes;
  52992. private _excludedMeshes;
  52993. private _meshesUsingTheirOwnMaterials;
  52994. /**
  52995. * Callback used to let the user override the color selection on a per mesh basis
  52996. */
  52997. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52998. /**
  52999. * Callback used to let the user override the texture selection on a per mesh basis
  53000. */
  53001. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53002. /**
  53003. * Instantiates a new glow Layer and references it to the scene.
  53004. * @param name The name of the layer
  53005. * @param scene The scene to use the layer in
  53006. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53007. */
  53008. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53009. /**
  53010. * Get the effect name of the layer.
  53011. * @return The effect name
  53012. */
  53013. getEffectName(): string;
  53014. /**
  53015. * Create the merge effect. This is the shader use to blit the information back
  53016. * to the main canvas at the end of the scene rendering.
  53017. */
  53018. protected _createMergeEffect(): Effect;
  53019. /**
  53020. * Creates the render target textures and post processes used in the glow layer.
  53021. */
  53022. protected _createTextureAndPostProcesses(): void;
  53023. /**
  53024. * Checks for the readiness of the element composing the layer.
  53025. * @param subMesh the mesh to check for
  53026. * @param useInstances specify wether or not to use instances to render the mesh
  53027. * @param emissiveTexture the associated emissive texture used to generate the glow
  53028. * @return true if ready otherwise, false
  53029. */
  53030. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53031. /**
  53032. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53033. */
  53034. needStencil(): boolean;
  53035. /**
  53036. * Returns true if the mesh can be rendered, otherwise false.
  53037. * @param mesh The mesh to render
  53038. * @param material The material used on the mesh
  53039. * @returns true if it can be rendered otherwise false
  53040. */
  53041. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53042. /**
  53043. * Implementation specific of rendering the generating effect on the main canvas.
  53044. * @param effect The effect used to render through
  53045. */
  53046. protected _internalRender(effect: Effect): void;
  53047. /**
  53048. * Sets the required values for both the emissive texture and and the main color.
  53049. */
  53050. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53051. /**
  53052. * Returns true if the mesh should render, otherwise false.
  53053. * @param mesh The mesh to render
  53054. * @returns true if it should render otherwise false
  53055. */
  53056. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53057. /**
  53058. * Adds specific effects defines.
  53059. * @param defines The defines to add specifics to.
  53060. */
  53061. protected _addCustomEffectDefines(defines: string[]): void;
  53062. /**
  53063. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53064. * @param mesh The mesh to exclude from the glow layer
  53065. */
  53066. addExcludedMesh(mesh: Mesh): void;
  53067. /**
  53068. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53069. * @param mesh The mesh to remove
  53070. */
  53071. removeExcludedMesh(mesh: Mesh): void;
  53072. /**
  53073. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53074. * @param mesh The mesh to include in the glow layer
  53075. */
  53076. addIncludedOnlyMesh(mesh: Mesh): void;
  53077. /**
  53078. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53079. * @param mesh The mesh to remove
  53080. */
  53081. removeIncludedOnlyMesh(mesh: Mesh): void;
  53082. /**
  53083. * Determine if a given mesh will be used in the glow layer
  53084. * @param mesh The mesh to test
  53085. * @returns true if the mesh will be highlighted by the current glow layer
  53086. */
  53087. hasMesh(mesh: AbstractMesh): boolean;
  53088. /**
  53089. * Defines wether the current material of the mesh should be use to render the effect.
  53090. * @param mesh defines the current mesh to render
  53091. */
  53092. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53093. /**
  53094. * Add a mesh to be rendered through its own material and not with emissive only.
  53095. * @param mesh The mesh for which we need to use its material
  53096. */
  53097. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53098. /**
  53099. * Remove a mesh from being rendered through its own material and not with emissive only.
  53100. * @param mesh The mesh for which we need to not use its material
  53101. */
  53102. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53103. /**
  53104. * Free any resources and references associated to a mesh.
  53105. * Internal use
  53106. * @param mesh The mesh to free.
  53107. * @hidden
  53108. */
  53109. _disposeMesh(mesh: Mesh): void;
  53110. /**
  53111. * Gets the class name of the effect layer
  53112. * @returns the string with the class name of the effect layer
  53113. */
  53114. getClassName(): string;
  53115. /**
  53116. * Serializes this glow layer
  53117. * @returns a serialized glow layer object
  53118. */
  53119. serialize(): any;
  53120. /**
  53121. * Creates a Glow Layer from parsed glow layer data
  53122. * @param parsedGlowLayer defines glow layer data
  53123. * @param scene defines the current scene
  53124. * @param rootUrl defines the root URL containing the glow layer information
  53125. * @returns a parsed Glow Layer
  53126. */
  53127. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53128. }
  53129. }
  53130. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  53131. /** @hidden */
  53132. export var glowBlurPostProcessPixelShader: {
  53133. name: string;
  53134. shader: string;
  53135. };
  53136. }
  53137. declare module "babylonjs/Layers/highlightLayer" {
  53138. import { Observable } from "babylonjs/Misc/observable";
  53139. import { Nullable } from "babylonjs/types";
  53140. import { Camera } from "babylonjs/Cameras/camera";
  53141. import { Scene } from "babylonjs/scene";
  53142. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53144. import { Mesh } from "babylonjs/Meshes/mesh";
  53145. import { Effect } from "babylonjs/Materials/effect";
  53146. import { Material } from "babylonjs/Materials/material";
  53147. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53148. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  53149. import "babylonjs/Shaders/glowMapMerge.fragment";
  53150. import "babylonjs/Shaders/glowMapMerge.vertex";
  53151. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  53152. module "babylonjs/abstractScene" {
  53153. interface AbstractScene {
  53154. /**
  53155. * Return a the first highlight layer of the scene with a given name.
  53156. * @param name The name of the highlight layer to look for.
  53157. * @return The highlight layer if found otherwise null.
  53158. */
  53159. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53160. }
  53161. }
  53162. /**
  53163. * Highlight layer options. This helps customizing the behaviour
  53164. * of the highlight layer.
  53165. */
  53166. export interface IHighlightLayerOptions {
  53167. /**
  53168. * Multiplication factor apply to the canvas size to compute the render target size
  53169. * used to generated the glowing objects (the smaller the faster).
  53170. */
  53171. mainTextureRatio: number;
  53172. /**
  53173. * Enforces a fixed size texture to ensure resize independant blur.
  53174. */
  53175. mainTextureFixedSize?: number;
  53176. /**
  53177. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53178. * of the picture to blur (the smaller the faster).
  53179. */
  53180. blurTextureSizeRatio: number;
  53181. /**
  53182. * How big in texel of the blur texture is the vertical blur.
  53183. */
  53184. blurVerticalSize: number;
  53185. /**
  53186. * How big in texel of the blur texture is the horizontal blur.
  53187. */
  53188. blurHorizontalSize: number;
  53189. /**
  53190. * Alpha blending mode used to apply the blur. Default is combine.
  53191. */
  53192. alphaBlendingMode: number;
  53193. /**
  53194. * The camera attached to the layer.
  53195. */
  53196. camera: Nullable<Camera>;
  53197. /**
  53198. * Should we display highlight as a solid stroke?
  53199. */
  53200. isStroke?: boolean;
  53201. /**
  53202. * The rendering group to draw the layer in.
  53203. */
  53204. renderingGroupId: number;
  53205. }
  53206. /**
  53207. * The highlight layer Helps adding a glow effect around a mesh.
  53208. *
  53209. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53210. * glowy meshes to your scene.
  53211. *
  53212. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53213. */
  53214. export class HighlightLayer extends EffectLayer {
  53215. name: string;
  53216. /**
  53217. * Effect Name of the highlight layer.
  53218. */
  53219. static readonly EffectName: string;
  53220. /**
  53221. * The neutral color used during the preparation of the glow effect.
  53222. * This is black by default as the blend operation is a blend operation.
  53223. */
  53224. static NeutralColor: Color4;
  53225. /**
  53226. * Stencil value used for glowing meshes.
  53227. */
  53228. static GlowingMeshStencilReference: number;
  53229. /**
  53230. * Stencil value used for the other meshes in the scene.
  53231. */
  53232. static NormalMeshStencilReference: number;
  53233. /**
  53234. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53235. */
  53236. innerGlow: boolean;
  53237. /**
  53238. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53239. */
  53240. outerGlow: boolean;
  53241. /**
  53242. * Specifies the horizontal size of the blur.
  53243. */
  53244. /**
  53245. * Gets the horizontal size of the blur.
  53246. */
  53247. blurHorizontalSize: number;
  53248. /**
  53249. * Specifies the vertical size of the blur.
  53250. */
  53251. /**
  53252. * Gets the vertical size of the blur.
  53253. */
  53254. blurVerticalSize: number;
  53255. /**
  53256. * An event triggered when the highlight layer is being blurred.
  53257. */
  53258. onBeforeBlurObservable: Observable<HighlightLayer>;
  53259. /**
  53260. * An event triggered when the highlight layer has been blurred.
  53261. */
  53262. onAfterBlurObservable: Observable<HighlightLayer>;
  53263. private _instanceGlowingMeshStencilReference;
  53264. private _options;
  53265. private _downSamplePostprocess;
  53266. private _horizontalBlurPostprocess;
  53267. private _verticalBlurPostprocess;
  53268. private _blurTexture;
  53269. private _meshes;
  53270. private _excludedMeshes;
  53271. /**
  53272. * Instantiates a new highlight Layer and references it to the scene..
  53273. * @param name The name of the layer
  53274. * @param scene The scene to use the layer in
  53275. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53276. */
  53277. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53278. /**
  53279. * Get the effect name of the layer.
  53280. * @return The effect name
  53281. */
  53282. getEffectName(): string;
  53283. /**
  53284. * Create the merge effect. This is the shader use to blit the information back
  53285. * to the main canvas at the end of the scene rendering.
  53286. */
  53287. protected _createMergeEffect(): Effect;
  53288. /**
  53289. * Creates the render target textures and post processes used in the highlight layer.
  53290. */
  53291. protected _createTextureAndPostProcesses(): void;
  53292. /**
  53293. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53294. */
  53295. needStencil(): boolean;
  53296. /**
  53297. * Checks for the readiness of the element composing the layer.
  53298. * @param subMesh the mesh to check for
  53299. * @param useInstances specify wether or not to use instances to render the mesh
  53300. * @param emissiveTexture the associated emissive texture used to generate the glow
  53301. * @return true if ready otherwise, false
  53302. */
  53303. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53304. /**
  53305. * Implementation specific of rendering the generating effect on the main canvas.
  53306. * @param effect The effect used to render through
  53307. */
  53308. protected _internalRender(effect: Effect): void;
  53309. /**
  53310. * Returns true if the layer contains information to display, otherwise false.
  53311. */
  53312. shouldRender(): boolean;
  53313. /**
  53314. * Returns true if the mesh should render, otherwise false.
  53315. * @param mesh The mesh to render
  53316. * @returns true if it should render otherwise false
  53317. */
  53318. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53319. /**
  53320. * Sets the required values for both the emissive texture and and the main color.
  53321. */
  53322. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53323. /**
  53324. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53325. * @param mesh The mesh to exclude from the highlight layer
  53326. */
  53327. addExcludedMesh(mesh: Mesh): void;
  53328. /**
  53329. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53330. * @param mesh The mesh to highlight
  53331. */
  53332. removeExcludedMesh(mesh: Mesh): void;
  53333. /**
  53334. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53335. * @param mesh mesh to test
  53336. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53337. */
  53338. hasMesh(mesh: AbstractMesh): boolean;
  53339. /**
  53340. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53341. * @param mesh The mesh to highlight
  53342. * @param color The color of the highlight
  53343. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53344. */
  53345. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53346. /**
  53347. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53348. * @param mesh The mesh to highlight
  53349. */
  53350. removeMesh(mesh: Mesh): void;
  53351. /**
  53352. * Force the stencil to the normal expected value for none glowing parts
  53353. */
  53354. private _defaultStencilReference;
  53355. /**
  53356. * Free any resources and references associated to a mesh.
  53357. * Internal use
  53358. * @param mesh The mesh to free.
  53359. * @hidden
  53360. */
  53361. _disposeMesh(mesh: Mesh): void;
  53362. /**
  53363. * Dispose the highlight layer and free resources.
  53364. */
  53365. dispose(): void;
  53366. /**
  53367. * Gets the class name of the effect layer
  53368. * @returns the string with the class name of the effect layer
  53369. */
  53370. getClassName(): string;
  53371. /**
  53372. * Serializes this Highlight layer
  53373. * @returns a serialized Highlight layer object
  53374. */
  53375. serialize(): any;
  53376. /**
  53377. * Creates a Highlight layer from parsed Highlight layer data
  53378. * @param parsedHightlightLayer defines the Highlight layer data
  53379. * @param scene defines the current scene
  53380. * @param rootUrl defines the root URL containing the Highlight layer information
  53381. * @returns a parsed Highlight layer
  53382. */
  53383. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53384. }
  53385. }
  53386. declare module "babylonjs/Layers/layerSceneComponent" {
  53387. import { Scene } from "babylonjs/scene";
  53388. import { ISceneComponent } from "babylonjs/sceneComponent";
  53389. import { Layer } from "babylonjs/Layers/layer";
  53390. import { AbstractScene } from "babylonjs/abstractScene";
  53391. module "babylonjs/abstractScene" {
  53392. interface AbstractScene {
  53393. /**
  53394. * The list of layers (background and foreground) of the scene
  53395. */
  53396. layers: Array<Layer>;
  53397. }
  53398. }
  53399. /**
  53400. * Defines the layer scene component responsible to manage any layers
  53401. * in a given scene.
  53402. */
  53403. export class LayerSceneComponent implements ISceneComponent {
  53404. /**
  53405. * The component name helpfull to identify the component in the list of scene components.
  53406. */
  53407. readonly name: string;
  53408. /**
  53409. * The scene the component belongs to.
  53410. */
  53411. scene: Scene;
  53412. private _engine;
  53413. /**
  53414. * Creates a new instance of the component for the given scene
  53415. * @param scene Defines the scene to register the component in
  53416. */
  53417. constructor(scene: Scene);
  53418. /**
  53419. * Registers the component in a given scene
  53420. */
  53421. register(): void;
  53422. /**
  53423. * Rebuilds the elements related to this component in case of
  53424. * context lost for instance.
  53425. */
  53426. rebuild(): void;
  53427. /**
  53428. * Disposes the component and the associated ressources.
  53429. */
  53430. dispose(): void;
  53431. private _draw;
  53432. private _drawCameraPredicate;
  53433. private _drawCameraBackground;
  53434. private _drawCameraForeground;
  53435. private _drawRenderTargetPredicate;
  53436. private _drawRenderTargetBackground;
  53437. private _drawRenderTargetForeground;
  53438. /**
  53439. * Adds all the elements from the container to the scene
  53440. * @param container the container holding the elements
  53441. */
  53442. addFromContainer(container: AbstractScene): void;
  53443. /**
  53444. * Removes all the elements in the container from the scene
  53445. * @param container contains the elements to remove
  53446. * @param dispose if the removed element should be disposed (default: false)
  53447. */
  53448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53449. }
  53450. }
  53451. declare module "babylonjs/Shaders/layer.fragment" {
  53452. /** @hidden */
  53453. export var layerPixelShader: {
  53454. name: string;
  53455. shader: string;
  53456. };
  53457. }
  53458. declare module "babylonjs/Shaders/layer.vertex" {
  53459. /** @hidden */
  53460. export var layerVertexShader: {
  53461. name: string;
  53462. shader: string;
  53463. };
  53464. }
  53465. declare module "babylonjs/Layers/layer" {
  53466. import { Observable } from "babylonjs/Misc/observable";
  53467. import { Nullable } from "babylonjs/types";
  53468. import { Scene } from "babylonjs/scene";
  53469. import { Vector2 } from "babylonjs/Maths/math.vector";
  53470. import { Color4 } from "babylonjs/Maths/math.color";
  53471. import { Texture } from "babylonjs/Materials/Textures/texture";
  53472. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53473. import "babylonjs/Shaders/layer.fragment";
  53474. import "babylonjs/Shaders/layer.vertex";
  53475. /**
  53476. * This represents a full screen 2d layer.
  53477. * This can be useful to display a picture in the background of your scene for instance.
  53478. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53479. */
  53480. export class Layer {
  53481. /**
  53482. * Define the name of the layer.
  53483. */
  53484. name: string;
  53485. /**
  53486. * Define the texture the layer should display.
  53487. */
  53488. texture: Nullable<Texture>;
  53489. /**
  53490. * Is the layer in background or foreground.
  53491. */
  53492. isBackground: boolean;
  53493. /**
  53494. * Define the color of the layer (instead of texture).
  53495. */
  53496. color: Color4;
  53497. /**
  53498. * Define the scale of the layer in order to zoom in out of the texture.
  53499. */
  53500. scale: Vector2;
  53501. /**
  53502. * Define an offset for the layer in order to shift the texture.
  53503. */
  53504. offset: Vector2;
  53505. /**
  53506. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53507. */
  53508. alphaBlendingMode: number;
  53509. /**
  53510. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53511. * Alpha test will not mix with the background color in case of transparency.
  53512. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53513. */
  53514. alphaTest: boolean;
  53515. /**
  53516. * Define a mask to restrict the layer to only some of the scene cameras.
  53517. */
  53518. layerMask: number;
  53519. /**
  53520. * Define the list of render target the layer is visible into.
  53521. */
  53522. renderTargetTextures: RenderTargetTexture[];
  53523. /**
  53524. * Define if the layer is only used in renderTarget or if it also
  53525. * renders in the main frame buffer of the canvas.
  53526. */
  53527. renderOnlyInRenderTargetTextures: boolean;
  53528. private _scene;
  53529. private _vertexBuffers;
  53530. private _indexBuffer;
  53531. private _effect;
  53532. private _alphaTestEffect;
  53533. /**
  53534. * An event triggered when the layer is disposed.
  53535. */
  53536. onDisposeObservable: Observable<Layer>;
  53537. private _onDisposeObserver;
  53538. /**
  53539. * Back compatibility with callback before the onDisposeObservable existed.
  53540. * The set callback will be triggered when the layer has been disposed.
  53541. */
  53542. onDispose: () => void;
  53543. /**
  53544. * An event triggered before rendering the scene
  53545. */
  53546. onBeforeRenderObservable: Observable<Layer>;
  53547. private _onBeforeRenderObserver;
  53548. /**
  53549. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53550. * The set callback will be triggered just before rendering the layer.
  53551. */
  53552. onBeforeRender: () => void;
  53553. /**
  53554. * An event triggered after rendering the scene
  53555. */
  53556. onAfterRenderObservable: Observable<Layer>;
  53557. private _onAfterRenderObserver;
  53558. /**
  53559. * Back compatibility with callback before the onAfterRenderObservable existed.
  53560. * The set callback will be triggered just after rendering the layer.
  53561. */
  53562. onAfterRender: () => void;
  53563. /**
  53564. * Instantiates a new layer.
  53565. * This represents a full screen 2d layer.
  53566. * This can be useful to display a picture in the background of your scene for instance.
  53567. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53568. * @param name Define the name of the layer in the scene
  53569. * @param imgUrl Define the url of the texture to display in the layer
  53570. * @param scene Define the scene the layer belongs to
  53571. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53572. * @param color Defines a color for the layer
  53573. */
  53574. constructor(
  53575. /**
  53576. * Define the name of the layer.
  53577. */
  53578. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53579. private _createIndexBuffer;
  53580. /** @hidden */
  53581. _rebuild(): void;
  53582. /**
  53583. * Renders the layer in the scene.
  53584. */
  53585. render(): void;
  53586. /**
  53587. * Disposes and releases the associated ressources.
  53588. */
  53589. dispose(): void;
  53590. }
  53591. }
  53592. declare module "babylonjs/Layers/index" {
  53593. export * from "babylonjs/Layers/effectLayer";
  53594. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53595. export * from "babylonjs/Layers/glowLayer";
  53596. export * from "babylonjs/Layers/highlightLayer";
  53597. export * from "babylonjs/Layers/layer";
  53598. export * from "babylonjs/Layers/layerSceneComponent";
  53599. }
  53600. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53601. /** @hidden */
  53602. export var lensFlarePixelShader: {
  53603. name: string;
  53604. shader: string;
  53605. };
  53606. }
  53607. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53608. /** @hidden */
  53609. export var lensFlareVertexShader: {
  53610. name: string;
  53611. shader: string;
  53612. };
  53613. }
  53614. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53615. import { Scene } from "babylonjs/scene";
  53616. import { Vector3 } from "babylonjs/Maths/math.vector";
  53617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53618. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53619. import "babylonjs/Shaders/lensFlare.fragment";
  53620. import "babylonjs/Shaders/lensFlare.vertex";
  53621. import { Viewport } from "babylonjs/Maths/math.viewport";
  53622. /**
  53623. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53624. * It is usually composed of several `lensFlare`.
  53625. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53626. */
  53627. export class LensFlareSystem {
  53628. /**
  53629. * Define the name of the lens flare system
  53630. */
  53631. name: string;
  53632. /**
  53633. * List of lens flares used in this system.
  53634. */
  53635. lensFlares: LensFlare[];
  53636. /**
  53637. * Define a limit from the border the lens flare can be visible.
  53638. */
  53639. borderLimit: number;
  53640. /**
  53641. * Define a viewport border we do not want to see the lens flare in.
  53642. */
  53643. viewportBorder: number;
  53644. /**
  53645. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53646. */
  53647. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53648. /**
  53649. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53650. */
  53651. layerMask: number;
  53652. /**
  53653. * Define the id of the lens flare system in the scene.
  53654. * (equal to name by default)
  53655. */
  53656. id: string;
  53657. private _scene;
  53658. private _emitter;
  53659. private _vertexBuffers;
  53660. private _indexBuffer;
  53661. private _effect;
  53662. private _positionX;
  53663. private _positionY;
  53664. private _isEnabled;
  53665. /** @hidden */
  53666. static _SceneComponentInitialization: (scene: Scene) => void;
  53667. /**
  53668. * Instantiates a lens flare system.
  53669. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53670. * It is usually composed of several `lensFlare`.
  53671. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53672. * @param name Define the name of the lens flare system in the scene
  53673. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53674. * @param scene Define the scene the lens flare system belongs to
  53675. */
  53676. constructor(
  53677. /**
  53678. * Define the name of the lens flare system
  53679. */
  53680. name: string, emitter: any, scene: Scene);
  53681. /**
  53682. * Define if the lens flare system is enabled.
  53683. */
  53684. isEnabled: boolean;
  53685. /**
  53686. * Get the scene the effects belongs to.
  53687. * @returns the scene holding the lens flare system
  53688. */
  53689. getScene(): Scene;
  53690. /**
  53691. * Get the emitter of the lens flare system.
  53692. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53693. * @returns the emitter of the lens flare system
  53694. */
  53695. getEmitter(): any;
  53696. /**
  53697. * Set the emitter of the lens flare system.
  53698. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53699. * @param newEmitter Define the new emitter of the system
  53700. */
  53701. setEmitter(newEmitter: any): void;
  53702. /**
  53703. * Get the lens flare system emitter position.
  53704. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53705. * @returns the position
  53706. */
  53707. getEmitterPosition(): Vector3;
  53708. /**
  53709. * @hidden
  53710. */
  53711. computeEffectivePosition(globalViewport: Viewport): boolean;
  53712. /** @hidden */
  53713. _isVisible(): boolean;
  53714. /**
  53715. * @hidden
  53716. */
  53717. render(): boolean;
  53718. /**
  53719. * Dispose and release the lens flare with its associated resources.
  53720. */
  53721. dispose(): void;
  53722. /**
  53723. * Parse a lens flare system from a JSON repressentation
  53724. * @param parsedLensFlareSystem Define the JSON to parse
  53725. * @param scene Define the scene the parsed system should be instantiated in
  53726. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53727. * @returns the parsed system
  53728. */
  53729. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53730. /**
  53731. * Serialize the current Lens Flare System into a JSON representation.
  53732. * @returns the serialized JSON
  53733. */
  53734. serialize(): any;
  53735. }
  53736. }
  53737. declare module "babylonjs/LensFlares/lensFlare" {
  53738. import { Nullable } from "babylonjs/types";
  53739. import { Color3 } from "babylonjs/Maths/math.color";
  53740. import { Texture } from "babylonjs/Materials/Textures/texture";
  53741. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53742. /**
  53743. * This represents one of the lens effect in a `lensFlareSystem`.
  53744. * It controls one of the indiviual texture used in the effect.
  53745. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53746. */
  53747. export class LensFlare {
  53748. /**
  53749. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53750. */
  53751. size: number;
  53752. /**
  53753. * 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.
  53754. */
  53755. position: number;
  53756. /**
  53757. * Define the lens color.
  53758. */
  53759. color: Color3;
  53760. /**
  53761. * Define the lens texture.
  53762. */
  53763. texture: Nullable<Texture>;
  53764. /**
  53765. * Define the alpha mode to render this particular lens.
  53766. */
  53767. alphaMode: number;
  53768. private _system;
  53769. /**
  53770. * Creates a new Lens Flare.
  53771. * This represents one of the lens effect in a `lensFlareSystem`.
  53772. * It controls one of the indiviual texture used in the effect.
  53773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53774. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53775. * @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.
  53776. * @param color Define the lens color
  53777. * @param imgUrl Define the lens texture url
  53778. * @param system Define the `lensFlareSystem` this flare is part of
  53779. * @returns The newly created Lens Flare
  53780. */
  53781. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53782. /**
  53783. * Instantiates a new Lens Flare.
  53784. * This represents one of the lens effect in a `lensFlareSystem`.
  53785. * It controls one of the indiviual texture used in the effect.
  53786. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53787. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53788. * @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.
  53789. * @param color Define the lens color
  53790. * @param imgUrl Define the lens texture url
  53791. * @param system Define the `lensFlareSystem` this flare is part of
  53792. */
  53793. constructor(
  53794. /**
  53795. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53796. */
  53797. size: number,
  53798. /**
  53799. * 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.
  53800. */
  53801. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53802. /**
  53803. * Dispose and release the lens flare with its associated resources.
  53804. */
  53805. dispose(): void;
  53806. }
  53807. }
  53808. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53809. import { Nullable } from "babylonjs/types";
  53810. import { Scene } from "babylonjs/scene";
  53811. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53812. import { AbstractScene } from "babylonjs/abstractScene";
  53813. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53814. module "babylonjs/abstractScene" {
  53815. interface AbstractScene {
  53816. /**
  53817. * The list of lens flare system added to the scene
  53818. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53819. */
  53820. lensFlareSystems: Array<LensFlareSystem>;
  53821. /**
  53822. * Removes the given lens flare system from this scene.
  53823. * @param toRemove The lens flare system to remove
  53824. * @returns The index of the removed lens flare system
  53825. */
  53826. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53827. /**
  53828. * Adds the given lens flare system to this scene
  53829. * @param newLensFlareSystem The lens flare system to add
  53830. */
  53831. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53832. /**
  53833. * Gets a lens flare system using its name
  53834. * @param name defines the name to look for
  53835. * @returns the lens flare system or null if not found
  53836. */
  53837. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53838. /**
  53839. * Gets a lens flare system using its id
  53840. * @param id defines the id to look for
  53841. * @returns the lens flare system or null if not found
  53842. */
  53843. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53844. }
  53845. }
  53846. /**
  53847. * Defines the lens flare scene component responsible to manage any lens flares
  53848. * in a given scene.
  53849. */
  53850. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53851. /**
  53852. * The component name helpfull to identify the component in the list of scene components.
  53853. */
  53854. readonly name: string;
  53855. /**
  53856. * The scene the component belongs to.
  53857. */
  53858. scene: Scene;
  53859. /**
  53860. * Creates a new instance of the component for the given scene
  53861. * @param scene Defines the scene to register the component in
  53862. */
  53863. constructor(scene: Scene);
  53864. /**
  53865. * Registers the component in a given scene
  53866. */
  53867. register(): void;
  53868. /**
  53869. * Rebuilds the elements related to this component in case of
  53870. * context lost for instance.
  53871. */
  53872. rebuild(): void;
  53873. /**
  53874. * Adds all the elements from the container to the scene
  53875. * @param container the container holding the elements
  53876. */
  53877. addFromContainer(container: AbstractScene): void;
  53878. /**
  53879. * Removes all the elements in the container from the scene
  53880. * @param container contains the elements to remove
  53881. * @param dispose if the removed element should be disposed (default: false)
  53882. */
  53883. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53884. /**
  53885. * Serializes the component data to the specified json object
  53886. * @param serializationObject The object to serialize to
  53887. */
  53888. serialize(serializationObject: any): void;
  53889. /**
  53890. * Disposes the component and the associated ressources.
  53891. */
  53892. dispose(): void;
  53893. private _draw;
  53894. }
  53895. }
  53896. declare module "babylonjs/LensFlares/index" {
  53897. export * from "babylonjs/LensFlares/lensFlare";
  53898. export * from "babylonjs/LensFlares/lensFlareSystem";
  53899. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53900. }
  53901. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53902. import { Scene } from "babylonjs/scene";
  53903. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53904. import { AbstractScene } from "babylonjs/abstractScene";
  53905. /**
  53906. * Defines the shadow generator component responsible to manage any shadow generators
  53907. * in a given scene.
  53908. */
  53909. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53910. /**
  53911. * The component name helpfull to identify the component in the list of scene components.
  53912. */
  53913. readonly name: string;
  53914. /**
  53915. * The scene the component belongs to.
  53916. */
  53917. scene: Scene;
  53918. /**
  53919. * Creates a new instance of the component for the given scene
  53920. * @param scene Defines the scene to register the component in
  53921. */
  53922. constructor(scene: Scene);
  53923. /**
  53924. * Registers the component in a given scene
  53925. */
  53926. register(): void;
  53927. /**
  53928. * Rebuilds the elements related to this component in case of
  53929. * context lost for instance.
  53930. */
  53931. rebuild(): void;
  53932. /**
  53933. * Serializes the component data to the specified json object
  53934. * @param serializationObject The object to serialize to
  53935. */
  53936. serialize(serializationObject: any): void;
  53937. /**
  53938. * Adds all the elements from the container to the scene
  53939. * @param container the container holding the elements
  53940. */
  53941. addFromContainer(container: AbstractScene): void;
  53942. /**
  53943. * Removes all the elements in the container from the scene
  53944. * @param container contains the elements to remove
  53945. * @param dispose if the removed element should be disposed (default: false)
  53946. */
  53947. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53948. /**
  53949. * Rebuilds the elements related to this component in case of
  53950. * context lost for instance.
  53951. */
  53952. dispose(): void;
  53953. private _gatherRenderTargets;
  53954. }
  53955. }
  53956. declare module "babylonjs/Lights/Shadows/index" {
  53957. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53958. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53959. }
  53960. declare module "babylonjs/Lights/pointLight" {
  53961. import { Scene } from "babylonjs/scene";
  53962. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53964. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53965. import { Effect } from "babylonjs/Materials/effect";
  53966. /**
  53967. * A point light is a light defined by an unique point in world space.
  53968. * The light is emitted in every direction from this point.
  53969. * A good example of a point light is a standard light bulb.
  53970. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53971. */
  53972. export class PointLight extends ShadowLight {
  53973. private _shadowAngle;
  53974. /**
  53975. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53976. * This specifies what angle the shadow will use to be created.
  53977. *
  53978. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53979. */
  53980. /**
  53981. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53982. * This specifies what angle the shadow will use to be created.
  53983. *
  53984. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53985. */
  53986. shadowAngle: number;
  53987. /**
  53988. * Gets the direction if it has been set.
  53989. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53990. */
  53991. /**
  53992. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53993. */
  53994. direction: Vector3;
  53995. /**
  53996. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53997. * A PointLight emits the light in every direction.
  53998. * It can cast shadows.
  53999. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54000. * ```javascript
  54001. * var pointLight = new PointLight("pl", camera.position, scene);
  54002. * ```
  54003. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54004. * @param name The light friendly name
  54005. * @param position The position of the point light in the scene
  54006. * @param scene The scene the lights belongs to
  54007. */
  54008. constructor(name: string, position: Vector3, scene: Scene);
  54009. /**
  54010. * Returns the string "PointLight"
  54011. * @returns the class name
  54012. */
  54013. getClassName(): string;
  54014. /**
  54015. * Returns the integer 0.
  54016. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54017. */
  54018. getTypeID(): number;
  54019. /**
  54020. * Specifies wether or not the shadowmap should be a cube texture.
  54021. * @returns true if the shadowmap needs to be a cube texture.
  54022. */
  54023. needCube(): boolean;
  54024. /**
  54025. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54026. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54027. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54028. */
  54029. getShadowDirection(faceIndex?: number): Vector3;
  54030. /**
  54031. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54032. * - fov = PI / 2
  54033. * - aspect ratio : 1.0
  54034. * - z-near and far equal to the active camera minZ and maxZ.
  54035. * Returns the PointLight.
  54036. */
  54037. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54038. protected _buildUniformLayout(): void;
  54039. /**
  54040. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54041. * @param effect The effect to update
  54042. * @param lightIndex The index of the light in the effect to update
  54043. * @returns The point light
  54044. */
  54045. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54046. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54047. /**
  54048. * Prepares the list of defines specific to the light type.
  54049. * @param defines the list of defines
  54050. * @param lightIndex defines the index of the light for the effect
  54051. */
  54052. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54053. }
  54054. }
  54055. declare module "babylonjs/Lights/index" {
  54056. export * from "babylonjs/Lights/light";
  54057. export * from "babylonjs/Lights/shadowLight";
  54058. export * from "babylonjs/Lights/Shadows/index";
  54059. export * from "babylonjs/Lights/directionalLight";
  54060. export * from "babylonjs/Lights/hemisphericLight";
  54061. export * from "babylonjs/Lights/pointLight";
  54062. export * from "babylonjs/Lights/spotLight";
  54063. }
  54064. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  54065. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54066. /**
  54067. * Header information of HDR texture files.
  54068. */
  54069. export interface HDRInfo {
  54070. /**
  54071. * The height of the texture in pixels.
  54072. */
  54073. height: number;
  54074. /**
  54075. * The width of the texture in pixels.
  54076. */
  54077. width: number;
  54078. /**
  54079. * The index of the beginning of the data in the binary file.
  54080. */
  54081. dataPosition: number;
  54082. }
  54083. /**
  54084. * This groups tools to convert HDR texture to native colors array.
  54085. */
  54086. export class HDRTools {
  54087. private static Ldexp;
  54088. private static Rgbe2float;
  54089. private static readStringLine;
  54090. /**
  54091. * Reads header information from an RGBE texture stored in a native array.
  54092. * More information on this format are available here:
  54093. * https://en.wikipedia.org/wiki/RGBE_image_format
  54094. *
  54095. * @param uint8array The binary file stored in native array.
  54096. * @return The header information.
  54097. */
  54098. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54099. /**
  54100. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54101. * This RGBE texture needs to store the information as a panorama.
  54102. *
  54103. * More information on this format are available here:
  54104. * https://en.wikipedia.org/wiki/RGBE_image_format
  54105. *
  54106. * @param buffer The binary file stored in an array buffer.
  54107. * @param size The expected size of the extracted cubemap.
  54108. * @return The Cube Map information.
  54109. */
  54110. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54111. /**
  54112. * Returns the pixels data extracted from an RGBE texture.
  54113. * This pixels will be stored left to right up to down in the R G B order in one array.
  54114. *
  54115. * More information on this format are available here:
  54116. * https://en.wikipedia.org/wiki/RGBE_image_format
  54117. *
  54118. * @param uint8array The binary file stored in an array buffer.
  54119. * @param hdrInfo The header information of the file.
  54120. * @return The pixels data in RGB right to left up to down order.
  54121. */
  54122. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54123. private static RGBE_ReadPixels_RLE;
  54124. }
  54125. }
  54126. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  54127. import { Nullable } from "babylonjs/types";
  54128. import { Scene } from "babylonjs/scene";
  54129. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54131. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54132. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54133. /**
  54134. * This represents a texture coming from an HDR input.
  54135. *
  54136. * The only supported format is currently panorama picture stored in RGBE format.
  54137. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54138. */
  54139. export class HDRCubeTexture extends BaseTexture {
  54140. private static _facesMapping;
  54141. private _generateHarmonics;
  54142. private _noMipmap;
  54143. private _textureMatrix;
  54144. private _size;
  54145. private _onLoad;
  54146. private _onError;
  54147. /**
  54148. * The texture URL.
  54149. */
  54150. url: string;
  54151. /**
  54152. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54153. */
  54154. coordinatesMode: number;
  54155. protected _isBlocking: boolean;
  54156. /**
  54157. * Sets wether or not the texture is blocking during loading.
  54158. */
  54159. /**
  54160. * Gets wether or not the texture is blocking during loading.
  54161. */
  54162. isBlocking: boolean;
  54163. protected _rotationY: number;
  54164. /**
  54165. * Sets texture matrix rotation angle around Y axis in radians.
  54166. */
  54167. /**
  54168. * Gets texture matrix rotation angle around Y axis radians.
  54169. */
  54170. rotationY: number;
  54171. /**
  54172. * Gets or sets the center of the bounding box associated with the cube texture
  54173. * It must define where the camera used to render the texture was set
  54174. */
  54175. boundingBoxPosition: Vector3;
  54176. private _boundingBoxSize;
  54177. /**
  54178. * Gets or sets the size of the bounding box associated with the cube texture
  54179. * When defined, the cubemap will switch to local mode
  54180. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54181. * @example https://www.babylonjs-playground.com/#RNASML
  54182. */
  54183. boundingBoxSize: Vector3;
  54184. /**
  54185. * Instantiates an HDRTexture from the following parameters.
  54186. *
  54187. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54188. * @param scene The scene the texture will be used in
  54189. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54190. * @param noMipmap Forces to not generate the mipmap if true
  54191. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54192. * @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)
  54193. * @param reserved Reserved flag for internal use.
  54194. */
  54195. 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>);
  54196. /**
  54197. * Get the current class name of the texture useful for serialization or dynamic coding.
  54198. * @returns "HDRCubeTexture"
  54199. */
  54200. getClassName(): string;
  54201. /**
  54202. * Occurs when the file is raw .hdr file.
  54203. */
  54204. private loadTexture;
  54205. clone(): HDRCubeTexture;
  54206. delayLoad(): void;
  54207. /**
  54208. * Get the texture reflection matrix used to rotate/transform the reflection.
  54209. * @returns the reflection matrix
  54210. */
  54211. getReflectionTextureMatrix(): Matrix;
  54212. /**
  54213. * Set the texture reflection matrix used to rotate/transform the reflection.
  54214. * @param value Define the reflection matrix to set
  54215. */
  54216. setReflectionTextureMatrix(value: Matrix): void;
  54217. /**
  54218. * Parses a JSON representation of an HDR Texture in order to create the texture
  54219. * @param parsedTexture Define the JSON representation
  54220. * @param scene Define the scene the texture should be created in
  54221. * @param rootUrl Define the root url in case we need to load relative dependencies
  54222. * @returns the newly created texture after parsing
  54223. */
  54224. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54225. serialize(): any;
  54226. }
  54227. }
  54228. declare module "babylonjs/Physics/physicsEngine" {
  54229. import { Nullable } from "babylonjs/types";
  54230. import { Vector3 } from "babylonjs/Maths/math.vector";
  54231. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54232. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  54233. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  54234. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54235. /**
  54236. * Class used to control physics engine
  54237. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54238. */
  54239. export class PhysicsEngine implements IPhysicsEngine {
  54240. private _physicsPlugin;
  54241. /**
  54242. * Global value used to control the smallest number supported by the simulation
  54243. */
  54244. static Epsilon: number;
  54245. private _impostors;
  54246. private _joints;
  54247. private _subTimeStep;
  54248. /**
  54249. * Gets the gravity vector used by the simulation
  54250. */
  54251. gravity: Vector3;
  54252. /**
  54253. * Factory used to create the default physics plugin.
  54254. * @returns The default physics plugin
  54255. */
  54256. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54257. /**
  54258. * Creates a new Physics Engine
  54259. * @param gravity defines the gravity vector used by the simulation
  54260. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54261. */
  54262. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54263. /**
  54264. * Sets the gravity vector used by the simulation
  54265. * @param gravity defines the gravity vector to use
  54266. */
  54267. setGravity(gravity: Vector3): void;
  54268. /**
  54269. * Set the time step of the physics engine.
  54270. * Default is 1/60.
  54271. * To slow it down, enter 1/600 for example.
  54272. * To speed it up, 1/30
  54273. * @param newTimeStep defines the new timestep to apply to this world.
  54274. */
  54275. setTimeStep(newTimeStep?: number): void;
  54276. /**
  54277. * Get the time step of the physics engine.
  54278. * @returns the current time step
  54279. */
  54280. getTimeStep(): number;
  54281. /**
  54282. * Set the sub time step of the physics engine.
  54283. * Default is 0 meaning there is no sub steps
  54284. * To increase physics resolution precision, set a small value (like 1 ms)
  54285. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54286. */
  54287. setSubTimeStep(subTimeStep?: number): void;
  54288. /**
  54289. * Get the sub time step of the physics engine.
  54290. * @returns the current sub time step
  54291. */
  54292. getSubTimeStep(): number;
  54293. /**
  54294. * Release all resources
  54295. */
  54296. dispose(): void;
  54297. /**
  54298. * Gets the name of the current physics plugin
  54299. * @returns the name of the plugin
  54300. */
  54301. getPhysicsPluginName(): string;
  54302. /**
  54303. * Adding a new impostor for the impostor tracking.
  54304. * This will be done by the impostor itself.
  54305. * @param impostor the impostor to add
  54306. */
  54307. addImpostor(impostor: PhysicsImpostor): void;
  54308. /**
  54309. * Remove an impostor from the engine.
  54310. * This impostor and its mesh will not longer be updated by the physics engine.
  54311. * @param impostor the impostor to remove
  54312. */
  54313. removeImpostor(impostor: PhysicsImpostor): void;
  54314. /**
  54315. * Add a joint to the physics engine
  54316. * @param mainImpostor defines the main impostor to which the joint is added.
  54317. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54318. * @param joint defines the joint that will connect both impostors.
  54319. */
  54320. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54321. /**
  54322. * Removes a joint from the simulation
  54323. * @param mainImpostor defines the impostor used with the joint
  54324. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54325. * @param joint defines the joint to remove
  54326. */
  54327. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54328. /**
  54329. * Called by the scene. No need to call it.
  54330. * @param delta defines the timespam between frames
  54331. */
  54332. _step(delta: number): void;
  54333. /**
  54334. * Gets the current plugin used to run the simulation
  54335. * @returns current plugin
  54336. */
  54337. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54338. /**
  54339. * Gets the list of physic impostors
  54340. * @returns an array of PhysicsImpostor
  54341. */
  54342. getImpostors(): Array<PhysicsImpostor>;
  54343. /**
  54344. * Gets the impostor for a physics enabled object
  54345. * @param object defines the object impersonated by the impostor
  54346. * @returns the PhysicsImpostor or null if not found
  54347. */
  54348. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54349. /**
  54350. * Gets the impostor for a physics body object
  54351. * @param body defines physics body used by the impostor
  54352. * @returns the PhysicsImpostor or null if not found
  54353. */
  54354. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54355. /**
  54356. * Does a raycast in the physics world
  54357. * @param from when should the ray start?
  54358. * @param to when should the ray end?
  54359. * @returns PhysicsRaycastResult
  54360. */
  54361. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54362. }
  54363. }
  54364. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54365. import { Nullable } from "babylonjs/types";
  54366. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54368. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54369. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54370. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54371. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54372. /** @hidden */
  54373. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54374. private _useDeltaForWorldStep;
  54375. world: any;
  54376. name: string;
  54377. private _physicsMaterials;
  54378. private _fixedTimeStep;
  54379. private _cannonRaycastResult;
  54380. private _raycastResult;
  54381. private _physicsBodysToRemoveAfterStep;
  54382. BJSCANNON: any;
  54383. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54384. setGravity(gravity: Vector3): void;
  54385. setTimeStep(timeStep: number): void;
  54386. getTimeStep(): number;
  54387. executeStep(delta: number): void;
  54388. private _removeMarkedPhysicsBodiesFromWorld;
  54389. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54390. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54391. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54392. private _processChildMeshes;
  54393. removePhysicsBody(impostor: PhysicsImpostor): void;
  54394. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54395. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54396. private _addMaterial;
  54397. private _checkWithEpsilon;
  54398. private _createShape;
  54399. private _createHeightmap;
  54400. private _minus90X;
  54401. private _plus90X;
  54402. private _tmpPosition;
  54403. private _tmpDeltaPosition;
  54404. private _tmpUnityRotation;
  54405. private _updatePhysicsBodyTransformation;
  54406. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54407. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54408. isSupported(): boolean;
  54409. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54410. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54411. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54412. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54413. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54414. getBodyMass(impostor: PhysicsImpostor): number;
  54415. getBodyFriction(impostor: PhysicsImpostor): number;
  54416. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54417. getBodyRestitution(impostor: PhysicsImpostor): number;
  54418. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54419. sleepBody(impostor: PhysicsImpostor): void;
  54420. wakeUpBody(impostor: PhysicsImpostor): void;
  54421. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54422. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54423. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54424. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54425. getRadius(impostor: PhysicsImpostor): number;
  54426. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54427. dispose(): void;
  54428. private _extendNamespace;
  54429. /**
  54430. * Does a raycast in the physics world
  54431. * @param from when should the ray start?
  54432. * @param to when should the ray end?
  54433. * @returns PhysicsRaycastResult
  54434. */
  54435. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54436. }
  54437. }
  54438. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54439. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54440. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54441. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54443. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54444. import { Nullable } from "babylonjs/types";
  54445. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54446. /** @hidden */
  54447. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54448. world: any;
  54449. name: string;
  54450. BJSOIMO: any;
  54451. private _raycastResult;
  54452. constructor(iterations?: number, oimoInjection?: any);
  54453. setGravity(gravity: Vector3): void;
  54454. setTimeStep(timeStep: number): void;
  54455. getTimeStep(): number;
  54456. private _tmpImpostorsArray;
  54457. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54458. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54459. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54460. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54461. private _tmpPositionVector;
  54462. removePhysicsBody(impostor: PhysicsImpostor): void;
  54463. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54464. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54465. isSupported(): boolean;
  54466. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54467. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54468. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54469. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54470. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54471. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54472. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54473. getBodyMass(impostor: PhysicsImpostor): number;
  54474. getBodyFriction(impostor: PhysicsImpostor): number;
  54475. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54476. getBodyRestitution(impostor: PhysicsImpostor): number;
  54477. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54478. sleepBody(impostor: PhysicsImpostor): void;
  54479. wakeUpBody(impostor: PhysicsImpostor): void;
  54480. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54481. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54482. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54483. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54484. getRadius(impostor: PhysicsImpostor): number;
  54485. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54486. dispose(): void;
  54487. /**
  54488. * Does a raycast in the physics world
  54489. * @param from when should the ray start?
  54490. * @param to when should the ray end?
  54491. * @returns PhysicsRaycastResult
  54492. */
  54493. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54494. }
  54495. }
  54496. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54497. import { Nullable } from "babylonjs/types";
  54498. import { Scene } from "babylonjs/scene";
  54499. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54500. import { Color4 } from "babylonjs/Maths/math.color";
  54501. import { Mesh } from "babylonjs/Meshes/mesh";
  54502. /**
  54503. * Class containing static functions to help procedurally build meshes
  54504. */
  54505. export class RibbonBuilder {
  54506. /**
  54507. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54508. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54509. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54510. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54511. * * 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
  54512. * * 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
  54513. * * 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
  54514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54517. * * 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
  54518. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54519. * * 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
  54520. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54522. * @param name defines the name of the mesh
  54523. * @param options defines the options used to create the mesh
  54524. * @param scene defines the hosting scene
  54525. * @returns the ribbon mesh
  54526. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54527. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54528. */
  54529. static CreateRibbon(name: string, options: {
  54530. pathArray: Vector3[][];
  54531. closeArray?: boolean;
  54532. closePath?: boolean;
  54533. offset?: number;
  54534. updatable?: boolean;
  54535. sideOrientation?: number;
  54536. frontUVs?: Vector4;
  54537. backUVs?: Vector4;
  54538. instance?: Mesh;
  54539. invertUV?: boolean;
  54540. uvs?: Vector2[];
  54541. colors?: Color4[];
  54542. }, scene?: Nullable<Scene>): Mesh;
  54543. }
  54544. }
  54545. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54546. import { Nullable } from "babylonjs/types";
  54547. import { Scene } from "babylonjs/scene";
  54548. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54549. import { Mesh } from "babylonjs/Meshes/mesh";
  54550. /**
  54551. * Class containing static functions to help procedurally build meshes
  54552. */
  54553. export class ShapeBuilder {
  54554. /**
  54555. * 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.
  54556. * * 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.
  54557. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54558. * * 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.
  54559. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54560. * * 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
  54561. * * 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
  54562. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54565. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54567. * @param name defines the name of the mesh
  54568. * @param options defines the options used to create the mesh
  54569. * @param scene defines the hosting scene
  54570. * @returns the extruded shape mesh
  54571. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54573. */
  54574. static ExtrudeShape(name: string, options: {
  54575. shape: Vector3[];
  54576. path: Vector3[];
  54577. scale?: number;
  54578. rotation?: number;
  54579. cap?: number;
  54580. updatable?: boolean;
  54581. sideOrientation?: number;
  54582. frontUVs?: Vector4;
  54583. backUVs?: Vector4;
  54584. instance?: Mesh;
  54585. invertUV?: boolean;
  54586. }, scene?: Nullable<Scene>): Mesh;
  54587. /**
  54588. * Creates an custom extruded shape mesh.
  54589. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54590. * * 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.
  54591. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54592. * * 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
  54593. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54594. * * 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
  54595. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54596. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54597. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54598. * * 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
  54599. * * 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
  54600. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54603. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54605. * @param name defines the name of the mesh
  54606. * @param options defines the options used to create the mesh
  54607. * @param scene defines the hosting scene
  54608. * @returns the custom extruded shape mesh
  54609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54610. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54611. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54612. */
  54613. static ExtrudeShapeCustom(name: string, options: {
  54614. shape: Vector3[];
  54615. path: Vector3[];
  54616. scaleFunction?: any;
  54617. rotationFunction?: any;
  54618. ribbonCloseArray?: boolean;
  54619. ribbonClosePath?: boolean;
  54620. cap?: number;
  54621. updatable?: boolean;
  54622. sideOrientation?: number;
  54623. frontUVs?: Vector4;
  54624. backUVs?: Vector4;
  54625. instance?: Mesh;
  54626. invertUV?: boolean;
  54627. }, scene?: Nullable<Scene>): Mesh;
  54628. private static _ExtrudeShapeGeneric;
  54629. }
  54630. }
  54631. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54632. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54633. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54634. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54635. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54636. import { Nullable } from "babylonjs/types";
  54637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54638. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54639. /**
  54640. * AmmoJS Physics plugin
  54641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54642. * @see https://github.com/kripken/ammo.js/
  54643. */
  54644. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54645. private _useDeltaForWorldStep;
  54646. /**
  54647. * Reference to the Ammo library
  54648. */
  54649. bjsAMMO: any;
  54650. /**
  54651. * Created ammoJS world which physics bodies are added to
  54652. */
  54653. world: any;
  54654. /**
  54655. * Name of the plugin
  54656. */
  54657. name: string;
  54658. private _timeStep;
  54659. private _fixedTimeStep;
  54660. private _maxSteps;
  54661. private _tmpQuaternion;
  54662. private _tmpAmmoTransform;
  54663. private _tmpAmmoQuaternion;
  54664. private _tmpAmmoConcreteContactResultCallback;
  54665. private _collisionConfiguration;
  54666. private _dispatcher;
  54667. private _overlappingPairCache;
  54668. private _solver;
  54669. private _softBodySolver;
  54670. private _tmpAmmoVectorA;
  54671. private _tmpAmmoVectorB;
  54672. private _tmpAmmoVectorC;
  54673. private _tmpAmmoVectorD;
  54674. private _tmpContactCallbackResult;
  54675. private _tmpAmmoVectorRCA;
  54676. private _tmpAmmoVectorRCB;
  54677. private _raycastResult;
  54678. private static readonly DISABLE_COLLISION_FLAG;
  54679. private static readonly KINEMATIC_FLAG;
  54680. private static readonly DISABLE_DEACTIVATION_FLAG;
  54681. /**
  54682. * Initializes the ammoJS plugin
  54683. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54684. * @param ammoInjection can be used to inject your own ammo reference
  54685. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54686. */
  54687. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54688. /**
  54689. * Sets the gravity of the physics world (m/(s^2))
  54690. * @param gravity Gravity to set
  54691. */
  54692. setGravity(gravity: Vector3): void;
  54693. /**
  54694. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54695. * @param timeStep timestep to use in seconds
  54696. */
  54697. setTimeStep(timeStep: number): void;
  54698. /**
  54699. * 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)
  54700. * @param fixedTimeStep fixedTimeStep to use in seconds
  54701. */
  54702. setFixedTimeStep(fixedTimeStep: number): void;
  54703. /**
  54704. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54705. * @param maxSteps the maximum number of steps by the physics engine per frame
  54706. */
  54707. setMaxSteps(maxSteps: number): void;
  54708. /**
  54709. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54710. * @returns the current timestep in seconds
  54711. */
  54712. getTimeStep(): number;
  54713. /**
  54714. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  54715. */
  54716. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  54717. private _isImpostorInContact;
  54718. private _isImpostorPairInContact;
  54719. private _stepSimulation;
  54720. /**
  54721. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54722. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54723. * After the step the babylon meshes are set to the position of the physics imposters
  54724. * @param delta amount of time to step forward
  54725. * @param impostors array of imposters to update before/after the step
  54726. */
  54727. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54728. /**
  54729. * Update babylon mesh to match physics world object
  54730. * @param impostor imposter to match
  54731. */
  54732. private _afterSoftStep;
  54733. /**
  54734. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54735. * @param impostor imposter to match
  54736. */
  54737. private _ropeStep;
  54738. /**
  54739. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54740. * @param impostor imposter to match
  54741. */
  54742. private _softbodyOrClothStep;
  54743. private _tmpVector;
  54744. private _tmpMatrix;
  54745. /**
  54746. * Applies an impulse on the imposter
  54747. * @param impostor imposter to apply impulse to
  54748. * @param force amount of force to be applied to the imposter
  54749. * @param contactPoint the location to apply the impulse on the imposter
  54750. */
  54751. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54752. /**
  54753. * Applies a force on the imposter
  54754. * @param impostor imposter to apply force
  54755. * @param force amount of force to be applied to the imposter
  54756. * @param contactPoint the location to apply the force on the imposter
  54757. */
  54758. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54759. /**
  54760. * Creates a physics body using the plugin
  54761. * @param impostor the imposter to create the physics body on
  54762. */
  54763. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54764. /**
  54765. * Removes the physics body from the imposter and disposes of the body's memory
  54766. * @param impostor imposter to remove the physics body from
  54767. */
  54768. removePhysicsBody(impostor: PhysicsImpostor): void;
  54769. /**
  54770. * Generates a joint
  54771. * @param impostorJoint the imposter joint to create the joint with
  54772. */
  54773. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54774. /**
  54775. * Removes a joint
  54776. * @param impostorJoint the imposter joint to remove the joint from
  54777. */
  54778. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54779. private _addMeshVerts;
  54780. /**
  54781. * Initialise the soft body vertices to match its object's (mesh) vertices
  54782. * Softbody vertices (nodes) are in world space and to match this
  54783. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54784. * @param impostor to create the softbody for
  54785. */
  54786. private _softVertexData;
  54787. /**
  54788. * Create an impostor's soft body
  54789. * @param impostor to create the softbody for
  54790. */
  54791. private _createSoftbody;
  54792. /**
  54793. * Create cloth for an impostor
  54794. * @param impostor to create the softbody for
  54795. */
  54796. private _createCloth;
  54797. /**
  54798. * Create rope for an impostor
  54799. * @param impostor to create the softbody for
  54800. */
  54801. private _createRope;
  54802. /**
  54803. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  54804. * @param impostor to create the custom physics shape for
  54805. */
  54806. private _createCustom;
  54807. private _addHullVerts;
  54808. private _createShape;
  54809. /**
  54810. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54811. * @param impostor imposter containing the physics body and babylon object
  54812. */
  54813. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54814. /**
  54815. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54816. * @param impostor imposter containing the physics body and babylon object
  54817. * @param newPosition new position
  54818. * @param newRotation new rotation
  54819. */
  54820. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54821. /**
  54822. * If this plugin is supported
  54823. * @returns true if its supported
  54824. */
  54825. isSupported(): boolean;
  54826. /**
  54827. * Sets the linear velocity of the physics body
  54828. * @param impostor imposter to set the velocity on
  54829. * @param velocity velocity to set
  54830. */
  54831. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54832. /**
  54833. * Sets the angular velocity of the physics body
  54834. * @param impostor imposter to set the velocity on
  54835. * @param velocity velocity to set
  54836. */
  54837. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54838. /**
  54839. * gets the linear velocity
  54840. * @param impostor imposter to get linear velocity from
  54841. * @returns linear velocity
  54842. */
  54843. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54844. /**
  54845. * gets the angular velocity
  54846. * @param impostor imposter to get angular velocity from
  54847. * @returns angular velocity
  54848. */
  54849. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54850. /**
  54851. * Sets the mass of physics body
  54852. * @param impostor imposter to set the mass on
  54853. * @param mass mass to set
  54854. */
  54855. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54856. /**
  54857. * Gets the mass of the physics body
  54858. * @param impostor imposter to get the mass from
  54859. * @returns mass
  54860. */
  54861. getBodyMass(impostor: PhysicsImpostor): number;
  54862. /**
  54863. * Gets friction of the impostor
  54864. * @param impostor impostor to get friction from
  54865. * @returns friction value
  54866. */
  54867. getBodyFriction(impostor: PhysicsImpostor): number;
  54868. /**
  54869. * Sets friction of the impostor
  54870. * @param impostor impostor to set friction on
  54871. * @param friction friction value
  54872. */
  54873. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54874. /**
  54875. * Gets restitution of the impostor
  54876. * @param impostor impostor to get restitution from
  54877. * @returns restitution value
  54878. */
  54879. getBodyRestitution(impostor: PhysicsImpostor): number;
  54880. /**
  54881. * Sets resitution of the impostor
  54882. * @param impostor impostor to set resitution on
  54883. * @param restitution resitution value
  54884. */
  54885. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54886. /**
  54887. * Gets pressure inside the impostor
  54888. * @param impostor impostor to get pressure from
  54889. * @returns pressure value
  54890. */
  54891. getBodyPressure(impostor: PhysicsImpostor): number;
  54892. /**
  54893. * Sets pressure inside a soft body impostor
  54894. * Cloth and rope must remain 0 pressure
  54895. * @param impostor impostor to set pressure on
  54896. * @param pressure pressure value
  54897. */
  54898. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54899. /**
  54900. * Gets stiffness of the impostor
  54901. * @param impostor impostor to get stiffness from
  54902. * @returns pressure value
  54903. */
  54904. getBodyStiffness(impostor: PhysicsImpostor): number;
  54905. /**
  54906. * Sets stiffness of the impostor
  54907. * @param impostor impostor to set stiffness on
  54908. * @param stiffness stiffness value from 0 to 1
  54909. */
  54910. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54911. /**
  54912. * Gets velocityIterations of the impostor
  54913. * @param impostor impostor to get velocity iterations from
  54914. * @returns velocityIterations value
  54915. */
  54916. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54917. /**
  54918. * Sets velocityIterations of the impostor
  54919. * @param impostor impostor to set velocity iterations on
  54920. * @param velocityIterations velocityIterations value
  54921. */
  54922. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54923. /**
  54924. * Gets positionIterations of the impostor
  54925. * @param impostor impostor to get position iterations from
  54926. * @returns positionIterations value
  54927. */
  54928. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54929. /**
  54930. * Sets positionIterations of the impostor
  54931. * @param impostor impostor to set position on
  54932. * @param positionIterations positionIterations value
  54933. */
  54934. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54935. /**
  54936. * Append an anchor to a cloth object
  54937. * @param impostor is the cloth impostor to add anchor to
  54938. * @param otherImpostor is the rigid impostor to anchor to
  54939. * @param width ratio across width from 0 to 1
  54940. * @param height ratio up height from 0 to 1
  54941. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54942. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54943. */
  54944. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54945. /**
  54946. * Append an hook to a rope object
  54947. * @param impostor is the rope impostor to add hook to
  54948. * @param otherImpostor is the rigid impostor to hook to
  54949. * @param length ratio along the rope from 0 to 1
  54950. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54951. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54952. */
  54953. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54954. /**
  54955. * Sleeps the physics body and stops it from being active
  54956. * @param impostor impostor to sleep
  54957. */
  54958. sleepBody(impostor: PhysicsImpostor): void;
  54959. /**
  54960. * Activates the physics body
  54961. * @param impostor impostor to activate
  54962. */
  54963. wakeUpBody(impostor: PhysicsImpostor): void;
  54964. /**
  54965. * Updates the distance parameters of the joint
  54966. * @param joint joint to update
  54967. * @param maxDistance maximum distance of the joint
  54968. * @param minDistance minimum distance of the joint
  54969. */
  54970. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54971. /**
  54972. * Sets a motor on the joint
  54973. * @param joint joint to set motor on
  54974. * @param speed speed of the motor
  54975. * @param maxForce maximum force of the motor
  54976. * @param motorIndex index of the motor
  54977. */
  54978. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54979. /**
  54980. * Sets the motors limit
  54981. * @param joint joint to set limit on
  54982. * @param upperLimit upper limit
  54983. * @param lowerLimit lower limit
  54984. */
  54985. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54986. /**
  54987. * Syncs the position and rotation of a mesh with the impostor
  54988. * @param mesh mesh to sync
  54989. * @param impostor impostor to update the mesh with
  54990. */
  54991. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54992. /**
  54993. * Gets the radius of the impostor
  54994. * @param impostor impostor to get radius from
  54995. * @returns the radius
  54996. */
  54997. getRadius(impostor: PhysicsImpostor): number;
  54998. /**
  54999. * Gets the box size of the impostor
  55000. * @param impostor impostor to get box size from
  55001. * @param result the resulting box size
  55002. */
  55003. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55004. /**
  55005. * Disposes of the impostor
  55006. */
  55007. dispose(): void;
  55008. /**
  55009. * Does a raycast in the physics world
  55010. * @param from when should the ray start?
  55011. * @param to when should the ray end?
  55012. * @returns PhysicsRaycastResult
  55013. */
  55014. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55015. }
  55016. }
  55017. declare module "babylonjs/Probes/reflectionProbe" {
  55018. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55019. import { Vector3 } from "babylonjs/Maths/math.vector";
  55020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55021. import { Nullable } from "babylonjs/types";
  55022. import { Scene } from "babylonjs/scene";
  55023. module "babylonjs/abstractScene" {
  55024. interface AbstractScene {
  55025. /**
  55026. * The list of reflection probes added to the scene
  55027. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55028. */
  55029. reflectionProbes: Array<ReflectionProbe>;
  55030. /**
  55031. * Removes the given reflection probe from this scene.
  55032. * @param toRemove The reflection probe to remove
  55033. * @returns The index of the removed reflection probe
  55034. */
  55035. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55036. /**
  55037. * Adds the given reflection probe to this scene.
  55038. * @param newReflectionProbe The reflection probe to add
  55039. */
  55040. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55041. }
  55042. }
  55043. /**
  55044. * Class used to generate realtime reflection / refraction cube textures
  55045. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55046. */
  55047. export class ReflectionProbe {
  55048. /** defines the name of the probe */
  55049. name: string;
  55050. private _scene;
  55051. private _renderTargetTexture;
  55052. private _projectionMatrix;
  55053. private _viewMatrix;
  55054. private _target;
  55055. private _add;
  55056. private _attachedMesh;
  55057. private _invertYAxis;
  55058. /** Gets or sets probe position (center of the cube map) */
  55059. position: Vector3;
  55060. /**
  55061. * Creates a new reflection probe
  55062. * @param name defines the name of the probe
  55063. * @param size defines the texture resolution (for each face)
  55064. * @param scene defines the hosting scene
  55065. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55066. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55067. */
  55068. constructor(
  55069. /** defines the name of the probe */
  55070. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55071. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55072. samples: number;
  55073. /** Gets or sets the refresh rate to use (on every frame by default) */
  55074. refreshRate: number;
  55075. /**
  55076. * Gets the hosting scene
  55077. * @returns a Scene
  55078. */
  55079. getScene(): Scene;
  55080. /** Gets the internal CubeTexture used to render to */
  55081. readonly cubeTexture: RenderTargetTexture;
  55082. /** Gets the list of meshes to render */
  55083. readonly renderList: Nullable<AbstractMesh[]>;
  55084. /**
  55085. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55086. * @param mesh defines the mesh to attach to
  55087. */
  55088. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55089. /**
  55090. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55091. * @param renderingGroupId The rendering group id corresponding to its index
  55092. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55093. */
  55094. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55095. /**
  55096. * Clean all associated resources
  55097. */
  55098. dispose(): void;
  55099. /**
  55100. * Converts the reflection probe information to a readable string for debug purpose.
  55101. * @param fullDetails Supports for multiple levels of logging within scene loading
  55102. * @returns the human readable reflection probe info
  55103. */
  55104. toString(fullDetails?: boolean): string;
  55105. /**
  55106. * Get the class name of the relfection probe.
  55107. * @returns "ReflectionProbe"
  55108. */
  55109. getClassName(): string;
  55110. /**
  55111. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55112. * @returns The JSON representation of the texture
  55113. */
  55114. serialize(): any;
  55115. /**
  55116. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55117. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55118. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55119. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55120. * @returns The parsed reflection probe if successful
  55121. */
  55122. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55123. }
  55124. }
  55125. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  55126. /** @hidden */
  55127. export var _BabylonLoaderRegistered: boolean;
  55128. /**
  55129. * Helps setting up some configuration for the babylon file loader.
  55130. */
  55131. export class BabylonFileLoaderConfiguration {
  55132. /**
  55133. * The loader does not allow injecting custom physix engine into the plugins.
  55134. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55135. * So you could set this variable to your engine import to make it work.
  55136. */
  55137. static LoaderInjectedPhysicsEngine: any;
  55138. }
  55139. }
  55140. declare module "babylonjs/Loading/Plugins/index" {
  55141. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  55142. }
  55143. declare module "babylonjs/Loading/index" {
  55144. export * from "babylonjs/Loading/loadingScreen";
  55145. export * from "babylonjs/Loading/Plugins/index";
  55146. export * from "babylonjs/Loading/sceneLoader";
  55147. export * from "babylonjs/Loading/sceneLoaderFlags";
  55148. }
  55149. declare module "babylonjs/Materials/Background/index" {
  55150. export * from "babylonjs/Materials/Background/backgroundMaterial";
  55151. }
  55152. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  55153. import { Scene } from "babylonjs/scene";
  55154. import { Color3 } from "babylonjs/Maths/math.color";
  55155. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55156. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55157. /**
  55158. * The Physically based simple base material of BJS.
  55159. *
  55160. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55161. * It is used as the base class for both the specGloss and metalRough conventions.
  55162. */
  55163. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55164. /**
  55165. * Number of Simultaneous lights allowed on the material.
  55166. */
  55167. maxSimultaneousLights: number;
  55168. /**
  55169. * If sets to true, disables all the lights affecting the material.
  55170. */
  55171. disableLighting: boolean;
  55172. /**
  55173. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55174. */
  55175. environmentTexture: BaseTexture;
  55176. /**
  55177. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55178. */
  55179. invertNormalMapX: boolean;
  55180. /**
  55181. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55182. */
  55183. invertNormalMapY: boolean;
  55184. /**
  55185. * Normal map used in the model.
  55186. */
  55187. normalTexture: BaseTexture;
  55188. /**
  55189. * Emissivie color used to self-illuminate the model.
  55190. */
  55191. emissiveColor: Color3;
  55192. /**
  55193. * Emissivie texture used to self-illuminate the model.
  55194. */
  55195. emissiveTexture: BaseTexture;
  55196. /**
  55197. * Occlusion Channel Strenght.
  55198. */
  55199. occlusionStrength: number;
  55200. /**
  55201. * Occlusion Texture of the material (adding extra occlusion effects).
  55202. */
  55203. occlusionTexture: BaseTexture;
  55204. /**
  55205. * Defines the alpha limits in alpha test mode.
  55206. */
  55207. alphaCutOff: number;
  55208. /**
  55209. * Gets the current double sided mode.
  55210. */
  55211. /**
  55212. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55213. */
  55214. doubleSided: boolean;
  55215. /**
  55216. * Stores the pre-calculated light information of a mesh in a texture.
  55217. */
  55218. lightmapTexture: BaseTexture;
  55219. /**
  55220. * If true, the light map contains occlusion information instead of lighting info.
  55221. */
  55222. useLightmapAsShadowmap: boolean;
  55223. /**
  55224. * Instantiates a new PBRMaterial instance.
  55225. *
  55226. * @param name The material name
  55227. * @param scene The scene the material will be use in.
  55228. */
  55229. constructor(name: string, scene: Scene);
  55230. getClassName(): string;
  55231. }
  55232. }
  55233. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  55234. import { Scene } from "babylonjs/scene";
  55235. import { Color3 } from "babylonjs/Maths/math.color";
  55236. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55237. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55238. /**
  55239. * The PBR material of BJS following the metal roughness convention.
  55240. *
  55241. * This fits to the PBR convention in the GLTF definition:
  55242. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55243. */
  55244. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55245. /**
  55246. * The base color has two different interpretations depending on the value of metalness.
  55247. * When the material is a metal, the base color is the specific measured reflectance value
  55248. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55249. * of the material.
  55250. */
  55251. baseColor: Color3;
  55252. /**
  55253. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55254. * well as opacity information in the alpha channel.
  55255. */
  55256. baseTexture: BaseTexture;
  55257. /**
  55258. * Specifies the metallic scalar value of the material.
  55259. * Can also be used to scale the metalness values of the metallic texture.
  55260. */
  55261. metallic: number;
  55262. /**
  55263. * Specifies the roughness scalar value of the material.
  55264. * Can also be used to scale the roughness values of the metallic texture.
  55265. */
  55266. roughness: number;
  55267. /**
  55268. * Texture containing both the metallic value in the B channel and the
  55269. * roughness value in the G channel to keep better precision.
  55270. */
  55271. metallicRoughnessTexture: BaseTexture;
  55272. /**
  55273. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55274. *
  55275. * @param name The material name
  55276. * @param scene The scene the material will be use in.
  55277. */
  55278. constructor(name: string, scene: Scene);
  55279. /**
  55280. * Return the currrent class name of the material.
  55281. */
  55282. getClassName(): string;
  55283. /**
  55284. * Makes a duplicate of the current material.
  55285. * @param name - name to use for the new material.
  55286. */
  55287. clone(name: string): PBRMetallicRoughnessMaterial;
  55288. /**
  55289. * Serialize the material to a parsable JSON object.
  55290. */
  55291. serialize(): any;
  55292. /**
  55293. * Parses a JSON object correponding to the serialize function.
  55294. */
  55295. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55296. }
  55297. }
  55298. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55299. import { Scene } from "babylonjs/scene";
  55300. import { Color3 } from "babylonjs/Maths/math.color";
  55301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55302. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55303. /**
  55304. * The PBR material of BJS following the specular glossiness convention.
  55305. *
  55306. * This fits to the PBR convention in the GLTF definition:
  55307. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55308. */
  55309. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55310. /**
  55311. * Specifies the diffuse color of the material.
  55312. */
  55313. diffuseColor: Color3;
  55314. /**
  55315. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55316. * channel.
  55317. */
  55318. diffuseTexture: BaseTexture;
  55319. /**
  55320. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55321. */
  55322. specularColor: Color3;
  55323. /**
  55324. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55325. */
  55326. glossiness: number;
  55327. /**
  55328. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55329. */
  55330. specularGlossinessTexture: BaseTexture;
  55331. /**
  55332. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55333. *
  55334. * @param name The material name
  55335. * @param scene The scene the material will be use in.
  55336. */
  55337. constructor(name: string, scene: Scene);
  55338. /**
  55339. * Return the currrent class name of the material.
  55340. */
  55341. getClassName(): string;
  55342. /**
  55343. * Makes a duplicate of the current material.
  55344. * @param name - name to use for the new material.
  55345. */
  55346. clone(name: string): PBRSpecularGlossinessMaterial;
  55347. /**
  55348. * Serialize the material to a parsable JSON object.
  55349. */
  55350. serialize(): any;
  55351. /**
  55352. * Parses a JSON object correponding to the serialize function.
  55353. */
  55354. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55355. }
  55356. }
  55357. declare module "babylonjs/Materials/PBR/index" {
  55358. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55359. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55360. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55361. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55362. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55363. }
  55364. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55365. import { Nullable } from "babylonjs/types";
  55366. import { Scene } from "babylonjs/scene";
  55367. import { Matrix } from "babylonjs/Maths/math.vector";
  55368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55369. /**
  55370. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55371. * It can help converting any input color in a desired output one. This can then be used to create effects
  55372. * from sepia, black and white to sixties or futuristic rendering...
  55373. *
  55374. * The only supported format is currently 3dl.
  55375. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55376. */
  55377. export class ColorGradingTexture extends BaseTexture {
  55378. /**
  55379. * The current texture matrix. (will always be identity in color grading texture)
  55380. */
  55381. private _textureMatrix;
  55382. /**
  55383. * The texture URL.
  55384. */
  55385. url: string;
  55386. /**
  55387. * Empty line regex stored for GC.
  55388. */
  55389. private static _noneEmptyLineRegex;
  55390. private _engine;
  55391. /**
  55392. * Instantiates a ColorGradingTexture from the following parameters.
  55393. *
  55394. * @param url The location of the color gradind data (currently only supporting 3dl)
  55395. * @param scene The scene the texture will be used in
  55396. */
  55397. constructor(url: string, scene: Scene);
  55398. /**
  55399. * Returns the texture matrix used in most of the material.
  55400. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55401. */
  55402. getTextureMatrix(): Matrix;
  55403. /**
  55404. * Occurs when the file being loaded is a .3dl LUT file.
  55405. */
  55406. private load3dlTexture;
  55407. /**
  55408. * Starts the loading process of the texture.
  55409. */
  55410. private loadTexture;
  55411. /**
  55412. * Clones the color gradind texture.
  55413. */
  55414. clone(): ColorGradingTexture;
  55415. /**
  55416. * Called during delayed load for textures.
  55417. */
  55418. delayLoad(): void;
  55419. /**
  55420. * Parses a color grading texture serialized by Babylon.
  55421. * @param parsedTexture The texture information being parsedTexture
  55422. * @param scene The scene to load the texture in
  55423. * @param rootUrl The root url of the data assets to load
  55424. * @return A color gradind texture
  55425. */
  55426. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55427. /**
  55428. * Serializes the LUT texture to json format.
  55429. */
  55430. serialize(): any;
  55431. }
  55432. }
  55433. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55435. import { Scene } from "babylonjs/scene";
  55436. import { Nullable } from "babylonjs/types";
  55437. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55438. /**
  55439. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55440. */
  55441. export class EquiRectangularCubeTexture extends BaseTexture {
  55442. /** The six faces of the cube. */
  55443. private static _FacesMapping;
  55444. private _noMipmap;
  55445. private _onLoad;
  55446. private _onError;
  55447. /** The size of the cubemap. */
  55448. private _size;
  55449. /** The buffer of the image. */
  55450. private _buffer;
  55451. /** The width of the input image. */
  55452. private _width;
  55453. /** The height of the input image. */
  55454. private _height;
  55455. /** The URL to the image. */
  55456. url: string;
  55457. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55458. coordinatesMode: number;
  55459. /**
  55460. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55461. * @param url The location of the image
  55462. * @param scene The scene the texture will be used in
  55463. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55464. * @param noMipmap Forces to not generate the mipmap if true
  55465. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55466. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55467. * @param onLoad — defines a callback called when texture is loaded
  55468. * @param onError — defines a callback called if there is an error
  55469. */
  55470. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55471. /**
  55472. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55473. */
  55474. private loadImage;
  55475. /**
  55476. * Convert the image buffer into a cubemap and create a CubeTexture.
  55477. */
  55478. private loadTexture;
  55479. /**
  55480. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55481. * @param buffer The ArrayBuffer that should be converted.
  55482. * @returns The buffer as Float32Array.
  55483. */
  55484. private getFloat32ArrayFromArrayBuffer;
  55485. /**
  55486. * Get the current class name of the texture useful for serialization or dynamic coding.
  55487. * @returns "EquiRectangularCubeTexture"
  55488. */
  55489. getClassName(): string;
  55490. /**
  55491. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55492. * @returns A clone of the current EquiRectangularCubeTexture.
  55493. */
  55494. clone(): EquiRectangularCubeTexture;
  55495. }
  55496. }
  55497. declare module "babylonjs/Misc/tga" {
  55498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55499. /**
  55500. * Based on jsTGALoader - Javascript loader for TGA file
  55501. * By Vincent Thibault
  55502. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55503. */
  55504. export class TGATools {
  55505. private static _TYPE_INDEXED;
  55506. private static _TYPE_RGB;
  55507. private static _TYPE_GREY;
  55508. private static _TYPE_RLE_INDEXED;
  55509. private static _TYPE_RLE_RGB;
  55510. private static _TYPE_RLE_GREY;
  55511. private static _ORIGIN_MASK;
  55512. private static _ORIGIN_SHIFT;
  55513. private static _ORIGIN_BL;
  55514. private static _ORIGIN_BR;
  55515. private static _ORIGIN_UL;
  55516. private static _ORIGIN_UR;
  55517. /**
  55518. * Gets the header of a TGA file
  55519. * @param data defines the TGA data
  55520. * @returns the header
  55521. */
  55522. static GetTGAHeader(data: Uint8Array): any;
  55523. /**
  55524. * Uploads TGA content to a Babylon Texture
  55525. * @hidden
  55526. */
  55527. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55528. /** @hidden */
  55529. 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;
  55530. /** @hidden */
  55531. 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;
  55532. /** @hidden */
  55533. 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;
  55534. /** @hidden */
  55535. 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;
  55536. /** @hidden */
  55537. 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;
  55538. /** @hidden */
  55539. 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;
  55540. }
  55541. }
  55542. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55543. import { Nullable } from "babylonjs/types";
  55544. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55545. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55546. /**
  55547. * Implementation of the TGA Texture Loader.
  55548. * @hidden
  55549. */
  55550. export class _TGATextureLoader implements IInternalTextureLoader {
  55551. /**
  55552. * Defines wether the loader supports cascade loading the different faces.
  55553. */
  55554. readonly supportCascades: boolean;
  55555. /**
  55556. * This returns if the loader support the current file information.
  55557. * @param extension defines the file extension of the file being loaded
  55558. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55559. * @param fallback defines the fallback internal texture if any
  55560. * @param isBase64 defines whether the texture is encoded as a base64
  55561. * @param isBuffer defines whether the texture data are stored as a buffer
  55562. * @returns true if the loader can load the specified file
  55563. */
  55564. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55565. /**
  55566. * Transform the url before loading if required.
  55567. * @param rootUrl the url of the texture
  55568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55569. * @returns the transformed texture
  55570. */
  55571. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55572. /**
  55573. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55574. * @param rootUrl the url of the texture
  55575. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55576. * @returns the fallback texture
  55577. */
  55578. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55579. /**
  55580. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55581. * @param data contains the texture data
  55582. * @param texture defines the BabylonJS internal texture
  55583. * @param createPolynomials will be true if polynomials have been requested
  55584. * @param onLoad defines the callback to trigger once the texture is ready
  55585. * @param onError defines the callback to trigger in case of error
  55586. */
  55587. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55588. /**
  55589. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55590. * @param data contains the texture data
  55591. * @param texture defines the BabylonJS internal texture
  55592. * @param callback defines the method to call once ready to upload
  55593. */
  55594. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55595. }
  55596. }
  55597. declare module "babylonjs/Misc/basis" {
  55598. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55599. /**
  55600. * Info about the .basis files
  55601. */
  55602. class BasisFileInfo {
  55603. /**
  55604. * If the file has alpha
  55605. */
  55606. hasAlpha: boolean;
  55607. /**
  55608. * Info about each image of the basis file
  55609. */
  55610. images: Array<{
  55611. levels: Array<{
  55612. width: number;
  55613. height: number;
  55614. transcodedPixels: ArrayBufferView;
  55615. }>;
  55616. }>;
  55617. }
  55618. /**
  55619. * Result of transcoding a basis file
  55620. */
  55621. class TranscodeResult {
  55622. /**
  55623. * Info about the .basis file
  55624. */
  55625. fileInfo: BasisFileInfo;
  55626. /**
  55627. * Format to use when loading the file
  55628. */
  55629. format: number;
  55630. }
  55631. /**
  55632. * Configuration options for the Basis transcoder
  55633. */
  55634. export class BasisTranscodeConfiguration {
  55635. /**
  55636. * Supported compression formats used to determine the supported output format of the transcoder
  55637. */
  55638. supportedCompressionFormats?: {
  55639. /**
  55640. * etc1 compression format
  55641. */
  55642. etc1?: boolean;
  55643. /**
  55644. * s3tc compression format
  55645. */
  55646. s3tc?: boolean;
  55647. /**
  55648. * pvrtc compression format
  55649. */
  55650. pvrtc?: boolean;
  55651. /**
  55652. * etc2 compression format
  55653. */
  55654. etc2?: boolean;
  55655. };
  55656. /**
  55657. * If mipmap levels should be loaded for transcoded images (Default: true)
  55658. */
  55659. loadMipmapLevels?: boolean;
  55660. /**
  55661. * Index of a single image to load (Default: all images)
  55662. */
  55663. loadSingleImage?: number;
  55664. }
  55665. /**
  55666. * Used to load .Basis files
  55667. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55668. */
  55669. export class BasisTools {
  55670. private static _IgnoreSupportedFormats;
  55671. /**
  55672. * URL to use when loading the basis transcoder
  55673. */
  55674. static JSModuleURL: string;
  55675. /**
  55676. * URL to use when loading the wasm module for the transcoder
  55677. */
  55678. static WasmModuleURL: string;
  55679. /**
  55680. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55681. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55682. * @returns internal format corresponding to the Basis format
  55683. */
  55684. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55685. private static _WorkerPromise;
  55686. private static _Worker;
  55687. private static _actionId;
  55688. private static _CreateWorkerAsync;
  55689. /**
  55690. * Transcodes a loaded image file to compressed pixel data
  55691. * @param imageData image data to transcode
  55692. * @param config configuration options for the transcoding
  55693. * @returns a promise resulting in the transcoded image
  55694. */
  55695. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55696. /**
  55697. * Loads a texture from the transcode result
  55698. * @param texture texture load to
  55699. * @param transcodeResult the result of transcoding the basis file to load from
  55700. */
  55701. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55702. }
  55703. }
  55704. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55705. import { Nullable } from "babylonjs/types";
  55706. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55707. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55708. /**
  55709. * Loader for .basis file format
  55710. */
  55711. export class _BasisTextureLoader implements IInternalTextureLoader {
  55712. /**
  55713. * Defines whether the loader supports cascade loading the different faces.
  55714. */
  55715. readonly supportCascades: boolean;
  55716. /**
  55717. * This returns if the loader support the current file information.
  55718. * @param extension defines the file extension of the file being loaded
  55719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55720. * @param fallback defines the fallback internal texture if any
  55721. * @param isBase64 defines whether the texture is encoded as a base64
  55722. * @param isBuffer defines whether the texture data are stored as a buffer
  55723. * @returns true if the loader can load the specified file
  55724. */
  55725. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55726. /**
  55727. * Transform the url before loading if required.
  55728. * @param rootUrl the url of the texture
  55729. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55730. * @returns the transformed texture
  55731. */
  55732. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55733. /**
  55734. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55735. * @param rootUrl the url of the texture
  55736. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55737. * @returns the fallback texture
  55738. */
  55739. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55740. /**
  55741. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55742. * @param data contains the texture data
  55743. * @param texture defines the BabylonJS internal texture
  55744. * @param createPolynomials will be true if polynomials have been requested
  55745. * @param onLoad defines the callback to trigger once the texture is ready
  55746. * @param onError defines the callback to trigger in case of error
  55747. */
  55748. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55749. /**
  55750. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55751. * @param data contains the texture data
  55752. * @param texture defines the BabylonJS internal texture
  55753. * @param callback defines the method to call once ready to upload
  55754. */
  55755. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55756. }
  55757. }
  55758. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55759. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55760. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55761. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55762. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55763. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55764. }
  55765. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55766. import { Scene } from "babylonjs/scene";
  55767. import { Texture } from "babylonjs/Materials/Textures/texture";
  55768. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55769. /**
  55770. * 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.
  55771. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55772. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55773. */
  55774. export class CustomProceduralTexture extends ProceduralTexture {
  55775. private _animate;
  55776. private _time;
  55777. private _config;
  55778. private _texturePath;
  55779. /**
  55780. * Instantiates a new Custom Procedural Texture.
  55781. * 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.
  55782. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55783. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55784. * @param name Define the name of the texture
  55785. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55786. * @param size Define the size of the texture to create
  55787. * @param scene Define the scene the texture belongs to
  55788. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55789. * @param generateMipMaps Define if the texture should creates mip maps or not
  55790. */
  55791. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55792. private _loadJson;
  55793. /**
  55794. * Is the texture ready to be used ? (rendered at least once)
  55795. * @returns true if ready, otherwise, false.
  55796. */
  55797. isReady(): boolean;
  55798. /**
  55799. * Render the texture to its associated render target.
  55800. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55801. */
  55802. render(useCameraPostProcess?: boolean): void;
  55803. /**
  55804. * Update the list of dependant textures samplers in the shader.
  55805. */
  55806. updateTextures(): void;
  55807. /**
  55808. * Update the uniform values of the procedural texture in the shader.
  55809. */
  55810. updateShaderUniforms(): void;
  55811. /**
  55812. * Define if the texture animates or not.
  55813. */
  55814. animate: boolean;
  55815. }
  55816. }
  55817. declare module "babylonjs/Shaders/noise.fragment" {
  55818. /** @hidden */
  55819. export var noisePixelShader: {
  55820. name: string;
  55821. shader: string;
  55822. };
  55823. }
  55824. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55825. import { Nullable } from "babylonjs/types";
  55826. import { Scene } from "babylonjs/scene";
  55827. import { Texture } from "babylonjs/Materials/Textures/texture";
  55828. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55829. import "babylonjs/Shaders/noise.fragment";
  55830. /**
  55831. * Class used to generate noise procedural textures
  55832. */
  55833. export class NoiseProceduralTexture extends ProceduralTexture {
  55834. private _time;
  55835. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55836. brightness: number;
  55837. /** Defines the number of octaves to process */
  55838. octaves: number;
  55839. /** Defines the level of persistence (0.8 by default) */
  55840. persistence: number;
  55841. /** Gets or sets animation speed factor (default is 1) */
  55842. animationSpeedFactor: number;
  55843. /**
  55844. * Creates a new NoiseProceduralTexture
  55845. * @param name defines the name fo the texture
  55846. * @param size defines the size of the texture (default is 256)
  55847. * @param scene defines the hosting scene
  55848. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55849. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55850. */
  55851. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55852. private _updateShaderUniforms;
  55853. protected _getDefines(): string;
  55854. /** Generate the current state of the procedural texture */
  55855. render(useCameraPostProcess?: boolean): void;
  55856. /**
  55857. * Serializes this noise procedural texture
  55858. * @returns a serialized noise procedural texture object
  55859. */
  55860. serialize(): any;
  55861. /**
  55862. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55863. * @param parsedTexture defines parsed texture data
  55864. * @param scene defines the current scene
  55865. * @param rootUrl defines the root URL containing noise procedural texture information
  55866. * @returns a parsed NoiseProceduralTexture
  55867. */
  55868. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55869. }
  55870. }
  55871. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55872. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55873. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55874. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55875. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55876. }
  55877. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55878. import { Nullable } from "babylonjs/types";
  55879. import { Scene } from "babylonjs/scene";
  55880. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55881. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55882. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55883. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55884. /**
  55885. * Raw cube texture where the raw buffers are passed in
  55886. */
  55887. export class RawCubeTexture extends CubeTexture {
  55888. /**
  55889. * Creates a cube texture where the raw buffers are passed in.
  55890. * @param scene defines the scene the texture is attached to
  55891. * @param data defines the array of data to use to create each face
  55892. * @param size defines the size of the textures
  55893. * @param format defines the format of the data
  55894. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55895. * @param generateMipMaps defines if the engine should generate the mip levels
  55896. * @param invertY defines if data must be stored with Y axis inverted
  55897. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55898. * @param compression defines the compression used (null by default)
  55899. */
  55900. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55901. /**
  55902. * Updates the raw cube texture.
  55903. * @param data defines the data to store
  55904. * @param format defines the data format
  55905. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55906. * @param invertY defines if data must be stored with Y axis inverted
  55907. * @param compression defines the compression used (null by default)
  55908. * @param level defines which level of the texture to update
  55909. */
  55910. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55911. /**
  55912. * Updates a raw cube texture with RGBD encoded data.
  55913. * @param data defines the array of data [mipmap][face] to use to create each face
  55914. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55915. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55916. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55917. * @returns a promsie that resolves when the operation is complete
  55918. */
  55919. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55920. /**
  55921. * Clones the raw cube texture.
  55922. * @return a new cube texture
  55923. */
  55924. clone(): CubeTexture;
  55925. /** @hidden */
  55926. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55927. }
  55928. }
  55929. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55930. import { Scene } from "babylonjs/scene";
  55931. import { Texture } from "babylonjs/Materials/Textures/texture";
  55932. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55933. /**
  55934. * Class used to store 3D textures containing user data
  55935. */
  55936. export class RawTexture3D extends Texture {
  55937. /** Gets or sets the texture format to use */
  55938. format: number;
  55939. private _engine;
  55940. /**
  55941. * Create a new RawTexture3D
  55942. * @param data defines the data of the texture
  55943. * @param width defines the width of the texture
  55944. * @param height defines the height of the texture
  55945. * @param depth defines the depth of the texture
  55946. * @param format defines the texture format to use
  55947. * @param scene defines the hosting scene
  55948. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55949. * @param invertY defines if texture must be stored with Y axis inverted
  55950. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55951. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55952. */
  55953. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55954. /** Gets or sets the texture format to use */
  55955. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55956. /**
  55957. * Update the texture with new data
  55958. * @param data defines the data to store in the texture
  55959. */
  55960. update(data: ArrayBufferView): void;
  55961. }
  55962. }
  55963. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55964. import { Scene } from "babylonjs/scene";
  55965. import { Texture } from "babylonjs/Materials/Textures/texture";
  55966. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55967. /**
  55968. * Class used to store 2D array textures containing user data
  55969. */
  55970. export class RawTexture2DArray extends Texture {
  55971. /** Gets or sets the texture format to use */
  55972. format: number;
  55973. private _engine;
  55974. /**
  55975. * Create a new RawTexture2DArray
  55976. * @param data defines the data of the texture
  55977. * @param width defines the width of the texture
  55978. * @param height defines the height of the texture
  55979. * @param depth defines the number of layers of the texture
  55980. * @param format defines the texture format to use
  55981. * @param scene defines the hosting scene
  55982. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55983. * @param invertY defines if texture must be stored with Y axis inverted
  55984. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55985. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55986. */
  55987. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55988. /** Gets or sets the texture format to use */
  55989. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55990. /**
  55991. * Update the texture with new data
  55992. * @param data defines the data to store in the texture
  55993. */
  55994. update(data: ArrayBufferView): void;
  55995. }
  55996. }
  55997. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55998. import { Scene } from "babylonjs/scene";
  55999. import { Plane } from "babylonjs/Maths/math.plane";
  56000. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56001. /**
  56002. * Creates a refraction texture used by refraction channel of the standard material.
  56003. * It is like a mirror but to see through a material.
  56004. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56005. */
  56006. export class RefractionTexture extends RenderTargetTexture {
  56007. /**
  56008. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56009. * 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.
  56010. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56011. */
  56012. refractionPlane: Plane;
  56013. /**
  56014. * Define how deep under the surface we should see.
  56015. */
  56016. depth: number;
  56017. /**
  56018. * Creates a refraction texture used by refraction channel of the standard material.
  56019. * It is like a mirror but to see through a material.
  56020. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56021. * @param name Define the texture name
  56022. * @param size Define the size of the underlying texture
  56023. * @param scene Define the scene the refraction belongs to
  56024. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56025. */
  56026. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56027. /**
  56028. * Clone the refraction texture.
  56029. * @returns the cloned texture
  56030. */
  56031. clone(): RefractionTexture;
  56032. /**
  56033. * Serialize the texture to a JSON representation you could use in Parse later on
  56034. * @returns the serialized JSON representation
  56035. */
  56036. serialize(): any;
  56037. }
  56038. }
  56039. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  56040. import { Nullable } from "babylonjs/types";
  56041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56042. import { Matrix } from "babylonjs/Maths/math.vector";
  56043. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  56044. import "babylonjs/Engines/Extensions/engine.videoTexture";
  56045. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  56046. import { Scene } from "babylonjs/scene";
  56047. /**
  56048. * Defines the options related to the creation of an HtmlElementTexture
  56049. */
  56050. export interface IHtmlElementTextureOptions {
  56051. /**
  56052. * Defines wether mip maps should be created or not.
  56053. */
  56054. generateMipMaps?: boolean;
  56055. /**
  56056. * Defines the sampling mode of the texture.
  56057. */
  56058. samplingMode?: number;
  56059. /**
  56060. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56061. */
  56062. engine: Nullable<ThinEngine>;
  56063. /**
  56064. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56065. */
  56066. scene: Nullable<Scene>;
  56067. }
  56068. /**
  56069. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56070. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56071. * is automatically managed.
  56072. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56073. * in your application.
  56074. *
  56075. * As the update is not automatic, you need to call them manually.
  56076. */
  56077. export class HtmlElementTexture extends BaseTexture {
  56078. /**
  56079. * The texture URL.
  56080. */
  56081. element: HTMLVideoElement | HTMLCanvasElement;
  56082. private static readonly DefaultOptions;
  56083. private _textureMatrix;
  56084. private _engine;
  56085. private _isVideo;
  56086. private _generateMipMaps;
  56087. private _samplingMode;
  56088. /**
  56089. * Instantiates a HtmlElementTexture from the following parameters.
  56090. *
  56091. * @param name Defines the name of the texture
  56092. * @param element Defines the video or canvas the texture is filled with
  56093. * @param options Defines the other none mandatory texture creation options
  56094. */
  56095. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56096. private _createInternalTexture;
  56097. /**
  56098. * Returns the texture matrix used in most of the material.
  56099. */
  56100. getTextureMatrix(): Matrix;
  56101. /**
  56102. * Updates the content of the texture.
  56103. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56104. */
  56105. update(invertY?: Nullable<boolean>): void;
  56106. }
  56107. }
  56108. declare module "babylonjs/Materials/Textures/index" {
  56109. export * from "babylonjs/Materials/Textures/baseTexture";
  56110. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  56111. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  56112. export * from "babylonjs/Materials/Textures/cubeTexture";
  56113. export * from "babylonjs/Materials/Textures/dynamicTexture";
  56114. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56115. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  56116. export * from "babylonjs/Materials/Textures/internalTexture";
  56117. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  56118. export * from "babylonjs/Materials/Textures/Loaders/index";
  56119. export * from "babylonjs/Materials/Textures/mirrorTexture";
  56120. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  56121. export * from "babylonjs/Materials/Textures/Procedurals/index";
  56122. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  56123. export * from "babylonjs/Materials/Textures/rawTexture";
  56124. export * from "babylonjs/Materials/Textures/rawTexture3D";
  56125. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  56126. export * from "babylonjs/Materials/Textures/refractionTexture";
  56127. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  56128. export * from "babylonjs/Materials/Textures/texture";
  56129. export * from "babylonjs/Materials/Textures/videoTexture";
  56130. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  56131. }
  56132. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  56133. /**
  56134. * Enum used to define the target of a block
  56135. */
  56136. export enum NodeMaterialBlockTargets {
  56137. /** Vertex shader */
  56138. Vertex = 1,
  56139. /** Fragment shader */
  56140. Fragment = 2,
  56141. /** Neutral */
  56142. Neutral = 4,
  56143. /** Vertex and Fragment */
  56144. VertexAndFragment = 3
  56145. }
  56146. }
  56147. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  56148. /**
  56149. * Defines the kind of connection point for node based material
  56150. */
  56151. export enum NodeMaterialBlockConnectionPointTypes {
  56152. /** Float */
  56153. Float = 1,
  56154. /** Int */
  56155. Int = 2,
  56156. /** Vector2 */
  56157. Vector2 = 4,
  56158. /** Vector3 */
  56159. Vector3 = 8,
  56160. /** Vector4 */
  56161. Vector4 = 16,
  56162. /** Color3 */
  56163. Color3 = 32,
  56164. /** Color4 */
  56165. Color4 = 64,
  56166. /** Matrix */
  56167. Matrix = 128,
  56168. /** Detect type based on connection */
  56169. AutoDetect = 1024,
  56170. /** Output type that will be defined by input type */
  56171. BasedOnInput = 2048
  56172. }
  56173. }
  56174. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  56175. /**
  56176. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56177. */
  56178. export enum NodeMaterialBlockConnectionPointMode {
  56179. /** Value is an uniform */
  56180. Uniform = 0,
  56181. /** Value is a mesh attribute */
  56182. Attribute = 1,
  56183. /** Value is a varying between vertex and fragment shaders */
  56184. Varying = 2,
  56185. /** Mode is undefined */
  56186. Undefined = 3
  56187. }
  56188. }
  56189. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  56190. /**
  56191. * Enum used to define system values e.g. values automatically provided by the system
  56192. */
  56193. export enum NodeMaterialSystemValues {
  56194. /** World */
  56195. World = 1,
  56196. /** View */
  56197. View = 2,
  56198. /** Projection */
  56199. Projection = 3,
  56200. /** ViewProjection */
  56201. ViewProjection = 4,
  56202. /** WorldView */
  56203. WorldView = 5,
  56204. /** WorldViewProjection */
  56205. WorldViewProjection = 6,
  56206. /** CameraPosition */
  56207. CameraPosition = 7,
  56208. /** Fog Color */
  56209. FogColor = 8,
  56210. /** Delta time */
  56211. DeltaTime = 9
  56212. }
  56213. }
  56214. declare module "babylonjs/Materials/Node/Enums/index" {
  56215. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56216. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56217. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  56218. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56219. }
  56220. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  56221. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56222. /**
  56223. * Root class for all node material optimizers
  56224. */
  56225. export class NodeMaterialOptimizer {
  56226. /**
  56227. * Function used to optimize a NodeMaterial graph
  56228. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56229. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56230. */
  56231. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56232. }
  56233. }
  56234. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  56235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56238. import { Scene } from "babylonjs/scene";
  56239. /**
  56240. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56241. */
  56242. export class TransformBlock extends NodeMaterialBlock {
  56243. /**
  56244. * Defines the value to use to complement W value to transform it to a Vector4
  56245. */
  56246. complementW: number;
  56247. /**
  56248. * Defines the value to use to complement z value to transform it to a Vector4
  56249. */
  56250. complementZ: number;
  56251. /**
  56252. * Creates a new TransformBlock
  56253. * @param name defines the block name
  56254. */
  56255. constructor(name: string);
  56256. /**
  56257. * Gets the current class name
  56258. * @returns the class name
  56259. */
  56260. getClassName(): string;
  56261. /**
  56262. * Gets the vector input
  56263. */
  56264. readonly vector: NodeMaterialConnectionPoint;
  56265. /**
  56266. * Gets the output component
  56267. */
  56268. readonly output: NodeMaterialConnectionPoint;
  56269. /**
  56270. * Gets the matrix transform input
  56271. */
  56272. readonly transform: NodeMaterialConnectionPoint;
  56273. protected _buildBlock(state: NodeMaterialBuildState): this;
  56274. serialize(): any;
  56275. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56276. protected _dumpPropertiesCode(): string;
  56277. }
  56278. }
  56279. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  56280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56283. /**
  56284. * Block used to output the vertex position
  56285. */
  56286. export class VertexOutputBlock extends NodeMaterialBlock {
  56287. /**
  56288. * Creates a new VertexOutputBlock
  56289. * @param name defines the block name
  56290. */
  56291. constructor(name: string);
  56292. /**
  56293. * Gets the current class name
  56294. * @returns the class name
  56295. */
  56296. getClassName(): string;
  56297. /**
  56298. * Gets the vector input component
  56299. */
  56300. readonly vector: NodeMaterialConnectionPoint;
  56301. protected _buildBlock(state: NodeMaterialBuildState): this;
  56302. }
  56303. }
  56304. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56306. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56308. /**
  56309. * Block used to output the final color
  56310. */
  56311. export class FragmentOutputBlock extends NodeMaterialBlock {
  56312. /**
  56313. * Create a new FragmentOutputBlock
  56314. * @param name defines the block name
  56315. */
  56316. constructor(name: string);
  56317. /**
  56318. * Gets the current class name
  56319. * @returns the class name
  56320. */
  56321. getClassName(): string;
  56322. /**
  56323. * Gets the rgba input component
  56324. */
  56325. readonly rgba: NodeMaterialConnectionPoint;
  56326. /**
  56327. * Gets the rgb input component
  56328. */
  56329. readonly rgb: NodeMaterialConnectionPoint;
  56330. /**
  56331. * Gets the a input component
  56332. */
  56333. readonly a: NodeMaterialConnectionPoint;
  56334. protected _buildBlock(state: NodeMaterialBuildState): this;
  56335. }
  56336. }
  56337. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56338. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56339. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56340. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56341. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56343. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56344. import { Effect } from "babylonjs/Materials/effect";
  56345. import { Mesh } from "babylonjs/Meshes/mesh";
  56346. import { Nullable } from "babylonjs/types";
  56347. import { Scene } from "babylonjs/scene";
  56348. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56349. /**
  56350. * Block used to read a reflection texture from a sampler
  56351. */
  56352. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56353. private _define3DName;
  56354. private _defineCubicName;
  56355. private _defineExplicitName;
  56356. private _defineProjectionName;
  56357. private _defineLocalCubicName;
  56358. private _defineSphericalName;
  56359. private _definePlanarName;
  56360. private _defineEquirectangularName;
  56361. private _defineMirroredEquirectangularFixedName;
  56362. private _defineEquirectangularFixedName;
  56363. private _defineSkyboxName;
  56364. private _cubeSamplerName;
  56365. private _2DSamplerName;
  56366. private _positionUVWName;
  56367. private _directionWName;
  56368. private _reflectionCoordsName;
  56369. private _reflection2DCoordsName;
  56370. private _reflectionColorName;
  56371. private _reflectionMatrixName;
  56372. /**
  56373. * Gets or sets the texture associated with the node
  56374. */
  56375. texture: Nullable<BaseTexture>;
  56376. /**
  56377. * Create a new TextureBlock
  56378. * @param name defines the block name
  56379. */
  56380. constructor(name: string);
  56381. /**
  56382. * Gets the current class name
  56383. * @returns the class name
  56384. */
  56385. getClassName(): string;
  56386. /**
  56387. * Gets the world position input component
  56388. */
  56389. readonly position: NodeMaterialConnectionPoint;
  56390. /**
  56391. * Gets the world position input component
  56392. */
  56393. readonly worldPosition: NodeMaterialConnectionPoint;
  56394. /**
  56395. * Gets the world normal input component
  56396. */
  56397. readonly worldNormal: NodeMaterialConnectionPoint;
  56398. /**
  56399. * Gets the world input component
  56400. */
  56401. readonly world: NodeMaterialConnectionPoint;
  56402. /**
  56403. * Gets the camera (or eye) position component
  56404. */
  56405. readonly cameraPosition: NodeMaterialConnectionPoint;
  56406. /**
  56407. * Gets the view input component
  56408. */
  56409. readonly view: NodeMaterialConnectionPoint;
  56410. /**
  56411. * Gets the rgb output component
  56412. */
  56413. readonly rgb: NodeMaterialConnectionPoint;
  56414. /**
  56415. * Gets the r output component
  56416. */
  56417. readonly r: NodeMaterialConnectionPoint;
  56418. /**
  56419. * Gets the g output component
  56420. */
  56421. readonly g: NodeMaterialConnectionPoint;
  56422. /**
  56423. * Gets the b output component
  56424. */
  56425. readonly b: NodeMaterialConnectionPoint;
  56426. autoConfigure(material: NodeMaterial): void;
  56427. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56428. isReady(): boolean;
  56429. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56430. private _injectVertexCode;
  56431. private _writeOutput;
  56432. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56433. protected _dumpPropertiesCode(): string;
  56434. serialize(): any;
  56435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56436. }
  56437. }
  56438. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56439. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56440. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56441. import { Scene } from "babylonjs/scene";
  56442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56443. import { Matrix } from "babylonjs/Maths/math.vector";
  56444. import { Mesh } from "babylonjs/Meshes/mesh";
  56445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56446. import { Observable } from "babylonjs/Misc/observable";
  56447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56448. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56449. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56450. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56451. import { Nullable } from "babylonjs/types";
  56452. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56453. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56454. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56455. /**
  56456. * Interface used to configure the node material editor
  56457. */
  56458. export interface INodeMaterialEditorOptions {
  56459. /** Define the URl to load node editor script */
  56460. editorURL?: string;
  56461. }
  56462. /** @hidden */
  56463. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56464. /** BONES */
  56465. NUM_BONE_INFLUENCERS: number;
  56466. BonesPerMesh: number;
  56467. BONETEXTURE: boolean;
  56468. /** MORPH TARGETS */
  56469. MORPHTARGETS: boolean;
  56470. MORPHTARGETS_NORMAL: boolean;
  56471. MORPHTARGETS_TANGENT: boolean;
  56472. MORPHTARGETS_UV: boolean;
  56473. NUM_MORPH_INFLUENCERS: number;
  56474. /** IMAGE PROCESSING */
  56475. IMAGEPROCESSING: boolean;
  56476. VIGNETTE: boolean;
  56477. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56478. VIGNETTEBLENDMODEOPAQUE: boolean;
  56479. TONEMAPPING: boolean;
  56480. TONEMAPPING_ACES: boolean;
  56481. CONTRAST: boolean;
  56482. EXPOSURE: boolean;
  56483. COLORCURVES: boolean;
  56484. COLORGRADING: boolean;
  56485. COLORGRADING3D: boolean;
  56486. SAMPLER3DGREENDEPTH: boolean;
  56487. SAMPLER3DBGRMAP: boolean;
  56488. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56489. /** MISC. */
  56490. BUMPDIRECTUV: number;
  56491. constructor();
  56492. setValue(name: string, value: boolean): void;
  56493. }
  56494. /**
  56495. * Class used to configure NodeMaterial
  56496. */
  56497. export interface INodeMaterialOptions {
  56498. /**
  56499. * Defines if blocks should emit comments
  56500. */
  56501. emitComments: boolean;
  56502. }
  56503. /**
  56504. * Class used to create a node based material built by assembling shader blocks
  56505. */
  56506. export class NodeMaterial extends PushMaterial {
  56507. private static _BuildIdGenerator;
  56508. private _options;
  56509. private _vertexCompilationState;
  56510. private _fragmentCompilationState;
  56511. private _sharedData;
  56512. private _buildId;
  56513. private _buildWasSuccessful;
  56514. private _cachedWorldViewMatrix;
  56515. private _cachedWorldViewProjectionMatrix;
  56516. private _optimizers;
  56517. private _animationFrame;
  56518. /** Define the URl to load node editor script */
  56519. static EditorURL: string;
  56520. private BJSNODEMATERIALEDITOR;
  56521. /** Get the inspector from bundle or global */
  56522. private _getGlobalNodeMaterialEditor;
  56523. /**
  56524. * Gets or sets data used by visual editor
  56525. * @see https://nme.babylonjs.com
  56526. */
  56527. editorData: any;
  56528. /**
  56529. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  56530. */
  56531. ignoreAlpha: boolean;
  56532. /**
  56533. * Defines the maximum number of lights that can be used in the material
  56534. */
  56535. maxSimultaneousLights: number;
  56536. /**
  56537. * Observable raised when the material is built
  56538. */
  56539. onBuildObservable: Observable<NodeMaterial>;
  56540. /**
  56541. * Gets or sets the root nodes of the material vertex shader
  56542. */
  56543. _vertexOutputNodes: NodeMaterialBlock[];
  56544. /**
  56545. * Gets or sets the root nodes of the material fragment (pixel) shader
  56546. */
  56547. _fragmentOutputNodes: NodeMaterialBlock[];
  56548. /** Gets or sets options to control the node material overall behavior */
  56549. options: INodeMaterialOptions;
  56550. /**
  56551. * Default configuration related to image processing available in the standard Material.
  56552. */
  56553. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56554. /**
  56555. * Gets the image processing configuration used either in this material.
  56556. */
  56557. /**
  56558. * Sets the Default image processing configuration used either in the this material.
  56559. *
  56560. * If sets to null, the scene one is in use.
  56561. */
  56562. imageProcessingConfiguration: ImageProcessingConfiguration;
  56563. /**
  56564. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56565. */
  56566. attachedBlocks: NodeMaterialBlock[];
  56567. /**
  56568. * Create a new node based material
  56569. * @param name defines the material name
  56570. * @param scene defines the hosting scene
  56571. * @param options defines creation option
  56572. */
  56573. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56574. /**
  56575. * Gets the current class name of the material e.g. "NodeMaterial"
  56576. * @returns the class name
  56577. */
  56578. getClassName(): string;
  56579. /**
  56580. * Keep track of the image processing observer to allow dispose and replace.
  56581. */
  56582. private _imageProcessingObserver;
  56583. /**
  56584. * Attaches a new image processing configuration to the Standard Material.
  56585. * @param configuration
  56586. */
  56587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56588. /**
  56589. * Get a block by its name
  56590. * @param name defines the name of the block to retrieve
  56591. * @returns the required block or null if not found
  56592. */
  56593. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56594. /**
  56595. * Get a block by its name
  56596. * @param predicate defines the predicate used to find the good candidate
  56597. * @returns the required block or null if not found
  56598. */
  56599. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56600. /**
  56601. * Get an input block by its name
  56602. * @param predicate defines the predicate used to find the good candidate
  56603. * @returns the required input block or null if not found
  56604. */
  56605. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56606. /**
  56607. * Gets the list of input blocks attached to this material
  56608. * @returns an array of InputBlocks
  56609. */
  56610. getInputBlocks(): InputBlock[];
  56611. /**
  56612. * Adds a new optimizer to the list of optimizers
  56613. * @param optimizer defines the optimizers to add
  56614. * @returns the current material
  56615. */
  56616. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56617. /**
  56618. * Remove an optimizer from the list of optimizers
  56619. * @param optimizer defines the optimizers to remove
  56620. * @returns the current material
  56621. */
  56622. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56623. /**
  56624. * Add a new block to the list of output nodes
  56625. * @param node defines the node to add
  56626. * @returns the current material
  56627. */
  56628. addOutputNode(node: NodeMaterialBlock): this;
  56629. /**
  56630. * Remove a block from the list of root nodes
  56631. * @param node defines the node to remove
  56632. * @returns the current material
  56633. */
  56634. removeOutputNode(node: NodeMaterialBlock): this;
  56635. private _addVertexOutputNode;
  56636. private _removeVertexOutputNode;
  56637. private _addFragmentOutputNode;
  56638. private _removeFragmentOutputNode;
  56639. /**
  56640. * Specifies if the material will require alpha blending
  56641. * @returns a boolean specifying if alpha blending is needed
  56642. */
  56643. needAlphaBlending(): boolean;
  56644. /**
  56645. * Specifies if this material should be rendered in alpha test mode
  56646. * @returns a boolean specifying if an alpha test is needed.
  56647. */
  56648. needAlphaTesting(): boolean;
  56649. private _initializeBlock;
  56650. private _resetDualBlocks;
  56651. /**
  56652. * Remove a block from the current node material
  56653. * @param block defines the block to remove
  56654. */
  56655. removeBlock(block: NodeMaterialBlock): void;
  56656. /**
  56657. * Build the material and generates the inner effect
  56658. * @param verbose defines if the build should log activity
  56659. */
  56660. build(verbose?: boolean): void;
  56661. /**
  56662. * Runs an otpimization phase to try to improve the shader code
  56663. */
  56664. optimize(): void;
  56665. private _prepareDefinesForAttributes;
  56666. /**
  56667. * Get if the submesh is ready to be used and all its information available.
  56668. * Child classes can use it to update shaders
  56669. * @param mesh defines the mesh to check
  56670. * @param subMesh defines which submesh to check
  56671. * @param useInstances specifies that instances should be used
  56672. * @returns a boolean indicating that the submesh is ready or not
  56673. */
  56674. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56675. /**
  56676. * Get a string representing the shaders built by the current node graph
  56677. */
  56678. readonly compiledShaders: string;
  56679. /**
  56680. * Binds the world matrix to the material
  56681. * @param world defines the world transformation matrix
  56682. */
  56683. bindOnlyWorldMatrix(world: Matrix): void;
  56684. /**
  56685. * Binds the submesh to this material by preparing the effect and shader to draw
  56686. * @param world defines the world transformation matrix
  56687. * @param mesh defines the mesh containing the submesh
  56688. * @param subMesh defines the submesh to bind the material to
  56689. */
  56690. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56691. /**
  56692. * Gets the active textures from the material
  56693. * @returns an array of textures
  56694. */
  56695. getActiveTextures(): BaseTexture[];
  56696. /**
  56697. * Gets the list of texture blocks
  56698. * @returns an array of texture blocks
  56699. */
  56700. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56701. /**
  56702. * Specifies if the material uses a texture
  56703. * @param texture defines the texture to check against the material
  56704. * @returns a boolean specifying if the material uses the texture
  56705. */
  56706. hasTexture(texture: BaseTexture): boolean;
  56707. /**
  56708. * Disposes the material
  56709. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56710. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56711. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56712. */
  56713. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56714. /** Creates the node editor window. */
  56715. private _createNodeEditor;
  56716. /**
  56717. * Launch the node material editor
  56718. * @param config Define the configuration of the editor
  56719. * @return a promise fulfilled when the node editor is visible
  56720. */
  56721. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56722. /**
  56723. * Clear the current material
  56724. */
  56725. clear(): void;
  56726. /**
  56727. * Clear the current material and set it to a default state
  56728. */
  56729. setToDefault(): void;
  56730. /**
  56731. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56732. * @param url defines the url to load from
  56733. * @returns a promise that will fullfil when the material is fully loaded
  56734. */
  56735. loadAsync(url: string): Promise<void>;
  56736. private _gatherBlocks;
  56737. /**
  56738. * Generate a string containing the code declaration required to create an equivalent of this material
  56739. * @returns a string
  56740. */
  56741. generateCode(): string;
  56742. /**
  56743. * Serializes this material in a JSON representation
  56744. * @returns the serialized material object
  56745. */
  56746. serialize(): any;
  56747. private _restoreConnections;
  56748. /**
  56749. * Clear the current graph and load a new one from a serialization object
  56750. * @param source defines the JSON representation of the material
  56751. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56752. */
  56753. loadFromSerialization(source: any, rootUrl?: string): void;
  56754. /**
  56755. * Creates a node material from parsed material data
  56756. * @param source defines the JSON representation of the material
  56757. * @param scene defines the hosting scene
  56758. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56759. * @returns a new node material
  56760. */
  56761. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56762. /**
  56763. * Creates a new node material set to default basic configuration
  56764. * @param name defines the name of the material
  56765. * @param scene defines the hosting scene
  56766. * @returns a new NodeMaterial
  56767. */
  56768. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56769. }
  56770. }
  56771. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56774. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56775. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56777. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56778. import { Effect } from "babylonjs/Materials/effect";
  56779. import { Mesh } from "babylonjs/Meshes/mesh";
  56780. import { Nullable } from "babylonjs/types";
  56781. import { Texture } from "babylonjs/Materials/Textures/texture";
  56782. import { Scene } from "babylonjs/scene";
  56783. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56784. /**
  56785. * Block used to read a texture from a sampler
  56786. */
  56787. export class TextureBlock extends NodeMaterialBlock {
  56788. private _defineName;
  56789. private _linearDefineName;
  56790. private _tempTextureRead;
  56791. private _samplerName;
  56792. private _transformedUVName;
  56793. private _textureTransformName;
  56794. private _textureInfoName;
  56795. private _mainUVName;
  56796. private _mainUVDefineName;
  56797. /**
  56798. * Gets or sets the texture associated with the node
  56799. */
  56800. texture: Nullable<Texture>;
  56801. /**
  56802. * Create a new TextureBlock
  56803. * @param name defines the block name
  56804. */
  56805. constructor(name: string);
  56806. /**
  56807. * Gets the current class name
  56808. * @returns the class name
  56809. */
  56810. getClassName(): string;
  56811. /**
  56812. * Gets the uv input component
  56813. */
  56814. readonly uv: NodeMaterialConnectionPoint;
  56815. /**
  56816. * Gets the rgba output component
  56817. */
  56818. readonly rgba: NodeMaterialConnectionPoint;
  56819. /**
  56820. * Gets the rgb output component
  56821. */
  56822. readonly rgb: NodeMaterialConnectionPoint;
  56823. /**
  56824. * Gets the r output component
  56825. */
  56826. readonly r: NodeMaterialConnectionPoint;
  56827. /**
  56828. * Gets the g output component
  56829. */
  56830. readonly g: NodeMaterialConnectionPoint;
  56831. /**
  56832. * Gets the b output component
  56833. */
  56834. readonly b: NodeMaterialConnectionPoint;
  56835. /**
  56836. * Gets the a output component
  56837. */
  56838. readonly a: NodeMaterialConnectionPoint;
  56839. readonly target: NodeMaterialBlockTargets;
  56840. autoConfigure(material: NodeMaterial): void;
  56841. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56843. private _getTextureBase;
  56844. isReady(): boolean;
  56845. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56846. private readonly _isMixed;
  56847. private _injectVertexCode;
  56848. private _writeTextureRead;
  56849. private _writeOutput;
  56850. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56851. protected _dumpPropertiesCode(): string;
  56852. serialize(): any;
  56853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56854. }
  56855. }
  56856. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56859. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56860. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56861. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56862. import { Scene } from "babylonjs/scene";
  56863. /**
  56864. * Class used to store shared data between 2 NodeMaterialBuildState
  56865. */
  56866. export class NodeMaterialBuildStateSharedData {
  56867. /**
  56868. * Gets the list of emitted varyings
  56869. */
  56870. temps: string[];
  56871. /**
  56872. * Gets the list of emitted varyings
  56873. */
  56874. varyings: string[];
  56875. /**
  56876. * Gets the varying declaration string
  56877. */
  56878. varyingDeclaration: string;
  56879. /**
  56880. * Input blocks
  56881. */
  56882. inputBlocks: InputBlock[];
  56883. /**
  56884. * Input blocks
  56885. */
  56886. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56887. /**
  56888. * Bindable blocks (Blocks that need to set data to the effect)
  56889. */
  56890. bindableBlocks: NodeMaterialBlock[];
  56891. /**
  56892. * List of blocks that can provide a compilation fallback
  56893. */
  56894. blocksWithFallbacks: NodeMaterialBlock[];
  56895. /**
  56896. * List of blocks that can provide a define update
  56897. */
  56898. blocksWithDefines: NodeMaterialBlock[];
  56899. /**
  56900. * List of blocks that can provide a repeatable content
  56901. */
  56902. repeatableContentBlocks: NodeMaterialBlock[];
  56903. /**
  56904. * List of blocks that can provide a dynamic list of uniforms
  56905. */
  56906. dynamicUniformBlocks: NodeMaterialBlock[];
  56907. /**
  56908. * List of blocks that can block the isReady function for the material
  56909. */
  56910. blockingBlocks: NodeMaterialBlock[];
  56911. /**
  56912. * Gets the list of animated inputs
  56913. */
  56914. animatedInputs: InputBlock[];
  56915. /**
  56916. * Build Id used to avoid multiple recompilations
  56917. */
  56918. buildId: number;
  56919. /** List of emitted variables */
  56920. variableNames: {
  56921. [key: string]: number;
  56922. };
  56923. /** List of emitted defines */
  56924. defineNames: {
  56925. [key: string]: number;
  56926. };
  56927. /** Should emit comments? */
  56928. emitComments: boolean;
  56929. /** Emit build activity */
  56930. verbose: boolean;
  56931. /** Gets or sets the hosting scene */
  56932. scene: Scene;
  56933. /**
  56934. * Gets the compilation hints emitted at compilation time
  56935. */
  56936. hints: {
  56937. needWorldViewMatrix: boolean;
  56938. needWorldViewProjectionMatrix: boolean;
  56939. needAlphaBlending: boolean;
  56940. needAlphaTesting: boolean;
  56941. };
  56942. /**
  56943. * List of compilation checks
  56944. */
  56945. checks: {
  56946. emitVertex: boolean;
  56947. emitFragment: boolean;
  56948. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56949. };
  56950. /** Creates a new shared data */
  56951. constructor();
  56952. /**
  56953. * Emits console errors and exceptions if there is a failing check
  56954. */
  56955. emitErrors(): void;
  56956. }
  56957. }
  56958. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56959. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56960. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56961. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56962. /**
  56963. * Class used to store node based material build state
  56964. */
  56965. export class NodeMaterialBuildState {
  56966. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56967. supportUniformBuffers: boolean;
  56968. /**
  56969. * Gets the list of emitted attributes
  56970. */
  56971. attributes: string[];
  56972. /**
  56973. * Gets the list of emitted uniforms
  56974. */
  56975. uniforms: string[];
  56976. /**
  56977. * Gets the list of emitted constants
  56978. */
  56979. constants: string[];
  56980. /**
  56981. * Gets the list of emitted samplers
  56982. */
  56983. samplers: string[];
  56984. /**
  56985. * Gets the list of emitted functions
  56986. */
  56987. functions: {
  56988. [key: string]: string;
  56989. };
  56990. /**
  56991. * Gets the list of emitted extensions
  56992. */
  56993. extensions: {
  56994. [key: string]: string;
  56995. };
  56996. /**
  56997. * Gets the target of the compilation state
  56998. */
  56999. target: NodeMaterialBlockTargets;
  57000. /**
  57001. * Gets the list of emitted counters
  57002. */
  57003. counters: {
  57004. [key: string]: number;
  57005. };
  57006. /**
  57007. * Shared data between multiple NodeMaterialBuildState instances
  57008. */
  57009. sharedData: NodeMaterialBuildStateSharedData;
  57010. /** @hidden */
  57011. _vertexState: NodeMaterialBuildState;
  57012. /** @hidden */
  57013. _attributeDeclaration: string;
  57014. /** @hidden */
  57015. _uniformDeclaration: string;
  57016. /** @hidden */
  57017. _constantDeclaration: string;
  57018. /** @hidden */
  57019. _samplerDeclaration: string;
  57020. /** @hidden */
  57021. _varyingTransfer: string;
  57022. private _repeatableContentAnchorIndex;
  57023. /** @hidden */
  57024. _builtCompilationString: string;
  57025. /**
  57026. * Gets the emitted compilation strings
  57027. */
  57028. compilationString: string;
  57029. /**
  57030. * Finalize the compilation strings
  57031. * @param state defines the current compilation state
  57032. */
  57033. finalize(state: NodeMaterialBuildState): void;
  57034. /** @hidden */
  57035. readonly _repeatableContentAnchor: string;
  57036. /** @hidden */
  57037. _getFreeVariableName(prefix: string): string;
  57038. /** @hidden */
  57039. _getFreeDefineName(prefix: string): string;
  57040. /** @hidden */
  57041. _excludeVariableName(name: string): void;
  57042. /** @hidden */
  57043. _emit2DSampler(name: string): void;
  57044. /** @hidden */
  57045. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57046. /** @hidden */
  57047. _emitExtension(name: string, extension: string): void;
  57048. /** @hidden */
  57049. _emitFunction(name: string, code: string, comments: string): void;
  57050. /** @hidden */
  57051. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57052. replaceStrings?: {
  57053. search: RegExp;
  57054. replace: string;
  57055. }[];
  57056. repeatKey?: string;
  57057. }): string;
  57058. /** @hidden */
  57059. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57060. repeatKey?: string;
  57061. removeAttributes?: boolean;
  57062. removeUniforms?: boolean;
  57063. removeVaryings?: boolean;
  57064. removeIfDef?: boolean;
  57065. replaceStrings?: {
  57066. search: RegExp;
  57067. replace: string;
  57068. }[];
  57069. }, storeKey?: string): void;
  57070. /** @hidden */
  57071. _registerTempVariable(name: string): boolean;
  57072. /** @hidden */
  57073. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57074. /** @hidden */
  57075. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57076. /** @hidden */
  57077. _emitFloat(value: number): string;
  57078. }
  57079. }
  57080. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  57081. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57083. import { Nullable } from "babylonjs/types";
  57084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57085. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57086. import { Effect } from "babylonjs/Materials/effect";
  57087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57088. import { Mesh } from "babylonjs/Meshes/mesh";
  57089. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57090. import { Scene } from "babylonjs/scene";
  57091. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57092. /**
  57093. * Defines a block that can be used inside a node based material
  57094. */
  57095. export class NodeMaterialBlock {
  57096. private _buildId;
  57097. private _buildTarget;
  57098. private _target;
  57099. private _isFinalMerger;
  57100. private _isInput;
  57101. protected _isUnique: boolean;
  57102. /** @hidden */
  57103. _codeVariableName: string;
  57104. /** @hidden */
  57105. _inputs: NodeMaterialConnectionPoint[];
  57106. /** @hidden */
  57107. _outputs: NodeMaterialConnectionPoint[];
  57108. /** @hidden */
  57109. _preparationId: number;
  57110. /**
  57111. * Gets or sets the name of the block
  57112. */
  57113. name: string;
  57114. /**
  57115. * Gets or sets the unique id of the node
  57116. */
  57117. uniqueId: number;
  57118. /**
  57119. * Gets or sets the comments associated with this block
  57120. */
  57121. comments: string;
  57122. /**
  57123. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57124. */
  57125. readonly isUnique: boolean;
  57126. /**
  57127. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57128. */
  57129. readonly isFinalMerger: boolean;
  57130. /**
  57131. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57132. */
  57133. readonly isInput: boolean;
  57134. /**
  57135. * Gets or sets the build Id
  57136. */
  57137. buildId: number;
  57138. /**
  57139. * Gets or sets the target of the block
  57140. */
  57141. target: NodeMaterialBlockTargets;
  57142. /**
  57143. * Gets the list of input points
  57144. */
  57145. readonly inputs: NodeMaterialConnectionPoint[];
  57146. /** Gets the list of output points */
  57147. readonly outputs: NodeMaterialConnectionPoint[];
  57148. /**
  57149. * Find an input by its name
  57150. * @param name defines the name of the input to look for
  57151. * @returns the input or null if not found
  57152. */
  57153. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57154. /**
  57155. * Find an output by its name
  57156. * @param name defines the name of the outputto look for
  57157. * @returns the output or null if not found
  57158. */
  57159. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57160. /**
  57161. * Creates a new NodeMaterialBlock
  57162. * @param name defines the block name
  57163. * @param target defines the target of that block (Vertex by default)
  57164. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57165. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57166. */
  57167. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57168. /**
  57169. * Initialize the block and prepare the context for build
  57170. * @param state defines the state that will be used for the build
  57171. */
  57172. initialize(state: NodeMaterialBuildState): void;
  57173. /**
  57174. * Bind data to effect. Will only be called for blocks with isBindable === true
  57175. * @param effect defines the effect to bind data to
  57176. * @param nodeMaterial defines the hosting NodeMaterial
  57177. * @param mesh defines the mesh that will be rendered
  57178. */
  57179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57180. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57181. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57182. protected _writeFloat(value: number): string;
  57183. /**
  57184. * Gets the current class name e.g. "NodeMaterialBlock"
  57185. * @returns the class name
  57186. */
  57187. getClassName(): string;
  57188. /**
  57189. * Register a new input. Must be called inside a block constructor
  57190. * @param name defines the connection point name
  57191. * @param type defines the connection point type
  57192. * @param isOptional defines a boolean indicating that this input can be omitted
  57193. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57194. * @returns the current block
  57195. */
  57196. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57197. /**
  57198. * Register a new output. Must be called inside a block constructor
  57199. * @param name defines the connection point name
  57200. * @param type defines the connection point type
  57201. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57202. * @returns the current block
  57203. */
  57204. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57205. /**
  57206. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57207. * @param forOutput defines an optional connection point to check compatibility with
  57208. * @returns the first available input or null
  57209. */
  57210. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57211. /**
  57212. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57213. * @param forBlock defines an optional block to check compatibility with
  57214. * @returns the first available input or null
  57215. */
  57216. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57217. /**
  57218. * Gets the sibling of the given output
  57219. * @param current defines the current output
  57220. * @returns the next output in the list or null
  57221. */
  57222. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57223. /**
  57224. * Connect current block with another block
  57225. * @param other defines the block to connect with
  57226. * @param options define the various options to help pick the right connections
  57227. * @returns the current block
  57228. */
  57229. connectTo(other: NodeMaterialBlock, options?: {
  57230. input?: string;
  57231. output?: string;
  57232. outputSwizzle?: string;
  57233. }): this | undefined;
  57234. protected _buildBlock(state: NodeMaterialBuildState): void;
  57235. /**
  57236. * Add uniforms, samplers and uniform buffers at compilation time
  57237. * @param state defines the state to update
  57238. * @param nodeMaterial defines the node material requesting the update
  57239. * @param defines defines the material defines to update
  57240. * @param uniformBuffers defines the list of uniform buffer names
  57241. */
  57242. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57243. /**
  57244. * Add potential fallbacks if shader compilation fails
  57245. * @param mesh defines the mesh to be rendered
  57246. * @param fallbacks defines the current prioritized list of fallbacks
  57247. */
  57248. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57249. /**
  57250. * Initialize defines for shader compilation
  57251. * @param mesh defines the mesh to be rendered
  57252. * @param nodeMaterial defines the node material requesting the update
  57253. * @param defines defines the material defines to update
  57254. * @param useInstances specifies that instances should be used
  57255. */
  57256. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57257. /**
  57258. * Update defines for shader compilation
  57259. * @param mesh defines the mesh to be rendered
  57260. * @param nodeMaterial defines the node material requesting the update
  57261. * @param defines defines the material defines to update
  57262. * @param useInstances specifies that instances should be used
  57263. */
  57264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57265. /**
  57266. * Lets the block try to connect some inputs automatically
  57267. * @param material defines the hosting NodeMaterial
  57268. */
  57269. autoConfigure(material: NodeMaterial): void;
  57270. /**
  57271. * Function called when a block is declared as repeatable content generator
  57272. * @param vertexShaderState defines the current compilation state for the vertex shader
  57273. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57274. * @param mesh defines the mesh to be rendered
  57275. * @param defines defines the material defines to update
  57276. */
  57277. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57278. /**
  57279. * Checks if the block is ready
  57280. * @param mesh defines the mesh to be rendered
  57281. * @param nodeMaterial defines the node material requesting the update
  57282. * @param defines defines the material defines to update
  57283. * @param useInstances specifies that instances should be used
  57284. * @returns true if the block is ready
  57285. */
  57286. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57287. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57288. private _processBuild;
  57289. /**
  57290. * Compile the current node and generate the shader code
  57291. * @param state defines the current compilation state (uniforms, samplers, current string)
  57292. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57293. * @returns true if already built
  57294. */
  57295. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57296. protected _inputRename(name: string): string;
  57297. protected _outputRename(name: string): string;
  57298. protected _dumpPropertiesCode(): string;
  57299. /** @hidden */
  57300. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57301. /** @hidden */
  57302. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57303. /**
  57304. * Clone the current block to a new identical block
  57305. * @param scene defines the hosting scene
  57306. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57307. * @returns a copy of the current block
  57308. */
  57309. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57310. /**
  57311. * Serializes this block in a JSON representation
  57312. * @returns the serialized block object
  57313. */
  57314. serialize(): any;
  57315. /** @hidden */
  57316. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57317. /**
  57318. * Release resources
  57319. */
  57320. dispose(): void;
  57321. }
  57322. }
  57323. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57324. /**
  57325. * Enum defining the type of animations supported by InputBlock
  57326. */
  57327. export enum AnimatedInputBlockTypes {
  57328. /** No animation */
  57329. None = 0,
  57330. /** Time based animation. Will only work for floats */
  57331. Time = 1
  57332. }
  57333. }
  57334. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57336. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57337. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57338. import { Nullable } from "babylonjs/types";
  57339. import { Effect } from "babylonjs/Materials/effect";
  57340. import { Matrix } from "babylonjs/Maths/math.vector";
  57341. import { Scene } from "babylonjs/scene";
  57342. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57344. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57345. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57346. /**
  57347. * Block used to expose an input value
  57348. */
  57349. export class InputBlock extends NodeMaterialBlock {
  57350. private _mode;
  57351. private _associatedVariableName;
  57352. private _storedValue;
  57353. private _valueCallback;
  57354. private _type;
  57355. private _animationType;
  57356. /** Gets or set a value used to limit the range of float values */
  57357. min: number;
  57358. /** Gets or set a value used to limit the range of float values */
  57359. max: number;
  57360. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57361. matrixMode: number;
  57362. /** @hidden */
  57363. _systemValue: Nullable<NodeMaterialSystemValues>;
  57364. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57365. visibleInInspector: boolean;
  57366. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57367. isConstant: boolean;
  57368. /**
  57369. * Gets or sets the connection point type (default is float)
  57370. */
  57371. readonly type: NodeMaterialBlockConnectionPointTypes;
  57372. /**
  57373. * Creates a new InputBlock
  57374. * @param name defines the block name
  57375. * @param target defines the target of that block (Vertex by default)
  57376. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57377. */
  57378. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57379. /**
  57380. * Gets the output component
  57381. */
  57382. readonly output: NodeMaterialConnectionPoint;
  57383. /**
  57384. * Set the source of this connection point to a vertex attribute
  57385. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57386. * @returns the current connection point
  57387. */
  57388. setAsAttribute(attributeName?: string): InputBlock;
  57389. /**
  57390. * Set the source of this connection point to a system value
  57391. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57392. * @returns the current connection point
  57393. */
  57394. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57395. /**
  57396. * Gets or sets the value of that point.
  57397. * Please note that this value will be ignored if valueCallback is defined
  57398. */
  57399. value: any;
  57400. /**
  57401. * Gets or sets a callback used to get the value of that point.
  57402. * Please note that setting this value will force the connection point to ignore the value property
  57403. */
  57404. valueCallback: () => any;
  57405. /**
  57406. * Gets or sets the associated variable name in the shader
  57407. */
  57408. associatedVariableName: string;
  57409. /** Gets or sets the type of animation applied to the input */
  57410. animationType: AnimatedInputBlockTypes;
  57411. /**
  57412. * Gets a boolean indicating that this connection point not defined yet
  57413. */
  57414. readonly isUndefined: boolean;
  57415. /**
  57416. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57417. * In this case the connection point name must be the name of the uniform to use.
  57418. * Can only be set on inputs
  57419. */
  57420. isUniform: boolean;
  57421. /**
  57422. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57423. * In this case the connection point name must be the name of the attribute to use
  57424. * Can only be set on inputs
  57425. */
  57426. isAttribute: boolean;
  57427. /**
  57428. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57429. * Can only be set on exit points
  57430. */
  57431. isVarying: boolean;
  57432. /**
  57433. * Gets a boolean indicating that the current connection point is a system value
  57434. */
  57435. readonly isSystemValue: boolean;
  57436. /**
  57437. * Gets or sets the current well known value or null if not defined as a system value
  57438. */
  57439. systemValue: Nullable<NodeMaterialSystemValues>;
  57440. /**
  57441. * Gets the current class name
  57442. * @returns the class name
  57443. */
  57444. getClassName(): string;
  57445. /**
  57446. * Animate the input if animationType !== None
  57447. * @param scene defines the rendering scene
  57448. */
  57449. animate(scene: Scene): void;
  57450. private _emitDefine;
  57451. initialize(state: NodeMaterialBuildState): void;
  57452. /**
  57453. * Set the input block to its default value (based on its type)
  57454. */
  57455. setDefaultValue(): void;
  57456. private _emitConstant;
  57457. private _emit;
  57458. /** @hidden */
  57459. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57460. /** @hidden */
  57461. _transmit(effect: Effect, scene: Scene): void;
  57462. protected _buildBlock(state: NodeMaterialBuildState): void;
  57463. protected _dumpPropertiesCode(): string;
  57464. serialize(): any;
  57465. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57466. }
  57467. }
  57468. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57469. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57470. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57471. import { Nullable } from "babylonjs/types";
  57472. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57473. import { Observable } from "babylonjs/Misc/observable";
  57474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57475. /**
  57476. * Enum used to define the compatibility state between two connection points
  57477. */
  57478. export enum NodeMaterialConnectionPointCompatibilityStates {
  57479. /** Points are compatibles */
  57480. Compatible = 0,
  57481. /** Points are incompatible because of their types */
  57482. TypeIncompatible = 1,
  57483. /** Points are incompatible because of their targets (vertex vs fragment) */
  57484. TargetIncompatible = 2
  57485. }
  57486. /**
  57487. * Defines the direction of a connection point
  57488. */
  57489. export enum NodeMaterialConnectionPointDirection {
  57490. /** Input */
  57491. Input = 0,
  57492. /** Output */
  57493. Output = 1
  57494. }
  57495. /**
  57496. * Defines a connection point for a block
  57497. */
  57498. export class NodeMaterialConnectionPoint {
  57499. /** @hidden */
  57500. _ownerBlock: NodeMaterialBlock;
  57501. /** @hidden */
  57502. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57503. private _endpoints;
  57504. private _associatedVariableName;
  57505. private _direction;
  57506. /** @hidden */
  57507. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57508. /** @hidden */
  57509. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57510. private _type;
  57511. /** @hidden */
  57512. _enforceAssociatedVariableName: boolean;
  57513. /** Gets the direction of the point */
  57514. readonly direction: NodeMaterialConnectionPointDirection;
  57515. /**
  57516. * Gets or sets the additional types supported by this connection point
  57517. */
  57518. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57519. /**
  57520. * Gets or sets the additional types excluded by this connection point
  57521. */
  57522. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57523. /**
  57524. * Observable triggered when this point is connected
  57525. */
  57526. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57527. /**
  57528. * Gets or sets the associated variable name in the shader
  57529. */
  57530. associatedVariableName: string;
  57531. /**
  57532. * Gets or sets the connection point type (default is float)
  57533. */
  57534. type: NodeMaterialBlockConnectionPointTypes;
  57535. /**
  57536. * Gets or sets the connection point name
  57537. */
  57538. name: string;
  57539. /**
  57540. * Gets or sets a boolean indicating that this connection point can be omitted
  57541. */
  57542. isOptional: boolean;
  57543. /**
  57544. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57545. */
  57546. define: string;
  57547. /** @hidden */
  57548. _prioritizeVertex: boolean;
  57549. private _target;
  57550. /** Gets or sets the target of that connection point */
  57551. target: NodeMaterialBlockTargets;
  57552. /**
  57553. * Gets a boolean indicating that the current point is connected
  57554. */
  57555. readonly isConnected: boolean;
  57556. /**
  57557. * Gets a boolean indicating that the current point is connected to an input block
  57558. */
  57559. readonly isConnectedToInputBlock: boolean;
  57560. /**
  57561. * Gets a the connected input block (if any)
  57562. */
  57563. readonly connectInputBlock: Nullable<InputBlock>;
  57564. /** Get the other side of the connection (if any) */
  57565. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57566. /** Get the block that owns this connection point */
  57567. readonly ownerBlock: NodeMaterialBlock;
  57568. /** Get the block connected on the other side of this connection (if any) */
  57569. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57570. /** Get the block connected on the endpoints of this connection (if any) */
  57571. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57572. /** Gets the list of connected endpoints */
  57573. readonly endpoints: NodeMaterialConnectionPoint[];
  57574. /** Gets a boolean indicating if that output point is connected to at least one input */
  57575. readonly hasEndpoints: boolean;
  57576. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57577. readonly isConnectedInVertexShader: boolean;
  57578. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57579. readonly isConnectedInFragmentShader: boolean;
  57580. /**
  57581. * Creates a new connection point
  57582. * @param name defines the connection point name
  57583. * @param ownerBlock defines the block hosting this connection point
  57584. * @param direction defines the direction of the connection point
  57585. */
  57586. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  57587. /**
  57588. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57589. * @returns the class name
  57590. */
  57591. getClassName(): string;
  57592. /**
  57593. * Gets a boolean indicating if the current point can be connected to another point
  57594. * @param connectionPoint defines the other connection point
  57595. * @returns a boolean
  57596. */
  57597. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57598. /**
  57599. * Gets a number indicating if the current point can be connected to another point
  57600. * @param connectionPoint defines the other connection point
  57601. * @returns a number defining the compatibility state
  57602. */
  57603. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57604. /**
  57605. * Connect this point to another connection point
  57606. * @param connectionPoint defines the other connection point
  57607. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57608. * @returns the current connection point
  57609. */
  57610. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57611. /**
  57612. * Disconnect this point from one of his endpoint
  57613. * @param endpoint defines the other connection point
  57614. * @returns the current connection point
  57615. */
  57616. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57617. /**
  57618. * Serializes this point in a JSON representation
  57619. * @returns the serialized point object
  57620. */
  57621. serialize(): any;
  57622. /**
  57623. * Release resources
  57624. */
  57625. dispose(): void;
  57626. }
  57627. }
  57628. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57632. import { Mesh } from "babylonjs/Meshes/mesh";
  57633. import { Effect } from "babylonjs/Materials/effect";
  57634. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57635. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57636. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57637. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57638. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57639. /**
  57640. * Block used to add support for vertex skinning (bones)
  57641. */
  57642. export class BonesBlock extends NodeMaterialBlock {
  57643. /**
  57644. * Creates a new BonesBlock
  57645. * @param name defines the block name
  57646. */
  57647. constructor(name: string);
  57648. /**
  57649. * Initialize the block and prepare the context for build
  57650. * @param state defines the state that will be used for the build
  57651. */
  57652. initialize(state: NodeMaterialBuildState): void;
  57653. /**
  57654. * Gets the current class name
  57655. * @returns the class name
  57656. */
  57657. getClassName(): string;
  57658. /**
  57659. * Gets the matrix indices input component
  57660. */
  57661. readonly matricesIndices: NodeMaterialConnectionPoint;
  57662. /**
  57663. * Gets the matrix weights input component
  57664. */
  57665. readonly matricesWeights: NodeMaterialConnectionPoint;
  57666. /**
  57667. * Gets the extra matrix indices input component
  57668. */
  57669. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57670. /**
  57671. * Gets the extra matrix weights input component
  57672. */
  57673. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57674. /**
  57675. * Gets the world input component
  57676. */
  57677. readonly world: NodeMaterialConnectionPoint;
  57678. /**
  57679. * Gets the output component
  57680. */
  57681. readonly output: NodeMaterialConnectionPoint;
  57682. autoConfigure(material: NodeMaterial): void;
  57683. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57685. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57686. protected _buildBlock(state: NodeMaterialBuildState): this;
  57687. }
  57688. }
  57689. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57694. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57695. /**
  57696. * Block used to add support for instances
  57697. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57698. */
  57699. export class InstancesBlock extends NodeMaterialBlock {
  57700. /**
  57701. * Creates a new InstancesBlock
  57702. * @param name defines the block name
  57703. */
  57704. constructor(name: string);
  57705. /**
  57706. * Gets the current class name
  57707. * @returns the class name
  57708. */
  57709. getClassName(): string;
  57710. /**
  57711. * Gets the first world row input component
  57712. */
  57713. readonly world0: NodeMaterialConnectionPoint;
  57714. /**
  57715. * Gets the second world row input component
  57716. */
  57717. readonly world1: NodeMaterialConnectionPoint;
  57718. /**
  57719. * Gets the third world row input component
  57720. */
  57721. readonly world2: NodeMaterialConnectionPoint;
  57722. /**
  57723. * Gets the forth world row input component
  57724. */
  57725. readonly world3: NodeMaterialConnectionPoint;
  57726. /**
  57727. * Gets the world input component
  57728. */
  57729. readonly world: NodeMaterialConnectionPoint;
  57730. /**
  57731. * Gets the output component
  57732. */
  57733. readonly output: NodeMaterialConnectionPoint;
  57734. autoConfigure(material: NodeMaterial): void;
  57735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57736. protected _buildBlock(state: NodeMaterialBuildState): this;
  57737. }
  57738. }
  57739. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57740. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57741. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57742. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57744. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57745. import { Effect } from "babylonjs/Materials/effect";
  57746. import { Mesh } from "babylonjs/Meshes/mesh";
  57747. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57748. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57749. /**
  57750. * Block used to add morph targets support to vertex shader
  57751. */
  57752. export class MorphTargetsBlock extends NodeMaterialBlock {
  57753. private _repeatableContentAnchor;
  57754. private _repeatebleContentGenerated;
  57755. /**
  57756. * Create a new MorphTargetsBlock
  57757. * @param name defines the block name
  57758. */
  57759. constructor(name: string);
  57760. /**
  57761. * Gets the current class name
  57762. * @returns the class name
  57763. */
  57764. getClassName(): string;
  57765. /**
  57766. * Gets the position input component
  57767. */
  57768. readonly position: NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the normal input component
  57771. */
  57772. readonly normal: NodeMaterialConnectionPoint;
  57773. /**
  57774. * Gets the tangent input component
  57775. */
  57776. readonly tangent: NodeMaterialConnectionPoint;
  57777. /**
  57778. * Gets the tangent input component
  57779. */
  57780. readonly uv: NodeMaterialConnectionPoint;
  57781. /**
  57782. * Gets the position output component
  57783. */
  57784. readonly positionOutput: NodeMaterialConnectionPoint;
  57785. /**
  57786. * Gets the normal output component
  57787. */
  57788. readonly normalOutput: NodeMaterialConnectionPoint;
  57789. /**
  57790. * Gets the tangent output component
  57791. */
  57792. readonly tangentOutput: NodeMaterialConnectionPoint;
  57793. /**
  57794. * Gets the tangent output component
  57795. */
  57796. readonly uvOutput: NodeMaterialConnectionPoint;
  57797. initialize(state: NodeMaterialBuildState): void;
  57798. autoConfigure(material: NodeMaterial): void;
  57799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57800. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57801. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57802. protected _buildBlock(state: NodeMaterialBuildState): this;
  57803. }
  57804. }
  57805. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57809. import { Nullable } from "babylonjs/types";
  57810. import { Scene } from "babylonjs/scene";
  57811. import { Effect } from "babylonjs/Materials/effect";
  57812. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57813. import { Mesh } from "babylonjs/Meshes/mesh";
  57814. import { Light } from "babylonjs/Lights/light";
  57815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57816. /**
  57817. * Block used to get data information from a light
  57818. */
  57819. export class LightInformationBlock extends NodeMaterialBlock {
  57820. private _lightDataUniformName;
  57821. private _lightColorUniformName;
  57822. private _lightTypeDefineName;
  57823. /**
  57824. * Gets or sets the light associated with this block
  57825. */
  57826. light: Nullable<Light>;
  57827. /**
  57828. * Creates a new LightInformationBlock
  57829. * @param name defines the block name
  57830. */
  57831. constructor(name: string);
  57832. /**
  57833. * Gets the current class name
  57834. * @returns the class name
  57835. */
  57836. getClassName(): string;
  57837. /**
  57838. * Gets the world position input component
  57839. */
  57840. readonly worldPosition: NodeMaterialConnectionPoint;
  57841. /**
  57842. * Gets the direction output component
  57843. */
  57844. readonly direction: NodeMaterialConnectionPoint;
  57845. /**
  57846. * Gets the direction output component
  57847. */
  57848. readonly color: NodeMaterialConnectionPoint;
  57849. /**
  57850. * Gets the direction output component
  57851. */
  57852. readonly intensity: NodeMaterialConnectionPoint;
  57853. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57855. protected _buildBlock(state: NodeMaterialBuildState): this;
  57856. serialize(): any;
  57857. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57858. }
  57859. }
  57860. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57861. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57862. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57863. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57864. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57865. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57866. }
  57867. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57872. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57873. import { Effect } from "babylonjs/Materials/effect";
  57874. import { Mesh } from "babylonjs/Meshes/mesh";
  57875. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57876. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57877. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57878. /**
  57879. * Block used to add image processing support to fragment shader
  57880. */
  57881. export class ImageProcessingBlock extends NodeMaterialBlock {
  57882. /**
  57883. * Create a new ImageProcessingBlock
  57884. * @param name defines the block name
  57885. */
  57886. constructor(name: string);
  57887. /**
  57888. * Gets the current class name
  57889. * @returns the class name
  57890. */
  57891. getClassName(): string;
  57892. /**
  57893. * Gets the color input component
  57894. */
  57895. readonly color: NodeMaterialConnectionPoint;
  57896. /**
  57897. * Gets the output component
  57898. */
  57899. readonly output: NodeMaterialConnectionPoint;
  57900. /**
  57901. * Initialize the block and prepare the context for build
  57902. * @param state defines the state that will be used for the build
  57903. */
  57904. initialize(state: NodeMaterialBuildState): void;
  57905. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57907. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57908. protected _buildBlock(state: NodeMaterialBuildState): this;
  57909. }
  57910. }
  57911. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57915. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57917. import { Effect } from "babylonjs/Materials/effect";
  57918. import { Mesh } from "babylonjs/Meshes/mesh";
  57919. import { Scene } from "babylonjs/scene";
  57920. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57921. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57922. /**
  57923. * Block used to pertub normals based on a normal map
  57924. */
  57925. export class PerturbNormalBlock extends NodeMaterialBlock {
  57926. private _tangentSpaceParameterName;
  57927. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57928. invertX: boolean;
  57929. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57930. invertY: boolean;
  57931. /**
  57932. * Create a new PerturbNormalBlock
  57933. * @param name defines the block name
  57934. */
  57935. constructor(name: string);
  57936. /**
  57937. * Gets the current class name
  57938. * @returns the class name
  57939. */
  57940. getClassName(): string;
  57941. /**
  57942. * Gets the world position input component
  57943. */
  57944. readonly worldPosition: NodeMaterialConnectionPoint;
  57945. /**
  57946. * Gets the world normal input component
  57947. */
  57948. readonly worldNormal: NodeMaterialConnectionPoint;
  57949. /**
  57950. * Gets the uv input component
  57951. */
  57952. readonly uv: NodeMaterialConnectionPoint;
  57953. /**
  57954. * Gets the normal map color input component
  57955. */
  57956. readonly normalMapColor: NodeMaterialConnectionPoint;
  57957. /**
  57958. * Gets the strength input component
  57959. */
  57960. readonly strength: NodeMaterialConnectionPoint;
  57961. /**
  57962. * Gets the output component
  57963. */
  57964. readonly output: NodeMaterialConnectionPoint;
  57965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57967. autoConfigure(material: NodeMaterial): void;
  57968. protected _buildBlock(state: NodeMaterialBuildState): this;
  57969. protected _dumpPropertiesCode(): string;
  57970. serialize(): any;
  57971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57972. }
  57973. }
  57974. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57977. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57978. /**
  57979. * Block used to discard a pixel if a value is smaller than a cutoff
  57980. */
  57981. export class DiscardBlock extends NodeMaterialBlock {
  57982. /**
  57983. * Create a new DiscardBlock
  57984. * @param name defines the block name
  57985. */
  57986. constructor(name: string);
  57987. /**
  57988. * Gets the current class name
  57989. * @returns the class name
  57990. */
  57991. getClassName(): string;
  57992. /**
  57993. * Gets the color input component
  57994. */
  57995. readonly value: NodeMaterialConnectionPoint;
  57996. /**
  57997. * Gets the cutoff input component
  57998. */
  57999. readonly cutoff: NodeMaterialConnectionPoint;
  58000. protected _buildBlock(state: NodeMaterialBuildState): this;
  58001. }
  58002. }
  58003. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  58004. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58005. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58006. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58007. /**
  58008. * Block used to test if the fragment shader is front facing
  58009. */
  58010. export class FrontFacingBlock extends NodeMaterialBlock {
  58011. /**
  58012. * Creates a new FrontFacingBlock
  58013. * @param name defines the block name
  58014. */
  58015. constructor(name: string);
  58016. /**
  58017. * Gets the current class name
  58018. * @returns the class name
  58019. */
  58020. getClassName(): string;
  58021. /**
  58022. * Gets the output component
  58023. */
  58024. readonly output: NodeMaterialConnectionPoint;
  58025. protected _buildBlock(state: NodeMaterialBuildState): this;
  58026. }
  58027. }
  58028. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  58029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58032. /**
  58033. * Block used to get the derivative value on x and y of a given input
  58034. */
  58035. export class DerivativeBlock extends NodeMaterialBlock {
  58036. /**
  58037. * Create a new DerivativeBlock
  58038. * @param name defines the block name
  58039. */
  58040. constructor(name: string);
  58041. /**
  58042. * Gets the current class name
  58043. * @returns the class name
  58044. */
  58045. getClassName(): string;
  58046. /**
  58047. * Gets the input component
  58048. */
  58049. readonly input: NodeMaterialConnectionPoint;
  58050. /**
  58051. * Gets the derivative output on x
  58052. */
  58053. readonly dx: NodeMaterialConnectionPoint;
  58054. /**
  58055. * Gets the derivative output on y
  58056. */
  58057. readonly dy: NodeMaterialConnectionPoint;
  58058. protected _buildBlock(state: NodeMaterialBuildState): this;
  58059. }
  58060. }
  58061. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  58062. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  58063. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  58064. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  58065. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  58066. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  58067. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  58068. }
  58069. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  58070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58072. import { Mesh } from "babylonjs/Meshes/mesh";
  58073. import { Effect } from "babylonjs/Materials/effect";
  58074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58076. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58077. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58078. /**
  58079. * Block used to add support for scene fog
  58080. */
  58081. export class FogBlock extends NodeMaterialBlock {
  58082. private _fogDistanceName;
  58083. private _fogParameters;
  58084. /**
  58085. * Create a new FogBlock
  58086. * @param name defines the block name
  58087. */
  58088. constructor(name: string);
  58089. /**
  58090. * Gets the current class name
  58091. * @returns the class name
  58092. */
  58093. getClassName(): string;
  58094. /**
  58095. * Gets the world position input component
  58096. */
  58097. readonly worldPosition: NodeMaterialConnectionPoint;
  58098. /**
  58099. * Gets the view input component
  58100. */
  58101. readonly view: NodeMaterialConnectionPoint;
  58102. /**
  58103. * Gets the color input component
  58104. */
  58105. readonly input: NodeMaterialConnectionPoint;
  58106. /**
  58107. * Gets the fog color input component
  58108. */
  58109. readonly fogColor: NodeMaterialConnectionPoint;
  58110. /**
  58111. * Gets the output component
  58112. */
  58113. readonly output: NodeMaterialConnectionPoint;
  58114. autoConfigure(material: NodeMaterial): void;
  58115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58116. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58117. protected _buildBlock(state: NodeMaterialBuildState): this;
  58118. }
  58119. }
  58120. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  58121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58125. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58126. import { Effect } from "babylonjs/Materials/effect";
  58127. import { Mesh } from "babylonjs/Meshes/mesh";
  58128. import { Light } from "babylonjs/Lights/light";
  58129. import { Nullable } from "babylonjs/types";
  58130. import { Scene } from "babylonjs/scene";
  58131. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58132. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58133. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58134. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58135. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  58136. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58137. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58138. /**
  58139. * Block used to add light in the fragment shader
  58140. */
  58141. export class LightBlock extends NodeMaterialBlock {
  58142. private _lightId;
  58143. /**
  58144. * Gets or sets the light associated with this block
  58145. */
  58146. light: Nullable<Light>;
  58147. /**
  58148. * Create a new LightBlock
  58149. * @param name defines the block name
  58150. */
  58151. constructor(name: string);
  58152. /**
  58153. * Gets the current class name
  58154. * @returns the class name
  58155. */
  58156. getClassName(): string;
  58157. /**
  58158. * Gets the world position input component
  58159. */
  58160. readonly worldPosition: NodeMaterialConnectionPoint;
  58161. /**
  58162. * Gets the world normal input component
  58163. */
  58164. readonly worldNormal: NodeMaterialConnectionPoint;
  58165. /**
  58166. * Gets the camera (or eye) position component
  58167. */
  58168. readonly cameraPosition: NodeMaterialConnectionPoint;
  58169. /**
  58170. * Gets the glossiness component
  58171. */
  58172. readonly glossiness: NodeMaterialConnectionPoint;
  58173. /**
  58174. * Gets the glossinness power component
  58175. */
  58176. readonly glossPower: NodeMaterialConnectionPoint;
  58177. /**
  58178. * Gets the diffuse color component
  58179. */
  58180. readonly diffuseColor: NodeMaterialConnectionPoint;
  58181. /**
  58182. * Gets the specular color component
  58183. */
  58184. readonly specularColor: NodeMaterialConnectionPoint;
  58185. /**
  58186. * Gets the diffuse output component
  58187. */
  58188. readonly diffuseOutput: NodeMaterialConnectionPoint;
  58189. /**
  58190. * Gets the specular output component
  58191. */
  58192. readonly specularOutput: NodeMaterialConnectionPoint;
  58193. autoConfigure(material: NodeMaterial): void;
  58194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58195. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58196. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58197. private _injectVertexCode;
  58198. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58199. serialize(): any;
  58200. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58201. }
  58202. }
  58203. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  58204. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  58205. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  58206. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58207. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58208. }
  58209. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  58210. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58211. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58212. }
  58213. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  58214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58217. /**
  58218. * Block used to multiply 2 values
  58219. */
  58220. export class MultiplyBlock extends NodeMaterialBlock {
  58221. /**
  58222. * Creates a new MultiplyBlock
  58223. * @param name defines the block name
  58224. */
  58225. constructor(name: string);
  58226. /**
  58227. * Gets the current class name
  58228. * @returns the class name
  58229. */
  58230. getClassName(): string;
  58231. /**
  58232. * Gets the left operand input component
  58233. */
  58234. readonly left: NodeMaterialConnectionPoint;
  58235. /**
  58236. * Gets the right operand input component
  58237. */
  58238. readonly right: NodeMaterialConnectionPoint;
  58239. /**
  58240. * Gets the output component
  58241. */
  58242. readonly output: NodeMaterialConnectionPoint;
  58243. protected _buildBlock(state: NodeMaterialBuildState): this;
  58244. }
  58245. }
  58246. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  58247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58250. /**
  58251. * Block used to add 2 vectors
  58252. */
  58253. export class AddBlock extends NodeMaterialBlock {
  58254. /**
  58255. * Creates a new AddBlock
  58256. * @param name defines the block name
  58257. */
  58258. constructor(name: string);
  58259. /**
  58260. * Gets the current class name
  58261. * @returns the class name
  58262. */
  58263. getClassName(): string;
  58264. /**
  58265. * Gets the left operand input component
  58266. */
  58267. readonly left: NodeMaterialConnectionPoint;
  58268. /**
  58269. * Gets the right operand input component
  58270. */
  58271. readonly right: NodeMaterialConnectionPoint;
  58272. /**
  58273. * Gets the output component
  58274. */
  58275. readonly output: NodeMaterialConnectionPoint;
  58276. protected _buildBlock(state: NodeMaterialBuildState): this;
  58277. }
  58278. }
  58279. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  58280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58283. /**
  58284. * Block used to scale a vector by a float
  58285. */
  58286. export class ScaleBlock extends NodeMaterialBlock {
  58287. /**
  58288. * Creates a new ScaleBlock
  58289. * @param name defines the block name
  58290. */
  58291. constructor(name: string);
  58292. /**
  58293. * Gets the current class name
  58294. * @returns the class name
  58295. */
  58296. getClassName(): string;
  58297. /**
  58298. * Gets the input component
  58299. */
  58300. readonly input: NodeMaterialConnectionPoint;
  58301. /**
  58302. * Gets the factor input component
  58303. */
  58304. readonly factor: NodeMaterialConnectionPoint;
  58305. /**
  58306. * Gets the output component
  58307. */
  58308. readonly output: NodeMaterialConnectionPoint;
  58309. protected _buildBlock(state: NodeMaterialBuildState): this;
  58310. }
  58311. }
  58312. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  58313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58316. import { Scene } from "babylonjs/scene";
  58317. /**
  58318. * Block used to clamp a float
  58319. */
  58320. export class ClampBlock extends NodeMaterialBlock {
  58321. /** Gets or sets the minimum range */
  58322. minimum: number;
  58323. /** Gets or sets the maximum range */
  58324. maximum: number;
  58325. /**
  58326. * Creates a new ClampBlock
  58327. * @param name defines the block name
  58328. */
  58329. constructor(name: string);
  58330. /**
  58331. * Gets the current class name
  58332. * @returns the class name
  58333. */
  58334. getClassName(): string;
  58335. /**
  58336. * Gets the value input component
  58337. */
  58338. readonly value: NodeMaterialConnectionPoint;
  58339. /**
  58340. * Gets the output component
  58341. */
  58342. readonly output: NodeMaterialConnectionPoint;
  58343. protected _buildBlock(state: NodeMaterialBuildState): this;
  58344. protected _dumpPropertiesCode(): string;
  58345. serialize(): any;
  58346. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58347. }
  58348. }
  58349. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58350. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58351. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58353. /**
  58354. * Block used to apply a cross product between 2 vectors
  58355. */
  58356. export class CrossBlock extends NodeMaterialBlock {
  58357. /**
  58358. * Creates a new CrossBlock
  58359. * @param name defines the block name
  58360. */
  58361. constructor(name: string);
  58362. /**
  58363. * Gets the current class name
  58364. * @returns the class name
  58365. */
  58366. getClassName(): string;
  58367. /**
  58368. * Gets the left operand input component
  58369. */
  58370. readonly left: NodeMaterialConnectionPoint;
  58371. /**
  58372. * Gets the right operand input component
  58373. */
  58374. readonly right: NodeMaterialConnectionPoint;
  58375. /**
  58376. * Gets the output component
  58377. */
  58378. readonly output: NodeMaterialConnectionPoint;
  58379. protected _buildBlock(state: NodeMaterialBuildState): this;
  58380. }
  58381. }
  58382. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58386. /**
  58387. * Block used to apply a dot product between 2 vectors
  58388. */
  58389. export class DotBlock extends NodeMaterialBlock {
  58390. /**
  58391. * Creates a new DotBlock
  58392. * @param name defines the block name
  58393. */
  58394. constructor(name: string);
  58395. /**
  58396. * Gets the current class name
  58397. * @returns the class name
  58398. */
  58399. getClassName(): string;
  58400. /**
  58401. * Gets the left operand input component
  58402. */
  58403. readonly left: NodeMaterialConnectionPoint;
  58404. /**
  58405. * Gets the right operand input component
  58406. */
  58407. readonly right: NodeMaterialConnectionPoint;
  58408. /**
  58409. * Gets the output component
  58410. */
  58411. readonly output: NodeMaterialConnectionPoint;
  58412. protected _buildBlock(state: NodeMaterialBuildState): this;
  58413. }
  58414. }
  58415. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58419. import { Vector2 } from "babylonjs/Maths/math.vector";
  58420. import { Scene } from "babylonjs/scene";
  58421. /**
  58422. * Block used to remap a float from a range to a new one
  58423. */
  58424. export class RemapBlock extends NodeMaterialBlock {
  58425. /**
  58426. * Gets or sets the source range
  58427. */
  58428. sourceRange: Vector2;
  58429. /**
  58430. * Gets or sets the target range
  58431. */
  58432. targetRange: Vector2;
  58433. /**
  58434. * Creates a new RemapBlock
  58435. * @param name defines the block name
  58436. */
  58437. constructor(name: string);
  58438. /**
  58439. * Gets the current class name
  58440. * @returns the class name
  58441. */
  58442. getClassName(): string;
  58443. /**
  58444. * Gets the input component
  58445. */
  58446. readonly input: NodeMaterialConnectionPoint;
  58447. /**
  58448. * Gets the source min input component
  58449. */
  58450. readonly sourceMin: NodeMaterialConnectionPoint;
  58451. /**
  58452. * Gets the source max input component
  58453. */
  58454. readonly sourceMax: NodeMaterialConnectionPoint;
  58455. /**
  58456. * Gets the target min input component
  58457. */
  58458. readonly targetMin: NodeMaterialConnectionPoint;
  58459. /**
  58460. * Gets the target max input component
  58461. */
  58462. readonly targetMax: NodeMaterialConnectionPoint;
  58463. /**
  58464. * Gets the output component
  58465. */
  58466. readonly output: NodeMaterialConnectionPoint;
  58467. protected _buildBlock(state: NodeMaterialBuildState): this;
  58468. protected _dumpPropertiesCode(): string;
  58469. serialize(): any;
  58470. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58471. }
  58472. }
  58473. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58477. /**
  58478. * Block used to normalize a vector
  58479. */
  58480. export class NormalizeBlock extends NodeMaterialBlock {
  58481. /**
  58482. * Creates a new NormalizeBlock
  58483. * @param name defines the block name
  58484. */
  58485. constructor(name: string);
  58486. /**
  58487. * Gets the current class name
  58488. * @returns the class name
  58489. */
  58490. getClassName(): string;
  58491. /**
  58492. * Gets the input component
  58493. */
  58494. readonly input: NodeMaterialConnectionPoint;
  58495. /**
  58496. * Gets the output component
  58497. */
  58498. readonly output: NodeMaterialConnectionPoint;
  58499. protected _buildBlock(state: NodeMaterialBuildState): this;
  58500. }
  58501. }
  58502. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58506. import { Scene } from "babylonjs/scene";
  58507. /**
  58508. * Operations supported by the Trigonometry block
  58509. */
  58510. export enum TrigonometryBlockOperations {
  58511. /** Cos */
  58512. Cos = 0,
  58513. /** Sin */
  58514. Sin = 1,
  58515. /** Abs */
  58516. Abs = 2,
  58517. /** Exp */
  58518. Exp = 3,
  58519. /** Exp2 */
  58520. Exp2 = 4,
  58521. /** Round */
  58522. Round = 5,
  58523. /** Floor */
  58524. Floor = 6,
  58525. /** Ceiling */
  58526. Ceiling = 7,
  58527. /** Square root */
  58528. Sqrt = 8,
  58529. /** Log */
  58530. Log = 9,
  58531. /** Tangent */
  58532. Tan = 10,
  58533. /** Arc tangent */
  58534. ArcTan = 11,
  58535. /** Arc cosinus */
  58536. ArcCos = 12,
  58537. /** Arc sinus */
  58538. ArcSin = 13,
  58539. /** Fraction */
  58540. Fract = 14,
  58541. /** Sign */
  58542. Sign = 15,
  58543. /** To radians (from degrees) */
  58544. Radians = 16,
  58545. /** To degrees (from radians) */
  58546. Degrees = 17
  58547. }
  58548. /**
  58549. * Block used to apply trigonometry operation to floats
  58550. */
  58551. export class TrigonometryBlock extends NodeMaterialBlock {
  58552. /**
  58553. * Gets or sets the operation applied by the block
  58554. */
  58555. operation: TrigonometryBlockOperations;
  58556. /**
  58557. * Creates a new TrigonometryBlock
  58558. * @param name defines the block name
  58559. */
  58560. constructor(name: string);
  58561. /**
  58562. * Gets the current class name
  58563. * @returns the class name
  58564. */
  58565. getClassName(): string;
  58566. /**
  58567. * Gets the input component
  58568. */
  58569. readonly input: NodeMaterialConnectionPoint;
  58570. /**
  58571. * Gets the output component
  58572. */
  58573. readonly output: NodeMaterialConnectionPoint;
  58574. protected _buildBlock(state: NodeMaterialBuildState): this;
  58575. serialize(): any;
  58576. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58577. protected _dumpPropertiesCode(): string;
  58578. }
  58579. }
  58580. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58584. /**
  58585. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58586. */
  58587. export class ColorMergerBlock extends NodeMaterialBlock {
  58588. /**
  58589. * Create a new ColorMergerBlock
  58590. * @param name defines the block name
  58591. */
  58592. constructor(name: string);
  58593. /**
  58594. * Gets the current class name
  58595. * @returns the class name
  58596. */
  58597. getClassName(): string;
  58598. /**
  58599. * Gets the rgb component (input)
  58600. */
  58601. readonly rgbIn: NodeMaterialConnectionPoint;
  58602. /**
  58603. * Gets the r component (input)
  58604. */
  58605. readonly r: NodeMaterialConnectionPoint;
  58606. /**
  58607. * Gets the g component (input)
  58608. */
  58609. readonly g: NodeMaterialConnectionPoint;
  58610. /**
  58611. * Gets the b component (input)
  58612. */
  58613. readonly b: NodeMaterialConnectionPoint;
  58614. /**
  58615. * Gets the a component (input)
  58616. */
  58617. readonly a: NodeMaterialConnectionPoint;
  58618. /**
  58619. * Gets the rgba component (output)
  58620. */
  58621. readonly rgba: NodeMaterialConnectionPoint;
  58622. /**
  58623. * Gets the rgb component (output)
  58624. */
  58625. readonly rgbOut: NodeMaterialConnectionPoint;
  58626. /**
  58627. * Gets the rgb component (output)
  58628. * @deprecated Please use rgbOut instead.
  58629. */
  58630. readonly rgb: NodeMaterialConnectionPoint;
  58631. protected _buildBlock(state: NodeMaterialBuildState): this;
  58632. }
  58633. }
  58634. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58635. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58636. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58637. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58638. /**
  58639. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58640. */
  58641. export class VectorMergerBlock extends NodeMaterialBlock {
  58642. /**
  58643. * Create a new VectorMergerBlock
  58644. * @param name defines the block name
  58645. */
  58646. constructor(name: string);
  58647. /**
  58648. * Gets the current class name
  58649. * @returns the class name
  58650. */
  58651. getClassName(): string;
  58652. /**
  58653. * Gets the xyz component (input)
  58654. */
  58655. readonly xyzIn: NodeMaterialConnectionPoint;
  58656. /**
  58657. * Gets the xy component (input)
  58658. */
  58659. readonly xyIn: NodeMaterialConnectionPoint;
  58660. /**
  58661. * Gets the x component (input)
  58662. */
  58663. readonly x: NodeMaterialConnectionPoint;
  58664. /**
  58665. * Gets the y component (input)
  58666. */
  58667. readonly y: NodeMaterialConnectionPoint;
  58668. /**
  58669. * Gets the z component (input)
  58670. */
  58671. readonly z: NodeMaterialConnectionPoint;
  58672. /**
  58673. * Gets the w component (input)
  58674. */
  58675. readonly w: NodeMaterialConnectionPoint;
  58676. /**
  58677. * Gets the xyzw component (output)
  58678. */
  58679. readonly xyzw: NodeMaterialConnectionPoint;
  58680. /**
  58681. * Gets the xyz component (output)
  58682. */
  58683. readonly xyzOut: NodeMaterialConnectionPoint;
  58684. /**
  58685. * Gets the xy component (output)
  58686. */
  58687. readonly xyOut: NodeMaterialConnectionPoint;
  58688. /**
  58689. * Gets the xy component (output)
  58690. * @deprecated Please use xyOut instead.
  58691. */
  58692. readonly xy: NodeMaterialConnectionPoint;
  58693. /**
  58694. * Gets the xyz component (output)
  58695. * @deprecated Please use xyzOut instead.
  58696. */
  58697. readonly xyz: NodeMaterialConnectionPoint;
  58698. protected _buildBlock(state: NodeMaterialBuildState): this;
  58699. }
  58700. }
  58701. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58705. /**
  58706. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58707. */
  58708. export class ColorSplitterBlock extends NodeMaterialBlock {
  58709. /**
  58710. * Create a new ColorSplitterBlock
  58711. * @param name defines the block name
  58712. */
  58713. constructor(name: string);
  58714. /**
  58715. * Gets the current class name
  58716. * @returns the class name
  58717. */
  58718. getClassName(): string;
  58719. /**
  58720. * Gets the rgba component (input)
  58721. */
  58722. readonly rgba: NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the rgb component (input)
  58725. */
  58726. readonly rgbIn: NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the rgb component (output)
  58729. */
  58730. readonly rgbOut: NodeMaterialConnectionPoint;
  58731. /**
  58732. * Gets the r component (output)
  58733. */
  58734. readonly r: NodeMaterialConnectionPoint;
  58735. /**
  58736. * Gets the g component (output)
  58737. */
  58738. readonly g: NodeMaterialConnectionPoint;
  58739. /**
  58740. * Gets the b component (output)
  58741. */
  58742. readonly b: NodeMaterialConnectionPoint;
  58743. /**
  58744. * Gets the a component (output)
  58745. */
  58746. readonly a: NodeMaterialConnectionPoint;
  58747. protected _inputRename(name: string): string;
  58748. protected _outputRename(name: string): string;
  58749. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58750. }
  58751. }
  58752. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58756. /**
  58757. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58758. */
  58759. export class VectorSplitterBlock extends NodeMaterialBlock {
  58760. /**
  58761. * Create a new VectorSplitterBlock
  58762. * @param name defines the block name
  58763. */
  58764. constructor(name: string);
  58765. /**
  58766. * Gets the current class name
  58767. * @returns the class name
  58768. */
  58769. getClassName(): string;
  58770. /**
  58771. * Gets the xyzw component (input)
  58772. */
  58773. readonly xyzw: NodeMaterialConnectionPoint;
  58774. /**
  58775. * Gets the xyz component (input)
  58776. */
  58777. readonly xyzIn: NodeMaterialConnectionPoint;
  58778. /**
  58779. * Gets the xy component (input)
  58780. */
  58781. readonly xyIn: NodeMaterialConnectionPoint;
  58782. /**
  58783. * Gets the xyz component (output)
  58784. */
  58785. readonly xyzOut: NodeMaterialConnectionPoint;
  58786. /**
  58787. * Gets the xy component (output)
  58788. */
  58789. readonly xyOut: NodeMaterialConnectionPoint;
  58790. /**
  58791. * Gets the x component (output)
  58792. */
  58793. readonly x: NodeMaterialConnectionPoint;
  58794. /**
  58795. * Gets the y component (output)
  58796. */
  58797. readonly y: NodeMaterialConnectionPoint;
  58798. /**
  58799. * Gets the z component (output)
  58800. */
  58801. readonly z: NodeMaterialConnectionPoint;
  58802. /**
  58803. * Gets the w component (output)
  58804. */
  58805. readonly w: NodeMaterialConnectionPoint;
  58806. protected _inputRename(name: string): string;
  58807. protected _outputRename(name: string): string;
  58808. protected _buildBlock(state: NodeMaterialBuildState): this;
  58809. }
  58810. }
  58811. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58812. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58815. /**
  58816. * Block used to lerp between 2 values
  58817. */
  58818. export class LerpBlock extends NodeMaterialBlock {
  58819. /**
  58820. * Creates a new LerpBlock
  58821. * @param name defines the block name
  58822. */
  58823. constructor(name: string);
  58824. /**
  58825. * Gets the current class name
  58826. * @returns the class name
  58827. */
  58828. getClassName(): string;
  58829. /**
  58830. * Gets the left operand input component
  58831. */
  58832. readonly left: NodeMaterialConnectionPoint;
  58833. /**
  58834. * Gets the right operand input component
  58835. */
  58836. readonly right: NodeMaterialConnectionPoint;
  58837. /**
  58838. * Gets the gradient operand input component
  58839. */
  58840. readonly gradient: NodeMaterialConnectionPoint;
  58841. /**
  58842. * Gets the output component
  58843. */
  58844. readonly output: NodeMaterialConnectionPoint;
  58845. protected _buildBlock(state: NodeMaterialBuildState): this;
  58846. }
  58847. }
  58848. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58852. /**
  58853. * Block used to divide 2 vectors
  58854. */
  58855. export class DivideBlock extends NodeMaterialBlock {
  58856. /**
  58857. * Creates a new DivideBlock
  58858. * @param name defines the block name
  58859. */
  58860. constructor(name: string);
  58861. /**
  58862. * Gets the current class name
  58863. * @returns the class name
  58864. */
  58865. getClassName(): string;
  58866. /**
  58867. * Gets the left operand input component
  58868. */
  58869. readonly left: NodeMaterialConnectionPoint;
  58870. /**
  58871. * Gets the right operand input component
  58872. */
  58873. readonly right: NodeMaterialConnectionPoint;
  58874. /**
  58875. * Gets the output component
  58876. */
  58877. readonly output: NodeMaterialConnectionPoint;
  58878. protected _buildBlock(state: NodeMaterialBuildState): this;
  58879. }
  58880. }
  58881. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58882. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58883. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58884. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58885. /**
  58886. * Block used to subtract 2 vectors
  58887. */
  58888. export class SubtractBlock extends NodeMaterialBlock {
  58889. /**
  58890. * Creates a new SubtractBlock
  58891. * @param name defines the block name
  58892. */
  58893. constructor(name: string);
  58894. /**
  58895. * Gets the current class name
  58896. * @returns the class name
  58897. */
  58898. getClassName(): string;
  58899. /**
  58900. * Gets the left operand input component
  58901. */
  58902. readonly left: NodeMaterialConnectionPoint;
  58903. /**
  58904. * Gets the right operand input component
  58905. */
  58906. readonly right: NodeMaterialConnectionPoint;
  58907. /**
  58908. * Gets the output component
  58909. */
  58910. readonly output: NodeMaterialConnectionPoint;
  58911. protected _buildBlock(state: NodeMaterialBuildState): this;
  58912. }
  58913. }
  58914. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58918. /**
  58919. * Block used to step a value
  58920. */
  58921. export class StepBlock extends NodeMaterialBlock {
  58922. /**
  58923. * Creates a new StepBlock
  58924. * @param name defines the block name
  58925. */
  58926. constructor(name: string);
  58927. /**
  58928. * Gets the current class name
  58929. * @returns the class name
  58930. */
  58931. getClassName(): string;
  58932. /**
  58933. * Gets the value operand input component
  58934. */
  58935. readonly value: NodeMaterialConnectionPoint;
  58936. /**
  58937. * Gets the edge operand input component
  58938. */
  58939. readonly edge: NodeMaterialConnectionPoint;
  58940. /**
  58941. * Gets the output component
  58942. */
  58943. readonly output: NodeMaterialConnectionPoint;
  58944. protected _buildBlock(state: NodeMaterialBuildState): this;
  58945. }
  58946. }
  58947. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58951. /**
  58952. * Block used to get the opposite (1 - x) of a value
  58953. */
  58954. export class OneMinusBlock extends NodeMaterialBlock {
  58955. /**
  58956. * Creates a new OneMinusBlock
  58957. * @param name defines the block name
  58958. */
  58959. constructor(name: string);
  58960. /**
  58961. * Gets the current class name
  58962. * @returns the class name
  58963. */
  58964. getClassName(): string;
  58965. /**
  58966. * Gets the input component
  58967. */
  58968. readonly input: NodeMaterialConnectionPoint;
  58969. /**
  58970. * Gets the output component
  58971. */
  58972. readonly output: NodeMaterialConnectionPoint;
  58973. protected _buildBlock(state: NodeMaterialBuildState): this;
  58974. }
  58975. }
  58976. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58977. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58978. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58980. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58981. /**
  58982. * Block used to get the view direction
  58983. */
  58984. export class ViewDirectionBlock extends NodeMaterialBlock {
  58985. /**
  58986. * Creates a new ViewDirectionBlock
  58987. * @param name defines the block name
  58988. */
  58989. constructor(name: string);
  58990. /**
  58991. * Gets the current class name
  58992. * @returns the class name
  58993. */
  58994. getClassName(): string;
  58995. /**
  58996. * Gets the world position component
  58997. */
  58998. readonly worldPosition: NodeMaterialConnectionPoint;
  58999. /**
  59000. * Gets the camera position component
  59001. */
  59002. readonly cameraPosition: NodeMaterialConnectionPoint;
  59003. /**
  59004. * Gets the output component
  59005. */
  59006. readonly output: NodeMaterialConnectionPoint;
  59007. autoConfigure(material: NodeMaterial): void;
  59008. protected _buildBlock(state: NodeMaterialBuildState): this;
  59009. }
  59010. }
  59011. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  59012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59015. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59016. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  59017. /**
  59018. * Block used to compute fresnel value
  59019. */
  59020. export class FresnelBlock extends NodeMaterialBlock {
  59021. /**
  59022. * Create a new FresnelBlock
  59023. * @param name defines the block name
  59024. */
  59025. constructor(name: string);
  59026. /**
  59027. * Gets the current class name
  59028. * @returns the class name
  59029. */
  59030. getClassName(): string;
  59031. /**
  59032. * Gets the world normal input component
  59033. */
  59034. readonly worldNormal: NodeMaterialConnectionPoint;
  59035. /**
  59036. * Gets the view direction input component
  59037. */
  59038. readonly viewDirection: NodeMaterialConnectionPoint;
  59039. /**
  59040. * Gets the bias input component
  59041. */
  59042. readonly bias: NodeMaterialConnectionPoint;
  59043. /**
  59044. * Gets the camera (or eye) position component
  59045. */
  59046. readonly power: NodeMaterialConnectionPoint;
  59047. /**
  59048. * Gets the fresnel output component
  59049. */
  59050. readonly fresnel: NodeMaterialConnectionPoint;
  59051. autoConfigure(material: NodeMaterial): void;
  59052. protected _buildBlock(state: NodeMaterialBuildState): this;
  59053. }
  59054. }
  59055. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  59056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59059. /**
  59060. * Block used to get the max of 2 values
  59061. */
  59062. export class MaxBlock extends NodeMaterialBlock {
  59063. /**
  59064. * Creates a new MaxBlock
  59065. * @param name defines the block name
  59066. */
  59067. constructor(name: string);
  59068. /**
  59069. * Gets the current class name
  59070. * @returns the class name
  59071. */
  59072. getClassName(): string;
  59073. /**
  59074. * Gets the left operand input component
  59075. */
  59076. readonly left: NodeMaterialConnectionPoint;
  59077. /**
  59078. * Gets the right operand input component
  59079. */
  59080. readonly right: NodeMaterialConnectionPoint;
  59081. /**
  59082. * Gets the output component
  59083. */
  59084. readonly output: NodeMaterialConnectionPoint;
  59085. protected _buildBlock(state: NodeMaterialBuildState): this;
  59086. }
  59087. }
  59088. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  59089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59092. /**
  59093. * Block used to get the min of 2 values
  59094. */
  59095. export class MinBlock extends NodeMaterialBlock {
  59096. /**
  59097. * Creates a new MinBlock
  59098. * @param name defines the block name
  59099. */
  59100. constructor(name: string);
  59101. /**
  59102. * Gets the current class name
  59103. * @returns the class name
  59104. */
  59105. getClassName(): string;
  59106. /**
  59107. * Gets the left operand input component
  59108. */
  59109. readonly left: NodeMaterialConnectionPoint;
  59110. /**
  59111. * Gets the right operand input component
  59112. */
  59113. readonly right: NodeMaterialConnectionPoint;
  59114. /**
  59115. * Gets the output component
  59116. */
  59117. readonly output: NodeMaterialConnectionPoint;
  59118. protected _buildBlock(state: NodeMaterialBuildState): this;
  59119. }
  59120. }
  59121. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  59122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59125. /**
  59126. * Block used to get the distance between 2 values
  59127. */
  59128. export class DistanceBlock extends NodeMaterialBlock {
  59129. /**
  59130. * Creates a new DistanceBlock
  59131. * @param name defines the block name
  59132. */
  59133. constructor(name: string);
  59134. /**
  59135. * Gets the current class name
  59136. * @returns the class name
  59137. */
  59138. getClassName(): string;
  59139. /**
  59140. * Gets the left operand input component
  59141. */
  59142. readonly left: NodeMaterialConnectionPoint;
  59143. /**
  59144. * Gets the right operand input component
  59145. */
  59146. readonly right: NodeMaterialConnectionPoint;
  59147. /**
  59148. * Gets the output component
  59149. */
  59150. readonly output: NodeMaterialConnectionPoint;
  59151. protected _buildBlock(state: NodeMaterialBuildState): this;
  59152. }
  59153. }
  59154. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  59155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59158. /**
  59159. * Block used to get the length of a vector
  59160. */
  59161. export class LengthBlock extends NodeMaterialBlock {
  59162. /**
  59163. * Creates a new LengthBlock
  59164. * @param name defines the block name
  59165. */
  59166. constructor(name: string);
  59167. /**
  59168. * Gets the current class name
  59169. * @returns the class name
  59170. */
  59171. getClassName(): string;
  59172. /**
  59173. * Gets the value input component
  59174. */
  59175. readonly value: NodeMaterialConnectionPoint;
  59176. /**
  59177. * Gets the output component
  59178. */
  59179. readonly output: NodeMaterialConnectionPoint;
  59180. protected _buildBlock(state: NodeMaterialBuildState): this;
  59181. }
  59182. }
  59183. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  59184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59187. /**
  59188. * Block used to get negative version of a value (i.e. x * -1)
  59189. */
  59190. export class NegateBlock extends NodeMaterialBlock {
  59191. /**
  59192. * Creates a new NegateBlock
  59193. * @param name defines the block name
  59194. */
  59195. constructor(name: string);
  59196. /**
  59197. * Gets the current class name
  59198. * @returns the class name
  59199. */
  59200. getClassName(): string;
  59201. /**
  59202. * Gets the value input component
  59203. */
  59204. readonly value: NodeMaterialConnectionPoint;
  59205. /**
  59206. * Gets the output component
  59207. */
  59208. readonly output: NodeMaterialConnectionPoint;
  59209. protected _buildBlock(state: NodeMaterialBuildState): this;
  59210. }
  59211. }
  59212. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  59213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59216. /**
  59217. * Block used to get the value of the first parameter raised to the power of the second
  59218. */
  59219. export class PowBlock extends NodeMaterialBlock {
  59220. /**
  59221. * Creates a new PowBlock
  59222. * @param name defines the block name
  59223. */
  59224. constructor(name: string);
  59225. /**
  59226. * Gets the current class name
  59227. * @returns the class name
  59228. */
  59229. getClassName(): string;
  59230. /**
  59231. * Gets the value operand input component
  59232. */
  59233. readonly value: NodeMaterialConnectionPoint;
  59234. /**
  59235. * Gets the power operand input component
  59236. */
  59237. readonly power: NodeMaterialConnectionPoint;
  59238. /**
  59239. * Gets the output component
  59240. */
  59241. readonly output: NodeMaterialConnectionPoint;
  59242. protected _buildBlock(state: NodeMaterialBuildState): this;
  59243. }
  59244. }
  59245. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  59246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59249. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59250. /**
  59251. * Block used to get a random number
  59252. */
  59253. export class RandomNumberBlock extends NodeMaterialBlock {
  59254. /**
  59255. * Creates a new RandomNumberBlock
  59256. * @param name defines the block name
  59257. */
  59258. constructor(name: string);
  59259. /**
  59260. * Gets the current class name
  59261. * @returns the class name
  59262. */
  59263. getClassName(): string;
  59264. /**
  59265. * Gets the seed input component
  59266. */
  59267. readonly seed: NodeMaterialConnectionPoint;
  59268. /**
  59269. * Gets the output component
  59270. */
  59271. readonly output: NodeMaterialConnectionPoint;
  59272. protected _buildBlock(state: NodeMaterialBuildState): this;
  59273. }
  59274. }
  59275. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  59276. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59277. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59278. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59279. /**
  59280. * Block used to compute arc tangent of 2 values
  59281. */
  59282. export class ArcTan2Block extends NodeMaterialBlock {
  59283. /**
  59284. * Creates a new ArcTan2Block
  59285. * @param name defines the block name
  59286. */
  59287. constructor(name: string);
  59288. /**
  59289. * Gets the current class name
  59290. * @returns the class name
  59291. */
  59292. getClassName(): string;
  59293. /**
  59294. * Gets the x operand input component
  59295. */
  59296. readonly x: NodeMaterialConnectionPoint;
  59297. /**
  59298. * Gets the y operand input component
  59299. */
  59300. readonly y: NodeMaterialConnectionPoint;
  59301. /**
  59302. * Gets the output component
  59303. */
  59304. readonly output: NodeMaterialConnectionPoint;
  59305. protected _buildBlock(state: NodeMaterialBuildState): this;
  59306. }
  59307. }
  59308. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  59309. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59310. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59311. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59312. /**
  59313. * Block used to smooth step a value
  59314. */
  59315. export class SmoothStepBlock extends NodeMaterialBlock {
  59316. /**
  59317. * Creates a new SmoothStepBlock
  59318. * @param name defines the block name
  59319. */
  59320. constructor(name: string);
  59321. /**
  59322. * Gets the current class name
  59323. * @returns the class name
  59324. */
  59325. getClassName(): string;
  59326. /**
  59327. * Gets the value operand input component
  59328. */
  59329. readonly value: NodeMaterialConnectionPoint;
  59330. /**
  59331. * Gets the first edge operand input component
  59332. */
  59333. readonly edge0: NodeMaterialConnectionPoint;
  59334. /**
  59335. * Gets the second edge operand input component
  59336. */
  59337. readonly edge1: NodeMaterialConnectionPoint;
  59338. /**
  59339. * Gets the output component
  59340. */
  59341. readonly output: NodeMaterialConnectionPoint;
  59342. protected _buildBlock(state: NodeMaterialBuildState): this;
  59343. }
  59344. }
  59345. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  59346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59349. /**
  59350. * Block used to get the reciprocal (1 / x) of a value
  59351. */
  59352. export class ReciprocalBlock extends NodeMaterialBlock {
  59353. /**
  59354. * Creates a new ReciprocalBlock
  59355. * @param name defines the block name
  59356. */
  59357. constructor(name: string);
  59358. /**
  59359. * Gets the current class name
  59360. * @returns the class name
  59361. */
  59362. getClassName(): string;
  59363. /**
  59364. * Gets the input component
  59365. */
  59366. readonly input: NodeMaterialConnectionPoint;
  59367. /**
  59368. * Gets the output component
  59369. */
  59370. readonly output: NodeMaterialConnectionPoint;
  59371. protected _buildBlock(state: NodeMaterialBuildState): this;
  59372. }
  59373. }
  59374. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59375. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59376. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59378. /**
  59379. * Block used to replace a color by another one
  59380. */
  59381. export class ReplaceColorBlock extends NodeMaterialBlock {
  59382. /**
  59383. * Creates a new ReplaceColorBlock
  59384. * @param name defines the block name
  59385. */
  59386. constructor(name: string);
  59387. /**
  59388. * Gets the current class name
  59389. * @returns the class name
  59390. */
  59391. getClassName(): string;
  59392. /**
  59393. * Gets the value input component
  59394. */
  59395. readonly value: NodeMaterialConnectionPoint;
  59396. /**
  59397. * Gets the reference input component
  59398. */
  59399. readonly reference: NodeMaterialConnectionPoint;
  59400. /**
  59401. * Gets the distance input component
  59402. */
  59403. readonly distance: NodeMaterialConnectionPoint;
  59404. /**
  59405. * Gets the replacement input component
  59406. */
  59407. readonly replacement: NodeMaterialConnectionPoint;
  59408. /**
  59409. * Gets the output component
  59410. */
  59411. readonly output: NodeMaterialConnectionPoint;
  59412. protected _buildBlock(state: NodeMaterialBuildState): this;
  59413. }
  59414. }
  59415. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59419. /**
  59420. * Block used to posterize a value
  59421. * @see https://en.wikipedia.org/wiki/Posterization
  59422. */
  59423. export class PosterizeBlock extends NodeMaterialBlock {
  59424. /**
  59425. * Creates a new PosterizeBlock
  59426. * @param name defines the block name
  59427. */
  59428. constructor(name: string);
  59429. /**
  59430. * Gets the current class name
  59431. * @returns the class name
  59432. */
  59433. getClassName(): string;
  59434. /**
  59435. * Gets the value input component
  59436. */
  59437. readonly value: NodeMaterialConnectionPoint;
  59438. /**
  59439. * Gets the steps input component
  59440. */
  59441. readonly steps: NodeMaterialConnectionPoint;
  59442. /**
  59443. * Gets the output component
  59444. */
  59445. readonly output: NodeMaterialConnectionPoint;
  59446. protected _buildBlock(state: NodeMaterialBuildState): this;
  59447. }
  59448. }
  59449. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59453. import { Scene } from "babylonjs/scene";
  59454. /**
  59455. * Operations supported by the Wave block
  59456. */
  59457. export enum WaveBlockKind {
  59458. /** SawTooth */
  59459. SawTooth = 0,
  59460. /** Square */
  59461. Square = 1,
  59462. /** Triangle */
  59463. Triangle = 2
  59464. }
  59465. /**
  59466. * Block used to apply wave operation to floats
  59467. */
  59468. export class WaveBlock extends NodeMaterialBlock {
  59469. /**
  59470. * Gets or sets the kibnd of wave to be applied by the block
  59471. */
  59472. kind: WaveBlockKind;
  59473. /**
  59474. * Creates a new WaveBlock
  59475. * @param name defines the block name
  59476. */
  59477. constructor(name: string);
  59478. /**
  59479. * Gets the current class name
  59480. * @returns the class name
  59481. */
  59482. getClassName(): string;
  59483. /**
  59484. * Gets the input component
  59485. */
  59486. readonly input: NodeMaterialConnectionPoint;
  59487. /**
  59488. * Gets the output component
  59489. */
  59490. readonly output: NodeMaterialConnectionPoint;
  59491. protected _buildBlock(state: NodeMaterialBuildState): this;
  59492. serialize(): any;
  59493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59494. }
  59495. }
  59496. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59498. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59500. import { Color3 } from "babylonjs/Maths/math.color";
  59501. import { Scene } from "babylonjs/scene";
  59502. /**
  59503. * Class used to store a color step for the GradientBlock
  59504. */
  59505. export class GradientBlockColorStep {
  59506. /**
  59507. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59508. */
  59509. step: number;
  59510. /**
  59511. * Gets or sets the color associated with this step
  59512. */
  59513. color: Color3;
  59514. /**
  59515. * Creates a new GradientBlockColorStep
  59516. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59517. * @param color defines the color associated with this step
  59518. */
  59519. constructor(
  59520. /**
  59521. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59522. */
  59523. step: number,
  59524. /**
  59525. * Gets or sets the color associated with this step
  59526. */
  59527. color: Color3);
  59528. }
  59529. /**
  59530. * Block used to return a color from a gradient based on an input value between 0 and 1
  59531. */
  59532. export class GradientBlock extends NodeMaterialBlock {
  59533. /**
  59534. * Gets or sets the list of color steps
  59535. */
  59536. colorSteps: GradientBlockColorStep[];
  59537. /**
  59538. * Creates a new GradientBlock
  59539. * @param name defines the block name
  59540. */
  59541. constructor(name: string);
  59542. /**
  59543. * Gets the current class name
  59544. * @returns the class name
  59545. */
  59546. getClassName(): string;
  59547. /**
  59548. * Gets the gradient input component
  59549. */
  59550. readonly gradient: NodeMaterialConnectionPoint;
  59551. /**
  59552. * Gets the output component
  59553. */
  59554. readonly output: NodeMaterialConnectionPoint;
  59555. private _writeColorConstant;
  59556. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59557. serialize(): any;
  59558. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59559. protected _dumpPropertiesCode(): string;
  59560. }
  59561. }
  59562. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59566. /**
  59567. * Block used to normalize lerp between 2 values
  59568. */
  59569. export class NLerpBlock extends NodeMaterialBlock {
  59570. /**
  59571. * Creates a new NLerpBlock
  59572. * @param name defines the block name
  59573. */
  59574. constructor(name: string);
  59575. /**
  59576. * Gets the current class name
  59577. * @returns the class name
  59578. */
  59579. getClassName(): string;
  59580. /**
  59581. * Gets the left operand input component
  59582. */
  59583. readonly left: NodeMaterialConnectionPoint;
  59584. /**
  59585. * Gets the right operand input component
  59586. */
  59587. readonly right: NodeMaterialConnectionPoint;
  59588. /**
  59589. * Gets the gradient operand input component
  59590. */
  59591. readonly gradient: NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the output component
  59594. */
  59595. readonly output: NodeMaterialConnectionPoint;
  59596. protected _buildBlock(state: NodeMaterialBuildState): this;
  59597. }
  59598. }
  59599. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59603. import { Scene } from "babylonjs/scene";
  59604. /**
  59605. * block used to Generate a Worley Noise 3D Noise Pattern
  59606. */
  59607. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59608. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59609. manhattanDistance: boolean;
  59610. /**
  59611. * Creates a new WorleyNoise3DBlock
  59612. * @param name defines the block name
  59613. */
  59614. constructor(name: string);
  59615. /**
  59616. * Gets the current class name
  59617. * @returns the class name
  59618. */
  59619. getClassName(): string;
  59620. /**
  59621. * Gets the seed input component
  59622. */
  59623. readonly seed: NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the jitter input component
  59626. */
  59627. readonly jitter: NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the output component
  59630. */
  59631. readonly output: NodeMaterialConnectionPoint;
  59632. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59633. /**
  59634. * Exposes the properties to the UI?
  59635. */
  59636. protected _dumpPropertiesCode(): string;
  59637. /**
  59638. * Exposes the properties to the Seralize?
  59639. */
  59640. serialize(): any;
  59641. /**
  59642. * Exposes the properties to the deseralize?
  59643. */
  59644. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59645. }
  59646. }
  59647. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59651. /**
  59652. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59653. */
  59654. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59655. /**
  59656. * Creates a new SimplexPerlin3DBlock
  59657. * @param name defines the block name
  59658. */
  59659. constructor(name: string);
  59660. /**
  59661. * Gets the current class name
  59662. * @returns the class name
  59663. */
  59664. getClassName(): string;
  59665. /**
  59666. * Gets the seed operand input component
  59667. */
  59668. readonly seed: NodeMaterialConnectionPoint;
  59669. /**
  59670. * Gets the output component
  59671. */
  59672. readonly output: NodeMaterialConnectionPoint;
  59673. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59674. }
  59675. }
  59676. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59680. /**
  59681. * Block used to blend normals
  59682. */
  59683. export class NormalBlendBlock extends NodeMaterialBlock {
  59684. /**
  59685. * Creates a new NormalBlendBlock
  59686. * @param name defines the block name
  59687. */
  59688. constructor(name: string);
  59689. /**
  59690. * Gets the current class name
  59691. * @returns the class name
  59692. */
  59693. getClassName(): string;
  59694. /**
  59695. * Gets the first input component
  59696. */
  59697. readonly normalMap0: NodeMaterialConnectionPoint;
  59698. /**
  59699. * Gets the second input component
  59700. */
  59701. readonly normalMap1: NodeMaterialConnectionPoint;
  59702. /**
  59703. * Gets the output component
  59704. */
  59705. readonly output: NodeMaterialConnectionPoint;
  59706. protected _buildBlock(state: NodeMaterialBuildState): this;
  59707. }
  59708. }
  59709. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59713. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59714. /**
  59715. * Block used to rotate a 2d vector by a given angle
  59716. */
  59717. export class Rotate2dBlock extends NodeMaterialBlock {
  59718. /**
  59719. * Creates a new Rotate2dBlock
  59720. * @param name defines the block name
  59721. */
  59722. constructor(name: string);
  59723. /**
  59724. * Gets the current class name
  59725. * @returns the class name
  59726. */
  59727. getClassName(): string;
  59728. /**
  59729. * Gets the input vector
  59730. */
  59731. readonly input: NodeMaterialConnectionPoint;
  59732. /**
  59733. * Gets the input angle
  59734. */
  59735. readonly angle: NodeMaterialConnectionPoint;
  59736. /**
  59737. * Gets the output component
  59738. */
  59739. readonly output: NodeMaterialConnectionPoint;
  59740. autoConfigure(material: NodeMaterial): void;
  59741. protected _buildBlock(state: NodeMaterialBuildState): this;
  59742. }
  59743. }
  59744. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  59745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59748. /**
  59749. * Block used to get the reflected vector from a direction and a normal
  59750. */
  59751. export class ReflectBlock extends NodeMaterialBlock {
  59752. /**
  59753. * Creates a new ReflectBlock
  59754. * @param name defines the block name
  59755. */
  59756. constructor(name: string);
  59757. /**
  59758. * Gets the current class name
  59759. * @returns the class name
  59760. */
  59761. getClassName(): string;
  59762. /**
  59763. * Gets the incident component
  59764. */
  59765. readonly incident: NodeMaterialConnectionPoint;
  59766. /**
  59767. * Gets the normal component
  59768. */
  59769. readonly normal: NodeMaterialConnectionPoint;
  59770. /**
  59771. * Gets the output component
  59772. */
  59773. readonly output: NodeMaterialConnectionPoint;
  59774. protected _buildBlock(state: NodeMaterialBuildState): this;
  59775. }
  59776. }
  59777. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  59778. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59779. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59780. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59781. /**
  59782. * Block used to get the refracted vector from a direction and a normal
  59783. */
  59784. export class RefractBlock extends NodeMaterialBlock {
  59785. /**
  59786. * Creates a new RefractBlock
  59787. * @param name defines the block name
  59788. */
  59789. constructor(name: string);
  59790. /**
  59791. * Gets the current class name
  59792. * @returns the class name
  59793. */
  59794. getClassName(): string;
  59795. /**
  59796. * Gets the incident component
  59797. */
  59798. readonly incident: NodeMaterialConnectionPoint;
  59799. /**
  59800. * Gets the normal component
  59801. */
  59802. readonly normal: NodeMaterialConnectionPoint;
  59803. /**
  59804. * Gets the index of refraction component
  59805. */
  59806. readonly ior: NodeMaterialConnectionPoint;
  59807. /**
  59808. * Gets the output component
  59809. */
  59810. readonly output: NodeMaterialConnectionPoint;
  59811. protected _buildBlock(state: NodeMaterialBuildState): this;
  59812. }
  59813. }
  59814. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  59815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59818. /**
  59819. * Block used to desaturate a color
  59820. */
  59821. export class DesaturateBlock extends NodeMaterialBlock {
  59822. /**
  59823. * Creates a new DesaturateBlock
  59824. * @param name defines the block name
  59825. */
  59826. constructor(name: string);
  59827. /**
  59828. * Gets the current class name
  59829. * @returns the class name
  59830. */
  59831. getClassName(): string;
  59832. /**
  59833. * Gets the color operand input component
  59834. */
  59835. readonly color: NodeMaterialConnectionPoint;
  59836. /**
  59837. * Gets the level operand input component
  59838. */
  59839. readonly level: NodeMaterialConnectionPoint;
  59840. /**
  59841. * Gets the output component
  59842. */
  59843. readonly output: NodeMaterialConnectionPoint;
  59844. protected _buildBlock(state: NodeMaterialBuildState): this;
  59845. }
  59846. }
  59847. declare module "babylonjs/Materials/Node/Blocks/index" {
  59848. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59849. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59850. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59851. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59852. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59853. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59854. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59855. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59856. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59857. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59858. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59859. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59860. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59861. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59862. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59863. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59864. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59865. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59866. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59867. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59868. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59869. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59870. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59871. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59872. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59873. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59874. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59875. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59876. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59877. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59878. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59879. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59880. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59881. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59882. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59883. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59884. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59885. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59886. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59887. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59888. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59889. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59890. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  59891. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  59892. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  59893. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  59894. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  59895. }
  59896. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59897. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59898. }
  59899. declare module "babylonjs/Materials/Node/index" {
  59900. export * from "babylonjs/Materials/Node/Enums/index";
  59901. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59902. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59903. export * from "babylonjs/Materials/Node/nodeMaterial";
  59904. export * from "babylonjs/Materials/Node/Blocks/index";
  59905. export * from "babylonjs/Materials/Node/Optimizers/index";
  59906. }
  59907. declare module "babylonjs/Materials/effectRenderer" {
  59908. import { Nullable } from "babylonjs/types";
  59909. import { Texture } from "babylonjs/Materials/Textures/texture";
  59910. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59911. import { Viewport } from "babylonjs/Maths/math.viewport";
  59912. import { Observable } from "babylonjs/Misc/observable";
  59913. import { Effect } from "babylonjs/Materials/effect";
  59914. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59915. import "babylonjs/Shaders/postprocess.vertex";
  59916. /**
  59917. * Effect Render Options
  59918. */
  59919. export interface IEffectRendererOptions {
  59920. /**
  59921. * Defines the vertices positions.
  59922. */
  59923. positions?: number[];
  59924. /**
  59925. * Defines the indices.
  59926. */
  59927. indices?: number[];
  59928. }
  59929. /**
  59930. * Helper class to render one or more effects
  59931. */
  59932. export class EffectRenderer {
  59933. private engine;
  59934. private static _DefaultOptions;
  59935. private _vertexBuffers;
  59936. private _indexBuffer;
  59937. private _ringBufferIndex;
  59938. private _ringScreenBuffer;
  59939. private _fullscreenViewport;
  59940. private _getNextFrameBuffer;
  59941. /**
  59942. * Creates an effect renderer
  59943. * @param engine the engine to use for rendering
  59944. * @param options defines the options of the effect renderer
  59945. */
  59946. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59947. /**
  59948. * Sets the current viewport in normalized coordinates 0-1
  59949. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59950. */
  59951. setViewport(viewport?: Viewport): void;
  59952. /**
  59953. * Binds the embedded attributes buffer to the effect.
  59954. * @param effect Defines the effect to bind the attributes for
  59955. */
  59956. bindBuffers(effect: Effect): void;
  59957. /**
  59958. * Sets the current effect wrapper to use during draw.
  59959. * The effect needs to be ready before calling this api.
  59960. * This also sets the default full screen position attribute.
  59961. * @param effectWrapper Defines the effect to draw with
  59962. */
  59963. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59964. /**
  59965. * Draws a full screen quad.
  59966. */
  59967. draw(): void;
  59968. /**
  59969. * renders one or more effects to a specified texture
  59970. * @param effectWrappers list of effects to renderer
  59971. * @param outputTexture texture to draw to, if null it will render to the screen
  59972. */
  59973. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59974. /**
  59975. * Disposes of the effect renderer
  59976. */
  59977. dispose(): void;
  59978. }
  59979. /**
  59980. * Options to create an EffectWrapper
  59981. */
  59982. interface EffectWrapperCreationOptions {
  59983. /**
  59984. * Engine to use to create the effect
  59985. */
  59986. engine: ThinEngine;
  59987. /**
  59988. * Fragment shader for the effect
  59989. */
  59990. fragmentShader: string;
  59991. /**
  59992. * Vertex shader for the effect
  59993. */
  59994. vertexShader?: string;
  59995. /**
  59996. * Attributes to use in the shader
  59997. */
  59998. attributeNames?: Array<string>;
  59999. /**
  60000. * Uniforms to use in the shader
  60001. */
  60002. uniformNames?: Array<string>;
  60003. /**
  60004. * Texture sampler names to use in the shader
  60005. */
  60006. samplerNames?: Array<string>;
  60007. /**
  60008. * The friendly name of the effect displayed in Spector.
  60009. */
  60010. name?: string;
  60011. }
  60012. /**
  60013. * Wraps an effect to be used for rendering
  60014. */
  60015. export class EffectWrapper {
  60016. /**
  60017. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60018. */
  60019. onApplyObservable: Observable<{}>;
  60020. /**
  60021. * The underlying effect
  60022. */
  60023. effect: Effect;
  60024. /**
  60025. * Creates an effect to be renderer
  60026. * @param creationOptions options to create the effect
  60027. */
  60028. constructor(creationOptions: EffectWrapperCreationOptions);
  60029. /**
  60030. * Disposes of the effect wrapper
  60031. */
  60032. dispose(): void;
  60033. }
  60034. }
  60035. declare module "babylonjs/Materials/index" {
  60036. export * from "babylonjs/Materials/Background/index";
  60037. export * from "babylonjs/Materials/colorCurves";
  60038. export * from "babylonjs/Materials/iEffectFallbacks";
  60039. export * from "babylonjs/Materials/effectFallbacks";
  60040. export * from "babylonjs/Materials/effect";
  60041. export * from "babylonjs/Materials/fresnelParameters";
  60042. export * from "babylonjs/Materials/imageProcessingConfiguration";
  60043. export * from "babylonjs/Materials/material";
  60044. export * from "babylonjs/Materials/materialDefines";
  60045. export * from "babylonjs/Materials/materialHelper";
  60046. export * from "babylonjs/Materials/multiMaterial";
  60047. export * from "babylonjs/Materials/PBR/index";
  60048. export * from "babylonjs/Materials/pushMaterial";
  60049. export * from "babylonjs/Materials/shaderMaterial";
  60050. export * from "babylonjs/Materials/standardMaterial";
  60051. export * from "babylonjs/Materials/Textures/index";
  60052. export * from "babylonjs/Materials/uniformBuffer";
  60053. export * from "babylonjs/Materials/materialFlags";
  60054. export * from "babylonjs/Materials/Node/index";
  60055. export * from "babylonjs/Materials/effectRenderer";
  60056. }
  60057. declare module "babylonjs/Maths/index" {
  60058. export * from "babylonjs/Maths/math.scalar";
  60059. export * from "babylonjs/Maths/math";
  60060. export * from "babylonjs/Maths/sphericalPolynomial";
  60061. }
  60062. declare module "babylonjs/Misc/workerPool" {
  60063. import { IDisposable } from "babylonjs/scene";
  60064. /**
  60065. * Helper class to push actions to a pool of workers.
  60066. */
  60067. export class WorkerPool implements IDisposable {
  60068. private _workerInfos;
  60069. private _pendingActions;
  60070. /**
  60071. * Constructor
  60072. * @param workers Array of workers to use for actions
  60073. */
  60074. constructor(workers: Array<Worker>);
  60075. /**
  60076. * Terminates all workers and clears any pending actions.
  60077. */
  60078. dispose(): void;
  60079. /**
  60080. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60081. * pended until a worker has completed its action.
  60082. * @param action The action to perform. Call onComplete when the action is complete.
  60083. */
  60084. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60085. private _execute;
  60086. }
  60087. }
  60088. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  60089. import { IDisposable } from "babylonjs/scene";
  60090. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60091. /**
  60092. * Configuration for Draco compression
  60093. */
  60094. export interface IDracoCompressionConfiguration {
  60095. /**
  60096. * Configuration for the decoder.
  60097. */
  60098. decoder: {
  60099. /**
  60100. * The url to the WebAssembly module.
  60101. */
  60102. wasmUrl?: string;
  60103. /**
  60104. * The url to the WebAssembly binary.
  60105. */
  60106. wasmBinaryUrl?: string;
  60107. /**
  60108. * The url to the fallback JavaScript module.
  60109. */
  60110. fallbackUrl?: string;
  60111. };
  60112. }
  60113. /**
  60114. * Draco compression (https://google.github.io/draco/)
  60115. *
  60116. * This class wraps the Draco module.
  60117. *
  60118. * **Encoder**
  60119. *
  60120. * The encoder is not currently implemented.
  60121. *
  60122. * **Decoder**
  60123. *
  60124. * 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.
  60125. *
  60126. * To update the configuration, use the following code:
  60127. * ```javascript
  60128. * DracoCompression.Configuration = {
  60129. * decoder: {
  60130. * wasmUrl: "<url to the WebAssembly library>",
  60131. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60132. * fallbackUrl: "<url to the fallback JavaScript library>",
  60133. * }
  60134. * };
  60135. * ```
  60136. *
  60137. * 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.
  60138. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60139. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60140. *
  60141. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60142. * ```javascript
  60143. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60144. * ```
  60145. *
  60146. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60147. */
  60148. export class DracoCompression implements IDisposable {
  60149. private _workerPoolPromise?;
  60150. private _decoderModulePromise?;
  60151. /**
  60152. * The configuration. Defaults to the following urls:
  60153. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60154. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60155. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60156. */
  60157. static Configuration: IDracoCompressionConfiguration;
  60158. /**
  60159. * Returns true if the decoder configuration is available.
  60160. */
  60161. static readonly DecoderAvailable: boolean;
  60162. /**
  60163. * Default number of workers to create when creating the draco compression object.
  60164. */
  60165. static DefaultNumWorkers: number;
  60166. private static GetDefaultNumWorkers;
  60167. private static _Default;
  60168. /**
  60169. * Default instance for the draco compression object.
  60170. */
  60171. static readonly Default: DracoCompression;
  60172. /**
  60173. * Constructor
  60174. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60175. */
  60176. constructor(numWorkers?: number);
  60177. /**
  60178. * Stop all async operations and release resources.
  60179. */
  60180. dispose(): void;
  60181. /**
  60182. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60183. * @returns a promise that resolves when ready
  60184. */
  60185. whenReadyAsync(): Promise<void>;
  60186. /**
  60187. * Decode Draco compressed mesh data to vertex data.
  60188. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60189. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60190. * @returns A promise that resolves with the decoded vertex data
  60191. */
  60192. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60193. [kind: string]: number;
  60194. }): Promise<VertexData>;
  60195. }
  60196. }
  60197. declare module "babylonjs/Meshes/Compression/index" {
  60198. export * from "babylonjs/Meshes/Compression/dracoCompression";
  60199. }
  60200. declare module "babylonjs/Meshes/csg" {
  60201. import { Nullable } from "babylonjs/types";
  60202. import { Scene } from "babylonjs/scene";
  60203. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60204. import { Mesh } from "babylonjs/Meshes/mesh";
  60205. import { Material } from "babylonjs/Materials/material";
  60206. /**
  60207. * Class for building Constructive Solid Geometry
  60208. */
  60209. export class CSG {
  60210. private polygons;
  60211. /**
  60212. * The world matrix
  60213. */
  60214. matrix: Matrix;
  60215. /**
  60216. * Stores the position
  60217. */
  60218. position: Vector3;
  60219. /**
  60220. * Stores the rotation
  60221. */
  60222. rotation: Vector3;
  60223. /**
  60224. * Stores the rotation quaternion
  60225. */
  60226. rotationQuaternion: Nullable<Quaternion>;
  60227. /**
  60228. * Stores the scaling vector
  60229. */
  60230. scaling: Vector3;
  60231. /**
  60232. * Convert the Mesh to CSG
  60233. * @param mesh The Mesh to convert to CSG
  60234. * @returns A new CSG from the Mesh
  60235. */
  60236. static FromMesh(mesh: Mesh): CSG;
  60237. /**
  60238. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60239. * @param polygons Polygons used to construct a CSG solid
  60240. */
  60241. private static FromPolygons;
  60242. /**
  60243. * Clones, or makes a deep copy, of the CSG
  60244. * @returns A new CSG
  60245. */
  60246. clone(): CSG;
  60247. /**
  60248. * Unions this CSG with another CSG
  60249. * @param csg The CSG to union against this CSG
  60250. * @returns The unioned CSG
  60251. */
  60252. union(csg: CSG): CSG;
  60253. /**
  60254. * Unions this CSG with another CSG in place
  60255. * @param csg The CSG to union against this CSG
  60256. */
  60257. unionInPlace(csg: CSG): void;
  60258. /**
  60259. * Subtracts this CSG with another CSG
  60260. * @param csg The CSG to subtract against this CSG
  60261. * @returns A new CSG
  60262. */
  60263. subtract(csg: CSG): CSG;
  60264. /**
  60265. * Subtracts this CSG with another CSG in place
  60266. * @param csg The CSG to subtact against this CSG
  60267. */
  60268. subtractInPlace(csg: CSG): void;
  60269. /**
  60270. * Intersect this CSG with another CSG
  60271. * @param csg The CSG to intersect against this CSG
  60272. * @returns A new CSG
  60273. */
  60274. intersect(csg: CSG): CSG;
  60275. /**
  60276. * Intersects this CSG with another CSG in place
  60277. * @param csg The CSG to intersect against this CSG
  60278. */
  60279. intersectInPlace(csg: CSG): void;
  60280. /**
  60281. * Return a new CSG solid with solid and empty space switched. This solid is
  60282. * not modified.
  60283. * @returns A new CSG solid with solid and empty space switched
  60284. */
  60285. inverse(): CSG;
  60286. /**
  60287. * Inverses the CSG in place
  60288. */
  60289. inverseInPlace(): void;
  60290. /**
  60291. * This is used to keep meshes transformations so they can be restored
  60292. * when we build back a Babylon Mesh
  60293. * NB : All CSG operations are performed in world coordinates
  60294. * @param csg The CSG to copy the transform attributes from
  60295. * @returns This CSG
  60296. */
  60297. copyTransformAttributes(csg: CSG): CSG;
  60298. /**
  60299. * Build Raw mesh from CSG
  60300. * Coordinates here are in world space
  60301. * @param name The name of the mesh geometry
  60302. * @param scene The Scene
  60303. * @param keepSubMeshes Specifies if the submeshes should be kept
  60304. * @returns A new Mesh
  60305. */
  60306. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60307. /**
  60308. * Build Mesh from CSG taking material and transforms into account
  60309. * @param name The name of the Mesh
  60310. * @param material The material of the Mesh
  60311. * @param scene The Scene
  60312. * @param keepSubMeshes Specifies if submeshes should be kept
  60313. * @returns The new Mesh
  60314. */
  60315. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60316. }
  60317. }
  60318. declare module "babylonjs/Meshes/trailMesh" {
  60319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60320. import { Mesh } from "babylonjs/Meshes/mesh";
  60321. import { Scene } from "babylonjs/scene";
  60322. /**
  60323. * Class used to create a trail following a mesh
  60324. */
  60325. export class TrailMesh extends Mesh {
  60326. private _generator;
  60327. private _autoStart;
  60328. private _running;
  60329. private _diameter;
  60330. private _length;
  60331. private _sectionPolygonPointsCount;
  60332. private _sectionVectors;
  60333. private _sectionNormalVectors;
  60334. private _beforeRenderObserver;
  60335. /**
  60336. * @constructor
  60337. * @param name The value used by scene.getMeshByName() to do a lookup.
  60338. * @param generator The mesh to generate a trail.
  60339. * @param scene The scene to add this mesh to.
  60340. * @param diameter Diameter of trailing mesh. Default is 1.
  60341. * @param length Length of trailing mesh. Default is 60.
  60342. * @param autoStart Automatically start trailing mesh. Default true.
  60343. */
  60344. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60345. /**
  60346. * "TrailMesh"
  60347. * @returns "TrailMesh"
  60348. */
  60349. getClassName(): string;
  60350. private _createMesh;
  60351. /**
  60352. * Start trailing mesh.
  60353. */
  60354. start(): void;
  60355. /**
  60356. * Stop trailing mesh.
  60357. */
  60358. stop(): void;
  60359. /**
  60360. * Update trailing mesh geometry.
  60361. */
  60362. update(): void;
  60363. /**
  60364. * Returns a new TrailMesh object.
  60365. * @param name is a string, the name given to the new mesh
  60366. * @param newGenerator use new generator object for cloned trail mesh
  60367. * @returns a new mesh
  60368. */
  60369. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60370. /**
  60371. * Serializes this trail mesh
  60372. * @param serializationObject object to write serialization to
  60373. */
  60374. serialize(serializationObject: any): void;
  60375. /**
  60376. * Parses a serialized trail mesh
  60377. * @param parsedMesh the serialized mesh
  60378. * @param scene the scene to create the trail mesh in
  60379. * @returns the created trail mesh
  60380. */
  60381. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60382. }
  60383. }
  60384. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  60385. import { Nullable } from "babylonjs/types";
  60386. import { Scene } from "babylonjs/scene";
  60387. import { Vector4 } from "babylonjs/Maths/math.vector";
  60388. import { Color4 } from "babylonjs/Maths/math.color";
  60389. import { Mesh } from "babylonjs/Meshes/mesh";
  60390. /**
  60391. * Class containing static functions to help procedurally build meshes
  60392. */
  60393. export class TiledBoxBuilder {
  60394. /**
  60395. * Creates a box mesh
  60396. * 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)
  60397. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60401. * @param name defines the name of the mesh
  60402. * @param options defines the options used to create the mesh
  60403. * @param scene defines the hosting scene
  60404. * @returns the box mesh
  60405. */
  60406. static CreateTiledBox(name: string, options: {
  60407. pattern?: number;
  60408. width?: number;
  60409. height?: number;
  60410. depth?: number;
  60411. tileSize?: number;
  60412. tileWidth?: number;
  60413. tileHeight?: number;
  60414. alignHorizontal?: number;
  60415. alignVertical?: number;
  60416. faceUV?: Vector4[];
  60417. faceColors?: Color4[];
  60418. sideOrientation?: number;
  60419. updatable?: boolean;
  60420. }, scene?: Nullable<Scene>): Mesh;
  60421. }
  60422. }
  60423. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  60424. import { Vector4 } from "babylonjs/Maths/math.vector";
  60425. import { Mesh } from "babylonjs/Meshes/mesh";
  60426. /**
  60427. * Class containing static functions to help procedurally build meshes
  60428. */
  60429. export class TorusKnotBuilder {
  60430. /**
  60431. * Creates a torus knot mesh
  60432. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60433. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60434. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60435. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60439. * @param name defines the name of the mesh
  60440. * @param options defines the options used to create the mesh
  60441. * @param scene defines the hosting scene
  60442. * @returns the torus knot mesh
  60443. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60444. */
  60445. static CreateTorusKnot(name: string, options: {
  60446. radius?: number;
  60447. tube?: number;
  60448. radialSegments?: number;
  60449. tubularSegments?: number;
  60450. p?: number;
  60451. q?: number;
  60452. updatable?: boolean;
  60453. sideOrientation?: number;
  60454. frontUVs?: Vector4;
  60455. backUVs?: Vector4;
  60456. }, scene: any): Mesh;
  60457. }
  60458. }
  60459. declare module "babylonjs/Meshes/polygonMesh" {
  60460. import { Scene } from "babylonjs/scene";
  60461. import { Vector2 } from "babylonjs/Maths/math.vector";
  60462. import { Mesh } from "babylonjs/Meshes/mesh";
  60463. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60464. import { Path2 } from "babylonjs/Maths/math.path";
  60465. /**
  60466. * Polygon
  60467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60468. */
  60469. export class Polygon {
  60470. /**
  60471. * Creates a rectangle
  60472. * @param xmin bottom X coord
  60473. * @param ymin bottom Y coord
  60474. * @param xmax top X coord
  60475. * @param ymax top Y coord
  60476. * @returns points that make the resulting rectation
  60477. */
  60478. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60479. /**
  60480. * Creates a circle
  60481. * @param radius radius of circle
  60482. * @param cx scale in x
  60483. * @param cy scale in y
  60484. * @param numberOfSides number of sides that make up the circle
  60485. * @returns points that make the resulting circle
  60486. */
  60487. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60488. /**
  60489. * Creates a polygon from input string
  60490. * @param input Input polygon data
  60491. * @returns the parsed points
  60492. */
  60493. static Parse(input: string): Vector2[];
  60494. /**
  60495. * Starts building a polygon from x and y coordinates
  60496. * @param x x coordinate
  60497. * @param y y coordinate
  60498. * @returns the started path2
  60499. */
  60500. static StartingAt(x: number, y: number): Path2;
  60501. }
  60502. /**
  60503. * Builds a polygon
  60504. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60505. */
  60506. export class PolygonMeshBuilder {
  60507. private _points;
  60508. private _outlinepoints;
  60509. private _holes;
  60510. private _name;
  60511. private _scene;
  60512. private _epoints;
  60513. private _eholes;
  60514. private _addToepoint;
  60515. /**
  60516. * Babylon reference to the earcut plugin.
  60517. */
  60518. bjsEarcut: any;
  60519. /**
  60520. * Creates a PolygonMeshBuilder
  60521. * @param name name of the builder
  60522. * @param contours Path of the polygon
  60523. * @param scene scene to add to when creating the mesh
  60524. * @param earcutInjection can be used to inject your own earcut reference
  60525. */
  60526. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60527. /**
  60528. * Adds a whole within the polygon
  60529. * @param hole Array of points defining the hole
  60530. * @returns this
  60531. */
  60532. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60533. /**
  60534. * Creates the polygon
  60535. * @param updatable If the mesh should be updatable
  60536. * @param depth The depth of the mesh created
  60537. * @returns the created mesh
  60538. */
  60539. build(updatable?: boolean, depth?: number): Mesh;
  60540. /**
  60541. * Creates the polygon
  60542. * @param depth The depth of the mesh created
  60543. * @returns the created VertexData
  60544. */
  60545. buildVertexData(depth?: number): VertexData;
  60546. /**
  60547. * Adds a side to the polygon
  60548. * @param positions points that make the polygon
  60549. * @param normals normals of the polygon
  60550. * @param uvs uvs of the polygon
  60551. * @param indices indices of the polygon
  60552. * @param bounds bounds of the polygon
  60553. * @param points points of the polygon
  60554. * @param depth depth of the polygon
  60555. * @param flip flip of the polygon
  60556. */
  60557. private addSide;
  60558. }
  60559. }
  60560. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60561. import { Scene } from "babylonjs/scene";
  60562. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60563. import { Color4 } from "babylonjs/Maths/math.color";
  60564. import { Mesh } from "babylonjs/Meshes/mesh";
  60565. import { Nullable } from "babylonjs/types";
  60566. /**
  60567. * Class containing static functions to help procedurally build meshes
  60568. */
  60569. export class PolygonBuilder {
  60570. /**
  60571. * Creates a polygon mesh
  60572. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60573. * * 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
  60574. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60577. * * Remember you can only change the shape positions, not their number when updating a polygon
  60578. * @param name defines the name of the mesh
  60579. * @param options defines the options used to create the mesh
  60580. * @param scene defines the hosting scene
  60581. * @param earcutInjection can be used to inject your own earcut reference
  60582. * @returns the polygon mesh
  60583. */
  60584. static CreatePolygon(name: string, options: {
  60585. shape: Vector3[];
  60586. holes?: Vector3[][];
  60587. depth?: number;
  60588. faceUV?: Vector4[];
  60589. faceColors?: Color4[];
  60590. updatable?: boolean;
  60591. sideOrientation?: number;
  60592. frontUVs?: Vector4;
  60593. backUVs?: Vector4;
  60594. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60595. /**
  60596. * Creates an extruded polygon mesh, with depth in the Y direction.
  60597. * * 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)
  60598. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60599. * @param name defines the name of the mesh
  60600. * @param options defines the options used to create the mesh
  60601. * @param scene defines the hosting scene
  60602. * @param earcutInjection can be used to inject your own earcut reference
  60603. * @returns the polygon mesh
  60604. */
  60605. static ExtrudePolygon(name: string, options: {
  60606. shape: Vector3[];
  60607. holes?: Vector3[][];
  60608. depth?: number;
  60609. faceUV?: Vector4[];
  60610. faceColors?: Color4[];
  60611. updatable?: boolean;
  60612. sideOrientation?: number;
  60613. frontUVs?: Vector4;
  60614. backUVs?: Vector4;
  60615. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60616. }
  60617. }
  60618. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60619. import { Scene } from "babylonjs/scene";
  60620. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60621. import { Mesh } from "babylonjs/Meshes/mesh";
  60622. import { Nullable } from "babylonjs/types";
  60623. /**
  60624. * Class containing static functions to help procedurally build meshes
  60625. */
  60626. export class LatheBuilder {
  60627. /**
  60628. * Creates lathe mesh.
  60629. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60630. * * 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
  60631. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60632. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60633. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60634. * * 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
  60635. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60636. * * 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
  60637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60641. * @param name defines the name of the mesh
  60642. * @param options defines the options used to create the mesh
  60643. * @param scene defines the hosting scene
  60644. * @returns the lathe mesh
  60645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60646. */
  60647. static CreateLathe(name: string, options: {
  60648. shape: Vector3[];
  60649. radius?: number;
  60650. tessellation?: number;
  60651. clip?: number;
  60652. arc?: number;
  60653. closed?: boolean;
  60654. updatable?: boolean;
  60655. sideOrientation?: number;
  60656. frontUVs?: Vector4;
  60657. backUVs?: Vector4;
  60658. cap?: number;
  60659. invertUV?: boolean;
  60660. }, scene?: Nullable<Scene>): Mesh;
  60661. }
  60662. }
  60663. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60664. import { Nullable } from "babylonjs/types";
  60665. import { Scene } from "babylonjs/scene";
  60666. import { Vector4 } from "babylonjs/Maths/math.vector";
  60667. import { Mesh } from "babylonjs/Meshes/mesh";
  60668. /**
  60669. * Class containing static functions to help procedurally build meshes
  60670. */
  60671. export class TiledPlaneBuilder {
  60672. /**
  60673. * Creates a tiled plane mesh
  60674. * * The parameter `pattern` will, depending on value, do nothing or
  60675. * * * flip (reflect about central vertical) alternate tiles across and up
  60676. * * * flip every tile on alternate rows
  60677. * * * rotate (180 degs) alternate tiles across and up
  60678. * * * rotate every tile on alternate rows
  60679. * * * flip and rotate alternate tiles across and up
  60680. * * * flip and rotate every tile on alternate rows
  60681. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60682. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60684. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60685. * * 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)
  60686. * * 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)
  60687. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60688. * @param name defines the name of the mesh
  60689. * @param options defines the options used to create the mesh
  60690. * @param scene defines the hosting scene
  60691. * @returns the box mesh
  60692. */
  60693. static CreateTiledPlane(name: string, options: {
  60694. pattern?: number;
  60695. tileSize?: number;
  60696. tileWidth?: number;
  60697. tileHeight?: number;
  60698. size?: number;
  60699. width?: number;
  60700. height?: number;
  60701. alignHorizontal?: number;
  60702. alignVertical?: number;
  60703. sideOrientation?: number;
  60704. frontUVs?: Vector4;
  60705. backUVs?: Vector4;
  60706. updatable?: boolean;
  60707. }, scene?: Nullable<Scene>): Mesh;
  60708. }
  60709. }
  60710. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60711. import { Nullable } from "babylonjs/types";
  60712. import { Scene } from "babylonjs/scene";
  60713. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60714. import { Mesh } from "babylonjs/Meshes/mesh";
  60715. /**
  60716. * Class containing static functions to help procedurally build meshes
  60717. */
  60718. export class TubeBuilder {
  60719. /**
  60720. * Creates a tube mesh.
  60721. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60722. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60723. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60724. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60725. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60726. * * 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)
  60727. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60728. * * 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
  60729. * * 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
  60730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60732. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60734. * @param name defines the name of the mesh
  60735. * @param options defines the options used to create the mesh
  60736. * @param scene defines the hosting scene
  60737. * @returns the tube mesh
  60738. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60739. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60740. */
  60741. static CreateTube(name: string, options: {
  60742. path: Vector3[];
  60743. radius?: number;
  60744. tessellation?: number;
  60745. radiusFunction?: {
  60746. (i: number, distance: number): number;
  60747. };
  60748. cap?: number;
  60749. arc?: number;
  60750. updatable?: boolean;
  60751. sideOrientation?: number;
  60752. frontUVs?: Vector4;
  60753. backUVs?: Vector4;
  60754. instance?: Mesh;
  60755. invertUV?: boolean;
  60756. }, scene?: Nullable<Scene>): Mesh;
  60757. }
  60758. }
  60759. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60760. import { Scene } from "babylonjs/scene";
  60761. import { Vector4 } from "babylonjs/Maths/math.vector";
  60762. import { Mesh } from "babylonjs/Meshes/mesh";
  60763. import { Nullable } from "babylonjs/types";
  60764. /**
  60765. * Class containing static functions to help procedurally build meshes
  60766. */
  60767. export class IcoSphereBuilder {
  60768. /**
  60769. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60770. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60771. * * 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`)
  60772. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60773. * * 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
  60774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60777. * @param name defines the name of the mesh
  60778. * @param options defines the options used to create the mesh
  60779. * @param scene defines the hosting scene
  60780. * @returns the icosahedron mesh
  60781. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60782. */
  60783. static CreateIcoSphere(name: string, options: {
  60784. radius?: number;
  60785. radiusX?: number;
  60786. radiusY?: number;
  60787. radiusZ?: number;
  60788. flat?: boolean;
  60789. subdivisions?: number;
  60790. sideOrientation?: number;
  60791. frontUVs?: Vector4;
  60792. backUVs?: Vector4;
  60793. updatable?: boolean;
  60794. }, scene?: Nullable<Scene>): Mesh;
  60795. }
  60796. }
  60797. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60798. import { Vector3 } from "babylonjs/Maths/math.vector";
  60799. import { Mesh } from "babylonjs/Meshes/mesh";
  60800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60801. /**
  60802. * Class containing static functions to help procedurally build meshes
  60803. */
  60804. export class DecalBuilder {
  60805. /**
  60806. * Creates a decal mesh.
  60807. * 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
  60808. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60809. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60810. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60811. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60812. * @param name defines the name of the mesh
  60813. * @param sourceMesh defines the mesh where the decal must be applied
  60814. * @param options defines the options used to create the mesh
  60815. * @param scene defines the hosting scene
  60816. * @returns the decal mesh
  60817. * @see https://doc.babylonjs.com/how_to/decals
  60818. */
  60819. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60820. position?: Vector3;
  60821. normal?: Vector3;
  60822. size?: Vector3;
  60823. angle?: number;
  60824. }): Mesh;
  60825. }
  60826. }
  60827. declare module "babylonjs/Meshes/meshBuilder" {
  60828. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60829. import { Nullable } from "babylonjs/types";
  60830. import { Scene } from "babylonjs/scene";
  60831. import { Mesh } from "babylonjs/Meshes/mesh";
  60832. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60833. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60835. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60836. import { Plane } from "babylonjs/Maths/math.plane";
  60837. /**
  60838. * Class containing static functions to help procedurally build meshes
  60839. */
  60840. export class MeshBuilder {
  60841. /**
  60842. * Creates a box mesh
  60843. * * The parameter `size` sets the size (float) of each box side (default 1)
  60844. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60845. * * 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)
  60846. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60850. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60851. * @param name defines the name of the mesh
  60852. * @param options defines the options used to create the mesh
  60853. * @param scene defines the hosting scene
  60854. * @returns the box mesh
  60855. */
  60856. static CreateBox(name: string, options: {
  60857. size?: number;
  60858. width?: number;
  60859. height?: number;
  60860. depth?: number;
  60861. faceUV?: Vector4[];
  60862. faceColors?: Color4[];
  60863. sideOrientation?: number;
  60864. frontUVs?: Vector4;
  60865. backUVs?: Vector4;
  60866. updatable?: boolean;
  60867. }, scene?: Nullable<Scene>): Mesh;
  60868. /**
  60869. * Creates a tiled box mesh
  60870. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60872. * @param name defines the name of the mesh
  60873. * @param options defines the options used to create the mesh
  60874. * @param scene defines the hosting scene
  60875. * @returns the tiled box mesh
  60876. */
  60877. static CreateTiledBox(name: string, options: {
  60878. pattern?: number;
  60879. size?: number;
  60880. width?: number;
  60881. height?: number;
  60882. depth: number;
  60883. tileSize?: number;
  60884. tileWidth?: number;
  60885. tileHeight?: number;
  60886. faceUV?: Vector4[];
  60887. faceColors?: Color4[];
  60888. alignHorizontal?: number;
  60889. alignVertical?: number;
  60890. sideOrientation?: number;
  60891. updatable?: boolean;
  60892. }, scene?: Nullable<Scene>): Mesh;
  60893. /**
  60894. * Creates a sphere mesh
  60895. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60896. * * 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`)
  60897. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60898. * * 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
  60899. * * 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)
  60900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60903. * @param name defines the name of the mesh
  60904. * @param options defines the options used to create the mesh
  60905. * @param scene defines the hosting scene
  60906. * @returns the sphere mesh
  60907. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60908. */
  60909. static CreateSphere(name: string, options: {
  60910. segments?: number;
  60911. diameter?: number;
  60912. diameterX?: number;
  60913. diameterY?: number;
  60914. diameterZ?: number;
  60915. arc?: number;
  60916. slice?: number;
  60917. sideOrientation?: number;
  60918. frontUVs?: Vector4;
  60919. backUVs?: Vector4;
  60920. updatable?: boolean;
  60921. }, scene?: Nullable<Scene>): Mesh;
  60922. /**
  60923. * Creates a plane polygonal mesh. By default, this is a disc
  60924. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60925. * * 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
  60926. * * 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
  60927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60930. * @param name defines the name of the mesh
  60931. * @param options defines the options used to create the mesh
  60932. * @param scene defines the hosting scene
  60933. * @returns the plane polygonal mesh
  60934. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60935. */
  60936. static CreateDisc(name: string, options: {
  60937. radius?: number;
  60938. tessellation?: number;
  60939. arc?: number;
  60940. updatable?: boolean;
  60941. sideOrientation?: number;
  60942. frontUVs?: Vector4;
  60943. backUVs?: Vector4;
  60944. }, scene?: Nullable<Scene>): Mesh;
  60945. /**
  60946. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60947. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60948. * * 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`)
  60949. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60950. * * 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
  60951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60954. * @param name defines the name of the mesh
  60955. * @param options defines the options used to create the mesh
  60956. * @param scene defines the hosting scene
  60957. * @returns the icosahedron mesh
  60958. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60959. */
  60960. static CreateIcoSphere(name: string, options: {
  60961. radius?: number;
  60962. radiusX?: number;
  60963. radiusY?: number;
  60964. radiusZ?: number;
  60965. flat?: boolean;
  60966. subdivisions?: number;
  60967. sideOrientation?: number;
  60968. frontUVs?: Vector4;
  60969. backUVs?: Vector4;
  60970. updatable?: boolean;
  60971. }, scene?: Nullable<Scene>): Mesh;
  60972. /**
  60973. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60974. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60975. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60976. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60977. * * 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
  60978. * * 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
  60979. * * 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
  60980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60983. * * 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
  60984. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60985. * * 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
  60986. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60988. * @param name defines the name of the mesh
  60989. * @param options defines the options used to create the mesh
  60990. * @param scene defines the hosting scene
  60991. * @returns the ribbon mesh
  60992. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60994. */
  60995. static CreateRibbon(name: string, options: {
  60996. pathArray: Vector3[][];
  60997. closeArray?: boolean;
  60998. closePath?: boolean;
  60999. offset?: number;
  61000. updatable?: boolean;
  61001. sideOrientation?: number;
  61002. frontUVs?: Vector4;
  61003. backUVs?: Vector4;
  61004. instance?: Mesh;
  61005. invertUV?: boolean;
  61006. uvs?: Vector2[];
  61007. colors?: Color4[];
  61008. }, scene?: Nullable<Scene>): Mesh;
  61009. /**
  61010. * Creates a cylinder or a cone mesh
  61011. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61012. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61013. * * 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.
  61014. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61015. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61016. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61017. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61018. * * 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).
  61019. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61020. * * 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).
  61021. * * 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
  61022. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61023. * * 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
  61024. * * 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.
  61025. * * If `enclose` is false, a ring surface is one element.
  61026. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61027. * * 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
  61028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61031. * @param name defines the name of the mesh
  61032. * @param options defines the options used to create the mesh
  61033. * @param scene defines the hosting scene
  61034. * @returns the cylinder mesh
  61035. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61036. */
  61037. static CreateCylinder(name: string, options: {
  61038. height?: number;
  61039. diameterTop?: number;
  61040. diameterBottom?: number;
  61041. diameter?: number;
  61042. tessellation?: number;
  61043. subdivisions?: number;
  61044. arc?: number;
  61045. faceColors?: Color4[];
  61046. faceUV?: Vector4[];
  61047. updatable?: boolean;
  61048. hasRings?: boolean;
  61049. enclose?: boolean;
  61050. cap?: number;
  61051. sideOrientation?: number;
  61052. frontUVs?: Vector4;
  61053. backUVs?: Vector4;
  61054. }, scene?: Nullable<Scene>): Mesh;
  61055. /**
  61056. * Creates a torus mesh
  61057. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61058. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61059. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61063. * @param name defines the name of the mesh
  61064. * @param options defines the options used to create the mesh
  61065. * @param scene defines the hosting scene
  61066. * @returns the torus mesh
  61067. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61068. */
  61069. static CreateTorus(name: string, options: {
  61070. diameter?: number;
  61071. thickness?: number;
  61072. tessellation?: number;
  61073. updatable?: boolean;
  61074. sideOrientation?: number;
  61075. frontUVs?: Vector4;
  61076. backUVs?: Vector4;
  61077. }, scene?: Nullable<Scene>): Mesh;
  61078. /**
  61079. * Creates a torus knot mesh
  61080. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61081. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61082. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61083. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61087. * @param name defines the name of the mesh
  61088. * @param options defines the options used to create the mesh
  61089. * @param scene defines the hosting scene
  61090. * @returns the torus knot mesh
  61091. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61092. */
  61093. static CreateTorusKnot(name: string, options: {
  61094. radius?: number;
  61095. tube?: number;
  61096. radialSegments?: number;
  61097. tubularSegments?: number;
  61098. p?: number;
  61099. q?: number;
  61100. updatable?: boolean;
  61101. sideOrientation?: number;
  61102. frontUVs?: Vector4;
  61103. backUVs?: Vector4;
  61104. }, scene?: Nullable<Scene>): Mesh;
  61105. /**
  61106. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61107. * * 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
  61108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61109. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61110. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61111. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61112. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61113. * * 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
  61114. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61117. * @param name defines the name of the new line system
  61118. * @param options defines the options used to create the line system
  61119. * @param scene defines the hosting scene
  61120. * @returns a new line system mesh
  61121. */
  61122. static CreateLineSystem(name: string, options: {
  61123. lines: Vector3[][];
  61124. updatable?: boolean;
  61125. instance?: Nullable<LinesMesh>;
  61126. colors?: Nullable<Color4[][]>;
  61127. useVertexAlpha?: boolean;
  61128. }, scene: Nullable<Scene>): LinesMesh;
  61129. /**
  61130. * Creates a line mesh
  61131. * 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
  61132. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61133. * * The parameter `points` is an array successive Vector3
  61134. * * 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
  61135. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61136. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61137. * * When updating an instance, remember that only point positions can change, not the number of points
  61138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61140. * @param name defines the name of the new line system
  61141. * @param options defines the options used to create the line system
  61142. * @param scene defines the hosting scene
  61143. * @returns a new line mesh
  61144. */
  61145. static CreateLines(name: string, options: {
  61146. points: Vector3[];
  61147. updatable?: boolean;
  61148. instance?: Nullable<LinesMesh>;
  61149. colors?: Color4[];
  61150. useVertexAlpha?: boolean;
  61151. }, scene?: Nullable<Scene>): LinesMesh;
  61152. /**
  61153. * Creates a dashed line mesh
  61154. * * 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
  61155. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61156. * * The parameter `points` is an array successive Vector3
  61157. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61158. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61159. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61160. * * 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
  61161. * * When updating an instance, remember that only point positions can change, not the number of points
  61162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61163. * @param name defines the name of the mesh
  61164. * @param options defines the options used to create the mesh
  61165. * @param scene defines the hosting scene
  61166. * @returns the dashed line mesh
  61167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61168. */
  61169. static CreateDashedLines(name: string, options: {
  61170. points: Vector3[];
  61171. dashSize?: number;
  61172. gapSize?: number;
  61173. dashNb?: number;
  61174. updatable?: boolean;
  61175. instance?: LinesMesh;
  61176. }, scene?: Nullable<Scene>): LinesMesh;
  61177. /**
  61178. * 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.
  61179. * * 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.
  61180. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61181. * * 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.
  61182. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61183. * * 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
  61184. * * 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
  61185. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61190. * @param name defines the name of the mesh
  61191. * @param options defines the options used to create the mesh
  61192. * @param scene defines the hosting scene
  61193. * @returns the extruded shape mesh
  61194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61196. */
  61197. static ExtrudeShape(name: string, options: {
  61198. shape: Vector3[];
  61199. path: Vector3[];
  61200. scale?: number;
  61201. rotation?: number;
  61202. cap?: number;
  61203. updatable?: boolean;
  61204. sideOrientation?: number;
  61205. frontUVs?: Vector4;
  61206. backUVs?: Vector4;
  61207. instance?: Mesh;
  61208. invertUV?: boolean;
  61209. }, scene?: Nullable<Scene>): Mesh;
  61210. /**
  61211. * Creates an custom extruded shape mesh.
  61212. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61213. * * 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.
  61214. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61215. * * 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
  61216. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61217. * * 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
  61218. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61219. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61220. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61221. * * 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
  61222. * * 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
  61223. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61228. * @param name defines the name of the mesh
  61229. * @param options defines the options used to create the mesh
  61230. * @param scene defines the hosting scene
  61231. * @returns the custom extruded shape mesh
  61232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61235. */
  61236. static ExtrudeShapeCustom(name: string, options: {
  61237. shape: Vector3[];
  61238. path: Vector3[];
  61239. scaleFunction?: any;
  61240. rotationFunction?: any;
  61241. ribbonCloseArray?: boolean;
  61242. ribbonClosePath?: boolean;
  61243. cap?: number;
  61244. updatable?: boolean;
  61245. sideOrientation?: number;
  61246. frontUVs?: Vector4;
  61247. backUVs?: Vector4;
  61248. instance?: Mesh;
  61249. invertUV?: boolean;
  61250. }, scene?: Nullable<Scene>): Mesh;
  61251. /**
  61252. * Creates lathe mesh.
  61253. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61254. * * 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
  61255. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61256. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61257. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61258. * * 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
  61259. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61260. * * 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
  61261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61263. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61265. * @param name defines the name of the mesh
  61266. * @param options defines the options used to create the mesh
  61267. * @param scene defines the hosting scene
  61268. * @returns the lathe mesh
  61269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61270. */
  61271. static CreateLathe(name: string, options: {
  61272. shape: Vector3[];
  61273. radius?: number;
  61274. tessellation?: number;
  61275. clip?: number;
  61276. arc?: number;
  61277. closed?: boolean;
  61278. updatable?: boolean;
  61279. sideOrientation?: number;
  61280. frontUVs?: Vector4;
  61281. backUVs?: Vector4;
  61282. cap?: number;
  61283. invertUV?: boolean;
  61284. }, scene?: Nullable<Scene>): Mesh;
  61285. /**
  61286. * Creates a tiled plane mesh
  61287. * * You can set a limited pattern arrangement with the tiles
  61288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61291. * @param name defines the name of the mesh
  61292. * @param options defines the options used to create the mesh
  61293. * @param scene defines the hosting scene
  61294. * @returns the plane mesh
  61295. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61296. */
  61297. static CreateTiledPlane(name: string, options: {
  61298. pattern?: number;
  61299. tileSize?: number;
  61300. tileWidth?: number;
  61301. tileHeight?: number;
  61302. size?: number;
  61303. width?: number;
  61304. height?: number;
  61305. alignHorizontal?: number;
  61306. alignVertical?: number;
  61307. sideOrientation?: number;
  61308. frontUVs?: Vector4;
  61309. backUVs?: Vector4;
  61310. updatable?: boolean;
  61311. }, scene?: Nullable<Scene>): Mesh;
  61312. /**
  61313. * Creates a plane mesh
  61314. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61315. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61316. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61320. * @param name defines the name of the mesh
  61321. * @param options defines the options used to create the mesh
  61322. * @param scene defines the hosting scene
  61323. * @returns the plane mesh
  61324. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61325. */
  61326. static CreatePlane(name: string, options: {
  61327. size?: number;
  61328. width?: number;
  61329. height?: number;
  61330. sideOrientation?: number;
  61331. frontUVs?: Vector4;
  61332. backUVs?: Vector4;
  61333. updatable?: boolean;
  61334. sourcePlane?: Plane;
  61335. }, scene?: Nullable<Scene>): Mesh;
  61336. /**
  61337. * Creates a ground mesh
  61338. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61339. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61341. * @param name defines the name of the mesh
  61342. * @param options defines the options used to create the mesh
  61343. * @param scene defines the hosting scene
  61344. * @returns the ground mesh
  61345. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61346. */
  61347. static CreateGround(name: string, options: {
  61348. width?: number;
  61349. height?: number;
  61350. subdivisions?: number;
  61351. subdivisionsX?: number;
  61352. subdivisionsY?: number;
  61353. updatable?: boolean;
  61354. }, scene?: Nullable<Scene>): Mesh;
  61355. /**
  61356. * Creates a tiled ground mesh
  61357. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61358. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61359. * * 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
  61360. * * 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
  61361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61362. * @param name defines the name of the mesh
  61363. * @param options defines the options used to create the mesh
  61364. * @param scene defines the hosting scene
  61365. * @returns the tiled ground mesh
  61366. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61367. */
  61368. static CreateTiledGround(name: string, options: {
  61369. xmin: number;
  61370. zmin: number;
  61371. xmax: number;
  61372. zmax: number;
  61373. subdivisions?: {
  61374. w: number;
  61375. h: number;
  61376. };
  61377. precision?: {
  61378. w: number;
  61379. h: number;
  61380. };
  61381. updatable?: boolean;
  61382. }, scene?: Nullable<Scene>): Mesh;
  61383. /**
  61384. * Creates a ground mesh from a height map
  61385. * * The parameter `url` sets the URL of the height map image resource.
  61386. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61387. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61388. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61389. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61390. * * 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.
  61391. * * 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).
  61392. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61394. * @param name defines the name of the mesh
  61395. * @param url defines the url to the height map
  61396. * @param options defines the options used to create the mesh
  61397. * @param scene defines the hosting scene
  61398. * @returns the ground mesh
  61399. * @see https://doc.babylonjs.com/babylon101/height_map
  61400. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61401. */
  61402. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61403. width?: number;
  61404. height?: number;
  61405. subdivisions?: number;
  61406. minHeight?: number;
  61407. maxHeight?: number;
  61408. colorFilter?: Color3;
  61409. alphaFilter?: number;
  61410. updatable?: boolean;
  61411. onReady?: (mesh: GroundMesh) => void;
  61412. }, scene?: Nullable<Scene>): GroundMesh;
  61413. /**
  61414. * Creates a polygon mesh
  61415. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61416. * * 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
  61417. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61420. * * Remember you can only change the shape positions, not their number when updating a polygon
  61421. * @param name defines the name of the mesh
  61422. * @param options defines the options used to create the mesh
  61423. * @param scene defines the hosting scene
  61424. * @param earcutInjection can be used to inject your own earcut reference
  61425. * @returns the polygon mesh
  61426. */
  61427. static CreatePolygon(name: string, options: {
  61428. shape: Vector3[];
  61429. holes?: Vector3[][];
  61430. depth?: number;
  61431. faceUV?: Vector4[];
  61432. faceColors?: Color4[];
  61433. updatable?: boolean;
  61434. sideOrientation?: number;
  61435. frontUVs?: Vector4;
  61436. backUVs?: Vector4;
  61437. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61438. /**
  61439. * Creates an extruded polygon mesh, with depth in the Y direction.
  61440. * * 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)
  61441. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61442. * @param name defines the name of the mesh
  61443. * @param options defines the options used to create the mesh
  61444. * @param scene defines the hosting scene
  61445. * @param earcutInjection can be used to inject your own earcut reference
  61446. * @returns the polygon mesh
  61447. */
  61448. static ExtrudePolygon(name: string, options: {
  61449. shape: Vector3[];
  61450. holes?: Vector3[][];
  61451. depth?: number;
  61452. faceUV?: Vector4[];
  61453. faceColors?: Color4[];
  61454. updatable?: boolean;
  61455. sideOrientation?: number;
  61456. frontUVs?: Vector4;
  61457. backUVs?: Vector4;
  61458. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61459. /**
  61460. * Creates a tube mesh.
  61461. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61462. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61463. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61464. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61465. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61466. * * 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)
  61467. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61468. * * 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
  61469. * * 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
  61470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61472. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61474. * @param name defines the name of the mesh
  61475. * @param options defines the options used to create the mesh
  61476. * @param scene defines the hosting scene
  61477. * @returns the tube mesh
  61478. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61479. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61480. */
  61481. static CreateTube(name: string, options: {
  61482. path: Vector3[];
  61483. radius?: number;
  61484. tessellation?: number;
  61485. radiusFunction?: {
  61486. (i: number, distance: number): number;
  61487. };
  61488. cap?: number;
  61489. arc?: number;
  61490. updatable?: boolean;
  61491. sideOrientation?: number;
  61492. frontUVs?: Vector4;
  61493. backUVs?: Vector4;
  61494. instance?: Mesh;
  61495. invertUV?: boolean;
  61496. }, scene?: Nullable<Scene>): Mesh;
  61497. /**
  61498. * Creates a polyhedron mesh
  61499. * * 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
  61500. * * The parameter `size` (positive float, default 1) sets the polygon size
  61501. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61502. * * 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`
  61503. * * 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
  61504. * * 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)`)
  61505. * * 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
  61506. * * 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
  61507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61510. * @param name defines the name of the mesh
  61511. * @param options defines the options used to create the mesh
  61512. * @param scene defines the hosting scene
  61513. * @returns the polyhedron mesh
  61514. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61515. */
  61516. static CreatePolyhedron(name: string, options: {
  61517. type?: number;
  61518. size?: number;
  61519. sizeX?: number;
  61520. sizeY?: number;
  61521. sizeZ?: number;
  61522. custom?: any;
  61523. faceUV?: Vector4[];
  61524. faceColors?: Color4[];
  61525. flat?: boolean;
  61526. updatable?: boolean;
  61527. sideOrientation?: number;
  61528. frontUVs?: Vector4;
  61529. backUVs?: Vector4;
  61530. }, scene?: Nullable<Scene>): Mesh;
  61531. /**
  61532. * Creates a decal mesh.
  61533. * 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
  61534. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61535. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61536. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61537. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61538. * @param name defines the name of the mesh
  61539. * @param sourceMesh defines the mesh where the decal must be applied
  61540. * @param options defines the options used to create the mesh
  61541. * @param scene defines the hosting scene
  61542. * @returns the decal mesh
  61543. * @see https://doc.babylonjs.com/how_to/decals
  61544. */
  61545. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61546. position?: Vector3;
  61547. normal?: Vector3;
  61548. size?: Vector3;
  61549. angle?: number;
  61550. }): Mesh;
  61551. }
  61552. }
  61553. declare module "babylonjs/Meshes/meshSimplification" {
  61554. import { Mesh } from "babylonjs/Meshes/mesh";
  61555. /**
  61556. * A simplifier interface for future simplification implementations
  61557. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61558. */
  61559. export interface ISimplifier {
  61560. /**
  61561. * Simplification of a given mesh according to the given settings.
  61562. * Since this requires computation, it is assumed that the function runs async.
  61563. * @param settings The settings of the simplification, including quality and distance
  61564. * @param successCallback A callback that will be called after the mesh was simplified.
  61565. * @param errorCallback in case of an error, this callback will be called. optional.
  61566. */
  61567. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61568. }
  61569. /**
  61570. * Expected simplification settings.
  61571. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61572. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61573. */
  61574. export interface ISimplificationSettings {
  61575. /**
  61576. * Gets or sets the expected quality
  61577. */
  61578. quality: number;
  61579. /**
  61580. * Gets or sets the distance when this optimized version should be used
  61581. */
  61582. distance: number;
  61583. /**
  61584. * Gets an already optimized mesh
  61585. */
  61586. optimizeMesh?: boolean;
  61587. }
  61588. /**
  61589. * Class used to specify simplification options
  61590. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61591. */
  61592. export class SimplificationSettings implements ISimplificationSettings {
  61593. /** expected quality */
  61594. quality: number;
  61595. /** distance when this optimized version should be used */
  61596. distance: number;
  61597. /** already optimized mesh */
  61598. optimizeMesh?: boolean | undefined;
  61599. /**
  61600. * Creates a SimplificationSettings
  61601. * @param quality expected quality
  61602. * @param distance distance when this optimized version should be used
  61603. * @param optimizeMesh already optimized mesh
  61604. */
  61605. constructor(
  61606. /** expected quality */
  61607. quality: number,
  61608. /** distance when this optimized version should be used */
  61609. distance: number,
  61610. /** already optimized mesh */
  61611. optimizeMesh?: boolean | undefined);
  61612. }
  61613. /**
  61614. * Interface used to define a simplification task
  61615. */
  61616. export interface ISimplificationTask {
  61617. /**
  61618. * Array of settings
  61619. */
  61620. settings: Array<ISimplificationSettings>;
  61621. /**
  61622. * Simplification type
  61623. */
  61624. simplificationType: SimplificationType;
  61625. /**
  61626. * Mesh to simplify
  61627. */
  61628. mesh: Mesh;
  61629. /**
  61630. * Callback called on success
  61631. */
  61632. successCallback?: () => void;
  61633. /**
  61634. * Defines if parallel processing can be used
  61635. */
  61636. parallelProcessing: boolean;
  61637. }
  61638. /**
  61639. * Queue used to order the simplification tasks
  61640. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61641. */
  61642. export class SimplificationQueue {
  61643. private _simplificationArray;
  61644. /**
  61645. * Gets a boolean indicating that the process is still running
  61646. */
  61647. running: boolean;
  61648. /**
  61649. * Creates a new queue
  61650. */
  61651. constructor();
  61652. /**
  61653. * Adds a new simplification task
  61654. * @param task defines a task to add
  61655. */
  61656. addTask(task: ISimplificationTask): void;
  61657. /**
  61658. * Execute next task
  61659. */
  61660. executeNext(): void;
  61661. /**
  61662. * Execute a simplification task
  61663. * @param task defines the task to run
  61664. */
  61665. runSimplification(task: ISimplificationTask): void;
  61666. private getSimplifier;
  61667. }
  61668. /**
  61669. * The implemented types of simplification
  61670. * At the moment only Quadratic Error Decimation is implemented
  61671. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61672. */
  61673. export enum SimplificationType {
  61674. /** Quadratic error decimation */
  61675. QUADRATIC = 0
  61676. }
  61677. }
  61678. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61679. import { Scene } from "babylonjs/scene";
  61680. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61681. import { ISceneComponent } from "babylonjs/sceneComponent";
  61682. module "babylonjs/scene" {
  61683. interface Scene {
  61684. /** @hidden (Backing field) */
  61685. _simplificationQueue: SimplificationQueue;
  61686. /**
  61687. * Gets or sets the simplification queue attached to the scene
  61688. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61689. */
  61690. simplificationQueue: SimplificationQueue;
  61691. }
  61692. }
  61693. module "babylonjs/Meshes/mesh" {
  61694. interface Mesh {
  61695. /**
  61696. * Simplify the mesh according to the given array of settings.
  61697. * Function will return immediately and will simplify async
  61698. * @param settings a collection of simplification settings
  61699. * @param parallelProcessing should all levels calculate parallel or one after the other
  61700. * @param simplificationType the type of simplification to run
  61701. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61702. * @returns the current mesh
  61703. */
  61704. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61705. }
  61706. }
  61707. /**
  61708. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61709. * created in a scene
  61710. */
  61711. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61712. /**
  61713. * The component name helpfull to identify the component in the list of scene components.
  61714. */
  61715. readonly name: string;
  61716. /**
  61717. * The scene the component belongs to.
  61718. */
  61719. scene: Scene;
  61720. /**
  61721. * Creates a new instance of the component for the given scene
  61722. * @param scene Defines the scene to register the component in
  61723. */
  61724. constructor(scene: Scene);
  61725. /**
  61726. * Registers the component in a given scene
  61727. */
  61728. register(): void;
  61729. /**
  61730. * Rebuilds the elements related to this component in case of
  61731. * context lost for instance.
  61732. */
  61733. rebuild(): void;
  61734. /**
  61735. * Disposes the component and the associated ressources
  61736. */
  61737. dispose(): void;
  61738. private _beforeCameraUpdate;
  61739. }
  61740. }
  61741. declare module "babylonjs/Meshes/Builders/index" {
  61742. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61743. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61744. export * from "babylonjs/Meshes/Builders/discBuilder";
  61745. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61746. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61747. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61748. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61749. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61750. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61751. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61752. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61753. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61754. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61755. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61756. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61757. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61758. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61759. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61760. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61761. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61762. }
  61763. declare module "babylonjs/Meshes/index" {
  61764. export * from "babylonjs/Meshes/abstractMesh";
  61765. export * from "babylonjs/Meshes/buffer";
  61766. export * from "babylonjs/Meshes/Compression/index";
  61767. export * from "babylonjs/Meshes/csg";
  61768. export * from "babylonjs/Meshes/geometry";
  61769. export * from "babylonjs/Meshes/groundMesh";
  61770. export * from "babylonjs/Meshes/trailMesh";
  61771. export * from "babylonjs/Meshes/instancedMesh";
  61772. export * from "babylonjs/Meshes/linesMesh";
  61773. export * from "babylonjs/Meshes/mesh";
  61774. export * from "babylonjs/Meshes/mesh.vertexData";
  61775. export * from "babylonjs/Meshes/meshBuilder";
  61776. export * from "babylonjs/Meshes/meshSimplification";
  61777. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61778. export * from "babylonjs/Meshes/polygonMesh";
  61779. export * from "babylonjs/Meshes/subMesh";
  61780. export * from "babylonjs/Meshes/meshLODLevel";
  61781. export * from "babylonjs/Meshes/transformNode";
  61782. export * from "babylonjs/Meshes/Builders/index";
  61783. export * from "babylonjs/Meshes/dataBuffer";
  61784. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61785. }
  61786. declare module "babylonjs/Morph/index" {
  61787. export * from "babylonjs/Morph/morphTarget";
  61788. export * from "babylonjs/Morph/morphTargetManager";
  61789. }
  61790. declare module "babylonjs/Navigation/INavigationEngine" {
  61791. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61792. import { Vector3 } from "babylonjs/Maths/math";
  61793. import { Mesh } from "babylonjs/Meshes/mesh";
  61794. import { Scene } from "babylonjs/scene";
  61795. /**
  61796. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61797. */
  61798. export interface INavigationEnginePlugin {
  61799. /**
  61800. * plugin name
  61801. */
  61802. name: string;
  61803. /**
  61804. * Creates a navigation mesh
  61805. * @param meshes array of all the geometry used to compute the navigatio mesh
  61806. * @param parameters bunch of parameters used to filter geometry
  61807. */
  61808. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61809. /**
  61810. * Create a navigation mesh debug mesh
  61811. * @param scene is where the mesh will be added
  61812. * @returns debug display mesh
  61813. */
  61814. createDebugNavMesh(scene: Scene): Mesh;
  61815. /**
  61816. * Get a navigation mesh constrained position, closest to the parameter position
  61817. * @param position world position
  61818. * @returns the closest point to position constrained by the navigation mesh
  61819. */
  61820. getClosestPoint(position: Vector3): Vector3;
  61821. /**
  61822. * Get a navigation mesh constrained position, within a particular radius
  61823. * @param position world position
  61824. * @param maxRadius the maximum distance to the constrained world position
  61825. * @returns the closest point to position constrained by the navigation mesh
  61826. */
  61827. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61828. /**
  61829. * Compute the final position from a segment made of destination-position
  61830. * @param position world position
  61831. * @param destination world position
  61832. * @returns the resulting point along the navmesh
  61833. */
  61834. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61835. /**
  61836. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61837. * @param start world position
  61838. * @param end world position
  61839. * @returns array containing world position composing the path
  61840. */
  61841. computePath(start: Vector3, end: Vector3): Vector3[];
  61842. /**
  61843. * If this plugin is supported
  61844. * @returns true if plugin is supported
  61845. */
  61846. isSupported(): boolean;
  61847. /**
  61848. * Create a new Crowd so you can add agents
  61849. * @param maxAgents the maximum agent count in the crowd
  61850. * @param maxAgentRadius the maximum radius an agent can have
  61851. * @param scene to attach the crowd to
  61852. * @returns the crowd you can add agents to
  61853. */
  61854. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61855. /**
  61856. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61857. * The queries will try to find a solution within those bounds
  61858. * default is (1,1,1)
  61859. * @param extent x,y,z value that define the extent around the queries point of reference
  61860. */
  61861. setDefaultQueryExtent(extent: Vector3): void;
  61862. /**
  61863. * Get the Bounding box extent specified by setDefaultQueryExtent
  61864. * @returns the box extent values
  61865. */
  61866. getDefaultQueryExtent(): Vector3;
  61867. /**
  61868. * Release all resources
  61869. */
  61870. dispose(): void;
  61871. }
  61872. /**
  61873. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61874. */
  61875. export interface ICrowd {
  61876. /**
  61877. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61878. * You can attach anything to that node. The node position is updated in the scene update tick.
  61879. * @param pos world position that will be constrained by the navigation mesh
  61880. * @param parameters agent parameters
  61881. * @param transform hooked to the agent that will be update by the scene
  61882. * @returns agent index
  61883. */
  61884. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61885. /**
  61886. * Returns the agent position in world space
  61887. * @param index agent index returned by addAgent
  61888. * @returns world space position
  61889. */
  61890. getAgentPosition(index: number): Vector3;
  61891. /**
  61892. * Gets the agent velocity in world space
  61893. * @param index agent index returned by addAgent
  61894. * @returns world space velocity
  61895. */
  61896. getAgentVelocity(index: number): Vector3;
  61897. /**
  61898. * remove a particular agent previously created
  61899. * @param index agent index returned by addAgent
  61900. */
  61901. removeAgent(index: number): void;
  61902. /**
  61903. * get the list of all agents attached to this crowd
  61904. * @returns list of agent indices
  61905. */
  61906. getAgents(): number[];
  61907. /**
  61908. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61909. * @param deltaTime in seconds
  61910. */
  61911. update(deltaTime: number): void;
  61912. /**
  61913. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61914. * @param index agent index returned by addAgent
  61915. * @param destination targeted world position
  61916. */
  61917. agentGoto(index: number, destination: Vector3): void;
  61918. /**
  61919. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61920. * The queries will try to find a solution within those bounds
  61921. * default is (1,1,1)
  61922. * @param extent x,y,z value that define the extent around the queries point of reference
  61923. */
  61924. setDefaultQueryExtent(extent: Vector3): void;
  61925. /**
  61926. * Get the Bounding box extent specified by setDefaultQueryExtent
  61927. * @returns the box extent values
  61928. */
  61929. getDefaultQueryExtent(): Vector3;
  61930. /**
  61931. * Release all resources
  61932. */
  61933. dispose(): void;
  61934. }
  61935. /**
  61936. * Configures an agent
  61937. */
  61938. export interface IAgentParameters {
  61939. /**
  61940. * Agent radius. [Limit: >= 0]
  61941. */
  61942. radius: number;
  61943. /**
  61944. * Agent height. [Limit: > 0]
  61945. */
  61946. height: number;
  61947. /**
  61948. * Maximum allowed acceleration. [Limit: >= 0]
  61949. */
  61950. maxAcceleration: number;
  61951. /**
  61952. * Maximum allowed speed. [Limit: >= 0]
  61953. */
  61954. maxSpeed: number;
  61955. /**
  61956. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61957. */
  61958. collisionQueryRange: number;
  61959. /**
  61960. * The path visibility optimization range. [Limit: > 0]
  61961. */
  61962. pathOptimizationRange: number;
  61963. /**
  61964. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61965. */
  61966. separationWeight: number;
  61967. }
  61968. /**
  61969. * Configures the navigation mesh creation
  61970. */
  61971. export interface INavMeshParameters {
  61972. /**
  61973. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61974. */
  61975. cs: number;
  61976. /**
  61977. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61978. */
  61979. ch: number;
  61980. /**
  61981. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61982. */
  61983. walkableSlopeAngle: number;
  61984. /**
  61985. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61986. * be considered walkable. [Limit: >= 3] [Units: vx]
  61987. */
  61988. walkableHeight: number;
  61989. /**
  61990. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61991. */
  61992. walkableClimb: number;
  61993. /**
  61994. * The distance to erode/shrink the walkable area of the heightfield away from
  61995. * obstructions. [Limit: >=0] [Units: vx]
  61996. */
  61997. walkableRadius: number;
  61998. /**
  61999. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62000. */
  62001. maxEdgeLen: number;
  62002. /**
  62003. * The maximum distance a simplfied contour's border edges should deviate
  62004. * the original raw contour. [Limit: >=0] [Units: vx]
  62005. */
  62006. maxSimplificationError: number;
  62007. /**
  62008. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62009. */
  62010. minRegionArea: number;
  62011. /**
  62012. * Any regions with a span count smaller than this value will, if possible,
  62013. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62014. */
  62015. mergeRegionArea: number;
  62016. /**
  62017. * The maximum number of vertices allowed for polygons generated during the
  62018. * contour to polygon conversion process. [Limit: >= 3]
  62019. */
  62020. maxVertsPerPoly: number;
  62021. /**
  62022. * Sets the sampling distance to use when generating the detail mesh.
  62023. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62024. */
  62025. detailSampleDist: number;
  62026. /**
  62027. * The maximum distance the detail mesh surface should deviate from heightfield
  62028. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62029. */
  62030. detailSampleMaxError: number;
  62031. }
  62032. }
  62033. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  62034. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  62035. import { Mesh } from "babylonjs/Meshes/mesh";
  62036. import { Scene } from "babylonjs/scene";
  62037. import { Vector3 } from "babylonjs/Maths/math";
  62038. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62039. /**
  62040. * RecastJS navigation plugin
  62041. */
  62042. export class RecastJSPlugin implements INavigationEnginePlugin {
  62043. /**
  62044. * Reference to the Recast library
  62045. */
  62046. bjsRECAST: any;
  62047. /**
  62048. * plugin name
  62049. */
  62050. name: string;
  62051. /**
  62052. * the first navmesh created. We might extend this to support multiple navmeshes
  62053. */
  62054. navMesh: any;
  62055. /**
  62056. * Initializes the recastJS plugin
  62057. * @param recastInjection can be used to inject your own recast reference
  62058. */
  62059. constructor(recastInjection?: any);
  62060. /**
  62061. * Creates a navigation mesh
  62062. * @param meshes array of all the geometry used to compute the navigatio mesh
  62063. * @param parameters bunch of parameters used to filter geometry
  62064. */
  62065. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62066. /**
  62067. * Create a navigation mesh debug mesh
  62068. * @param scene is where the mesh will be added
  62069. * @returns debug display mesh
  62070. */
  62071. createDebugNavMesh(scene: Scene): Mesh;
  62072. /**
  62073. * Get a navigation mesh constrained position, closest to the parameter position
  62074. * @param position world position
  62075. * @returns the closest point to position constrained by the navigation mesh
  62076. */
  62077. getClosestPoint(position: Vector3): Vector3;
  62078. /**
  62079. * Get a navigation mesh constrained position, within a particular radius
  62080. * @param position world position
  62081. * @param maxRadius the maximum distance to the constrained world position
  62082. * @returns the closest point to position constrained by the navigation mesh
  62083. */
  62084. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62085. /**
  62086. * Compute the final position from a segment made of destination-position
  62087. * @param position world position
  62088. * @param destination world position
  62089. * @returns the resulting point along the navmesh
  62090. */
  62091. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62092. /**
  62093. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62094. * @param start world position
  62095. * @param end world position
  62096. * @returns array containing world position composing the path
  62097. */
  62098. computePath(start: Vector3, end: Vector3): Vector3[];
  62099. /**
  62100. * Create a new Crowd so you can add agents
  62101. * @param maxAgents the maximum agent count in the crowd
  62102. * @param maxAgentRadius the maximum radius an agent can have
  62103. * @param scene to attach the crowd to
  62104. * @returns the crowd you can add agents to
  62105. */
  62106. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62107. /**
  62108. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62109. * The queries will try to find a solution within those bounds
  62110. * default is (1,1,1)
  62111. * @param extent x,y,z value that define the extent around the queries point of reference
  62112. */
  62113. setDefaultQueryExtent(extent: Vector3): void;
  62114. /**
  62115. * Get the Bounding box extent specified by setDefaultQueryExtent
  62116. * @returns the box extent values
  62117. */
  62118. getDefaultQueryExtent(): Vector3;
  62119. /**
  62120. * Disposes
  62121. */
  62122. dispose(): void;
  62123. /**
  62124. * If this plugin is supported
  62125. * @returns true if plugin is supported
  62126. */
  62127. isSupported(): boolean;
  62128. }
  62129. /**
  62130. * Recast detour crowd implementation
  62131. */
  62132. export class RecastJSCrowd implements ICrowd {
  62133. /**
  62134. * Recast/detour plugin
  62135. */
  62136. bjsRECASTPlugin: RecastJSPlugin;
  62137. /**
  62138. * Link to the detour crowd
  62139. */
  62140. recastCrowd: any;
  62141. /**
  62142. * One transform per agent
  62143. */
  62144. transforms: TransformNode[];
  62145. /**
  62146. * All agents created
  62147. */
  62148. agents: number[];
  62149. /**
  62150. * Link to the scene is kept to unregister the crowd from the scene
  62151. */
  62152. private _scene;
  62153. /**
  62154. * Observer for crowd updates
  62155. */
  62156. private _onBeforeAnimationsObserver;
  62157. /**
  62158. * Constructor
  62159. * @param plugin recastJS plugin
  62160. * @param maxAgents the maximum agent count in the crowd
  62161. * @param maxAgentRadius the maximum radius an agent can have
  62162. * @param scene to attach the crowd to
  62163. * @returns the crowd you can add agents to
  62164. */
  62165. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62166. /**
  62167. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62168. * You can attach anything to that node. The node position is updated in the scene update tick.
  62169. * @param pos world position that will be constrained by the navigation mesh
  62170. * @param parameters agent parameters
  62171. * @param transform hooked to the agent that will be update by the scene
  62172. * @returns agent index
  62173. */
  62174. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62175. /**
  62176. * Returns the agent position in world space
  62177. * @param index agent index returned by addAgent
  62178. * @returns world space position
  62179. */
  62180. getAgentPosition(index: number): Vector3;
  62181. /**
  62182. * Returns the agent velocity in world space
  62183. * @param index agent index returned by addAgent
  62184. * @returns world space velocity
  62185. */
  62186. getAgentVelocity(index: number): Vector3;
  62187. /**
  62188. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62189. * @param index agent index returned by addAgent
  62190. * @param destination targeted world position
  62191. */
  62192. agentGoto(index: number, destination: Vector3): void;
  62193. /**
  62194. * remove a particular agent previously created
  62195. * @param index agent index returned by addAgent
  62196. */
  62197. removeAgent(index: number): void;
  62198. /**
  62199. * get the list of all agents attached to this crowd
  62200. * @returns list of agent indices
  62201. */
  62202. getAgents(): number[];
  62203. /**
  62204. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62205. * @param deltaTime in seconds
  62206. */
  62207. update(deltaTime: number): void;
  62208. /**
  62209. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62210. * The queries will try to find a solution within those bounds
  62211. * default is (1,1,1)
  62212. * @param extent x,y,z value that define the extent around the queries point of reference
  62213. */
  62214. setDefaultQueryExtent(extent: Vector3): void;
  62215. /**
  62216. * Get the Bounding box extent specified by setDefaultQueryExtent
  62217. * @returns the box extent values
  62218. */
  62219. getDefaultQueryExtent(): Vector3;
  62220. /**
  62221. * Release all resources
  62222. */
  62223. dispose(): void;
  62224. }
  62225. }
  62226. declare module "babylonjs/Navigation/Plugins/index" {
  62227. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  62228. }
  62229. declare module "babylonjs/Navigation/index" {
  62230. export * from "babylonjs/Navigation/INavigationEngine";
  62231. export * from "babylonjs/Navigation/Plugins/index";
  62232. }
  62233. declare module "babylonjs/Offline/database" {
  62234. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  62235. /**
  62236. * Class used to enable access to IndexedDB
  62237. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62238. */
  62239. export class Database implements IOfflineProvider {
  62240. private _callbackManifestChecked;
  62241. private _currentSceneUrl;
  62242. private _db;
  62243. private _enableSceneOffline;
  62244. private _enableTexturesOffline;
  62245. private _manifestVersionFound;
  62246. private _mustUpdateRessources;
  62247. private _hasReachedQuota;
  62248. private _isSupported;
  62249. private _idbFactory;
  62250. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62251. private static IsUASupportingBlobStorage;
  62252. /**
  62253. * Gets a boolean indicating if Database storate is enabled (off by default)
  62254. */
  62255. static IDBStorageEnabled: boolean;
  62256. /**
  62257. * Gets a boolean indicating if scene must be saved in the database
  62258. */
  62259. readonly enableSceneOffline: boolean;
  62260. /**
  62261. * Gets a boolean indicating if textures must be saved in the database
  62262. */
  62263. readonly enableTexturesOffline: boolean;
  62264. /**
  62265. * Creates a new Database
  62266. * @param urlToScene defines the url to load the scene
  62267. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62268. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62269. */
  62270. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62271. private static _ParseURL;
  62272. private static _ReturnFullUrlLocation;
  62273. private _checkManifestFile;
  62274. /**
  62275. * Open the database and make it available
  62276. * @param successCallback defines the callback to call on success
  62277. * @param errorCallback defines the callback to call on error
  62278. */
  62279. open(successCallback: () => void, errorCallback: () => void): void;
  62280. /**
  62281. * Loads an image from the database
  62282. * @param url defines the url to load from
  62283. * @param image defines the target DOM image
  62284. */
  62285. loadImage(url: string, image: HTMLImageElement): void;
  62286. private _loadImageFromDBAsync;
  62287. private _saveImageIntoDBAsync;
  62288. private _checkVersionFromDB;
  62289. private _loadVersionFromDBAsync;
  62290. private _saveVersionIntoDBAsync;
  62291. /**
  62292. * Loads a file from database
  62293. * @param url defines the URL to load from
  62294. * @param sceneLoaded defines a callback to call on success
  62295. * @param progressCallBack defines a callback to call when progress changed
  62296. * @param errorCallback defines a callback to call on error
  62297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62298. */
  62299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62300. private _loadFileAsync;
  62301. private _saveFileAsync;
  62302. /**
  62303. * Validates if xhr data is correct
  62304. * @param xhr defines the request to validate
  62305. * @param dataType defines the expected data type
  62306. * @returns true if data is correct
  62307. */
  62308. private static _ValidateXHRData;
  62309. }
  62310. }
  62311. declare module "babylonjs/Offline/index" {
  62312. export * from "babylonjs/Offline/database";
  62313. export * from "babylonjs/Offline/IOfflineProvider";
  62314. }
  62315. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  62316. /** @hidden */
  62317. export var gpuUpdateParticlesPixelShader: {
  62318. name: string;
  62319. shader: string;
  62320. };
  62321. }
  62322. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  62323. /** @hidden */
  62324. export var gpuUpdateParticlesVertexShader: {
  62325. name: string;
  62326. shader: string;
  62327. };
  62328. }
  62329. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  62330. /** @hidden */
  62331. export var clipPlaneFragmentDeclaration2: {
  62332. name: string;
  62333. shader: string;
  62334. };
  62335. }
  62336. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  62337. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  62338. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62339. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62340. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62341. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  62342. /** @hidden */
  62343. export var gpuRenderParticlesPixelShader: {
  62344. name: string;
  62345. shader: string;
  62346. };
  62347. }
  62348. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  62349. /** @hidden */
  62350. export var clipPlaneVertexDeclaration2: {
  62351. name: string;
  62352. shader: string;
  62353. };
  62354. }
  62355. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  62356. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  62357. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  62358. /** @hidden */
  62359. export var gpuRenderParticlesVertexShader: {
  62360. name: string;
  62361. shader: string;
  62362. };
  62363. }
  62364. declare module "babylonjs/Particles/gpuParticleSystem" {
  62365. import { Nullable } from "babylonjs/types";
  62366. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  62367. import { Observable } from "babylonjs/Misc/observable";
  62368. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62369. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62370. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  62371. import { Scene, IDisposable } from "babylonjs/scene";
  62372. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  62373. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62374. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  62375. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  62376. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  62377. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  62378. /**
  62379. * This represents a GPU particle system in Babylon
  62380. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62381. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62382. */
  62383. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62384. /**
  62385. * The layer mask we are rendering the particles through.
  62386. */
  62387. layerMask: number;
  62388. private _capacity;
  62389. private _activeCount;
  62390. private _currentActiveCount;
  62391. private _accumulatedCount;
  62392. private _renderEffect;
  62393. private _updateEffect;
  62394. private _buffer0;
  62395. private _buffer1;
  62396. private _spriteBuffer;
  62397. private _updateVAO;
  62398. private _renderVAO;
  62399. private _targetIndex;
  62400. private _sourceBuffer;
  62401. private _targetBuffer;
  62402. private _engine;
  62403. private _currentRenderId;
  62404. private _started;
  62405. private _stopped;
  62406. private _timeDelta;
  62407. private _randomTexture;
  62408. private _randomTexture2;
  62409. private _attributesStrideSize;
  62410. private _updateEffectOptions;
  62411. private _randomTextureSize;
  62412. private _actualFrame;
  62413. private readonly _rawTextureWidth;
  62414. /**
  62415. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62416. */
  62417. static readonly IsSupported: boolean;
  62418. /**
  62419. * An event triggered when the system is disposed.
  62420. */
  62421. onDisposeObservable: Observable<GPUParticleSystem>;
  62422. /**
  62423. * Gets the maximum number of particles active at the same time.
  62424. * @returns The max number of active particles.
  62425. */
  62426. getCapacity(): number;
  62427. /**
  62428. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62429. * to override the particles.
  62430. */
  62431. forceDepthWrite: boolean;
  62432. /**
  62433. * Gets or set the number of active particles
  62434. */
  62435. activeParticleCount: number;
  62436. private _preWarmDone;
  62437. /**
  62438. * Is this system ready to be used/rendered
  62439. * @return true if the system is ready
  62440. */
  62441. isReady(): boolean;
  62442. /**
  62443. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62444. * @returns True if it has been started, otherwise false.
  62445. */
  62446. isStarted(): boolean;
  62447. /**
  62448. * Starts the particle system and begins to emit
  62449. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62450. */
  62451. start(delay?: number): void;
  62452. /**
  62453. * Stops the particle system.
  62454. */
  62455. stop(): void;
  62456. /**
  62457. * Remove all active particles
  62458. */
  62459. reset(): void;
  62460. /**
  62461. * Returns the string "GPUParticleSystem"
  62462. * @returns a string containing the class name
  62463. */
  62464. getClassName(): string;
  62465. private _colorGradientsTexture;
  62466. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62467. /**
  62468. * Adds a new color gradient
  62469. * @param gradient defines the gradient to use (between 0 and 1)
  62470. * @param color1 defines the color to affect to the specified gradient
  62471. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62472. * @returns the current particle system
  62473. */
  62474. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62475. /**
  62476. * Remove a specific color gradient
  62477. * @param gradient defines the gradient to remove
  62478. * @returns the current particle system
  62479. */
  62480. removeColorGradient(gradient: number): GPUParticleSystem;
  62481. private _angularSpeedGradientsTexture;
  62482. private _sizeGradientsTexture;
  62483. private _velocityGradientsTexture;
  62484. private _limitVelocityGradientsTexture;
  62485. private _dragGradientsTexture;
  62486. private _addFactorGradient;
  62487. /**
  62488. * Adds a new size gradient
  62489. * @param gradient defines the gradient to use (between 0 and 1)
  62490. * @param factor defines the size factor to affect to the specified gradient
  62491. * @returns the current particle system
  62492. */
  62493. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62494. /**
  62495. * Remove a specific size gradient
  62496. * @param gradient defines the gradient to remove
  62497. * @returns the current particle system
  62498. */
  62499. removeSizeGradient(gradient: number): GPUParticleSystem;
  62500. /**
  62501. * Adds a new angular speed gradient
  62502. * @param gradient defines the gradient to use (between 0 and 1)
  62503. * @param factor defines the angular speed to affect to the specified gradient
  62504. * @returns the current particle system
  62505. */
  62506. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62507. /**
  62508. * Remove a specific angular speed gradient
  62509. * @param gradient defines the gradient to remove
  62510. * @returns the current particle system
  62511. */
  62512. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62513. /**
  62514. * Adds a new velocity gradient
  62515. * @param gradient defines the gradient to use (between 0 and 1)
  62516. * @param factor defines the velocity to affect to the specified gradient
  62517. * @returns the current particle system
  62518. */
  62519. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62520. /**
  62521. * Remove a specific velocity gradient
  62522. * @param gradient defines the gradient to remove
  62523. * @returns the current particle system
  62524. */
  62525. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62526. /**
  62527. * Adds a new limit velocity gradient
  62528. * @param gradient defines the gradient to use (between 0 and 1)
  62529. * @param factor defines the limit velocity value to affect to the specified gradient
  62530. * @returns the current particle system
  62531. */
  62532. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62533. /**
  62534. * Remove a specific limit velocity gradient
  62535. * @param gradient defines the gradient to remove
  62536. * @returns the current particle system
  62537. */
  62538. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62539. /**
  62540. * Adds a new drag gradient
  62541. * @param gradient defines the gradient to use (between 0 and 1)
  62542. * @param factor defines the drag value to affect to the specified gradient
  62543. * @returns the current particle system
  62544. */
  62545. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62546. /**
  62547. * Remove a specific drag gradient
  62548. * @param gradient defines the gradient to remove
  62549. * @returns the current particle system
  62550. */
  62551. removeDragGradient(gradient: number): GPUParticleSystem;
  62552. /**
  62553. * Not supported by GPUParticleSystem
  62554. * @param gradient defines the gradient to use (between 0 and 1)
  62555. * @param factor defines the emit rate value to affect to the specified gradient
  62556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62557. * @returns the current particle system
  62558. */
  62559. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62560. /**
  62561. * Not supported by GPUParticleSystem
  62562. * @param gradient defines the gradient to remove
  62563. * @returns the current particle system
  62564. */
  62565. removeEmitRateGradient(gradient: number): IParticleSystem;
  62566. /**
  62567. * Not supported by GPUParticleSystem
  62568. * @param gradient defines the gradient to use (between 0 and 1)
  62569. * @param factor defines the start size value to affect to the specified gradient
  62570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62571. * @returns the current particle system
  62572. */
  62573. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62574. /**
  62575. * Not supported by GPUParticleSystem
  62576. * @param gradient defines the gradient to remove
  62577. * @returns the current particle system
  62578. */
  62579. removeStartSizeGradient(gradient: number): IParticleSystem;
  62580. /**
  62581. * Not supported by GPUParticleSystem
  62582. * @param gradient defines the gradient to use (between 0 and 1)
  62583. * @param min defines the color remap minimal range
  62584. * @param max defines the color remap maximal range
  62585. * @returns the current particle system
  62586. */
  62587. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62588. /**
  62589. * Not supported by GPUParticleSystem
  62590. * @param gradient defines the gradient to remove
  62591. * @returns the current particle system
  62592. */
  62593. removeColorRemapGradient(): IParticleSystem;
  62594. /**
  62595. * Not supported by GPUParticleSystem
  62596. * @param gradient defines the gradient to use (between 0 and 1)
  62597. * @param min defines the alpha remap minimal range
  62598. * @param max defines the alpha remap maximal range
  62599. * @returns the current particle system
  62600. */
  62601. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62602. /**
  62603. * Not supported by GPUParticleSystem
  62604. * @param gradient defines the gradient to remove
  62605. * @returns the current particle system
  62606. */
  62607. removeAlphaRemapGradient(): IParticleSystem;
  62608. /**
  62609. * Not supported by GPUParticleSystem
  62610. * @param gradient defines the gradient to use (between 0 and 1)
  62611. * @param color defines the color to affect to the specified gradient
  62612. * @returns the current particle system
  62613. */
  62614. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62615. /**
  62616. * Not supported by GPUParticleSystem
  62617. * @param gradient defines the gradient to remove
  62618. * @returns the current particle system
  62619. */
  62620. removeRampGradient(): IParticleSystem;
  62621. /**
  62622. * Not supported by GPUParticleSystem
  62623. * @returns the list of ramp gradients
  62624. */
  62625. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62626. /**
  62627. * Not supported by GPUParticleSystem
  62628. * Gets or sets a boolean indicating that ramp gradients must be used
  62629. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62630. */
  62631. useRampGradients: boolean;
  62632. /**
  62633. * Not supported by GPUParticleSystem
  62634. * @param gradient defines the gradient to use (between 0 and 1)
  62635. * @param factor defines the life time factor to affect to the specified gradient
  62636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62637. * @returns the current particle system
  62638. */
  62639. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62640. /**
  62641. * Not supported by GPUParticleSystem
  62642. * @param gradient defines the gradient to remove
  62643. * @returns the current particle system
  62644. */
  62645. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62646. /**
  62647. * Instantiates a GPU particle system.
  62648. * 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.
  62649. * @param name The name of the particle system
  62650. * @param options The options used to create the system
  62651. * @param scene The scene the particle system belongs to
  62652. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62653. */
  62654. constructor(name: string, options: Partial<{
  62655. capacity: number;
  62656. randomTextureSize: number;
  62657. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62658. protected _reset(): void;
  62659. private _createUpdateVAO;
  62660. private _createRenderVAO;
  62661. private _initialize;
  62662. /** @hidden */
  62663. _recreateUpdateEffect(): void;
  62664. /** @hidden */
  62665. _recreateRenderEffect(): void;
  62666. /**
  62667. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62668. * @param preWarm defines if we are in the pre-warmimg phase
  62669. */
  62670. animate(preWarm?: boolean): void;
  62671. private _createFactorGradientTexture;
  62672. private _createSizeGradientTexture;
  62673. private _createAngularSpeedGradientTexture;
  62674. private _createVelocityGradientTexture;
  62675. private _createLimitVelocityGradientTexture;
  62676. private _createDragGradientTexture;
  62677. private _createColorGradientTexture;
  62678. /**
  62679. * Renders the particle system in its current state
  62680. * @param preWarm defines if the system should only update the particles but not render them
  62681. * @returns the current number of particles
  62682. */
  62683. render(preWarm?: boolean): number;
  62684. /**
  62685. * Rebuilds the particle system
  62686. */
  62687. rebuild(): void;
  62688. private _releaseBuffers;
  62689. private _releaseVAOs;
  62690. /**
  62691. * Disposes the particle system and free the associated resources
  62692. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62693. */
  62694. dispose(disposeTexture?: boolean): void;
  62695. /**
  62696. * Clones the particle system.
  62697. * @param name The name of the cloned object
  62698. * @param newEmitter The new emitter to use
  62699. * @returns the cloned particle system
  62700. */
  62701. clone(name: string, newEmitter: any): GPUParticleSystem;
  62702. /**
  62703. * Serializes the particle system to a JSON object.
  62704. * @returns the JSON object
  62705. */
  62706. serialize(): any;
  62707. /**
  62708. * Parses a JSON object to create a GPU particle system.
  62709. * @param parsedParticleSystem The JSON object to parse
  62710. * @param scene The scene to create the particle system in
  62711. * @param rootUrl The root url to use to load external dependencies like texture
  62712. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62713. * @returns the parsed GPU particle system
  62714. */
  62715. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62716. }
  62717. }
  62718. declare module "babylonjs/Particles/particleSystemSet" {
  62719. import { Nullable } from "babylonjs/types";
  62720. import { Color3 } from "babylonjs/Maths/math.color";
  62721. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62723. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62724. import { Scene, IDisposable } from "babylonjs/scene";
  62725. /**
  62726. * Represents a set of particle systems working together to create a specific effect
  62727. */
  62728. export class ParticleSystemSet implements IDisposable {
  62729. /**
  62730. * Gets or sets base Assets URL
  62731. */
  62732. static BaseAssetsUrl: string;
  62733. private _emitterCreationOptions;
  62734. private _emitterNode;
  62735. /**
  62736. * Gets the particle system list
  62737. */
  62738. systems: IParticleSystem[];
  62739. /**
  62740. * Gets the emitter node used with this set
  62741. */
  62742. readonly emitterNode: Nullable<TransformNode>;
  62743. /**
  62744. * Creates a new emitter mesh as a sphere
  62745. * @param options defines the options used to create the sphere
  62746. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62747. * @param scene defines the hosting scene
  62748. */
  62749. setEmitterAsSphere(options: {
  62750. diameter: number;
  62751. segments: number;
  62752. color: Color3;
  62753. }, renderingGroupId: number, scene: Scene): void;
  62754. /**
  62755. * Starts all particle systems of the set
  62756. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62757. */
  62758. start(emitter?: AbstractMesh): void;
  62759. /**
  62760. * Release all associated resources
  62761. */
  62762. dispose(): void;
  62763. /**
  62764. * Serialize the set into a JSON compatible object
  62765. * @returns a JSON compatible representation of the set
  62766. */
  62767. serialize(): any;
  62768. /**
  62769. * Parse a new ParticleSystemSet from a serialized source
  62770. * @param data defines a JSON compatible representation of the set
  62771. * @param scene defines the hosting scene
  62772. * @param gpu defines if we want GPU particles or CPU particles
  62773. * @returns a new ParticleSystemSet
  62774. */
  62775. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62776. }
  62777. }
  62778. declare module "babylonjs/Particles/particleHelper" {
  62779. import { Nullable } from "babylonjs/types";
  62780. import { Scene } from "babylonjs/scene";
  62781. import { Vector3 } from "babylonjs/Maths/math.vector";
  62782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62783. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62784. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62785. /**
  62786. * This class is made for on one-liner static method to help creating particle system set.
  62787. */
  62788. export class ParticleHelper {
  62789. /**
  62790. * Gets or sets base Assets URL
  62791. */
  62792. static BaseAssetsUrl: string;
  62793. /**
  62794. * Create a default particle system that you can tweak
  62795. * @param emitter defines the emitter to use
  62796. * @param capacity defines the system capacity (default is 500 particles)
  62797. * @param scene defines the hosting scene
  62798. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62799. * @returns the new Particle system
  62800. */
  62801. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62802. /**
  62803. * This is the main static method (one-liner) of this helper to create different particle systems
  62804. * @param type This string represents the type to the particle system to create
  62805. * @param scene The scene where the particle system should live
  62806. * @param gpu If the system will use gpu
  62807. * @returns the ParticleSystemSet created
  62808. */
  62809. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62810. /**
  62811. * Static function used to export a particle system to a ParticleSystemSet variable.
  62812. * Please note that the emitter shape is not exported
  62813. * @param systems defines the particle systems to export
  62814. * @returns the created particle system set
  62815. */
  62816. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62817. }
  62818. }
  62819. declare module "babylonjs/Particles/particleSystemComponent" {
  62820. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62821. import { Effect } from "babylonjs/Materials/effect";
  62822. import "babylonjs/Shaders/particles.vertex";
  62823. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62824. module "babylonjs/Engines/engine" {
  62825. interface Engine {
  62826. /**
  62827. * Create an effect to use with particle systems.
  62828. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62829. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62830. * @param uniformsNames defines a list of attribute names
  62831. * @param samplers defines an array of string used to represent textures
  62832. * @param defines defines the string containing the defines to use to compile the shaders
  62833. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62834. * @param onCompiled defines a function to call when the effect creation is successful
  62835. * @param onError defines a function to call when the effect creation has failed
  62836. * @returns the new Effect
  62837. */
  62838. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62839. }
  62840. }
  62841. module "babylonjs/Meshes/mesh" {
  62842. interface Mesh {
  62843. /**
  62844. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62845. * @returns an array of IParticleSystem
  62846. */
  62847. getEmittedParticleSystems(): IParticleSystem[];
  62848. /**
  62849. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62850. * @returns an array of IParticleSystem
  62851. */
  62852. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62853. }
  62854. }
  62855. /**
  62856. * @hidden
  62857. */
  62858. export var _IDoNeedToBeInTheBuild: number;
  62859. }
  62860. declare module "babylonjs/Particles/pointsCloudSystem" {
  62861. import { Color4 } from "babylonjs/Maths/math";
  62862. import { Mesh } from "babylonjs/Meshes/mesh";
  62863. import { Scene, IDisposable } from "babylonjs/scene";
  62864. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62865. /** Defines the 4 color options */
  62866. export enum PointColor {
  62867. /** color value */
  62868. Color = 2,
  62869. /** uv value */
  62870. UV = 1,
  62871. /** random value */
  62872. Random = 0,
  62873. /** stated value */
  62874. Stated = 3
  62875. }
  62876. /**
  62877. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62878. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  62879. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62880. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62881. *
  62882. * Full documentation here : TO BE ENTERED
  62883. */
  62884. export class PointsCloudSystem implements IDisposable {
  62885. /**
  62886. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62887. * Example : var p = SPS.particles[i];
  62888. */
  62889. particles: CloudPoint[];
  62890. /**
  62891. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62892. */
  62893. nbParticles: number;
  62894. /**
  62895. * This a counter for your own usage. It's not set by any SPS functions.
  62896. */
  62897. counter: number;
  62898. /**
  62899. * The PCS name. This name is also given to the underlying mesh.
  62900. */
  62901. name: string;
  62902. /**
  62903. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62904. */
  62905. mesh: Mesh;
  62906. /**
  62907. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62908. * Please read :
  62909. */
  62910. vars: any;
  62911. /**
  62912. * @hidden
  62913. */
  62914. _size: number;
  62915. private _scene;
  62916. private _promises;
  62917. private _positions;
  62918. private _indices;
  62919. private _normals;
  62920. private _colors;
  62921. private _uvs;
  62922. private _indices32;
  62923. private _positions32;
  62924. private _colors32;
  62925. private _uvs32;
  62926. private _updatable;
  62927. private _isVisibilityBoxLocked;
  62928. private _alwaysVisible;
  62929. private _groups;
  62930. private _groupCounter;
  62931. private _computeParticleColor;
  62932. private _computeParticleTexture;
  62933. private _computeParticleRotation;
  62934. private _computeBoundingBox;
  62935. private _isReady;
  62936. /**
  62937. * Creates a PCS (Points Cloud System) object
  62938. * @param name (String) is the PCS name, this will be the underlying mesh name
  62939. * @param pointSize (number) is the size for each point
  62940. * @param scene (Scene) is the scene in which the PCS is added
  62941. * @param options defines the options of the PCS e.g.
  62942. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62943. */
  62944. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62945. updatable?: boolean;
  62946. });
  62947. /**
  62948. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62949. * If no points were added to the PCS, the returned mesh is just a single point.
  62950. * @returns a promise for the created mesh
  62951. */
  62952. buildMeshAsync(): Promise<Mesh>;
  62953. /**
  62954. * @hidden
  62955. */
  62956. private _buildMesh;
  62957. private _addParticle;
  62958. private _randomUnitVector;
  62959. private _getColorIndicesForCoord;
  62960. private _setPointsColorOrUV;
  62961. private _colorFromTexture;
  62962. private _calculateDensity;
  62963. /**
  62964. * Adds points to the PCS in random positions within a unit sphere
  62965. * @param nb (positive integer) the number of particles to be created from this model
  62966. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62967. * @returns the number of groups in the system
  62968. */
  62969. addPoints(nb: number, pointFunction?: any): number;
  62970. /**
  62971. * Adds points to the PCS from the surface of the model shape
  62972. * @param mesh is any Mesh object that will be used as a surface model for the points
  62973. * @param nb (positive integer) the number of particles to be created from this model
  62974. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62975. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62976. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62977. * @returns the number of groups in the system
  62978. */
  62979. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62980. /**
  62981. * Adds points to the PCS inside the model shape
  62982. * @param mesh is any Mesh object that will be used as a surface model for the points
  62983. * @param nb (positive integer) the number of particles to be created from this model
  62984. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62985. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62986. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62987. * @returns the number of groups in the system
  62988. */
  62989. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62990. /**
  62991. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62992. * This method calls `updateParticle()` for each particle of the SPS.
  62993. * For an animated SPS, it is usually called within the render loop.
  62994. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62995. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62996. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62997. * @returns the PCS.
  62998. */
  62999. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63000. /**
  63001. * Disposes the PCS.
  63002. */
  63003. dispose(): void;
  63004. /**
  63005. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63006. * doc :
  63007. * @returns the PCS.
  63008. */
  63009. refreshVisibleSize(): PointsCloudSystem;
  63010. /**
  63011. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63012. * @param size the size (float) of the visibility box
  63013. * note : this doesn't lock the PCS mesh bounding box.
  63014. * doc :
  63015. */
  63016. setVisibilityBox(size: number): void;
  63017. /**
  63018. * Gets whether the PCS is always visible or not
  63019. * doc :
  63020. */
  63021. /**
  63022. * Sets the PCS as always visible or not
  63023. * doc :
  63024. */
  63025. isAlwaysVisible: boolean;
  63026. /**
  63027. * Tells to `setParticles()` to compute the particle rotations or not
  63028. * Default value : false. The PCS is faster when it's set to false
  63029. * Note : particle rotations are only applied to parent particles
  63030. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63031. */
  63032. computeParticleRotation: boolean;
  63033. /**
  63034. * Tells to `setParticles()` to compute the particle colors or not.
  63035. * Default value : true. The PCS is faster when it's set to false.
  63036. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63037. */
  63038. /**
  63039. * Gets if `setParticles()` computes the particle colors or not.
  63040. * Default value : false. The PCS is faster when it's set to false.
  63041. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63042. */
  63043. computeParticleColor: boolean;
  63044. /**
  63045. * Gets if `setParticles()` computes the particle textures or not.
  63046. * Default value : false. The PCS is faster when it's set to false.
  63047. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63048. */
  63049. computeParticleTexture: boolean;
  63050. /**
  63051. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63052. */
  63053. /**
  63054. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63055. */
  63056. computeBoundingBox: boolean;
  63057. /**
  63058. * This function does nothing. It may be overwritten to set all the particle first values.
  63059. * The PCS doesn't call this function, you may have to call it by your own.
  63060. * doc :
  63061. */
  63062. initParticles(): void;
  63063. /**
  63064. * This function does nothing. It may be overwritten to recycle a particle
  63065. * The PCS doesn't call this function, you can to call it
  63066. * doc :
  63067. * @param particle The particle to recycle
  63068. * @returns the recycled particle
  63069. */
  63070. recycleParticle(particle: CloudPoint): CloudPoint;
  63071. /**
  63072. * Updates a particle : this function should be overwritten by the user.
  63073. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63074. * doc :
  63075. * @example : just set a particle position or velocity and recycle conditions
  63076. * @param particle The particle to update
  63077. * @returns the updated particle
  63078. */
  63079. updateParticle(particle: CloudPoint): CloudPoint;
  63080. /**
  63081. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63082. * This does nothing and may be overwritten by the user.
  63083. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63084. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63085. * @param update the boolean update value actually passed to setParticles()
  63086. */
  63087. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63088. /**
  63089. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63090. * This will be passed three parameters.
  63091. * This does nothing and may be overwritten by the user.
  63092. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63093. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63094. * @param update the boolean update value actually passed to setParticles()
  63095. */
  63096. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63097. }
  63098. }
  63099. declare module "babylonjs/Particles/cloudPoint" {
  63100. import { Nullable } from "babylonjs/types";
  63101. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  63102. import { Mesh } from "babylonjs/Meshes/mesh";
  63103. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63104. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  63105. /**
  63106. * Represents one particle of a points cloud system.
  63107. */
  63108. export class CloudPoint {
  63109. /**
  63110. * particle global index
  63111. */
  63112. idx: number;
  63113. /**
  63114. * The color of the particle
  63115. */
  63116. color: Nullable<Color4>;
  63117. /**
  63118. * The world space position of the particle.
  63119. */
  63120. position: Vector3;
  63121. /**
  63122. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63123. */
  63124. rotation: Vector3;
  63125. /**
  63126. * The world space rotation quaternion of the particle.
  63127. */
  63128. rotationQuaternion: Nullable<Quaternion>;
  63129. /**
  63130. * The uv of the particle.
  63131. */
  63132. uv: Nullable<Vector2>;
  63133. /**
  63134. * The current speed of the particle.
  63135. */
  63136. velocity: Vector3;
  63137. /**
  63138. * The pivot point in the particle local space.
  63139. */
  63140. pivot: Vector3;
  63141. /**
  63142. * Must the particle be translated from its pivot point in its local space ?
  63143. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63144. * Default : false
  63145. */
  63146. translateFromPivot: boolean;
  63147. /**
  63148. * Index of this particle in the global "positions" array (Internal use)
  63149. * @hidden
  63150. */
  63151. _pos: number;
  63152. /**
  63153. * @hidden Index of this particle in the global "indices" array (Internal use)
  63154. */
  63155. _ind: number;
  63156. /**
  63157. * Group this particle belongs to
  63158. */
  63159. _group: PointsGroup;
  63160. /**
  63161. * Group id of this particle
  63162. */
  63163. groupId: number;
  63164. /**
  63165. * Index of the particle in its group id (Internal use)
  63166. */
  63167. idxInGroup: number;
  63168. /**
  63169. * @hidden Particle BoundingInfo object (Internal use)
  63170. */
  63171. _boundingInfo: BoundingInfo;
  63172. /**
  63173. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63174. */
  63175. _pcs: PointsCloudSystem;
  63176. /**
  63177. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63178. */
  63179. _stillInvisible: boolean;
  63180. /**
  63181. * @hidden Last computed particle rotation matrix
  63182. */
  63183. _rotationMatrix: number[];
  63184. /**
  63185. * Parent particle Id, if any.
  63186. * Default null.
  63187. */
  63188. parentId: Nullable<number>;
  63189. /**
  63190. * @hidden Internal global position in the PCS.
  63191. */
  63192. _globalPosition: Vector3;
  63193. /**
  63194. * Creates a Point Cloud object.
  63195. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63196. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63197. * @param group (PointsGroup) is the group the particle belongs to
  63198. * @param groupId (integer) is the group identifier in the PCS.
  63199. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63200. * @param pcs defines the PCS it is associated to
  63201. */
  63202. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63203. /**
  63204. * get point size
  63205. */
  63206. /**
  63207. * Set point size
  63208. */
  63209. size: Vector3;
  63210. /**
  63211. * Legacy support, changed quaternion to rotationQuaternion
  63212. */
  63213. /**
  63214. * Legacy support, changed quaternion to rotationQuaternion
  63215. */
  63216. quaternion: Nullable<Quaternion>;
  63217. /**
  63218. * Returns a boolean. True if the particle intersects a mesh, else false
  63219. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63220. * @param target is the object (point or mesh) what the intersection is computed against
  63221. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63222. * @returns true if it intersects
  63223. */
  63224. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63225. /**
  63226. * get the rotation matrix of the particle
  63227. * @hidden
  63228. */
  63229. getRotationMatrix(m: Matrix): void;
  63230. }
  63231. /**
  63232. * Represents a group of points in a points cloud system
  63233. * * PCS internal tool, don't use it manually.
  63234. */
  63235. export class PointsGroup {
  63236. /**
  63237. * The group id
  63238. * @hidden
  63239. */
  63240. groupID: number;
  63241. /**
  63242. * image data for group (internal use)
  63243. * @hidden
  63244. */
  63245. _groupImageData: Nullable<ArrayBufferView>;
  63246. /**
  63247. * Image Width (internal use)
  63248. * @hidden
  63249. */
  63250. _groupImgWidth: number;
  63251. /**
  63252. * Image Height (internal use)
  63253. * @hidden
  63254. */
  63255. _groupImgHeight: number;
  63256. /**
  63257. * Custom position function (internal use)
  63258. * @hidden
  63259. */
  63260. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63261. /**
  63262. * density per facet for surface points
  63263. * @hidden
  63264. */
  63265. _groupDensity: number[];
  63266. /**
  63267. * Only when points are colored by texture carries pointer to texture list array
  63268. * @hidden
  63269. */
  63270. _textureNb: number;
  63271. /**
  63272. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63273. * PCS internal tool, don't use it manually.
  63274. * @hidden
  63275. */
  63276. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63277. }
  63278. }
  63279. declare module "babylonjs/Particles/index" {
  63280. export * from "babylonjs/Particles/baseParticleSystem";
  63281. export * from "babylonjs/Particles/EmitterTypes/index";
  63282. export * from "babylonjs/Particles/gpuParticleSystem";
  63283. export * from "babylonjs/Particles/IParticleSystem";
  63284. export * from "babylonjs/Particles/particle";
  63285. export * from "babylonjs/Particles/particleHelper";
  63286. export * from "babylonjs/Particles/particleSystem";
  63287. export * from "babylonjs/Particles/particleSystemComponent";
  63288. export * from "babylonjs/Particles/particleSystemSet";
  63289. export * from "babylonjs/Particles/solidParticle";
  63290. export * from "babylonjs/Particles/solidParticleSystem";
  63291. export * from "babylonjs/Particles/cloudPoint";
  63292. export * from "babylonjs/Particles/pointsCloudSystem";
  63293. export * from "babylonjs/Particles/subEmitter";
  63294. }
  63295. declare module "babylonjs/Physics/physicsEngineComponent" {
  63296. import { Nullable } from "babylonjs/types";
  63297. import { Observable, Observer } from "babylonjs/Misc/observable";
  63298. import { Vector3 } from "babylonjs/Maths/math.vector";
  63299. import { Mesh } from "babylonjs/Meshes/mesh";
  63300. import { ISceneComponent } from "babylonjs/sceneComponent";
  63301. import { Scene } from "babylonjs/scene";
  63302. import { Node } from "babylonjs/node";
  63303. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63304. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63305. module "babylonjs/scene" {
  63306. interface Scene {
  63307. /** @hidden (Backing field) */
  63308. _physicsEngine: Nullable<IPhysicsEngine>;
  63309. /** @hidden */
  63310. _physicsTimeAccumulator: number;
  63311. /**
  63312. * Gets the current physics engine
  63313. * @returns a IPhysicsEngine or null if none attached
  63314. */
  63315. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63316. /**
  63317. * Enables physics to the current scene
  63318. * @param gravity defines the scene's gravity for the physics engine
  63319. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63320. * @return a boolean indicating if the physics engine was initialized
  63321. */
  63322. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63323. /**
  63324. * Disables and disposes the physics engine associated with the scene
  63325. */
  63326. disablePhysicsEngine(): void;
  63327. /**
  63328. * Gets a boolean indicating if there is an active physics engine
  63329. * @returns a boolean indicating if there is an active physics engine
  63330. */
  63331. isPhysicsEnabled(): boolean;
  63332. /**
  63333. * Deletes a physics compound impostor
  63334. * @param compound defines the compound to delete
  63335. */
  63336. deleteCompoundImpostor(compound: any): void;
  63337. /**
  63338. * An event triggered when physic simulation is about to be run
  63339. */
  63340. onBeforePhysicsObservable: Observable<Scene>;
  63341. /**
  63342. * An event triggered when physic simulation has been done
  63343. */
  63344. onAfterPhysicsObservable: Observable<Scene>;
  63345. }
  63346. }
  63347. module "babylonjs/Meshes/abstractMesh" {
  63348. interface AbstractMesh {
  63349. /** @hidden */
  63350. _physicsImpostor: Nullable<PhysicsImpostor>;
  63351. /**
  63352. * Gets or sets impostor used for physic simulation
  63353. * @see http://doc.babylonjs.com/features/physics_engine
  63354. */
  63355. physicsImpostor: Nullable<PhysicsImpostor>;
  63356. /**
  63357. * Gets the current physics impostor
  63358. * @see http://doc.babylonjs.com/features/physics_engine
  63359. * @returns a physics impostor or null
  63360. */
  63361. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63362. /** Apply a physic impulse to the mesh
  63363. * @param force defines the force to apply
  63364. * @param contactPoint defines where to apply the force
  63365. * @returns the current mesh
  63366. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63367. */
  63368. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63369. /**
  63370. * Creates a physic joint between two meshes
  63371. * @param otherMesh defines the other mesh to use
  63372. * @param pivot1 defines the pivot to use on this mesh
  63373. * @param pivot2 defines the pivot to use on the other mesh
  63374. * @param options defines additional options (can be plugin dependent)
  63375. * @returns the current mesh
  63376. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63377. */
  63378. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63379. /** @hidden */
  63380. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63381. }
  63382. }
  63383. /**
  63384. * Defines the physics engine scene component responsible to manage a physics engine
  63385. */
  63386. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63387. /**
  63388. * The component name helpful to identify the component in the list of scene components.
  63389. */
  63390. readonly name: string;
  63391. /**
  63392. * The scene the component belongs to.
  63393. */
  63394. scene: Scene;
  63395. /**
  63396. * Creates a new instance of the component for the given scene
  63397. * @param scene Defines the scene to register the component in
  63398. */
  63399. constructor(scene: Scene);
  63400. /**
  63401. * Registers the component in a given scene
  63402. */
  63403. register(): void;
  63404. /**
  63405. * Rebuilds the elements related to this component in case of
  63406. * context lost for instance.
  63407. */
  63408. rebuild(): void;
  63409. /**
  63410. * Disposes the component and the associated ressources
  63411. */
  63412. dispose(): void;
  63413. }
  63414. }
  63415. declare module "babylonjs/Physics/physicsHelper" {
  63416. import { Nullable } from "babylonjs/types";
  63417. import { Vector3 } from "babylonjs/Maths/math.vector";
  63418. import { Mesh } from "babylonjs/Meshes/mesh";
  63419. import { Scene } from "babylonjs/scene";
  63420. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63421. /**
  63422. * A helper for physics simulations
  63423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63424. */
  63425. export class PhysicsHelper {
  63426. private _scene;
  63427. private _physicsEngine;
  63428. /**
  63429. * Initializes the Physics helper
  63430. * @param scene Babylon.js scene
  63431. */
  63432. constructor(scene: Scene);
  63433. /**
  63434. * Applies a radial explosion impulse
  63435. * @param origin the origin of the explosion
  63436. * @param radiusOrEventOptions the radius or the options of radial explosion
  63437. * @param strength the explosion strength
  63438. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63439. * @returns A physics radial explosion event, or null
  63440. */
  63441. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63442. /**
  63443. * Applies a radial explosion force
  63444. * @param origin the origin of the explosion
  63445. * @param radiusOrEventOptions the radius or the options of radial explosion
  63446. * @param strength the explosion strength
  63447. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63448. * @returns A physics radial explosion event, or null
  63449. */
  63450. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63451. /**
  63452. * Creates a gravitational field
  63453. * @param origin the origin of the explosion
  63454. * @param radiusOrEventOptions the radius or the options of radial explosion
  63455. * @param strength the explosion strength
  63456. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63457. * @returns A physics gravitational field event, or null
  63458. */
  63459. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63460. /**
  63461. * Creates a physics updraft event
  63462. * @param origin the origin of the updraft
  63463. * @param radiusOrEventOptions the radius or the options of the updraft
  63464. * @param strength the strength of the updraft
  63465. * @param height the height of the updraft
  63466. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63467. * @returns A physics updraft event, or null
  63468. */
  63469. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63470. /**
  63471. * Creates a physics vortex event
  63472. * @param origin the of the vortex
  63473. * @param radiusOrEventOptions the radius or the options of the vortex
  63474. * @param strength the strength of the vortex
  63475. * @param height the height of the vortex
  63476. * @returns a Physics vortex event, or null
  63477. * A physics vortex event or null
  63478. */
  63479. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63480. }
  63481. /**
  63482. * Represents a physics radial explosion event
  63483. */
  63484. class PhysicsRadialExplosionEvent {
  63485. private _scene;
  63486. private _options;
  63487. private _sphere;
  63488. private _dataFetched;
  63489. /**
  63490. * Initializes a radial explosioin event
  63491. * @param _scene BabylonJS scene
  63492. * @param _options The options for the vortex event
  63493. */
  63494. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63495. /**
  63496. * Returns the data related to the radial explosion event (sphere).
  63497. * @returns The radial explosion event data
  63498. */
  63499. getData(): PhysicsRadialExplosionEventData;
  63500. /**
  63501. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63502. * @param impostor A physics imposter
  63503. * @param origin the origin of the explosion
  63504. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63505. */
  63506. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63507. /**
  63508. * Triggers affecterd impostors callbacks
  63509. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63510. */
  63511. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63512. /**
  63513. * Disposes the sphere.
  63514. * @param force Specifies if the sphere should be disposed by force
  63515. */
  63516. dispose(force?: boolean): void;
  63517. /*** Helpers ***/
  63518. private _prepareSphere;
  63519. private _intersectsWithSphere;
  63520. }
  63521. /**
  63522. * Represents a gravitational field event
  63523. */
  63524. class PhysicsGravitationalFieldEvent {
  63525. private _physicsHelper;
  63526. private _scene;
  63527. private _origin;
  63528. private _options;
  63529. private _tickCallback;
  63530. private _sphere;
  63531. private _dataFetched;
  63532. /**
  63533. * Initializes the physics gravitational field event
  63534. * @param _physicsHelper A physics helper
  63535. * @param _scene BabylonJS scene
  63536. * @param _origin The origin position of the gravitational field event
  63537. * @param _options The options for the vortex event
  63538. */
  63539. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63540. /**
  63541. * Returns the data related to the gravitational field event (sphere).
  63542. * @returns A gravitational field event
  63543. */
  63544. getData(): PhysicsGravitationalFieldEventData;
  63545. /**
  63546. * Enables the gravitational field.
  63547. */
  63548. enable(): void;
  63549. /**
  63550. * Disables the gravitational field.
  63551. */
  63552. disable(): void;
  63553. /**
  63554. * Disposes the sphere.
  63555. * @param force The force to dispose from the gravitational field event
  63556. */
  63557. dispose(force?: boolean): void;
  63558. private _tick;
  63559. }
  63560. /**
  63561. * Represents a physics updraft event
  63562. */
  63563. class PhysicsUpdraftEvent {
  63564. private _scene;
  63565. private _origin;
  63566. private _options;
  63567. private _physicsEngine;
  63568. private _originTop;
  63569. private _originDirection;
  63570. private _tickCallback;
  63571. private _cylinder;
  63572. private _cylinderPosition;
  63573. private _dataFetched;
  63574. /**
  63575. * Initializes the physics updraft event
  63576. * @param _scene BabylonJS scene
  63577. * @param _origin The origin position of the updraft
  63578. * @param _options The options for the updraft event
  63579. */
  63580. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63581. /**
  63582. * Returns the data related to the updraft event (cylinder).
  63583. * @returns A physics updraft event
  63584. */
  63585. getData(): PhysicsUpdraftEventData;
  63586. /**
  63587. * Enables the updraft.
  63588. */
  63589. enable(): void;
  63590. /**
  63591. * Disables the updraft.
  63592. */
  63593. disable(): void;
  63594. /**
  63595. * Disposes the cylinder.
  63596. * @param force Specifies if the updraft should be disposed by force
  63597. */
  63598. dispose(force?: boolean): void;
  63599. private getImpostorHitData;
  63600. private _tick;
  63601. /*** Helpers ***/
  63602. private _prepareCylinder;
  63603. private _intersectsWithCylinder;
  63604. }
  63605. /**
  63606. * Represents a physics vortex event
  63607. */
  63608. class PhysicsVortexEvent {
  63609. private _scene;
  63610. private _origin;
  63611. private _options;
  63612. private _physicsEngine;
  63613. private _originTop;
  63614. private _tickCallback;
  63615. private _cylinder;
  63616. private _cylinderPosition;
  63617. private _dataFetched;
  63618. /**
  63619. * Initializes the physics vortex event
  63620. * @param _scene The BabylonJS scene
  63621. * @param _origin The origin position of the vortex
  63622. * @param _options The options for the vortex event
  63623. */
  63624. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63625. /**
  63626. * Returns the data related to the vortex event (cylinder).
  63627. * @returns The physics vortex event data
  63628. */
  63629. getData(): PhysicsVortexEventData;
  63630. /**
  63631. * Enables the vortex.
  63632. */
  63633. enable(): void;
  63634. /**
  63635. * Disables the cortex.
  63636. */
  63637. disable(): void;
  63638. /**
  63639. * Disposes the sphere.
  63640. * @param force
  63641. */
  63642. dispose(force?: boolean): void;
  63643. private getImpostorHitData;
  63644. private _tick;
  63645. /*** Helpers ***/
  63646. private _prepareCylinder;
  63647. private _intersectsWithCylinder;
  63648. }
  63649. /**
  63650. * Options fot the radial explosion event
  63651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63652. */
  63653. export class PhysicsRadialExplosionEventOptions {
  63654. /**
  63655. * The radius of the sphere for the radial explosion.
  63656. */
  63657. radius: number;
  63658. /**
  63659. * The strenth of the explosion.
  63660. */
  63661. strength: number;
  63662. /**
  63663. * The strenght of the force in correspondence to the distance of the affected object
  63664. */
  63665. falloff: PhysicsRadialImpulseFalloff;
  63666. /**
  63667. * Sphere options for the radial explosion.
  63668. */
  63669. sphere: {
  63670. segments: number;
  63671. diameter: number;
  63672. };
  63673. /**
  63674. * Sphere options for the radial explosion.
  63675. */
  63676. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63677. }
  63678. /**
  63679. * Options fot the updraft event
  63680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63681. */
  63682. export class PhysicsUpdraftEventOptions {
  63683. /**
  63684. * The radius of the cylinder for the vortex
  63685. */
  63686. radius: number;
  63687. /**
  63688. * The strenth of the updraft.
  63689. */
  63690. strength: number;
  63691. /**
  63692. * The height of the cylinder for the updraft.
  63693. */
  63694. height: number;
  63695. /**
  63696. * The mode for the the updraft.
  63697. */
  63698. updraftMode: PhysicsUpdraftMode;
  63699. }
  63700. /**
  63701. * Options fot the vortex event
  63702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63703. */
  63704. export class PhysicsVortexEventOptions {
  63705. /**
  63706. * The radius of the cylinder for the vortex
  63707. */
  63708. radius: number;
  63709. /**
  63710. * The strenth of the vortex.
  63711. */
  63712. strength: number;
  63713. /**
  63714. * The height of the cylinder for the vortex.
  63715. */
  63716. height: number;
  63717. /**
  63718. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63719. */
  63720. centripetalForceThreshold: number;
  63721. /**
  63722. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63723. */
  63724. centripetalForceMultiplier: number;
  63725. /**
  63726. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63727. */
  63728. centrifugalForceMultiplier: number;
  63729. /**
  63730. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63731. */
  63732. updraftForceMultiplier: number;
  63733. }
  63734. /**
  63735. * The strenght of the force in correspondence to the distance of the affected object
  63736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63737. */
  63738. export enum PhysicsRadialImpulseFalloff {
  63739. /** Defines that impulse is constant in strength across it's whole radius */
  63740. Constant = 0,
  63741. /** Defines that impulse gets weaker if it's further from the origin */
  63742. Linear = 1
  63743. }
  63744. /**
  63745. * The strength of the force in correspondence to the distance of the affected object
  63746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63747. */
  63748. export enum PhysicsUpdraftMode {
  63749. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63750. Center = 0,
  63751. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63752. Perpendicular = 1
  63753. }
  63754. /**
  63755. * Interface for a physics hit data
  63756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63757. */
  63758. export interface PhysicsHitData {
  63759. /**
  63760. * The force applied at the contact point
  63761. */
  63762. force: Vector3;
  63763. /**
  63764. * The contact point
  63765. */
  63766. contactPoint: Vector3;
  63767. /**
  63768. * The distance from the origin to the contact point
  63769. */
  63770. distanceFromOrigin: number;
  63771. }
  63772. /**
  63773. * Interface for radial explosion event data
  63774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63775. */
  63776. export interface PhysicsRadialExplosionEventData {
  63777. /**
  63778. * A sphere used for the radial explosion event
  63779. */
  63780. sphere: Mesh;
  63781. }
  63782. /**
  63783. * Interface for gravitational field event data
  63784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63785. */
  63786. export interface PhysicsGravitationalFieldEventData {
  63787. /**
  63788. * A sphere mesh used for the gravitational field event
  63789. */
  63790. sphere: Mesh;
  63791. }
  63792. /**
  63793. * Interface for updraft event data
  63794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63795. */
  63796. export interface PhysicsUpdraftEventData {
  63797. /**
  63798. * A cylinder used for the updraft event
  63799. */
  63800. cylinder: Mesh;
  63801. }
  63802. /**
  63803. * Interface for vortex event data
  63804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63805. */
  63806. export interface PhysicsVortexEventData {
  63807. /**
  63808. * A cylinder used for the vortex event
  63809. */
  63810. cylinder: Mesh;
  63811. }
  63812. /**
  63813. * Interface for an affected physics impostor
  63814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63815. */
  63816. export interface PhysicsAffectedImpostorWithData {
  63817. /**
  63818. * The impostor affected by the effect
  63819. */
  63820. impostor: PhysicsImpostor;
  63821. /**
  63822. * The data about the hit/horce from the explosion
  63823. */
  63824. hitData: PhysicsHitData;
  63825. }
  63826. }
  63827. declare module "babylonjs/Physics/Plugins/index" {
  63828. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63829. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63830. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63831. }
  63832. declare module "babylonjs/Physics/index" {
  63833. export * from "babylonjs/Physics/IPhysicsEngine";
  63834. export * from "babylonjs/Physics/physicsEngine";
  63835. export * from "babylonjs/Physics/physicsEngineComponent";
  63836. export * from "babylonjs/Physics/physicsHelper";
  63837. export * from "babylonjs/Physics/physicsImpostor";
  63838. export * from "babylonjs/Physics/physicsJoint";
  63839. export * from "babylonjs/Physics/Plugins/index";
  63840. }
  63841. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63842. /** @hidden */
  63843. export var blackAndWhitePixelShader: {
  63844. name: string;
  63845. shader: string;
  63846. };
  63847. }
  63848. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63849. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63850. import { Camera } from "babylonjs/Cameras/camera";
  63851. import { Engine } from "babylonjs/Engines/engine";
  63852. import "babylonjs/Shaders/blackAndWhite.fragment";
  63853. /**
  63854. * Post process used to render in black and white
  63855. */
  63856. export class BlackAndWhitePostProcess extends PostProcess {
  63857. /**
  63858. * Linear about to convert he result to black and white (default: 1)
  63859. */
  63860. degree: number;
  63861. /**
  63862. * Creates a black and white post process
  63863. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63864. * @param name The name of the effect.
  63865. * @param options The required width/height ratio to downsize to before computing the render pass.
  63866. * @param camera The camera to apply the render pass to.
  63867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63868. * @param engine The engine which the post process will be applied. (default: current engine)
  63869. * @param reusable If the post process can be reused on the same frame. (default: false)
  63870. */
  63871. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63872. }
  63873. }
  63874. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63875. import { Nullable } from "babylonjs/types";
  63876. import { Camera } from "babylonjs/Cameras/camera";
  63877. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63878. import { Engine } from "babylonjs/Engines/engine";
  63879. /**
  63880. * This represents a set of one or more post processes in Babylon.
  63881. * A post process can be used to apply a shader to a texture after it is rendered.
  63882. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63883. */
  63884. export class PostProcessRenderEffect {
  63885. private _postProcesses;
  63886. private _getPostProcesses;
  63887. private _singleInstance;
  63888. private _cameras;
  63889. private _indicesForCamera;
  63890. /**
  63891. * Name of the effect
  63892. * @hidden
  63893. */
  63894. _name: string;
  63895. /**
  63896. * Instantiates a post process render effect.
  63897. * A post process can be used to apply a shader to a texture after it is rendered.
  63898. * @param engine The engine the effect is tied to
  63899. * @param name The name of the effect
  63900. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63901. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63902. */
  63903. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63904. /**
  63905. * Checks if all the post processes in the effect are supported.
  63906. */
  63907. readonly isSupported: boolean;
  63908. /**
  63909. * Updates the current state of the effect
  63910. * @hidden
  63911. */
  63912. _update(): void;
  63913. /**
  63914. * Attaches the effect on cameras
  63915. * @param cameras The camera to attach to.
  63916. * @hidden
  63917. */
  63918. _attachCameras(cameras: Camera): void;
  63919. /**
  63920. * Attaches the effect on cameras
  63921. * @param cameras The camera to attach to.
  63922. * @hidden
  63923. */
  63924. _attachCameras(cameras: Camera[]): void;
  63925. /**
  63926. * Detaches the effect on cameras
  63927. * @param cameras The camera to detatch from.
  63928. * @hidden
  63929. */
  63930. _detachCameras(cameras: Camera): void;
  63931. /**
  63932. * Detatches the effect on cameras
  63933. * @param cameras The camera to detatch from.
  63934. * @hidden
  63935. */
  63936. _detachCameras(cameras: Camera[]): void;
  63937. /**
  63938. * Enables the effect on given cameras
  63939. * @param cameras The camera to enable.
  63940. * @hidden
  63941. */
  63942. _enable(cameras: Camera): void;
  63943. /**
  63944. * Enables the effect on given cameras
  63945. * @param cameras The camera to enable.
  63946. * @hidden
  63947. */
  63948. _enable(cameras: Nullable<Camera[]>): void;
  63949. /**
  63950. * Disables the effect on the given cameras
  63951. * @param cameras The camera to disable.
  63952. * @hidden
  63953. */
  63954. _disable(cameras: Camera): void;
  63955. /**
  63956. * Disables the effect on the given cameras
  63957. * @param cameras The camera to disable.
  63958. * @hidden
  63959. */
  63960. _disable(cameras: Nullable<Camera[]>): void;
  63961. /**
  63962. * Gets a list of the post processes contained in the effect.
  63963. * @param camera The camera to get the post processes on.
  63964. * @returns The list of the post processes in the effect.
  63965. */
  63966. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63967. }
  63968. }
  63969. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63970. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63971. /** @hidden */
  63972. export var extractHighlightsPixelShader: {
  63973. name: string;
  63974. shader: string;
  63975. };
  63976. }
  63977. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63978. import { Nullable } from "babylonjs/types";
  63979. import { Camera } from "babylonjs/Cameras/camera";
  63980. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63981. import { Engine } from "babylonjs/Engines/engine";
  63982. import "babylonjs/Shaders/extractHighlights.fragment";
  63983. /**
  63984. * 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.
  63985. */
  63986. export class ExtractHighlightsPostProcess extends PostProcess {
  63987. /**
  63988. * The luminance threshold, pixels below this value will be set to black.
  63989. */
  63990. threshold: number;
  63991. /** @hidden */
  63992. _exposure: number;
  63993. /**
  63994. * Post process which has the input texture to be used when performing highlight extraction
  63995. * @hidden
  63996. */
  63997. _inputPostProcess: Nullable<PostProcess>;
  63998. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63999. }
  64000. }
  64001. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  64002. /** @hidden */
  64003. export var bloomMergePixelShader: {
  64004. name: string;
  64005. shader: string;
  64006. };
  64007. }
  64008. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  64009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64010. import { Nullable } from "babylonjs/types";
  64011. import { Engine } from "babylonjs/Engines/engine";
  64012. import { Camera } from "babylonjs/Cameras/camera";
  64013. import "babylonjs/Shaders/bloomMerge.fragment";
  64014. /**
  64015. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64016. */
  64017. export class BloomMergePostProcess extends PostProcess {
  64018. /** Weight of the bloom to be added to the original input. */
  64019. weight: number;
  64020. /**
  64021. * Creates a new instance of @see BloomMergePostProcess
  64022. * @param name The name of the effect.
  64023. * @param originalFromInput Post process which's input will be used for the merge.
  64024. * @param blurred Blurred highlights post process which's output will be used.
  64025. * @param weight Weight of the bloom to be added to the original input.
  64026. * @param options The required width/height ratio to downsize to before computing the render pass.
  64027. * @param camera The camera to apply the render pass to.
  64028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64029. * @param engine The engine which the post process will be applied. (default: current engine)
  64030. * @param reusable If the post process can be reused on the same frame. (default: false)
  64031. * @param textureType Type of textures used when performing the post process. (default: 0)
  64032. * @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)
  64033. */
  64034. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64035. /** Weight of the bloom to be added to the original input. */
  64036. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64037. }
  64038. }
  64039. declare module "babylonjs/PostProcesses/bloomEffect" {
  64040. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64041. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64042. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64043. import { Camera } from "babylonjs/Cameras/camera";
  64044. import { Scene } from "babylonjs/scene";
  64045. /**
  64046. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64047. */
  64048. export class BloomEffect extends PostProcessRenderEffect {
  64049. private bloomScale;
  64050. /**
  64051. * @hidden Internal
  64052. */
  64053. _effects: Array<PostProcess>;
  64054. /**
  64055. * @hidden Internal
  64056. */
  64057. _downscale: ExtractHighlightsPostProcess;
  64058. private _blurX;
  64059. private _blurY;
  64060. private _merge;
  64061. /**
  64062. * The luminance threshold to find bright areas of the image to bloom.
  64063. */
  64064. threshold: number;
  64065. /**
  64066. * The strength of the bloom.
  64067. */
  64068. weight: number;
  64069. /**
  64070. * Specifies the size of the bloom blur kernel, relative to the final output size
  64071. */
  64072. kernel: number;
  64073. /**
  64074. * Creates a new instance of @see BloomEffect
  64075. * @param scene The scene the effect belongs to.
  64076. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64077. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64078. * @param bloomWeight The the strength of bloom.
  64079. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64080. * @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)
  64081. */
  64082. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64083. /**
  64084. * Disposes each of the internal effects for a given camera.
  64085. * @param camera The camera to dispose the effect on.
  64086. */
  64087. disposeEffects(camera: Camera): void;
  64088. /**
  64089. * @hidden Internal
  64090. */
  64091. _updateEffects(): void;
  64092. /**
  64093. * Internal
  64094. * @returns if all the contained post processes are ready.
  64095. * @hidden
  64096. */
  64097. _isReady(): boolean;
  64098. }
  64099. }
  64100. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  64101. /** @hidden */
  64102. export var chromaticAberrationPixelShader: {
  64103. name: string;
  64104. shader: string;
  64105. };
  64106. }
  64107. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  64108. import { Vector2 } from "babylonjs/Maths/math.vector";
  64109. import { Nullable } from "babylonjs/types";
  64110. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64111. import { Camera } from "babylonjs/Cameras/camera";
  64112. import { Engine } from "babylonjs/Engines/engine";
  64113. import "babylonjs/Shaders/chromaticAberration.fragment";
  64114. /**
  64115. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64116. */
  64117. export class ChromaticAberrationPostProcess extends PostProcess {
  64118. /**
  64119. * The amount of seperation of rgb channels (default: 30)
  64120. */
  64121. aberrationAmount: number;
  64122. /**
  64123. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64124. */
  64125. radialIntensity: number;
  64126. /**
  64127. * 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))
  64128. */
  64129. direction: Vector2;
  64130. /**
  64131. * 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))
  64132. */
  64133. centerPosition: Vector2;
  64134. /**
  64135. * Creates a new instance ChromaticAberrationPostProcess
  64136. * @param name The name of the effect.
  64137. * @param screenWidth The width of the screen to apply the effect on.
  64138. * @param screenHeight The height of the screen to apply the effect on.
  64139. * @param options The required width/height ratio to downsize to before computing the render pass.
  64140. * @param camera The camera to apply the render pass to.
  64141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64142. * @param engine The engine which the post process will be applied. (default: current engine)
  64143. * @param reusable If the post process can be reused on the same frame. (default: false)
  64144. * @param textureType Type of textures used when performing the post process. (default: 0)
  64145. * @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)
  64146. */
  64147. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64148. }
  64149. }
  64150. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  64151. /** @hidden */
  64152. export var circleOfConfusionPixelShader: {
  64153. name: string;
  64154. shader: string;
  64155. };
  64156. }
  64157. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  64158. import { Nullable } from "babylonjs/types";
  64159. import { Engine } from "babylonjs/Engines/engine";
  64160. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64161. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64162. import { Camera } from "babylonjs/Cameras/camera";
  64163. import "babylonjs/Shaders/circleOfConfusion.fragment";
  64164. /**
  64165. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64166. */
  64167. export class CircleOfConfusionPostProcess extends PostProcess {
  64168. /**
  64169. * 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.
  64170. */
  64171. lensSize: number;
  64172. /**
  64173. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64174. */
  64175. fStop: number;
  64176. /**
  64177. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64178. */
  64179. focusDistance: number;
  64180. /**
  64181. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64182. */
  64183. focalLength: number;
  64184. private _depthTexture;
  64185. /**
  64186. * Creates a new instance CircleOfConfusionPostProcess
  64187. * @param name The name of the effect.
  64188. * @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.
  64189. * @param options The required width/height ratio to downsize to before computing the render pass.
  64190. * @param camera The camera to apply the render pass to.
  64191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64192. * @param engine The engine which the post process will be applied. (default: current engine)
  64193. * @param reusable If the post process can be reused on the same frame. (default: false)
  64194. * @param textureType Type of textures used when performing the post process. (default: 0)
  64195. * @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)
  64196. */
  64197. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64198. /**
  64199. * 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.
  64200. */
  64201. depthTexture: RenderTargetTexture;
  64202. }
  64203. }
  64204. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  64205. /** @hidden */
  64206. export var colorCorrectionPixelShader: {
  64207. name: string;
  64208. shader: string;
  64209. };
  64210. }
  64211. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  64212. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64213. import { Engine } from "babylonjs/Engines/engine";
  64214. import { Camera } from "babylonjs/Cameras/camera";
  64215. import "babylonjs/Shaders/colorCorrection.fragment";
  64216. /**
  64217. *
  64218. * This post-process allows the modification of rendered colors by using
  64219. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64220. *
  64221. * The object needs to be provided an url to a texture containing the color
  64222. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64223. * Use an image editing software to tweak the LUT to match your needs.
  64224. *
  64225. * For an example of a color LUT, see here:
  64226. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64227. * For explanations on color grading, see here:
  64228. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64229. *
  64230. */
  64231. export class ColorCorrectionPostProcess extends PostProcess {
  64232. private _colorTableTexture;
  64233. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64234. }
  64235. }
  64236. declare module "babylonjs/Shaders/convolution.fragment" {
  64237. /** @hidden */
  64238. export var convolutionPixelShader: {
  64239. name: string;
  64240. shader: string;
  64241. };
  64242. }
  64243. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  64244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64245. import { Nullable } from "babylonjs/types";
  64246. import { Camera } from "babylonjs/Cameras/camera";
  64247. import { Engine } from "babylonjs/Engines/engine";
  64248. import "babylonjs/Shaders/convolution.fragment";
  64249. /**
  64250. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64251. * input texture to perform effects such as edge detection or sharpening
  64252. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64253. */
  64254. export class ConvolutionPostProcess extends PostProcess {
  64255. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64256. kernel: number[];
  64257. /**
  64258. * Creates a new instance ConvolutionPostProcess
  64259. * @param name The name of the effect.
  64260. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64261. * @param options The required width/height ratio to downsize to before computing the render pass.
  64262. * @param camera The camera to apply the render pass to.
  64263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64264. * @param engine The engine which the post process will be applied. (default: current engine)
  64265. * @param reusable If the post process can be reused on the same frame. (default: false)
  64266. * @param textureType Type of textures used when performing the post process. (default: 0)
  64267. */
  64268. constructor(name: string,
  64269. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64270. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64271. /**
  64272. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64273. */
  64274. static EdgeDetect0Kernel: number[];
  64275. /**
  64276. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64277. */
  64278. static EdgeDetect1Kernel: number[];
  64279. /**
  64280. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64281. */
  64282. static EdgeDetect2Kernel: number[];
  64283. /**
  64284. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64285. */
  64286. static SharpenKernel: number[];
  64287. /**
  64288. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64289. */
  64290. static EmbossKernel: number[];
  64291. /**
  64292. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64293. */
  64294. static GaussianKernel: number[];
  64295. }
  64296. }
  64297. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  64298. import { Nullable } from "babylonjs/types";
  64299. import { Vector2 } from "babylonjs/Maths/math.vector";
  64300. import { Camera } from "babylonjs/Cameras/camera";
  64301. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64302. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64303. import { Engine } from "babylonjs/Engines/engine";
  64304. import { Scene } from "babylonjs/scene";
  64305. /**
  64306. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64307. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64308. * based on samples that have a large difference in distance than the center pixel.
  64309. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64310. */
  64311. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64312. direction: Vector2;
  64313. /**
  64314. * Creates a new instance CircleOfConfusionPostProcess
  64315. * @param name The name of the effect.
  64316. * @param scene The scene the effect belongs to.
  64317. * @param direction The direction the blur should be applied.
  64318. * @param kernel The size of the kernel used to blur.
  64319. * @param options The required width/height ratio to downsize to before computing the render pass.
  64320. * @param camera The camera to apply the render pass to.
  64321. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64322. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64324. * @param engine The engine which the post process will be applied. (default: current engine)
  64325. * @param reusable If the post process can be reused on the same frame. (default: false)
  64326. * @param textureType Type of textures used when performing the post process. (default: 0)
  64327. * @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)
  64328. */
  64329. 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);
  64330. }
  64331. }
  64332. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  64333. /** @hidden */
  64334. export var depthOfFieldMergePixelShader: {
  64335. name: string;
  64336. shader: string;
  64337. };
  64338. }
  64339. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  64340. import { Nullable } from "babylonjs/types";
  64341. import { Camera } from "babylonjs/Cameras/camera";
  64342. import { Effect } from "babylonjs/Materials/effect";
  64343. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64344. import { Engine } from "babylonjs/Engines/engine";
  64345. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  64346. /**
  64347. * Options to be set when merging outputs from the default pipeline.
  64348. */
  64349. export class DepthOfFieldMergePostProcessOptions {
  64350. /**
  64351. * The original image to merge on top of
  64352. */
  64353. originalFromInput: PostProcess;
  64354. /**
  64355. * Parameters to perform the merge of the depth of field effect
  64356. */
  64357. depthOfField?: {
  64358. circleOfConfusion: PostProcess;
  64359. blurSteps: Array<PostProcess>;
  64360. };
  64361. /**
  64362. * Parameters to perform the merge of bloom effect
  64363. */
  64364. bloom?: {
  64365. blurred: PostProcess;
  64366. weight: number;
  64367. };
  64368. }
  64369. /**
  64370. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64371. */
  64372. export class DepthOfFieldMergePostProcess extends PostProcess {
  64373. private blurSteps;
  64374. /**
  64375. * Creates a new instance of DepthOfFieldMergePostProcess
  64376. * @param name The name of the effect.
  64377. * @param originalFromInput Post process which's input will be used for the merge.
  64378. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64379. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64380. * @param options The required width/height ratio to downsize to before computing the render pass.
  64381. * @param camera The camera to apply the render pass to.
  64382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64383. * @param engine The engine which the post process will be applied. (default: current engine)
  64384. * @param reusable If the post process can be reused on the same frame. (default: false)
  64385. * @param textureType Type of textures used when performing the post process. (default: 0)
  64386. * @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)
  64387. */
  64388. 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);
  64389. /**
  64390. * Updates the effect with the current post process compile time values and recompiles the shader.
  64391. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64392. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64393. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64394. * @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
  64395. * @param onCompiled Called when the shader has been compiled.
  64396. * @param onError Called if there is an error when compiling a shader.
  64397. */
  64398. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64399. }
  64400. }
  64401. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  64402. import { Nullable } from "babylonjs/types";
  64403. import { Camera } from "babylonjs/Cameras/camera";
  64404. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64405. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64406. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64407. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64408. import { Scene } from "babylonjs/scene";
  64409. /**
  64410. * Specifies the level of max blur that should be applied when using the depth of field effect
  64411. */
  64412. export enum DepthOfFieldEffectBlurLevel {
  64413. /**
  64414. * Subtle blur
  64415. */
  64416. Low = 0,
  64417. /**
  64418. * Medium blur
  64419. */
  64420. Medium = 1,
  64421. /**
  64422. * Large blur
  64423. */
  64424. High = 2
  64425. }
  64426. /**
  64427. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64428. */
  64429. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64430. private _circleOfConfusion;
  64431. /**
  64432. * @hidden Internal, blurs from high to low
  64433. */
  64434. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64435. private _depthOfFieldBlurY;
  64436. private _dofMerge;
  64437. /**
  64438. * @hidden Internal post processes in depth of field effect
  64439. */
  64440. _effects: Array<PostProcess>;
  64441. /**
  64442. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64443. */
  64444. focalLength: number;
  64445. /**
  64446. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64447. */
  64448. fStop: number;
  64449. /**
  64450. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64451. */
  64452. focusDistance: number;
  64453. /**
  64454. * 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.
  64455. */
  64456. lensSize: number;
  64457. /**
  64458. * Creates a new instance DepthOfFieldEffect
  64459. * @param scene The scene the effect belongs to.
  64460. * @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.
  64461. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64462. * @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)
  64463. */
  64464. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64465. /**
  64466. * Get the current class name of the current effet
  64467. * @returns "DepthOfFieldEffect"
  64468. */
  64469. getClassName(): string;
  64470. /**
  64471. * 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.
  64472. */
  64473. depthTexture: RenderTargetTexture;
  64474. /**
  64475. * Disposes each of the internal effects for a given camera.
  64476. * @param camera The camera to dispose the effect on.
  64477. */
  64478. disposeEffects(camera: Camera): void;
  64479. /**
  64480. * @hidden Internal
  64481. */
  64482. _updateEffects(): void;
  64483. /**
  64484. * Internal
  64485. * @returns if all the contained post processes are ready.
  64486. * @hidden
  64487. */
  64488. _isReady(): boolean;
  64489. }
  64490. }
  64491. declare module "babylonjs/Shaders/displayPass.fragment" {
  64492. /** @hidden */
  64493. export var displayPassPixelShader: {
  64494. name: string;
  64495. shader: string;
  64496. };
  64497. }
  64498. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64499. import { Nullable } from "babylonjs/types";
  64500. import { Camera } from "babylonjs/Cameras/camera";
  64501. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64502. import { Engine } from "babylonjs/Engines/engine";
  64503. import "babylonjs/Shaders/displayPass.fragment";
  64504. /**
  64505. * DisplayPassPostProcess which produces an output the same as it's input
  64506. */
  64507. export class DisplayPassPostProcess extends PostProcess {
  64508. /**
  64509. * Creates the DisplayPassPostProcess
  64510. * @param name The name of the effect.
  64511. * @param options The required width/height ratio to downsize to before computing the render pass.
  64512. * @param camera The camera to apply the render pass to.
  64513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64514. * @param engine The engine which the post process will be applied. (default: current engine)
  64515. * @param reusable If the post process can be reused on the same frame. (default: false)
  64516. */
  64517. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64518. }
  64519. }
  64520. declare module "babylonjs/Shaders/filter.fragment" {
  64521. /** @hidden */
  64522. export var filterPixelShader: {
  64523. name: string;
  64524. shader: string;
  64525. };
  64526. }
  64527. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64528. import { Nullable } from "babylonjs/types";
  64529. import { Matrix } from "babylonjs/Maths/math.vector";
  64530. import { Camera } from "babylonjs/Cameras/camera";
  64531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64532. import { Engine } from "babylonjs/Engines/engine";
  64533. import "babylonjs/Shaders/filter.fragment";
  64534. /**
  64535. * Applies a kernel filter to the image
  64536. */
  64537. export class FilterPostProcess extends PostProcess {
  64538. /** The matrix to be applied to the image */
  64539. kernelMatrix: Matrix;
  64540. /**
  64541. *
  64542. * @param name The name of the effect.
  64543. * @param kernelMatrix The matrix to be applied to the image
  64544. * @param options The required width/height ratio to downsize to before computing the render pass.
  64545. * @param camera The camera to apply the render pass to.
  64546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64547. * @param engine The engine which the post process will be applied. (default: current engine)
  64548. * @param reusable If the post process can be reused on the same frame. (default: false)
  64549. */
  64550. constructor(name: string,
  64551. /** The matrix to be applied to the image */
  64552. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64553. }
  64554. }
  64555. declare module "babylonjs/Shaders/fxaa.fragment" {
  64556. /** @hidden */
  64557. export var fxaaPixelShader: {
  64558. name: string;
  64559. shader: string;
  64560. };
  64561. }
  64562. declare module "babylonjs/Shaders/fxaa.vertex" {
  64563. /** @hidden */
  64564. export var fxaaVertexShader: {
  64565. name: string;
  64566. shader: string;
  64567. };
  64568. }
  64569. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64570. import { Nullable } from "babylonjs/types";
  64571. import { Camera } from "babylonjs/Cameras/camera";
  64572. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64573. import { Engine } from "babylonjs/Engines/engine";
  64574. import "babylonjs/Shaders/fxaa.fragment";
  64575. import "babylonjs/Shaders/fxaa.vertex";
  64576. /**
  64577. * Fxaa post process
  64578. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64579. */
  64580. export class FxaaPostProcess extends PostProcess {
  64581. /** @hidden */
  64582. texelWidth: number;
  64583. /** @hidden */
  64584. texelHeight: number;
  64585. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64586. private _getDefines;
  64587. }
  64588. }
  64589. declare module "babylonjs/Shaders/grain.fragment" {
  64590. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64591. /** @hidden */
  64592. export var grainPixelShader: {
  64593. name: string;
  64594. shader: string;
  64595. };
  64596. }
  64597. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64598. import { Nullable } from "babylonjs/types";
  64599. import { Camera } from "babylonjs/Cameras/camera";
  64600. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64601. import { Engine } from "babylonjs/Engines/engine";
  64602. import "babylonjs/Shaders/grain.fragment";
  64603. /**
  64604. * The GrainPostProcess adds noise to the image at mid luminance levels
  64605. */
  64606. export class GrainPostProcess extends PostProcess {
  64607. /**
  64608. * The intensity of the grain added (default: 30)
  64609. */
  64610. intensity: number;
  64611. /**
  64612. * If the grain should be randomized on every frame
  64613. */
  64614. animated: boolean;
  64615. /**
  64616. * Creates a new instance of @see GrainPostProcess
  64617. * @param name The name of the effect.
  64618. * @param options The required width/height ratio to downsize to before computing the render pass.
  64619. * @param camera The camera to apply the render pass to.
  64620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64621. * @param engine The engine which the post process will be applied. (default: current engine)
  64622. * @param reusable If the post process can be reused on the same frame. (default: false)
  64623. * @param textureType Type of textures used when performing the post process. (default: 0)
  64624. * @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)
  64625. */
  64626. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64627. }
  64628. }
  64629. declare module "babylonjs/Shaders/highlights.fragment" {
  64630. /** @hidden */
  64631. export var highlightsPixelShader: {
  64632. name: string;
  64633. shader: string;
  64634. };
  64635. }
  64636. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64637. import { Nullable } from "babylonjs/types";
  64638. import { Camera } from "babylonjs/Cameras/camera";
  64639. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64640. import { Engine } from "babylonjs/Engines/engine";
  64641. import "babylonjs/Shaders/highlights.fragment";
  64642. /**
  64643. * Extracts highlights from the image
  64644. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64645. */
  64646. export class HighlightsPostProcess extends PostProcess {
  64647. /**
  64648. * Extracts highlights from the image
  64649. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64650. * @param name The name of the effect.
  64651. * @param options The required width/height ratio to downsize to before computing the render pass.
  64652. * @param camera The camera to apply the render pass to.
  64653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64654. * @param engine The engine which the post process will be applied. (default: current engine)
  64655. * @param reusable If the post process can be reused on the same frame. (default: false)
  64656. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64657. */
  64658. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64659. }
  64660. }
  64661. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64662. /** @hidden */
  64663. export var mrtFragmentDeclaration: {
  64664. name: string;
  64665. shader: string;
  64666. };
  64667. }
  64668. declare module "babylonjs/Shaders/geometry.fragment" {
  64669. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64670. /** @hidden */
  64671. export var geometryPixelShader: {
  64672. name: string;
  64673. shader: string;
  64674. };
  64675. }
  64676. declare module "babylonjs/Shaders/geometry.vertex" {
  64677. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64678. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64679. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64680. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64681. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64682. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64683. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64684. /** @hidden */
  64685. export var geometryVertexShader: {
  64686. name: string;
  64687. shader: string;
  64688. };
  64689. }
  64690. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64691. import { Matrix } from "babylonjs/Maths/math.vector";
  64692. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64693. import { Mesh } from "babylonjs/Meshes/mesh";
  64694. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64695. import { Effect } from "babylonjs/Materials/effect";
  64696. import { Scene } from "babylonjs/scene";
  64697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64698. import "babylonjs/Shaders/geometry.fragment";
  64699. import "babylonjs/Shaders/geometry.vertex";
  64700. /** @hidden */
  64701. interface ISavedTransformationMatrix {
  64702. world: Matrix;
  64703. viewProjection: Matrix;
  64704. }
  64705. /**
  64706. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64707. */
  64708. export class GeometryBufferRenderer {
  64709. /**
  64710. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64711. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64712. */
  64713. static readonly POSITION_TEXTURE_TYPE: number;
  64714. /**
  64715. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64716. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64717. */
  64718. static readonly VELOCITY_TEXTURE_TYPE: number;
  64719. /**
  64720. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64721. * in order to compute objects velocities when enableVelocity is set to "true"
  64722. * @hidden
  64723. */
  64724. _previousTransformationMatrices: {
  64725. [index: number]: ISavedTransformationMatrix;
  64726. };
  64727. /**
  64728. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64729. * in order to compute objects velocities when enableVelocity is set to "true"
  64730. * @hidden
  64731. */
  64732. _previousBonesTransformationMatrices: {
  64733. [index: number]: Float32Array;
  64734. };
  64735. /**
  64736. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64737. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64738. */
  64739. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64740. private _scene;
  64741. private _multiRenderTarget;
  64742. private _ratio;
  64743. private _enablePosition;
  64744. private _enableVelocity;
  64745. private _positionIndex;
  64746. private _velocityIndex;
  64747. protected _effect: Effect;
  64748. protected _cachedDefines: string;
  64749. /**
  64750. * Set the render list (meshes to be rendered) used in the G buffer.
  64751. */
  64752. renderList: Mesh[];
  64753. /**
  64754. * Gets wether or not G buffer are supported by the running hardware.
  64755. * This requires draw buffer supports
  64756. */
  64757. readonly isSupported: boolean;
  64758. /**
  64759. * Returns the index of the given texture type in the G-Buffer textures array
  64760. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64761. * @returns the index of the given texture type in the G-Buffer textures array
  64762. */
  64763. getTextureIndex(textureType: number): number;
  64764. /**
  64765. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64766. */
  64767. /**
  64768. * Sets whether or not objects positions are enabled for the G buffer.
  64769. */
  64770. enablePosition: boolean;
  64771. /**
  64772. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64773. */
  64774. /**
  64775. * Sets wether or not objects velocities are enabled for the G buffer.
  64776. */
  64777. enableVelocity: boolean;
  64778. /**
  64779. * Gets the scene associated with the buffer.
  64780. */
  64781. readonly scene: Scene;
  64782. /**
  64783. * Gets the ratio used by the buffer during its creation.
  64784. * How big is the buffer related to the main canvas.
  64785. */
  64786. readonly ratio: number;
  64787. /** @hidden */
  64788. static _SceneComponentInitialization: (scene: Scene) => void;
  64789. /**
  64790. * Creates a new G Buffer for the scene
  64791. * @param scene The scene the buffer belongs to
  64792. * @param ratio How big is the buffer related to the main canvas.
  64793. */
  64794. constructor(scene: Scene, ratio?: number);
  64795. /**
  64796. * Checks wether everything is ready to render a submesh to the G buffer.
  64797. * @param subMesh the submesh to check readiness for
  64798. * @param useInstances is the mesh drawn using instance or not
  64799. * @returns true if ready otherwise false
  64800. */
  64801. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64802. /**
  64803. * Gets the current underlying G Buffer.
  64804. * @returns the buffer
  64805. */
  64806. getGBuffer(): MultiRenderTarget;
  64807. /**
  64808. * Gets the number of samples used to render the buffer (anti aliasing).
  64809. */
  64810. /**
  64811. * Sets the number of samples used to render the buffer (anti aliasing).
  64812. */
  64813. samples: number;
  64814. /**
  64815. * Disposes the renderer and frees up associated resources.
  64816. */
  64817. dispose(): void;
  64818. protected _createRenderTargets(): void;
  64819. private _copyBonesTransformationMatrices;
  64820. }
  64821. }
  64822. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64823. import { Nullable } from "babylonjs/types";
  64824. import { Scene } from "babylonjs/scene";
  64825. import { ISceneComponent } from "babylonjs/sceneComponent";
  64826. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64827. module "babylonjs/scene" {
  64828. interface Scene {
  64829. /** @hidden (Backing field) */
  64830. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64831. /**
  64832. * Gets or Sets the current geometry buffer associated to the scene.
  64833. */
  64834. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64835. /**
  64836. * Enables a GeometryBufferRender and associates it with the scene
  64837. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64838. * @returns the GeometryBufferRenderer
  64839. */
  64840. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64841. /**
  64842. * Disables the GeometryBufferRender associated with the scene
  64843. */
  64844. disableGeometryBufferRenderer(): void;
  64845. }
  64846. }
  64847. /**
  64848. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64849. * in several rendering techniques.
  64850. */
  64851. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64852. /**
  64853. * The component name helpful to identify the component in the list of scene components.
  64854. */
  64855. readonly name: string;
  64856. /**
  64857. * The scene the component belongs to.
  64858. */
  64859. scene: Scene;
  64860. /**
  64861. * Creates a new instance of the component for the given scene
  64862. * @param scene Defines the scene to register the component in
  64863. */
  64864. constructor(scene: Scene);
  64865. /**
  64866. * Registers the component in a given scene
  64867. */
  64868. register(): void;
  64869. /**
  64870. * Rebuilds the elements related to this component in case of
  64871. * context lost for instance.
  64872. */
  64873. rebuild(): void;
  64874. /**
  64875. * Disposes the component and the associated ressources
  64876. */
  64877. dispose(): void;
  64878. private _gatherRenderTargets;
  64879. }
  64880. }
  64881. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64882. /** @hidden */
  64883. export var motionBlurPixelShader: {
  64884. name: string;
  64885. shader: string;
  64886. };
  64887. }
  64888. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64889. import { Nullable } from "babylonjs/types";
  64890. import { Camera } from "babylonjs/Cameras/camera";
  64891. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64892. import { Scene } from "babylonjs/scene";
  64893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64894. import "babylonjs/Animations/animatable";
  64895. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64896. import "babylonjs/Shaders/motionBlur.fragment";
  64897. import { Engine } from "babylonjs/Engines/engine";
  64898. /**
  64899. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64900. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64901. * As an example, all you have to do is to create the post-process:
  64902. * var mb = new BABYLON.MotionBlurPostProcess(
  64903. * 'mb', // The name of the effect.
  64904. * scene, // The scene containing the objects to blur according to their velocity.
  64905. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64906. * camera // The camera to apply the render pass to.
  64907. * );
  64908. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64909. */
  64910. export class MotionBlurPostProcess extends PostProcess {
  64911. /**
  64912. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64913. */
  64914. motionStrength: number;
  64915. /**
  64916. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64917. */
  64918. /**
  64919. * Sets the number of iterations to be used for motion blur quality
  64920. */
  64921. motionBlurSamples: number;
  64922. private _motionBlurSamples;
  64923. private _geometryBufferRenderer;
  64924. /**
  64925. * Creates a new instance MotionBlurPostProcess
  64926. * @param name The name of the effect.
  64927. * @param scene The scene containing the objects to blur according to their velocity.
  64928. * @param options The required width/height ratio to downsize to before computing the render pass.
  64929. * @param camera The camera to apply the render pass to.
  64930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64931. * @param engine The engine which the post process will be applied. (default: current engine)
  64932. * @param reusable If the post process can be reused on the same frame. (default: false)
  64933. * @param textureType Type of textures used when performing the post process. (default: 0)
  64934. * @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)
  64935. */
  64936. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64937. /**
  64938. * Excludes the given skinned mesh from computing bones velocities.
  64939. * 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.
  64940. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64941. */
  64942. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64943. /**
  64944. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64945. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64946. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64947. */
  64948. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64949. /**
  64950. * Disposes the post process.
  64951. * @param camera The camera to dispose the post process on.
  64952. */
  64953. dispose(camera?: Camera): void;
  64954. }
  64955. }
  64956. declare module "babylonjs/Shaders/refraction.fragment" {
  64957. /** @hidden */
  64958. export var refractionPixelShader: {
  64959. name: string;
  64960. shader: string;
  64961. };
  64962. }
  64963. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64964. import { Color3 } from "babylonjs/Maths/math.color";
  64965. import { Camera } from "babylonjs/Cameras/camera";
  64966. import { Texture } from "babylonjs/Materials/Textures/texture";
  64967. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64968. import { Engine } from "babylonjs/Engines/engine";
  64969. import "babylonjs/Shaders/refraction.fragment";
  64970. /**
  64971. * Post process which applies a refractin texture
  64972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64973. */
  64974. export class RefractionPostProcess extends PostProcess {
  64975. /** the base color of the refraction (used to taint the rendering) */
  64976. color: Color3;
  64977. /** simulated refraction depth */
  64978. depth: number;
  64979. /** the coefficient of the base color (0 to remove base color tainting) */
  64980. colorLevel: number;
  64981. private _refTexture;
  64982. private _ownRefractionTexture;
  64983. /**
  64984. * Gets or sets the refraction texture
  64985. * Please note that you are responsible for disposing the texture if you set it manually
  64986. */
  64987. refractionTexture: Texture;
  64988. /**
  64989. * Initializes the RefractionPostProcess
  64990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64991. * @param name The name of the effect.
  64992. * @param refractionTextureUrl Url of the refraction texture to use
  64993. * @param color the base color of the refraction (used to taint the rendering)
  64994. * @param depth simulated refraction depth
  64995. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64996. * @param camera The camera to apply the render pass to.
  64997. * @param options The required width/height ratio to downsize to before computing the render pass.
  64998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64999. * @param engine The engine which the post process will be applied. (default: current engine)
  65000. * @param reusable If the post process can be reused on the same frame. (default: false)
  65001. */
  65002. constructor(name: string, refractionTextureUrl: string,
  65003. /** the base color of the refraction (used to taint the rendering) */
  65004. color: Color3,
  65005. /** simulated refraction depth */
  65006. depth: number,
  65007. /** the coefficient of the base color (0 to remove base color tainting) */
  65008. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65009. /**
  65010. * Disposes of the post process
  65011. * @param camera Camera to dispose post process on
  65012. */
  65013. dispose(camera: Camera): void;
  65014. }
  65015. }
  65016. declare module "babylonjs/Shaders/sharpen.fragment" {
  65017. /** @hidden */
  65018. export var sharpenPixelShader: {
  65019. name: string;
  65020. shader: string;
  65021. };
  65022. }
  65023. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  65024. import { Nullable } from "babylonjs/types";
  65025. import { Camera } from "babylonjs/Cameras/camera";
  65026. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65027. import "babylonjs/Shaders/sharpen.fragment";
  65028. import { Engine } from "babylonjs/Engines/engine";
  65029. /**
  65030. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65031. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65032. */
  65033. export class SharpenPostProcess extends PostProcess {
  65034. /**
  65035. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65036. */
  65037. colorAmount: number;
  65038. /**
  65039. * How much sharpness should be applied (default: 0.3)
  65040. */
  65041. edgeAmount: number;
  65042. /**
  65043. * Creates a new instance ConvolutionPostProcess
  65044. * @param name The name of the effect.
  65045. * @param options The required width/height ratio to downsize to before computing the render pass.
  65046. * @param camera The camera to apply the render pass to.
  65047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65048. * @param engine The engine which the post process will be applied. (default: current engine)
  65049. * @param reusable If the post process can be reused on the same frame. (default: false)
  65050. * @param textureType Type of textures used when performing the post process. (default: 0)
  65051. * @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)
  65052. */
  65053. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65054. }
  65055. }
  65056. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  65057. import { Nullable } from "babylonjs/types";
  65058. import { Camera } from "babylonjs/Cameras/camera";
  65059. import { Engine } from "babylonjs/Engines/engine";
  65060. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65061. import { IInspectable } from "babylonjs/Misc/iInspectable";
  65062. /**
  65063. * PostProcessRenderPipeline
  65064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65065. */
  65066. export class PostProcessRenderPipeline {
  65067. private engine;
  65068. private _renderEffects;
  65069. private _renderEffectsForIsolatedPass;
  65070. /**
  65071. * List of inspectable custom properties (used by the Inspector)
  65072. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65073. */
  65074. inspectableCustomProperties: IInspectable[];
  65075. /**
  65076. * @hidden
  65077. */
  65078. protected _cameras: Camera[];
  65079. /** @hidden */
  65080. _name: string;
  65081. /**
  65082. * Gets pipeline name
  65083. */
  65084. readonly name: string;
  65085. /** Gets the list of attached cameras */
  65086. readonly cameras: Camera[];
  65087. /**
  65088. * Initializes a PostProcessRenderPipeline
  65089. * @param engine engine to add the pipeline to
  65090. * @param name name of the pipeline
  65091. */
  65092. constructor(engine: Engine, name: string);
  65093. /**
  65094. * Gets the class name
  65095. * @returns "PostProcessRenderPipeline"
  65096. */
  65097. getClassName(): string;
  65098. /**
  65099. * If all the render effects in the pipeline are supported
  65100. */
  65101. readonly isSupported: boolean;
  65102. /**
  65103. * Adds an effect to the pipeline
  65104. * @param renderEffect the effect to add
  65105. */
  65106. addEffect(renderEffect: PostProcessRenderEffect): void;
  65107. /** @hidden */
  65108. _rebuild(): void;
  65109. /** @hidden */
  65110. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65111. /** @hidden */
  65112. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65113. /** @hidden */
  65114. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65115. /** @hidden */
  65116. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65117. /** @hidden */
  65118. _attachCameras(cameras: Camera, unique: boolean): void;
  65119. /** @hidden */
  65120. _attachCameras(cameras: Camera[], unique: boolean): void;
  65121. /** @hidden */
  65122. _detachCameras(cameras: Camera): void;
  65123. /** @hidden */
  65124. _detachCameras(cameras: Nullable<Camera[]>): void;
  65125. /** @hidden */
  65126. _update(): void;
  65127. /** @hidden */
  65128. _reset(): void;
  65129. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65130. /**
  65131. * Disposes of the pipeline
  65132. */
  65133. dispose(): void;
  65134. }
  65135. }
  65136. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  65137. import { Camera } from "babylonjs/Cameras/camera";
  65138. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65139. /**
  65140. * PostProcessRenderPipelineManager class
  65141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65142. */
  65143. export class PostProcessRenderPipelineManager {
  65144. private _renderPipelines;
  65145. /**
  65146. * Initializes a PostProcessRenderPipelineManager
  65147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65148. */
  65149. constructor();
  65150. /**
  65151. * Gets the list of supported render pipelines
  65152. */
  65153. readonly supportedPipelines: PostProcessRenderPipeline[];
  65154. /**
  65155. * Adds a pipeline to the manager
  65156. * @param renderPipeline The pipeline to add
  65157. */
  65158. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65159. /**
  65160. * Attaches a camera to the pipeline
  65161. * @param renderPipelineName The name of the pipeline to attach to
  65162. * @param cameras the camera to attach
  65163. * @param unique if the camera can be attached multiple times to the pipeline
  65164. */
  65165. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65166. /**
  65167. * Detaches a camera from the pipeline
  65168. * @param renderPipelineName The name of the pipeline to detach from
  65169. * @param cameras the camera to detach
  65170. */
  65171. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65172. /**
  65173. * Enables an effect by name on a pipeline
  65174. * @param renderPipelineName the name of the pipeline to enable the effect in
  65175. * @param renderEffectName the name of the effect to enable
  65176. * @param cameras the cameras that the effect should be enabled on
  65177. */
  65178. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65179. /**
  65180. * Disables an effect by name on a pipeline
  65181. * @param renderPipelineName the name of the pipeline to disable the effect in
  65182. * @param renderEffectName the name of the effect to disable
  65183. * @param cameras the cameras that the effect should be disabled on
  65184. */
  65185. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65186. /**
  65187. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65188. */
  65189. update(): void;
  65190. /** @hidden */
  65191. _rebuild(): void;
  65192. /**
  65193. * Disposes of the manager and pipelines
  65194. */
  65195. dispose(): void;
  65196. }
  65197. }
  65198. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  65199. import { ISceneComponent } from "babylonjs/sceneComponent";
  65200. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65201. import { Scene } from "babylonjs/scene";
  65202. module "babylonjs/scene" {
  65203. interface Scene {
  65204. /** @hidden (Backing field) */
  65205. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65206. /**
  65207. * Gets the postprocess render pipeline manager
  65208. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65209. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65210. */
  65211. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65212. }
  65213. }
  65214. /**
  65215. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65216. */
  65217. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65218. /**
  65219. * The component name helpfull to identify the component in the list of scene components.
  65220. */
  65221. readonly name: string;
  65222. /**
  65223. * The scene the component belongs to.
  65224. */
  65225. scene: Scene;
  65226. /**
  65227. * Creates a new instance of the component for the given scene
  65228. * @param scene Defines the scene to register the component in
  65229. */
  65230. constructor(scene: Scene);
  65231. /**
  65232. * Registers the component in a given scene
  65233. */
  65234. register(): void;
  65235. /**
  65236. * Rebuilds the elements related to this component in case of
  65237. * context lost for instance.
  65238. */
  65239. rebuild(): void;
  65240. /**
  65241. * Disposes the component and the associated ressources
  65242. */
  65243. dispose(): void;
  65244. private _gatherRenderTargets;
  65245. }
  65246. }
  65247. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  65248. import { Nullable } from "babylonjs/types";
  65249. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65250. import { Camera } from "babylonjs/Cameras/camera";
  65251. import { IDisposable } from "babylonjs/scene";
  65252. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  65253. import { Scene } from "babylonjs/scene";
  65254. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  65255. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65256. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65257. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  65258. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65259. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65260. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  65261. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65262. import { Animation } from "babylonjs/Animations/animation";
  65263. /**
  65264. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65265. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65266. */
  65267. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65268. private _scene;
  65269. private _camerasToBeAttached;
  65270. /**
  65271. * ID of the sharpen post process,
  65272. */
  65273. private readonly SharpenPostProcessId;
  65274. /**
  65275. * @ignore
  65276. * ID of the image processing post process;
  65277. */
  65278. readonly ImageProcessingPostProcessId: string;
  65279. /**
  65280. * @ignore
  65281. * ID of the Fast Approximate Anti-Aliasing post process;
  65282. */
  65283. readonly FxaaPostProcessId: string;
  65284. /**
  65285. * ID of the chromatic aberration post process,
  65286. */
  65287. private readonly ChromaticAberrationPostProcessId;
  65288. /**
  65289. * ID of the grain post process
  65290. */
  65291. private readonly GrainPostProcessId;
  65292. /**
  65293. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65294. */
  65295. sharpen: SharpenPostProcess;
  65296. private _sharpenEffect;
  65297. private bloom;
  65298. /**
  65299. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65300. */
  65301. depthOfField: DepthOfFieldEffect;
  65302. /**
  65303. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65304. */
  65305. fxaa: FxaaPostProcess;
  65306. /**
  65307. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65308. */
  65309. imageProcessing: ImageProcessingPostProcess;
  65310. /**
  65311. * Chromatic aberration post process which will shift rgb colors in the image
  65312. */
  65313. chromaticAberration: ChromaticAberrationPostProcess;
  65314. private _chromaticAberrationEffect;
  65315. /**
  65316. * Grain post process which add noise to the image
  65317. */
  65318. grain: GrainPostProcess;
  65319. private _grainEffect;
  65320. /**
  65321. * Glow post process which adds a glow to emissive areas of the image
  65322. */
  65323. private _glowLayer;
  65324. /**
  65325. * Animations which can be used to tweak settings over a period of time
  65326. */
  65327. animations: Animation[];
  65328. private _imageProcessingConfigurationObserver;
  65329. private _sharpenEnabled;
  65330. private _bloomEnabled;
  65331. private _depthOfFieldEnabled;
  65332. private _depthOfFieldBlurLevel;
  65333. private _fxaaEnabled;
  65334. private _imageProcessingEnabled;
  65335. private _defaultPipelineTextureType;
  65336. private _bloomScale;
  65337. private _chromaticAberrationEnabled;
  65338. private _grainEnabled;
  65339. private _buildAllowed;
  65340. /**
  65341. * Gets active scene
  65342. */
  65343. readonly scene: Scene;
  65344. /**
  65345. * Enable or disable the sharpen process from the pipeline
  65346. */
  65347. sharpenEnabled: boolean;
  65348. private _resizeObserver;
  65349. private _hardwareScaleLevel;
  65350. private _bloomKernel;
  65351. /**
  65352. * Specifies the size of the bloom blur kernel, relative to the final output size
  65353. */
  65354. bloomKernel: number;
  65355. /**
  65356. * Specifies the weight of the bloom in the final rendering
  65357. */
  65358. private _bloomWeight;
  65359. /**
  65360. * Specifies the luma threshold for the area that will be blurred by the bloom
  65361. */
  65362. private _bloomThreshold;
  65363. private _hdr;
  65364. /**
  65365. * The strength of the bloom.
  65366. */
  65367. bloomWeight: number;
  65368. /**
  65369. * The strength of the bloom.
  65370. */
  65371. bloomThreshold: number;
  65372. /**
  65373. * The scale of the bloom, lower value will provide better performance.
  65374. */
  65375. bloomScale: number;
  65376. /**
  65377. * Enable or disable the bloom from the pipeline
  65378. */
  65379. bloomEnabled: boolean;
  65380. private _rebuildBloom;
  65381. /**
  65382. * If the depth of field is enabled.
  65383. */
  65384. depthOfFieldEnabled: boolean;
  65385. /**
  65386. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65387. */
  65388. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  65389. /**
  65390. * If the anti aliasing is enabled.
  65391. */
  65392. fxaaEnabled: boolean;
  65393. private _samples;
  65394. /**
  65395. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65396. */
  65397. samples: number;
  65398. /**
  65399. * If image processing is enabled.
  65400. */
  65401. imageProcessingEnabled: boolean;
  65402. /**
  65403. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65404. */
  65405. glowLayerEnabled: boolean;
  65406. /**
  65407. * Gets the glow layer (or null if not defined)
  65408. */
  65409. readonly glowLayer: Nullable<GlowLayer>;
  65410. /**
  65411. * Enable or disable the chromaticAberration process from the pipeline
  65412. */
  65413. chromaticAberrationEnabled: boolean;
  65414. /**
  65415. * Enable or disable the grain process from the pipeline
  65416. */
  65417. grainEnabled: boolean;
  65418. /**
  65419. * @constructor
  65420. * @param name - The rendering pipeline name (default: "")
  65421. * @param hdr - If high dynamic range textures should be used (default: true)
  65422. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65423. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65424. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65425. */
  65426. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65427. /**
  65428. * Get the class name
  65429. * @returns "DefaultRenderingPipeline"
  65430. */
  65431. getClassName(): string;
  65432. /**
  65433. * Force the compilation of the entire pipeline.
  65434. */
  65435. prepare(): void;
  65436. private _hasCleared;
  65437. private _prevPostProcess;
  65438. private _prevPrevPostProcess;
  65439. private _setAutoClearAndTextureSharing;
  65440. private _depthOfFieldSceneObserver;
  65441. private _buildPipeline;
  65442. private _disposePostProcesses;
  65443. /**
  65444. * Adds a camera to the pipeline
  65445. * @param camera the camera to be added
  65446. */
  65447. addCamera(camera: Camera): void;
  65448. /**
  65449. * Removes a camera from the pipeline
  65450. * @param camera the camera to remove
  65451. */
  65452. removeCamera(camera: Camera): void;
  65453. /**
  65454. * Dispose of the pipeline and stop all post processes
  65455. */
  65456. dispose(): void;
  65457. /**
  65458. * Serialize the rendering pipeline (Used when exporting)
  65459. * @returns the serialized object
  65460. */
  65461. serialize(): any;
  65462. /**
  65463. * Parse the serialized pipeline
  65464. * @param source Source pipeline.
  65465. * @param scene The scene to load the pipeline to.
  65466. * @param rootUrl The URL of the serialized pipeline.
  65467. * @returns An instantiated pipeline from the serialized object.
  65468. */
  65469. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65470. }
  65471. }
  65472. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  65473. /** @hidden */
  65474. export var lensHighlightsPixelShader: {
  65475. name: string;
  65476. shader: string;
  65477. };
  65478. }
  65479. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65480. /** @hidden */
  65481. export var depthOfFieldPixelShader: {
  65482. name: string;
  65483. shader: string;
  65484. };
  65485. }
  65486. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65487. import { Camera } from "babylonjs/Cameras/camera";
  65488. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65489. import { Scene } from "babylonjs/scene";
  65490. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65491. import "babylonjs/Shaders/chromaticAberration.fragment";
  65492. import "babylonjs/Shaders/lensHighlights.fragment";
  65493. import "babylonjs/Shaders/depthOfField.fragment";
  65494. /**
  65495. * BABYLON.JS Chromatic Aberration GLSL Shader
  65496. * Author: Olivier Guyot
  65497. * Separates very slightly R, G and B colors on the edges of the screen
  65498. * Inspired by Francois Tarlier & Martins Upitis
  65499. */
  65500. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65501. /**
  65502. * @ignore
  65503. * The chromatic aberration PostProcess id in the pipeline
  65504. */
  65505. LensChromaticAberrationEffect: string;
  65506. /**
  65507. * @ignore
  65508. * The highlights enhancing PostProcess id in the pipeline
  65509. */
  65510. HighlightsEnhancingEffect: string;
  65511. /**
  65512. * @ignore
  65513. * The depth-of-field PostProcess id in the pipeline
  65514. */
  65515. LensDepthOfFieldEffect: string;
  65516. private _scene;
  65517. private _depthTexture;
  65518. private _grainTexture;
  65519. private _chromaticAberrationPostProcess;
  65520. private _highlightsPostProcess;
  65521. private _depthOfFieldPostProcess;
  65522. private _edgeBlur;
  65523. private _grainAmount;
  65524. private _chromaticAberration;
  65525. private _distortion;
  65526. private _highlightsGain;
  65527. private _highlightsThreshold;
  65528. private _dofDistance;
  65529. private _dofAperture;
  65530. private _dofDarken;
  65531. private _dofPentagon;
  65532. private _blurNoise;
  65533. /**
  65534. * @constructor
  65535. *
  65536. * Effect parameters are as follow:
  65537. * {
  65538. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65539. * edge_blur: number; // from 0 to x (1 for realism)
  65540. * distortion: number; // from 0 to x (1 for realism)
  65541. * grain_amount: number; // from 0 to 1
  65542. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65543. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65544. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65545. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65546. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65547. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65548. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65549. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65550. * }
  65551. * Note: if an effect parameter is unset, effect is disabled
  65552. *
  65553. * @param name The rendering pipeline name
  65554. * @param parameters - An object containing all parameters (see above)
  65555. * @param scene The scene linked to this pipeline
  65556. * @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)
  65557. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65558. */
  65559. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65560. /**
  65561. * Get the class name
  65562. * @returns "LensRenderingPipeline"
  65563. */
  65564. getClassName(): string;
  65565. /**
  65566. * Gets associated scene
  65567. */
  65568. readonly scene: Scene;
  65569. /**
  65570. * Gets or sets the edge blur
  65571. */
  65572. edgeBlur: number;
  65573. /**
  65574. * Gets or sets the grain amount
  65575. */
  65576. grainAmount: number;
  65577. /**
  65578. * Gets or sets the chromatic aberration amount
  65579. */
  65580. chromaticAberration: number;
  65581. /**
  65582. * Gets or sets the depth of field aperture
  65583. */
  65584. dofAperture: number;
  65585. /**
  65586. * Gets or sets the edge distortion
  65587. */
  65588. edgeDistortion: number;
  65589. /**
  65590. * Gets or sets the depth of field distortion
  65591. */
  65592. dofDistortion: number;
  65593. /**
  65594. * Gets or sets the darken out of focus amount
  65595. */
  65596. darkenOutOfFocus: number;
  65597. /**
  65598. * Gets or sets a boolean indicating if blur noise is enabled
  65599. */
  65600. blurNoise: boolean;
  65601. /**
  65602. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65603. */
  65604. pentagonBokeh: boolean;
  65605. /**
  65606. * Gets or sets the highlight grain amount
  65607. */
  65608. highlightsGain: number;
  65609. /**
  65610. * Gets or sets the highlight threshold
  65611. */
  65612. highlightsThreshold: number;
  65613. /**
  65614. * Sets the amount of blur at the edges
  65615. * @param amount blur amount
  65616. */
  65617. setEdgeBlur(amount: number): void;
  65618. /**
  65619. * Sets edge blur to 0
  65620. */
  65621. disableEdgeBlur(): void;
  65622. /**
  65623. * Sets the amout of grain
  65624. * @param amount Amount of grain
  65625. */
  65626. setGrainAmount(amount: number): void;
  65627. /**
  65628. * Set grain amount to 0
  65629. */
  65630. disableGrain(): void;
  65631. /**
  65632. * Sets the chromatic aberration amount
  65633. * @param amount amount of chromatic aberration
  65634. */
  65635. setChromaticAberration(amount: number): void;
  65636. /**
  65637. * Sets chromatic aberration amount to 0
  65638. */
  65639. disableChromaticAberration(): void;
  65640. /**
  65641. * Sets the EdgeDistortion amount
  65642. * @param amount amount of EdgeDistortion
  65643. */
  65644. setEdgeDistortion(amount: number): void;
  65645. /**
  65646. * Sets edge distortion to 0
  65647. */
  65648. disableEdgeDistortion(): void;
  65649. /**
  65650. * Sets the FocusDistance amount
  65651. * @param amount amount of FocusDistance
  65652. */
  65653. setFocusDistance(amount: number): void;
  65654. /**
  65655. * Disables depth of field
  65656. */
  65657. disableDepthOfField(): void;
  65658. /**
  65659. * Sets the Aperture amount
  65660. * @param amount amount of Aperture
  65661. */
  65662. setAperture(amount: number): void;
  65663. /**
  65664. * Sets the DarkenOutOfFocus amount
  65665. * @param amount amount of DarkenOutOfFocus
  65666. */
  65667. setDarkenOutOfFocus(amount: number): void;
  65668. private _pentagonBokehIsEnabled;
  65669. /**
  65670. * Creates a pentagon bokeh effect
  65671. */
  65672. enablePentagonBokeh(): void;
  65673. /**
  65674. * Disables the pentagon bokeh effect
  65675. */
  65676. disablePentagonBokeh(): void;
  65677. /**
  65678. * Enables noise blur
  65679. */
  65680. enableNoiseBlur(): void;
  65681. /**
  65682. * Disables noise blur
  65683. */
  65684. disableNoiseBlur(): void;
  65685. /**
  65686. * Sets the HighlightsGain amount
  65687. * @param amount amount of HighlightsGain
  65688. */
  65689. setHighlightsGain(amount: number): void;
  65690. /**
  65691. * Sets the HighlightsThreshold amount
  65692. * @param amount amount of HighlightsThreshold
  65693. */
  65694. setHighlightsThreshold(amount: number): void;
  65695. /**
  65696. * Disables highlights
  65697. */
  65698. disableHighlights(): void;
  65699. /**
  65700. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65701. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65702. */
  65703. dispose(disableDepthRender?: boolean): void;
  65704. private _createChromaticAberrationPostProcess;
  65705. private _createHighlightsPostProcess;
  65706. private _createDepthOfFieldPostProcess;
  65707. private _createGrainTexture;
  65708. }
  65709. }
  65710. declare module "babylonjs/Shaders/ssao2.fragment" {
  65711. /** @hidden */
  65712. export var ssao2PixelShader: {
  65713. name: string;
  65714. shader: string;
  65715. };
  65716. }
  65717. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65718. /** @hidden */
  65719. export var ssaoCombinePixelShader: {
  65720. name: string;
  65721. shader: string;
  65722. };
  65723. }
  65724. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65725. import { Camera } from "babylonjs/Cameras/camera";
  65726. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65727. import { Scene } from "babylonjs/scene";
  65728. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65729. import "babylonjs/Shaders/ssao2.fragment";
  65730. import "babylonjs/Shaders/ssaoCombine.fragment";
  65731. /**
  65732. * Render pipeline to produce ssao effect
  65733. */
  65734. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65735. /**
  65736. * @ignore
  65737. * The PassPostProcess id in the pipeline that contains the original scene color
  65738. */
  65739. SSAOOriginalSceneColorEffect: string;
  65740. /**
  65741. * @ignore
  65742. * The SSAO PostProcess id in the pipeline
  65743. */
  65744. SSAORenderEffect: string;
  65745. /**
  65746. * @ignore
  65747. * The horizontal blur PostProcess id in the pipeline
  65748. */
  65749. SSAOBlurHRenderEffect: string;
  65750. /**
  65751. * @ignore
  65752. * The vertical blur PostProcess id in the pipeline
  65753. */
  65754. SSAOBlurVRenderEffect: string;
  65755. /**
  65756. * @ignore
  65757. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65758. */
  65759. SSAOCombineRenderEffect: string;
  65760. /**
  65761. * The output strength of the SSAO post-process. Default value is 1.0.
  65762. */
  65763. totalStrength: number;
  65764. /**
  65765. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65766. */
  65767. maxZ: number;
  65768. /**
  65769. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65770. */
  65771. minZAspect: number;
  65772. private _samples;
  65773. /**
  65774. * Number of samples used for the SSAO calculations. Default value is 8
  65775. */
  65776. samples: number;
  65777. private _textureSamples;
  65778. /**
  65779. * Number of samples to use for antialiasing
  65780. */
  65781. textureSamples: number;
  65782. /**
  65783. * Ratio object used for SSAO ratio and blur ratio
  65784. */
  65785. private _ratio;
  65786. /**
  65787. * Dynamically generated sphere sampler.
  65788. */
  65789. private _sampleSphere;
  65790. /**
  65791. * Blur filter offsets
  65792. */
  65793. private _samplerOffsets;
  65794. private _expensiveBlur;
  65795. /**
  65796. * If bilateral blur should be used
  65797. */
  65798. expensiveBlur: boolean;
  65799. /**
  65800. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65801. */
  65802. radius: number;
  65803. /**
  65804. * The base color of the SSAO post-process
  65805. * The final result is "base + ssao" between [0, 1]
  65806. */
  65807. base: number;
  65808. /**
  65809. * Support test.
  65810. */
  65811. static readonly IsSupported: boolean;
  65812. private _scene;
  65813. private _depthTexture;
  65814. private _normalTexture;
  65815. private _randomTexture;
  65816. private _originalColorPostProcess;
  65817. private _ssaoPostProcess;
  65818. private _blurHPostProcess;
  65819. private _blurVPostProcess;
  65820. private _ssaoCombinePostProcess;
  65821. /**
  65822. * Gets active scene
  65823. */
  65824. readonly scene: Scene;
  65825. /**
  65826. * @constructor
  65827. * @param name The rendering pipeline name
  65828. * @param scene The scene linked to this pipeline
  65829. * @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 }
  65830. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65831. */
  65832. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65833. /**
  65834. * Get the class name
  65835. * @returns "SSAO2RenderingPipeline"
  65836. */
  65837. getClassName(): string;
  65838. /**
  65839. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65840. */
  65841. dispose(disableGeometryBufferRenderer?: boolean): void;
  65842. private _createBlurPostProcess;
  65843. /** @hidden */
  65844. _rebuild(): void;
  65845. private _bits;
  65846. private _radicalInverse_VdC;
  65847. private _hammersley;
  65848. private _hemisphereSample_uniform;
  65849. private _generateHemisphere;
  65850. private _createSSAOPostProcess;
  65851. private _createSSAOCombinePostProcess;
  65852. private _createRandomTexture;
  65853. /**
  65854. * Serialize the rendering pipeline (Used when exporting)
  65855. * @returns the serialized object
  65856. */
  65857. serialize(): any;
  65858. /**
  65859. * Parse the serialized pipeline
  65860. * @param source Source pipeline.
  65861. * @param scene The scene to load the pipeline to.
  65862. * @param rootUrl The URL of the serialized pipeline.
  65863. * @returns An instantiated pipeline from the serialized object.
  65864. */
  65865. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65866. }
  65867. }
  65868. declare module "babylonjs/Shaders/ssao.fragment" {
  65869. /** @hidden */
  65870. export var ssaoPixelShader: {
  65871. name: string;
  65872. shader: string;
  65873. };
  65874. }
  65875. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65876. import { Camera } from "babylonjs/Cameras/camera";
  65877. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65878. import { Scene } from "babylonjs/scene";
  65879. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65880. import "babylonjs/Shaders/ssao.fragment";
  65881. import "babylonjs/Shaders/ssaoCombine.fragment";
  65882. /**
  65883. * Render pipeline to produce ssao effect
  65884. */
  65885. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65886. /**
  65887. * @ignore
  65888. * The PassPostProcess id in the pipeline that contains the original scene color
  65889. */
  65890. SSAOOriginalSceneColorEffect: string;
  65891. /**
  65892. * @ignore
  65893. * The SSAO PostProcess id in the pipeline
  65894. */
  65895. SSAORenderEffect: string;
  65896. /**
  65897. * @ignore
  65898. * The horizontal blur PostProcess id in the pipeline
  65899. */
  65900. SSAOBlurHRenderEffect: string;
  65901. /**
  65902. * @ignore
  65903. * The vertical blur PostProcess id in the pipeline
  65904. */
  65905. SSAOBlurVRenderEffect: string;
  65906. /**
  65907. * @ignore
  65908. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65909. */
  65910. SSAOCombineRenderEffect: string;
  65911. /**
  65912. * The output strength of the SSAO post-process. Default value is 1.0.
  65913. */
  65914. totalStrength: number;
  65915. /**
  65916. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65917. */
  65918. radius: number;
  65919. /**
  65920. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65921. * Must not be equal to fallOff and superior to fallOff.
  65922. * Default value is 0.0075
  65923. */
  65924. area: number;
  65925. /**
  65926. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65927. * Must not be equal to area and inferior to area.
  65928. * Default value is 0.000001
  65929. */
  65930. fallOff: number;
  65931. /**
  65932. * The base color of the SSAO post-process
  65933. * The final result is "base + ssao" between [0, 1]
  65934. */
  65935. base: number;
  65936. private _scene;
  65937. private _depthTexture;
  65938. private _randomTexture;
  65939. private _originalColorPostProcess;
  65940. private _ssaoPostProcess;
  65941. private _blurHPostProcess;
  65942. private _blurVPostProcess;
  65943. private _ssaoCombinePostProcess;
  65944. private _firstUpdate;
  65945. /**
  65946. * Gets active scene
  65947. */
  65948. readonly scene: Scene;
  65949. /**
  65950. * @constructor
  65951. * @param name - The rendering pipeline name
  65952. * @param scene - The scene linked to this pipeline
  65953. * @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 }
  65954. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65955. */
  65956. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65957. /**
  65958. * Get the class name
  65959. * @returns "SSAORenderingPipeline"
  65960. */
  65961. getClassName(): string;
  65962. /**
  65963. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65964. */
  65965. dispose(disableDepthRender?: boolean): void;
  65966. private _createBlurPostProcess;
  65967. /** @hidden */
  65968. _rebuild(): void;
  65969. private _createSSAOPostProcess;
  65970. private _createSSAOCombinePostProcess;
  65971. private _createRandomTexture;
  65972. }
  65973. }
  65974. declare module "babylonjs/Shaders/standard.fragment" {
  65975. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65976. /** @hidden */
  65977. export var standardPixelShader: {
  65978. name: string;
  65979. shader: string;
  65980. };
  65981. }
  65982. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65983. import { Nullable } from "babylonjs/types";
  65984. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65985. import { Camera } from "babylonjs/Cameras/camera";
  65986. import { Texture } from "babylonjs/Materials/Textures/texture";
  65987. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65988. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65989. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65990. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65991. import { IDisposable } from "babylonjs/scene";
  65992. import { SpotLight } from "babylonjs/Lights/spotLight";
  65993. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65994. import { Scene } from "babylonjs/scene";
  65995. import { Animation } from "babylonjs/Animations/animation";
  65996. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65997. import "babylonjs/Shaders/standard.fragment";
  65998. /**
  65999. * Standard rendering pipeline
  66000. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66001. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66002. */
  66003. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66004. /**
  66005. * Public members
  66006. */
  66007. /**
  66008. * Post-process which contains the original scene color before the pipeline applies all the effects
  66009. */
  66010. originalPostProcess: Nullable<PostProcess>;
  66011. /**
  66012. * Post-process used to down scale an image x4
  66013. */
  66014. downSampleX4PostProcess: Nullable<PostProcess>;
  66015. /**
  66016. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66017. */
  66018. brightPassPostProcess: Nullable<PostProcess>;
  66019. /**
  66020. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66021. */
  66022. blurHPostProcesses: PostProcess[];
  66023. /**
  66024. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66025. */
  66026. blurVPostProcesses: PostProcess[];
  66027. /**
  66028. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66029. */
  66030. textureAdderPostProcess: Nullable<PostProcess>;
  66031. /**
  66032. * Post-process used to create volumetric lighting effect
  66033. */
  66034. volumetricLightPostProcess: Nullable<PostProcess>;
  66035. /**
  66036. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66037. */
  66038. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66039. /**
  66040. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66041. */
  66042. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66043. /**
  66044. * Post-process used to merge the volumetric light effect and the real scene color
  66045. */
  66046. volumetricLightMergePostProces: Nullable<PostProcess>;
  66047. /**
  66048. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66049. */
  66050. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66051. /**
  66052. * Base post-process used to calculate the average luminance of the final image for HDR
  66053. */
  66054. luminancePostProcess: Nullable<PostProcess>;
  66055. /**
  66056. * Post-processes used to create down sample post-processes in order to get
  66057. * the average luminance of the final image for HDR
  66058. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66059. */
  66060. luminanceDownSamplePostProcesses: PostProcess[];
  66061. /**
  66062. * Post-process used to create a HDR effect (light adaptation)
  66063. */
  66064. hdrPostProcess: Nullable<PostProcess>;
  66065. /**
  66066. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66067. */
  66068. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66069. /**
  66070. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66071. */
  66072. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66073. /**
  66074. * Post-process used to merge the final HDR post-process and the real scene color
  66075. */
  66076. hdrFinalPostProcess: Nullable<PostProcess>;
  66077. /**
  66078. * Post-process used to create a lens flare effect
  66079. */
  66080. lensFlarePostProcess: Nullable<PostProcess>;
  66081. /**
  66082. * Post-process that merges the result of the lens flare post-process and the real scene color
  66083. */
  66084. lensFlareComposePostProcess: Nullable<PostProcess>;
  66085. /**
  66086. * Post-process used to create a motion blur effect
  66087. */
  66088. motionBlurPostProcess: Nullable<PostProcess>;
  66089. /**
  66090. * Post-process used to create a depth of field effect
  66091. */
  66092. depthOfFieldPostProcess: Nullable<PostProcess>;
  66093. /**
  66094. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66095. */
  66096. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66097. /**
  66098. * Represents the brightness threshold in order to configure the illuminated surfaces
  66099. */
  66100. brightThreshold: number;
  66101. /**
  66102. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66103. */
  66104. blurWidth: number;
  66105. /**
  66106. * Sets if the blur for highlighted surfaces must be only horizontal
  66107. */
  66108. horizontalBlur: boolean;
  66109. /**
  66110. * Gets the overall exposure used by the pipeline
  66111. */
  66112. /**
  66113. * Sets the overall exposure used by the pipeline
  66114. */
  66115. exposure: number;
  66116. /**
  66117. * Texture used typically to simulate "dirty" on camera lens
  66118. */
  66119. lensTexture: Nullable<Texture>;
  66120. /**
  66121. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66122. */
  66123. volumetricLightCoefficient: number;
  66124. /**
  66125. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66126. */
  66127. volumetricLightPower: number;
  66128. /**
  66129. * Used the set the blur intensity to smooth the volumetric lights
  66130. */
  66131. volumetricLightBlurScale: number;
  66132. /**
  66133. * Light (spot or directional) used to generate the volumetric lights rays
  66134. * The source light must have a shadow generate so the pipeline can get its
  66135. * depth map
  66136. */
  66137. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66138. /**
  66139. * For eye adaptation, represents the minimum luminance the eye can see
  66140. */
  66141. hdrMinimumLuminance: number;
  66142. /**
  66143. * For eye adaptation, represents the decrease luminance speed
  66144. */
  66145. hdrDecreaseRate: number;
  66146. /**
  66147. * For eye adaptation, represents the increase luminance speed
  66148. */
  66149. hdrIncreaseRate: number;
  66150. /**
  66151. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66152. */
  66153. /**
  66154. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66155. */
  66156. hdrAutoExposure: boolean;
  66157. /**
  66158. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66159. */
  66160. lensColorTexture: Nullable<Texture>;
  66161. /**
  66162. * The overall strengh for the lens flare effect
  66163. */
  66164. lensFlareStrength: number;
  66165. /**
  66166. * Dispersion coefficient for lens flare ghosts
  66167. */
  66168. lensFlareGhostDispersal: number;
  66169. /**
  66170. * Main lens flare halo width
  66171. */
  66172. lensFlareHaloWidth: number;
  66173. /**
  66174. * Based on the lens distortion effect, defines how much the lens flare result
  66175. * is distorted
  66176. */
  66177. lensFlareDistortionStrength: number;
  66178. /**
  66179. * Configures the blur intensity used for for lens flare (halo)
  66180. */
  66181. lensFlareBlurWidth: number;
  66182. /**
  66183. * Lens star texture must be used to simulate rays on the flares and is available
  66184. * in the documentation
  66185. */
  66186. lensStarTexture: Nullable<Texture>;
  66187. /**
  66188. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66189. * flare effect by taking account of the dirt texture
  66190. */
  66191. lensFlareDirtTexture: Nullable<Texture>;
  66192. /**
  66193. * Represents the focal length for the depth of field effect
  66194. */
  66195. depthOfFieldDistance: number;
  66196. /**
  66197. * Represents the blur intensity for the blurred part of the depth of field effect
  66198. */
  66199. depthOfFieldBlurWidth: number;
  66200. /**
  66201. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66202. */
  66203. /**
  66204. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66205. */
  66206. motionStrength: number;
  66207. /**
  66208. * Gets wether or not the motion blur post-process is object based or screen based.
  66209. */
  66210. /**
  66211. * Sets wether or not the motion blur post-process should be object based or screen based
  66212. */
  66213. objectBasedMotionBlur: boolean;
  66214. /**
  66215. * List of animations for the pipeline (IAnimatable implementation)
  66216. */
  66217. animations: Animation[];
  66218. /**
  66219. * Private members
  66220. */
  66221. private _scene;
  66222. private _currentDepthOfFieldSource;
  66223. private _basePostProcess;
  66224. private _fixedExposure;
  66225. private _currentExposure;
  66226. private _hdrAutoExposure;
  66227. private _hdrCurrentLuminance;
  66228. private _motionStrength;
  66229. private _isObjectBasedMotionBlur;
  66230. private _floatTextureType;
  66231. private _camerasToBeAttached;
  66232. private _ratio;
  66233. private _bloomEnabled;
  66234. private _depthOfFieldEnabled;
  66235. private _vlsEnabled;
  66236. private _lensFlareEnabled;
  66237. private _hdrEnabled;
  66238. private _motionBlurEnabled;
  66239. private _fxaaEnabled;
  66240. private _motionBlurSamples;
  66241. private _volumetricLightStepsCount;
  66242. private _samples;
  66243. /**
  66244. * @ignore
  66245. * Specifies if the bloom pipeline is enabled
  66246. */
  66247. BloomEnabled: boolean;
  66248. /**
  66249. * @ignore
  66250. * Specifies if the depth of field pipeline is enabed
  66251. */
  66252. DepthOfFieldEnabled: boolean;
  66253. /**
  66254. * @ignore
  66255. * Specifies if the lens flare pipeline is enabed
  66256. */
  66257. LensFlareEnabled: boolean;
  66258. /**
  66259. * @ignore
  66260. * Specifies if the HDR pipeline is enabled
  66261. */
  66262. HDREnabled: boolean;
  66263. /**
  66264. * @ignore
  66265. * Specifies if the volumetric lights scattering effect is enabled
  66266. */
  66267. VLSEnabled: boolean;
  66268. /**
  66269. * @ignore
  66270. * Specifies if the motion blur effect is enabled
  66271. */
  66272. MotionBlurEnabled: boolean;
  66273. /**
  66274. * Specifies if anti-aliasing is enabled
  66275. */
  66276. fxaaEnabled: boolean;
  66277. /**
  66278. * Specifies the number of steps used to calculate the volumetric lights
  66279. * Typically in interval [50, 200]
  66280. */
  66281. volumetricLightStepsCount: number;
  66282. /**
  66283. * Specifies the number of samples used for the motion blur effect
  66284. * Typically in interval [16, 64]
  66285. */
  66286. motionBlurSamples: number;
  66287. /**
  66288. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66289. */
  66290. samples: number;
  66291. /**
  66292. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66293. * @constructor
  66294. * @param name The rendering pipeline name
  66295. * @param scene The scene linked to this pipeline
  66296. * @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)
  66297. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66298. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66299. */
  66300. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66301. private _buildPipeline;
  66302. private _createDownSampleX4PostProcess;
  66303. private _createBrightPassPostProcess;
  66304. private _createBlurPostProcesses;
  66305. private _createTextureAdderPostProcess;
  66306. private _createVolumetricLightPostProcess;
  66307. private _createLuminancePostProcesses;
  66308. private _createHdrPostProcess;
  66309. private _createLensFlarePostProcess;
  66310. private _createDepthOfFieldPostProcess;
  66311. private _createMotionBlurPostProcess;
  66312. private _getDepthTexture;
  66313. private _disposePostProcesses;
  66314. /**
  66315. * Dispose of the pipeline and stop all post processes
  66316. */
  66317. dispose(): void;
  66318. /**
  66319. * Serialize the rendering pipeline (Used when exporting)
  66320. * @returns the serialized object
  66321. */
  66322. serialize(): any;
  66323. /**
  66324. * Parse the serialized pipeline
  66325. * @param source Source pipeline.
  66326. * @param scene The scene to load the pipeline to.
  66327. * @param rootUrl The URL of the serialized pipeline.
  66328. * @returns An instantiated pipeline from the serialized object.
  66329. */
  66330. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66331. /**
  66332. * Luminance steps
  66333. */
  66334. static LuminanceSteps: number;
  66335. }
  66336. }
  66337. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  66338. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  66339. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  66340. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  66341. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  66342. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  66343. }
  66344. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  66345. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  66346. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66347. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66348. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66349. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66350. }
  66351. declare module "babylonjs/Shaders/tonemap.fragment" {
  66352. /** @hidden */
  66353. export var tonemapPixelShader: {
  66354. name: string;
  66355. shader: string;
  66356. };
  66357. }
  66358. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  66359. import { Camera } from "babylonjs/Cameras/camera";
  66360. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66361. import "babylonjs/Shaders/tonemap.fragment";
  66362. import { Engine } from "babylonjs/Engines/engine";
  66363. /** Defines operator used for tonemapping */
  66364. export enum TonemappingOperator {
  66365. /** Hable */
  66366. Hable = 0,
  66367. /** Reinhard */
  66368. Reinhard = 1,
  66369. /** HejiDawson */
  66370. HejiDawson = 2,
  66371. /** Photographic */
  66372. Photographic = 3
  66373. }
  66374. /**
  66375. * Defines a post process to apply tone mapping
  66376. */
  66377. export class TonemapPostProcess extends PostProcess {
  66378. private _operator;
  66379. /** Defines the required exposure adjustement */
  66380. exposureAdjustment: number;
  66381. /**
  66382. * Creates a new TonemapPostProcess
  66383. * @param name defines the name of the postprocess
  66384. * @param _operator defines the operator to use
  66385. * @param exposureAdjustment defines the required exposure adjustement
  66386. * @param camera defines the camera to use (can be null)
  66387. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66388. * @param engine defines the hosting engine (can be ignore if camera is set)
  66389. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66390. */
  66391. constructor(name: string, _operator: TonemappingOperator,
  66392. /** Defines the required exposure adjustement */
  66393. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66394. }
  66395. }
  66396. declare module "babylonjs/Shaders/depth.vertex" {
  66397. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66399. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66400. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66402. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66403. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66404. /** @hidden */
  66405. export var depthVertexShader: {
  66406. name: string;
  66407. shader: string;
  66408. };
  66409. }
  66410. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  66411. /** @hidden */
  66412. export var volumetricLightScatteringPixelShader: {
  66413. name: string;
  66414. shader: string;
  66415. };
  66416. }
  66417. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  66418. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66419. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66421. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66422. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66423. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66424. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66425. /** @hidden */
  66426. export var volumetricLightScatteringPassVertexShader: {
  66427. name: string;
  66428. shader: string;
  66429. };
  66430. }
  66431. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  66432. /** @hidden */
  66433. export var volumetricLightScatteringPassPixelShader: {
  66434. name: string;
  66435. shader: string;
  66436. };
  66437. }
  66438. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  66439. import { Vector3 } from "babylonjs/Maths/math.vector";
  66440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66441. import { Mesh } from "babylonjs/Meshes/mesh";
  66442. import { Camera } from "babylonjs/Cameras/camera";
  66443. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66444. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66445. import { Scene } from "babylonjs/scene";
  66446. import "babylonjs/Meshes/Builders/planeBuilder";
  66447. import "babylonjs/Shaders/depth.vertex";
  66448. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  66449. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  66450. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  66451. import { Engine } from "babylonjs/Engines/engine";
  66452. /**
  66453. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66454. */
  66455. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66456. private _volumetricLightScatteringPass;
  66457. private _volumetricLightScatteringRTT;
  66458. private _viewPort;
  66459. private _screenCoordinates;
  66460. private _cachedDefines;
  66461. /**
  66462. * If not undefined, the mesh position is computed from the attached node position
  66463. */
  66464. attachedNode: {
  66465. position: Vector3;
  66466. };
  66467. /**
  66468. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66469. */
  66470. customMeshPosition: Vector3;
  66471. /**
  66472. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66473. */
  66474. useCustomMeshPosition: boolean;
  66475. /**
  66476. * If the post-process should inverse the light scattering direction
  66477. */
  66478. invert: boolean;
  66479. /**
  66480. * The internal mesh used by the post-process
  66481. */
  66482. mesh: Mesh;
  66483. /**
  66484. * @hidden
  66485. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66486. */
  66487. useDiffuseColor: boolean;
  66488. /**
  66489. * Array containing the excluded meshes not rendered in the internal pass
  66490. */
  66491. excludedMeshes: AbstractMesh[];
  66492. /**
  66493. * Controls the overall intensity of the post-process
  66494. */
  66495. exposure: number;
  66496. /**
  66497. * Dissipates each sample's contribution in range [0, 1]
  66498. */
  66499. decay: number;
  66500. /**
  66501. * Controls the overall intensity of each sample
  66502. */
  66503. weight: number;
  66504. /**
  66505. * Controls the density of each sample
  66506. */
  66507. density: number;
  66508. /**
  66509. * @constructor
  66510. * @param name The post-process name
  66511. * @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)
  66512. * @param camera The camera that the post-process will be attached to
  66513. * @param mesh The mesh used to create the light scattering
  66514. * @param samples The post-process quality, default 100
  66515. * @param samplingModeThe post-process filtering mode
  66516. * @param engine The babylon engine
  66517. * @param reusable If the post-process is reusable
  66518. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66519. */
  66520. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66521. /**
  66522. * Returns the string "VolumetricLightScatteringPostProcess"
  66523. * @returns "VolumetricLightScatteringPostProcess"
  66524. */
  66525. getClassName(): string;
  66526. private _isReady;
  66527. /**
  66528. * Sets the new light position for light scattering effect
  66529. * @param position The new custom light position
  66530. */
  66531. setCustomMeshPosition(position: Vector3): void;
  66532. /**
  66533. * Returns the light position for light scattering effect
  66534. * @return Vector3 The custom light position
  66535. */
  66536. getCustomMeshPosition(): Vector3;
  66537. /**
  66538. * Disposes the internal assets and detaches the post-process from the camera
  66539. */
  66540. dispose(camera: Camera): void;
  66541. /**
  66542. * Returns the render target texture used by the post-process
  66543. * @return the render target texture used by the post-process
  66544. */
  66545. getPass(): RenderTargetTexture;
  66546. private _meshExcluded;
  66547. private _createPass;
  66548. private _updateMeshScreenCoordinates;
  66549. /**
  66550. * Creates a default mesh for the Volumeric Light Scattering post-process
  66551. * @param name The mesh name
  66552. * @param scene The scene where to create the mesh
  66553. * @return the default mesh
  66554. */
  66555. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66556. }
  66557. }
  66558. declare module "babylonjs/PostProcesses/index" {
  66559. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66560. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66561. export * from "babylonjs/PostProcesses/bloomEffect";
  66562. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66563. export * from "babylonjs/PostProcesses/blurPostProcess";
  66564. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66565. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66566. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66567. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66568. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66569. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66570. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66571. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66572. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66573. export * from "babylonjs/PostProcesses/filterPostProcess";
  66574. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66575. export * from "babylonjs/PostProcesses/grainPostProcess";
  66576. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66577. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66578. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66579. export * from "babylonjs/PostProcesses/passPostProcess";
  66580. export * from "babylonjs/PostProcesses/postProcess";
  66581. export * from "babylonjs/PostProcesses/postProcessManager";
  66582. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66583. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66584. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66585. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66586. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66587. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66588. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66589. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66590. }
  66591. declare module "babylonjs/Probes/index" {
  66592. export * from "babylonjs/Probes/reflectionProbe";
  66593. }
  66594. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66595. import { Scene } from "babylonjs/scene";
  66596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66597. import { SmartArray } from "babylonjs/Misc/smartArray";
  66598. import { ISceneComponent } from "babylonjs/sceneComponent";
  66599. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66600. import "babylonjs/Meshes/Builders/boxBuilder";
  66601. import "babylonjs/Shaders/color.fragment";
  66602. import "babylonjs/Shaders/color.vertex";
  66603. import { Color3 } from "babylonjs/Maths/math.color";
  66604. module "babylonjs/scene" {
  66605. interface Scene {
  66606. /** @hidden (Backing field) */
  66607. _boundingBoxRenderer: BoundingBoxRenderer;
  66608. /** @hidden (Backing field) */
  66609. _forceShowBoundingBoxes: boolean;
  66610. /**
  66611. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66612. */
  66613. forceShowBoundingBoxes: boolean;
  66614. /**
  66615. * Gets the bounding box renderer associated with the scene
  66616. * @returns a BoundingBoxRenderer
  66617. */
  66618. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66619. }
  66620. }
  66621. module "babylonjs/Meshes/abstractMesh" {
  66622. interface AbstractMesh {
  66623. /** @hidden (Backing field) */
  66624. _showBoundingBox: boolean;
  66625. /**
  66626. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66627. */
  66628. showBoundingBox: boolean;
  66629. }
  66630. }
  66631. /**
  66632. * Component responsible of rendering the bounding box of the meshes in a scene.
  66633. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66634. */
  66635. export class BoundingBoxRenderer implements ISceneComponent {
  66636. /**
  66637. * The component name helpfull to identify the component in the list of scene components.
  66638. */
  66639. readonly name: string;
  66640. /**
  66641. * The scene the component belongs to.
  66642. */
  66643. scene: Scene;
  66644. /**
  66645. * Color of the bounding box lines placed in front of an object
  66646. */
  66647. frontColor: Color3;
  66648. /**
  66649. * Color of the bounding box lines placed behind an object
  66650. */
  66651. backColor: Color3;
  66652. /**
  66653. * Defines if the renderer should show the back lines or not
  66654. */
  66655. showBackLines: boolean;
  66656. /**
  66657. * @hidden
  66658. */
  66659. renderList: SmartArray<BoundingBox>;
  66660. private _colorShader;
  66661. private _vertexBuffers;
  66662. private _indexBuffer;
  66663. private _fillIndexBuffer;
  66664. private _fillIndexData;
  66665. /**
  66666. * Instantiates a new bounding box renderer in a scene.
  66667. * @param scene the scene the renderer renders in
  66668. */
  66669. constructor(scene: Scene);
  66670. /**
  66671. * Registers the component in a given scene
  66672. */
  66673. register(): void;
  66674. private _evaluateSubMesh;
  66675. private _activeMesh;
  66676. private _prepareRessources;
  66677. private _createIndexBuffer;
  66678. /**
  66679. * Rebuilds the elements related to this component in case of
  66680. * context lost for instance.
  66681. */
  66682. rebuild(): void;
  66683. /**
  66684. * @hidden
  66685. */
  66686. reset(): void;
  66687. /**
  66688. * Render the bounding boxes of a specific rendering group
  66689. * @param renderingGroupId defines the rendering group to render
  66690. */
  66691. render(renderingGroupId: number): void;
  66692. /**
  66693. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66694. * @param mesh Define the mesh to render the occlusion bounding box for
  66695. */
  66696. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66697. /**
  66698. * Dispose and release the resources attached to this renderer.
  66699. */
  66700. dispose(): void;
  66701. }
  66702. }
  66703. declare module "babylonjs/Shaders/depth.fragment" {
  66704. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66705. /** @hidden */
  66706. export var depthPixelShader: {
  66707. name: string;
  66708. shader: string;
  66709. };
  66710. }
  66711. declare module "babylonjs/Rendering/depthRenderer" {
  66712. import { Nullable } from "babylonjs/types";
  66713. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66714. import { Scene } from "babylonjs/scene";
  66715. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66716. import { Camera } from "babylonjs/Cameras/camera";
  66717. import "babylonjs/Shaders/depth.fragment";
  66718. import "babylonjs/Shaders/depth.vertex";
  66719. /**
  66720. * This represents a depth renderer in Babylon.
  66721. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66722. */
  66723. export class DepthRenderer {
  66724. private _scene;
  66725. private _depthMap;
  66726. private _effect;
  66727. private readonly _storeNonLinearDepth;
  66728. private readonly _clearColor;
  66729. /** Get if the depth renderer is using packed depth or not */
  66730. readonly isPacked: boolean;
  66731. private _cachedDefines;
  66732. private _camera;
  66733. /**
  66734. * Specifiess that the depth renderer will only be used within
  66735. * the camera it is created for.
  66736. * This can help forcing its rendering during the camera processing.
  66737. */
  66738. useOnlyInActiveCamera: boolean;
  66739. /** @hidden */
  66740. static _SceneComponentInitialization: (scene: Scene) => void;
  66741. /**
  66742. * Instantiates a depth renderer
  66743. * @param scene The scene the renderer belongs to
  66744. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66745. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66746. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66747. */
  66748. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66749. /**
  66750. * Creates the depth rendering effect and checks if the effect is ready.
  66751. * @param subMesh The submesh to be used to render the depth map of
  66752. * @param useInstances If multiple world instances should be used
  66753. * @returns if the depth renderer is ready to render the depth map
  66754. */
  66755. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66756. /**
  66757. * Gets the texture which the depth map will be written to.
  66758. * @returns The depth map texture
  66759. */
  66760. getDepthMap(): RenderTargetTexture;
  66761. /**
  66762. * Disposes of the depth renderer.
  66763. */
  66764. dispose(): void;
  66765. }
  66766. }
  66767. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66768. import { Nullable } from "babylonjs/types";
  66769. import { Scene } from "babylonjs/scene";
  66770. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66771. import { Camera } from "babylonjs/Cameras/camera";
  66772. import { ISceneComponent } from "babylonjs/sceneComponent";
  66773. module "babylonjs/scene" {
  66774. interface Scene {
  66775. /** @hidden (Backing field) */
  66776. _depthRenderer: {
  66777. [id: string]: DepthRenderer;
  66778. };
  66779. /**
  66780. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66781. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66782. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66783. * @returns the created depth renderer
  66784. */
  66785. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66786. /**
  66787. * Disables a depth renderer for a given camera
  66788. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66789. */
  66790. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66791. }
  66792. }
  66793. /**
  66794. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66795. * in several rendering techniques.
  66796. */
  66797. export class DepthRendererSceneComponent implements ISceneComponent {
  66798. /**
  66799. * The component name helpfull to identify the component in the list of scene components.
  66800. */
  66801. readonly name: string;
  66802. /**
  66803. * The scene the component belongs to.
  66804. */
  66805. scene: Scene;
  66806. /**
  66807. * Creates a new instance of the component for the given scene
  66808. * @param scene Defines the scene to register the component in
  66809. */
  66810. constructor(scene: Scene);
  66811. /**
  66812. * Registers the component in a given scene
  66813. */
  66814. register(): void;
  66815. /**
  66816. * Rebuilds the elements related to this component in case of
  66817. * context lost for instance.
  66818. */
  66819. rebuild(): void;
  66820. /**
  66821. * Disposes the component and the associated ressources
  66822. */
  66823. dispose(): void;
  66824. private _gatherRenderTargets;
  66825. private _gatherActiveCameraRenderTargets;
  66826. }
  66827. }
  66828. declare module "babylonjs/Shaders/outline.fragment" {
  66829. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66830. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66831. /** @hidden */
  66832. export var outlinePixelShader: {
  66833. name: string;
  66834. shader: string;
  66835. };
  66836. }
  66837. declare module "babylonjs/Shaders/outline.vertex" {
  66838. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66839. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66840. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66841. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66842. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66844. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66845. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66846. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66847. /** @hidden */
  66848. export var outlineVertexShader: {
  66849. name: string;
  66850. shader: string;
  66851. };
  66852. }
  66853. declare module "babylonjs/Rendering/outlineRenderer" {
  66854. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66855. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66856. import { Scene } from "babylonjs/scene";
  66857. import { ISceneComponent } from "babylonjs/sceneComponent";
  66858. import "babylonjs/Shaders/outline.fragment";
  66859. import "babylonjs/Shaders/outline.vertex";
  66860. module "babylonjs/scene" {
  66861. interface Scene {
  66862. /** @hidden */
  66863. _outlineRenderer: OutlineRenderer;
  66864. /**
  66865. * Gets the outline renderer associated with the scene
  66866. * @returns a OutlineRenderer
  66867. */
  66868. getOutlineRenderer(): OutlineRenderer;
  66869. }
  66870. }
  66871. module "babylonjs/Meshes/abstractMesh" {
  66872. interface AbstractMesh {
  66873. /** @hidden (Backing field) */
  66874. _renderOutline: boolean;
  66875. /**
  66876. * Gets or sets a boolean indicating if the outline must be rendered as well
  66877. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66878. */
  66879. renderOutline: boolean;
  66880. /** @hidden (Backing field) */
  66881. _renderOverlay: boolean;
  66882. /**
  66883. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66884. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66885. */
  66886. renderOverlay: boolean;
  66887. }
  66888. }
  66889. /**
  66890. * This class is responsible to draw bothe outline/overlay of meshes.
  66891. * It should not be used directly but through the available method on mesh.
  66892. */
  66893. export class OutlineRenderer implements ISceneComponent {
  66894. /**
  66895. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66896. */
  66897. private static _StencilReference;
  66898. /**
  66899. * The name of the component. Each component must have a unique name.
  66900. */
  66901. name: string;
  66902. /**
  66903. * The scene the component belongs to.
  66904. */
  66905. scene: Scene;
  66906. /**
  66907. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66908. */
  66909. zOffset: number;
  66910. private _engine;
  66911. private _effect;
  66912. private _cachedDefines;
  66913. private _savedDepthWrite;
  66914. /**
  66915. * Instantiates a new outline renderer. (There could be only one per scene).
  66916. * @param scene Defines the scene it belongs to
  66917. */
  66918. constructor(scene: Scene);
  66919. /**
  66920. * Register the component to one instance of a scene.
  66921. */
  66922. register(): void;
  66923. /**
  66924. * Rebuilds the elements related to this component in case of
  66925. * context lost for instance.
  66926. */
  66927. rebuild(): void;
  66928. /**
  66929. * Disposes the component and the associated ressources.
  66930. */
  66931. dispose(): void;
  66932. /**
  66933. * Renders the outline in the canvas.
  66934. * @param subMesh Defines the sumesh to render
  66935. * @param batch Defines the batch of meshes in case of instances
  66936. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66937. */
  66938. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66939. /**
  66940. * Returns whether or not the outline renderer is ready for a given submesh.
  66941. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66942. * @param subMesh Defines the submesh to check readyness for
  66943. * @param useInstances Defines wheter wee are trying to render instances or not
  66944. * @returns true if ready otherwise false
  66945. */
  66946. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66947. private _beforeRenderingMesh;
  66948. private _afterRenderingMesh;
  66949. }
  66950. }
  66951. declare module "babylonjs/Rendering/index" {
  66952. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66953. export * from "babylonjs/Rendering/depthRenderer";
  66954. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66955. export * from "babylonjs/Rendering/edgesRenderer";
  66956. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66957. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66958. export * from "babylonjs/Rendering/outlineRenderer";
  66959. export * from "babylonjs/Rendering/renderingGroup";
  66960. export * from "babylonjs/Rendering/renderingManager";
  66961. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66962. }
  66963. declare module "babylonjs/Sprites/spritePackedManager" {
  66964. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66965. import { Scene } from "babylonjs/scene";
  66966. /**
  66967. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66968. * @see http://doc.babylonjs.com/babylon101/sprites
  66969. */
  66970. export class SpritePackedManager extends SpriteManager {
  66971. /** defines the packed manager's name */
  66972. name: string;
  66973. /**
  66974. * Creates a new sprite manager from a packed sprite sheet
  66975. * @param name defines the manager's name
  66976. * @param imgUrl defines the sprite sheet url
  66977. * @param capacity defines the maximum allowed number of sprites
  66978. * @param scene defines the hosting scene
  66979. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66980. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66981. * @param samplingMode defines the smapling mode to use with spritesheet
  66982. * @param fromPacked set to true; do not alter
  66983. */
  66984. constructor(
  66985. /** defines the packed manager's name */
  66986. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66987. }
  66988. }
  66989. declare module "babylonjs/Sprites/index" {
  66990. export * from "babylonjs/Sprites/sprite";
  66991. export * from "babylonjs/Sprites/spriteManager";
  66992. export * from "babylonjs/Sprites/spritePackedManager";
  66993. export * from "babylonjs/Sprites/spriteSceneComponent";
  66994. }
  66995. declare module "babylonjs/States/index" {
  66996. export * from "babylonjs/States/alphaCullingState";
  66997. export * from "babylonjs/States/depthCullingState";
  66998. export * from "babylonjs/States/stencilState";
  66999. }
  67000. declare module "babylonjs/Misc/assetsManager" {
  67001. import { Scene } from "babylonjs/scene";
  67002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67003. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67004. import { Skeleton } from "babylonjs/Bones/skeleton";
  67005. import { Observable } from "babylonjs/Misc/observable";
  67006. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67007. import { Texture } from "babylonjs/Materials/Textures/texture";
  67008. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  67009. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  67010. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  67011. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  67012. /**
  67013. * Defines the list of states available for a task inside a AssetsManager
  67014. */
  67015. export enum AssetTaskState {
  67016. /**
  67017. * Initialization
  67018. */
  67019. INIT = 0,
  67020. /**
  67021. * Running
  67022. */
  67023. RUNNING = 1,
  67024. /**
  67025. * Done
  67026. */
  67027. DONE = 2,
  67028. /**
  67029. * Error
  67030. */
  67031. ERROR = 3
  67032. }
  67033. /**
  67034. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67035. */
  67036. export abstract class AbstractAssetTask {
  67037. /**
  67038. * Task name
  67039. */ name: string;
  67040. /**
  67041. * Callback called when the task is successful
  67042. */
  67043. onSuccess: (task: any) => void;
  67044. /**
  67045. * Callback called when the task is not successful
  67046. */
  67047. onError: (task: any, message?: string, exception?: any) => void;
  67048. /**
  67049. * Creates a new AssetsManager
  67050. * @param name defines the name of the task
  67051. */
  67052. constructor(
  67053. /**
  67054. * Task name
  67055. */ name: string);
  67056. private _isCompleted;
  67057. private _taskState;
  67058. private _errorObject;
  67059. /**
  67060. * Get if the task is completed
  67061. */
  67062. readonly isCompleted: boolean;
  67063. /**
  67064. * Gets the current state of the task
  67065. */
  67066. readonly taskState: AssetTaskState;
  67067. /**
  67068. * Gets the current error object (if task is in error)
  67069. */
  67070. readonly errorObject: {
  67071. message?: string;
  67072. exception?: any;
  67073. };
  67074. /**
  67075. * Internal only
  67076. * @hidden
  67077. */
  67078. _setErrorObject(message?: string, exception?: any): void;
  67079. /**
  67080. * Execute the current task
  67081. * @param scene defines the scene where you want your assets to be loaded
  67082. * @param onSuccess is a callback called when the task is successfully executed
  67083. * @param onError is a callback called if an error occurs
  67084. */
  67085. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67086. /**
  67087. * Execute the current task
  67088. * @param scene defines the scene where you want your assets to be loaded
  67089. * @param onSuccess is a callback called when the task is successfully executed
  67090. * @param onError is a callback called if an error occurs
  67091. */
  67092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67093. /**
  67094. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67095. * This can be used with failed tasks that have the reason for failure fixed.
  67096. */
  67097. reset(): void;
  67098. private onErrorCallback;
  67099. private onDoneCallback;
  67100. }
  67101. /**
  67102. * Define the interface used by progress events raised during assets loading
  67103. */
  67104. export interface IAssetsProgressEvent {
  67105. /**
  67106. * Defines the number of remaining tasks to process
  67107. */
  67108. remainingCount: number;
  67109. /**
  67110. * Defines the total number of tasks
  67111. */
  67112. totalCount: number;
  67113. /**
  67114. * Defines the task that was just processed
  67115. */
  67116. task: AbstractAssetTask;
  67117. }
  67118. /**
  67119. * Class used to share progress information about assets loading
  67120. */
  67121. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67122. /**
  67123. * Defines the number of remaining tasks to process
  67124. */
  67125. remainingCount: number;
  67126. /**
  67127. * Defines the total number of tasks
  67128. */
  67129. totalCount: number;
  67130. /**
  67131. * Defines the task that was just processed
  67132. */
  67133. task: AbstractAssetTask;
  67134. /**
  67135. * Creates a AssetsProgressEvent
  67136. * @param remainingCount defines the number of remaining tasks to process
  67137. * @param totalCount defines the total number of tasks
  67138. * @param task defines the task that was just processed
  67139. */
  67140. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67141. }
  67142. /**
  67143. * Define a task used by AssetsManager to load meshes
  67144. */
  67145. export class MeshAssetTask extends AbstractAssetTask {
  67146. /**
  67147. * Defines the name of the task
  67148. */
  67149. name: string;
  67150. /**
  67151. * Defines the list of mesh's names you want to load
  67152. */
  67153. meshesNames: any;
  67154. /**
  67155. * Defines the root url to use as a base to load your meshes and associated resources
  67156. */
  67157. rootUrl: string;
  67158. /**
  67159. * Defines the filename of the scene to load from
  67160. */
  67161. sceneFilename: string;
  67162. /**
  67163. * Gets the list of loaded meshes
  67164. */
  67165. loadedMeshes: Array<AbstractMesh>;
  67166. /**
  67167. * Gets the list of loaded particle systems
  67168. */
  67169. loadedParticleSystems: Array<IParticleSystem>;
  67170. /**
  67171. * Gets the list of loaded skeletons
  67172. */
  67173. loadedSkeletons: Array<Skeleton>;
  67174. /**
  67175. * Gets the list of loaded animation groups
  67176. */
  67177. loadedAnimationGroups: Array<AnimationGroup>;
  67178. /**
  67179. * Callback called when the task is successful
  67180. */
  67181. onSuccess: (task: MeshAssetTask) => void;
  67182. /**
  67183. * Callback called when the task is successful
  67184. */
  67185. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67186. /**
  67187. * Creates a new MeshAssetTask
  67188. * @param name defines the name of the task
  67189. * @param meshesNames defines the list of mesh's names you want to load
  67190. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67191. * @param sceneFilename defines the filename of the scene to load from
  67192. */
  67193. constructor(
  67194. /**
  67195. * Defines the name of the task
  67196. */
  67197. name: string,
  67198. /**
  67199. * Defines the list of mesh's names you want to load
  67200. */
  67201. meshesNames: any,
  67202. /**
  67203. * Defines the root url to use as a base to load your meshes and associated resources
  67204. */
  67205. rootUrl: string,
  67206. /**
  67207. * Defines the filename of the scene to load from
  67208. */
  67209. sceneFilename: string);
  67210. /**
  67211. * Execute the current task
  67212. * @param scene defines the scene where you want your assets to be loaded
  67213. * @param onSuccess is a callback called when the task is successfully executed
  67214. * @param onError is a callback called if an error occurs
  67215. */
  67216. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67217. }
  67218. /**
  67219. * Define a task used by AssetsManager to load text content
  67220. */
  67221. export class TextFileAssetTask extends AbstractAssetTask {
  67222. /**
  67223. * Defines the name of the task
  67224. */
  67225. name: string;
  67226. /**
  67227. * Defines the location of the file to load
  67228. */
  67229. url: string;
  67230. /**
  67231. * Gets the loaded text string
  67232. */
  67233. text: string;
  67234. /**
  67235. * Callback called when the task is successful
  67236. */
  67237. onSuccess: (task: TextFileAssetTask) => void;
  67238. /**
  67239. * Callback called when the task is successful
  67240. */
  67241. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67242. /**
  67243. * Creates a new TextFileAssetTask object
  67244. * @param name defines the name of the task
  67245. * @param url defines the location of the file to load
  67246. */
  67247. constructor(
  67248. /**
  67249. * Defines the name of the task
  67250. */
  67251. name: string,
  67252. /**
  67253. * Defines the location of the file to load
  67254. */
  67255. url: string);
  67256. /**
  67257. * Execute the current task
  67258. * @param scene defines the scene where you want your assets to be loaded
  67259. * @param onSuccess is a callback called when the task is successfully executed
  67260. * @param onError is a callback called if an error occurs
  67261. */
  67262. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67263. }
  67264. /**
  67265. * Define a task used by AssetsManager to load binary data
  67266. */
  67267. export class BinaryFileAssetTask extends AbstractAssetTask {
  67268. /**
  67269. * Defines the name of the task
  67270. */
  67271. name: string;
  67272. /**
  67273. * Defines the location of the file to load
  67274. */
  67275. url: string;
  67276. /**
  67277. * Gets the lodaded data (as an array buffer)
  67278. */
  67279. data: ArrayBuffer;
  67280. /**
  67281. * Callback called when the task is successful
  67282. */
  67283. onSuccess: (task: BinaryFileAssetTask) => void;
  67284. /**
  67285. * Callback called when the task is successful
  67286. */
  67287. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67288. /**
  67289. * Creates a new BinaryFileAssetTask object
  67290. * @param name defines the name of the new task
  67291. * @param url defines the location of the file to load
  67292. */
  67293. constructor(
  67294. /**
  67295. * Defines the name of the task
  67296. */
  67297. name: string,
  67298. /**
  67299. * Defines the location of the file to load
  67300. */
  67301. url: string);
  67302. /**
  67303. * Execute the current task
  67304. * @param scene defines the scene where you want your assets to be loaded
  67305. * @param onSuccess is a callback called when the task is successfully executed
  67306. * @param onError is a callback called if an error occurs
  67307. */
  67308. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67309. }
  67310. /**
  67311. * Define a task used by AssetsManager to load images
  67312. */
  67313. export class ImageAssetTask extends AbstractAssetTask {
  67314. /**
  67315. * Defines the name of the task
  67316. */
  67317. name: string;
  67318. /**
  67319. * Defines the location of the image to load
  67320. */
  67321. url: string;
  67322. /**
  67323. * Gets the loaded images
  67324. */
  67325. image: HTMLImageElement;
  67326. /**
  67327. * Callback called when the task is successful
  67328. */
  67329. onSuccess: (task: ImageAssetTask) => void;
  67330. /**
  67331. * Callback called when the task is successful
  67332. */
  67333. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67334. /**
  67335. * Creates a new ImageAssetTask
  67336. * @param name defines the name of the task
  67337. * @param url defines the location of the image to load
  67338. */
  67339. constructor(
  67340. /**
  67341. * Defines the name of the task
  67342. */
  67343. name: string,
  67344. /**
  67345. * Defines the location of the image to load
  67346. */
  67347. url: string);
  67348. /**
  67349. * Execute the current task
  67350. * @param scene defines the scene where you want your assets to be loaded
  67351. * @param onSuccess is a callback called when the task is successfully executed
  67352. * @param onError is a callback called if an error occurs
  67353. */
  67354. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67355. }
  67356. /**
  67357. * Defines the interface used by texture loading tasks
  67358. */
  67359. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67360. /**
  67361. * Gets the loaded texture
  67362. */
  67363. texture: TEX;
  67364. }
  67365. /**
  67366. * Define a task used by AssetsManager to load 2D textures
  67367. */
  67368. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67369. /**
  67370. * Defines the name of the task
  67371. */
  67372. name: string;
  67373. /**
  67374. * Defines the location of the file to load
  67375. */
  67376. url: string;
  67377. /**
  67378. * Defines if mipmap should not be generated (default is false)
  67379. */
  67380. noMipmap?: boolean | undefined;
  67381. /**
  67382. * Defines if texture must be inverted on Y axis (default is false)
  67383. */
  67384. invertY?: boolean | undefined;
  67385. /**
  67386. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67387. */
  67388. samplingMode: number;
  67389. /**
  67390. * Gets the loaded texture
  67391. */
  67392. texture: Texture;
  67393. /**
  67394. * Callback called when the task is successful
  67395. */
  67396. onSuccess: (task: TextureAssetTask) => void;
  67397. /**
  67398. * Callback called when the task is successful
  67399. */
  67400. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67401. /**
  67402. * Creates a new TextureAssetTask object
  67403. * @param name defines the name of the task
  67404. * @param url defines the location of the file to load
  67405. * @param noMipmap defines if mipmap should not be generated (default is false)
  67406. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67407. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67408. */
  67409. constructor(
  67410. /**
  67411. * Defines the name of the task
  67412. */
  67413. name: string,
  67414. /**
  67415. * Defines the location of the file to load
  67416. */
  67417. url: string,
  67418. /**
  67419. * Defines if mipmap should not be generated (default is false)
  67420. */
  67421. noMipmap?: boolean | undefined,
  67422. /**
  67423. * Defines if texture must be inverted on Y axis (default is false)
  67424. */
  67425. invertY?: boolean | undefined,
  67426. /**
  67427. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67428. */
  67429. samplingMode?: number);
  67430. /**
  67431. * Execute the current task
  67432. * @param scene defines the scene where you want your assets to be loaded
  67433. * @param onSuccess is a callback called when the task is successfully executed
  67434. * @param onError is a callback called if an error occurs
  67435. */
  67436. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67437. }
  67438. /**
  67439. * Define a task used by AssetsManager to load cube textures
  67440. */
  67441. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67442. /**
  67443. * Defines the name of the task
  67444. */
  67445. name: string;
  67446. /**
  67447. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67448. */
  67449. url: string;
  67450. /**
  67451. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67452. */
  67453. extensions?: string[] | undefined;
  67454. /**
  67455. * Defines if mipmaps should not be generated (default is false)
  67456. */
  67457. noMipmap?: boolean | undefined;
  67458. /**
  67459. * Defines the explicit list of files (undefined by default)
  67460. */
  67461. files?: string[] | undefined;
  67462. /**
  67463. * Gets the loaded texture
  67464. */
  67465. texture: CubeTexture;
  67466. /**
  67467. * Callback called when the task is successful
  67468. */
  67469. onSuccess: (task: CubeTextureAssetTask) => void;
  67470. /**
  67471. * Callback called when the task is successful
  67472. */
  67473. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67474. /**
  67475. * Creates a new CubeTextureAssetTask
  67476. * @param name defines the name of the task
  67477. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67478. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67479. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67480. * @param files defines the explicit list of files (undefined by default)
  67481. */
  67482. constructor(
  67483. /**
  67484. * Defines the name of the task
  67485. */
  67486. name: string,
  67487. /**
  67488. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67489. */
  67490. url: string,
  67491. /**
  67492. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67493. */
  67494. extensions?: string[] | undefined,
  67495. /**
  67496. * Defines if mipmaps should not be generated (default is false)
  67497. */
  67498. noMipmap?: boolean | undefined,
  67499. /**
  67500. * Defines the explicit list of files (undefined by default)
  67501. */
  67502. files?: string[] | undefined);
  67503. /**
  67504. * Execute the current task
  67505. * @param scene defines the scene where you want your assets to be loaded
  67506. * @param onSuccess is a callback called when the task is successfully executed
  67507. * @param onError is a callback called if an error occurs
  67508. */
  67509. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67510. }
  67511. /**
  67512. * Define a task used by AssetsManager to load HDR cube textures
  67513. */
  67514. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67515. /**
  67516. * Defines the name of the task
  67517. */
  67518. name: string;
  67519. /**
  67520. * Defines the location of the file to load
  67521. */
  67522. url: string;
  67523. /**
  67524. * Defines the desired size (the more it increases the longer the generation will be)
  67525. */
  67526. size: number;
  67527. /**
  67528. * Defines if mipmaps should not be generated (default is false)
  67529. */
  67530. noMipmap: boolean;
  67531. /**
  67532. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67533. */
  67534. generateHarmonics: boolean;
  67535. /**
  67536. * 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)
  67537. */
  67538. gammaSpace: boolean;
  67539. /**
  67540. * Internal Use Only
  67541. */
  67542. reserved: boolean;
  67543. /**
  67544. * Gets the loaded texture
  67545. */
  67546. texture: HDRCubeTexture;
  67547. /**
  67548. * Callback called when the task is successful
  67549. */
  67550. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67551. /**
  67552. * Callback called when the task is successful
  67553. */
  67554. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67555. /**
  67556. * Creates a new HDRCubeTextureAssetTask object
  67557. * @param name defines the name of the task
  67558. * @param url defines the location of the file to load
  67559. * @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.
  67560. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67561. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67562. * @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)
  67563. * @param reserved Internal use only
  67564. */
  67565. constructor(
  67566. /**
  67567. * Defines the name of the task
  67568. */
  67569. name: string,
  67570. /**
  67571. * Defines the location of the file to load
  67572. */
  67573. url: string,
  67574. /**
  67575. * Defines the desired size (the more it increases the longer the generation will be)
  67576. */
  67577. size: number,
  67578. /**
  67579. * Defines if mipmaps should not be generated (default is false)
  67580. */
  67581. noMipmap?: boolean,
  67582. /**
  67583. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67584. */
  67585. generateHarmonics?: boolean,
  67586. /**
  67587. * 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)
  67588. */
  67589. gammaSpace?: boolean,
  67590. /**
  67591. * Internal Use Only
  67592. */
  67593. reserved?: boolean);
  67594. /**
  67595. * Execute the current task
  67596. * @param scene defines the scene where you want your assets to be loaded
  67597. * @param onSuccess is a callback called when the task is successfully executed
  67598. * @param onError is a callback called if an error occurs
  67599. */
  67600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67601. }
  67602. /**
  67603. * Define a task used by AssetsManager to load Equirectangular cube textures
  67604. */
  67605. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67606. /**
  67607. * Defines the name of the task
  67608. */
  67609. name: string;
  67610. /**
  67611. * Defines the location of the file to load
  67612. */
  67613. url: string;
  67614. /**
  67615. * Defines the desired size (the more it increases the longer the generation will be)
  67616. */
  67617. size: number;
  67618. /**
  67619. * Defines if mipmaps should not be generated (default is false)
  67620. */
  67621. noMipmap: boolean;
  67622. /**
  67623. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67624. * but the standard material would require them in Gamma space) (default is true)
  67625. */
  67626. gammaSpace: boolean;
  67627. /**
  67628. * Gets the loaded texture
  67629. */
  67630. texture: EquiRectangularCubeTexture;
  67631. /**
  67632. * Callback called when the task is successful
  67633. */
  67634. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67635. /**
  67636. * Callback called when the task is successful
  67637. */
  67638. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67639. /**
  67640. * Creates a new EquiRectangularCubeTextureAssetTask object
  67641. * @param name defines the name of the task
  67642. * @param url defines the location of the file to load
  67643. * @param size defines the desired size (the more it increases the longer the generation will be)
  67644. * If the size is omitted this implies you are using a preprocessed cubemap.
  67645. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67646. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67647. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67648. * (default is true)
  67649. */
  67650. constructor(
  67651. /**
  67652. * Defines the name of the task
  67653. */
  67654. name: string,
  67655. /**
  67656. * Defines the location of the file to load
  67657. */
  67658. url: string,
  67659. /**
  67660. * Defines the desired size (the more it increases the longer the generation will be)
  67661. */
  67662. size: number,
  67663. /**
  67664. * Defines if mipmaps should not be generated (default is false)
  67665. */
  67666. noMipmap?: boolean,
  67667. /**
  67668. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67669. * but the standard material would require them in Gamma space) (default is true)
  67670. */
  67671. gammaSpace?: boolean);
  67672. /**
  67673. * Execute the current task
  67674. * @param scene defines the scene where you want your assets to be loaded
  67675. * @param onSuccess is a callback called when the task is successfully executed
  67676. * @param onError is a callback called if an error occurs
  67677. */
  67678. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67679. }
  67680. /**
  67681. * This class can be used to easily import assets into a scene
  67682. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67683. */
  67684. export class AssetsManager {
  67685. private _scene;
  67686. private _isLoading;
  67687. protected _tasks: AbstractAssetTask[];
  67688. protected _waitingTasksCount: number;
  67689. protected _totalTasksCount: number;
  67690. /**
  67691. * Callback called when all tasks are processed
  67692. */
  67693. onFinish: (tasks: AbstractAssetTask[]) => void;
  67694. /**
  67695. * Callback called when a task is successful
  67696. */
  67697. onTaskSuccess: (task: AbstractAssetTask) => void;
  67698. /**
  67699. * Callback called when a task had an error
  67700. */
  67701. onTaskError: (task: AbstractAssetTask) => void;
  67702. /**
  67703. * Callback called when a task is done (whatever the result is)
  67704. */
  67705. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67706. /**
  67707. * Observable called when all tasks are processed
  67708. */
  67709. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67710. /**
  67711. * Observable called when a task had an error
  67712. */
  67713. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67714. /**
  67715. * Observable called when all tasks were executed
  67716. */
  67717. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67718. /**
  67719. * Observable called when a task is done (whatever the result is)
  67720. */
  67721. onProgressObservable: Observable<IAssetsProgressEvent>;
  67722. /**
  67723. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67724. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67725. */
  67726. useDefaultLoadingScreen: boolean;
  67727. /**
  67728. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67729. * when all assets have been downloaded.
  67730. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67731. */
  67732. autoHideLoadingUI: boolean;
  67733. /**
  67734. * Creates a new AssetsManager
  67735. * @param scene defines the scene to work on
  67736. */
  67737. constructor(scene: Scene);
  67738. /**
  67739. * Add a MeshAssetTask to the list of active tasks
  67740. * @param taskName defines the name of the new task
  67741. * @param meshesNames defines the name of meshes to load
  67742. * @param rootUrl defines the root url to use to locate files
  67743. * @param sceneFilename defines the filename of the scene file
  67744. * @returns a new MeshAssetTask object
  67745. */
  67746. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67747. /**
  67748. * Add a TextFileAssetTask to the list of active tasks
  67749. * @param taskName defines the name of the new task
  67750. * @param url defines the url of the file to load
  67751. * @returns a new TextFileAssetTask object
  67752. */
  67753. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67754. /**
  67755. * Add a BinaryFileAssetTask to the list of active tasks
  67756. * @param taskName defines the name of the new task
  67757. * @param url defines the url of the file to load
  67758. * @returns a new BinaryFileAssetTask object
  67759. */
  67760. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67761. /**
  67762. * Add a ImageAssetTask to the list of active tasks
  67763. * @param taskName defines the name of the new task
  67764. * @param url defines the url of the file to load
  67765. * @returns a new ImageAssetTask object
  67766. */
  67767. addImageTask(taskName: string, url: string): ImageAssetTask;
  67768. /**
  67769. * Add a TextureAssetTask to the list of active tasks
  67770. * @param taskName defines the name of the new task
  67771. * @param url defines the url of the file to load
  67772. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67773. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67774. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67775. * @returns a new TextureAssetTask object
  67776. */
  67777. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67778. /**
  67779. * Add a CubeTextureAssetTask to the list of active tasks
  67780. * @param taskName defines the name of the new task
  67781. * @param url defines the url of the file to load
  67782. * @param extensions defines the extension to use to load the cube map (can be null)
  67783. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67784. * @param files defines the list of files to load (can be null)
  67785. * @returns a new CubeTextureAssetTask object
  67786. */
  67787. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67788. /**
  67789. *
  67790. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67791. * @param taskName defines the name of the new task
  67792. * @param url defines the url of the file to load
  67793. * @param size defines the size you want for the cubemap (can be null)
  67794. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67795. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67796. * @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)
  67797. * @param reserved Internal use only
  67798. * @returns a new HDRCubeTextureAssetTask object
  67799. */
  67800. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67801. /**
  67802. *
  67803. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67804. * @param taskName defines the name of the new task
  67805. * @param url defines the url of the file to load
  67806. * @param size defines the size you want for the cubemap (can be null)
  67807. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67808. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67809. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67810. * @returns a new EquiRectangularCubeTextureAssetTask object
  67811. */
  67812. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67813. /**
  67814. * Remove a task from the assets manager.
  67815. * @param task the task to remove
  67816. */
  67817. removeTask(task: AbstractAssetTask): void;
  67818. private _decreaseWaitingTasksCount;
  67819. private _runTask;
  67820. /**
  67821. * Reset the AssetsManager and remove all tasks
  67822. * @return the current instance of the AssetsManager
  67823. */
  67824. reset(): AssetsManager;
  67825. /**
  67826. * Start the loading process
  67827. * @return the current instance of the AssetsManager
  67828. */
  67829. load(): AssetsManager;
  67830. /**
  67831. * Start the loading process as an async operation
  67832. * @return a promise returning the list of failed tasks
  67833. */
  67834. loadAsync(): Promise<void>;
  67835. }
  67836. }
  67837. declare module "babylonjs/Misc/deferred" {
  67838. /**
  67839. * Wrapper class for promise with external resolve and reject.
  67840. */
  67841. export class Deferred<T> {
  67842. /**
  67843. * The promise associated with this deferred object.
  67844. */
  67845. readonly promise: Promise<T>;
  67846. private _resolve;
  67847. private _reject;
  67848. /**
  67849. * The resolve method of the promise associated with this deferred object.
  67850. */
  67851. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67852. /**
  67853. * The reject method of the promise associated with this deferred object.
  67854. */
  67855. readonly reject: (reason?: any) => void;
  67856. /**
  67857. * Constructor for this deferred object.
  67858. */
  67859. constructor();
  67860. }
  67861. }
  67862. declare module "babylonjs/Misc/meshExploder" {
  67863. import { Mesh } from "babylonjs/Meshes/mesh";
  67864. /**
  67865. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67866. */
  67867. export class MeshExploder {
  67868. private _centerMesh;
  67869. private _meshes;
  67870. private _meshesOrigins;
  67871. private _toCenterVectors;
  67872. private _scaledDirection;
  67873. private _newPosition;
  67874. private _centerPosition;
  67875. /**
  67876. * Explodes meshes from a center mesh.
  67877. * @param meshes The meshes to explode.
  67878. * @param centerMesh The mesh to be center of explosion.
  67879. */
  67880. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67881. private _setCenterMesh;
  67882. /**
  67883. * Get class name
  67884. * @returns "MeshExploder"
  67885. */
  67886. getClassName(): string;
  67887. /**
  67888. * "Exploded meshes"
  67889. * @returns Array of meshes with the centerMesh at index 0.
  67890. */
  67891. getMeshes(): Array<Mesh>;
  67892. /**
  67893. * Explodes meshes giving a specific direction
  67894. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67895. */
  67896. explode(direction?: number): void;
  67897. }
  67898. }
  67899. declare module "babylonjs/Misc/filesInput" {
  67900. import { Engine } from "babylonjs/Engines/engine";
  67901. import { Scene } from "babylonjs/scene";
  67902. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67903. /**
  67904. * Class used to help managing file picking and drag'n'drop
  67905. */
  67906. export class FilesInput {
  67907. /**
  67908. * List of files ready to be loaded
  67909. */
  67910. static readonly FilesToLoad: {
  67911. [key: string]: File;
  67912. };
  67913. /**
  67914. * Callback called when a file is processed
  67915. */
  67916. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67917. private _engine;
  67918. private _currentScene;
  67919. private _sceneLoadedCallback;
  67920. private _progressCallback;
  67921. private _additionalRenderLoopLogicCallback;
  67922. private _textureLoadingCallback;
  67923. private _startingProcessingFilesCallback;
  67924. private _onReloadCallback;
  67925. private _errorCallback;
  67926. private _elementToMonitor;
  67927. private _sceneFileToLoad;
  67928. private _filesToLoad;
  67929. /**
  67930. * Creates a new FilesInput
  67931. * @param engine defines the rendering engine
  67932. * @param scene defines the hosting scene
  67933. * @param sceneLoadedCallback callback called when scene is loaded
  67934. * @param progressCallback callback called to track progress
  67935. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67936. * @param textureLoadingCallback callback called when a texture is loading
  67937. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67938. * @param onReloadCallback callback called when a reload is requested
  67939. * @param errorCallback callback call if an error occurs
  67940. */
  67941. 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);
  67942. private _dragEnterHandler;
  67943. private _dragOverHandler;
  67944. private _dropHandler;
  67945. /**
  67946. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67947. * @param elementToMonitor defines the DOM element to track
  67948. */
  67949. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67950. /**
  67951. * Release all associated resources
  67952. */
  67953. dispose(): void;
  67954. private renderFunction;
  67955. private drag;
  67956. private drop;
  67957. private _traverseFolder;
  67958. private _processFiles;
  67959. /**
  67960. * Load files from a drop event
  67961. * @param event defines the drop event to use as source
  67962. */
  67963. loadFiles(event: any): void;
  67964. private _processReload;
  67965. /**
  67966. * Reload the current scene from the loaded files
  67967. */
  67968. reload(): void;
  67969. }
  67970. }
  67971. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67972. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67973. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67974. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67975. }
  67976. declare module "babylonjs/Misc/sceneOptimizer" {
  67977. import { Scene, IDisposable } from "babylonjs/scene";
  67978. import { Observable } from "babylonjs/Misc/observable";
  67979. /**
  67980. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67982. */
  67983. export class SceneOptimization {
  67984. /**
  67985. * Defines the priority of this optimization (0 by default which means first in the list)
  67986. */
  67987. priority: number;
  67988. /**
  67989. * Gets a string describing the action executed by the current optimization
  67990. * @returns description string
  67991. */
  67992. getDescription(): string;
  67993. /**
  67994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67995. * @param scene defines the current scene where to apply this optimization
  67996. * @param optimizer defines the current optimizer
  67997. * @returns true if everything that can be done was applied
  67998. */
  67999. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68000. /**
  68001. * Creates the SceneOptimization object
  68002. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68003. * @param desc defines the description associated with the optimization
  68004. */
  68005. constructor(
  68006. /**
  68007. * Defines the priority of this optimization (0 by default which means first in the list)
  68008. */
  68009. priority?: number);
  68010. }
  68011. /**
  68012. * Defines an optimization used to reduce the size of render target textures
  68013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68014. */
  68015. export class TextureOptimization extends SceneOptimization {
  68016. /**
  68017. * Defines the priority of this optimization (0 by default which means first in the list)
  68018. */
  68019. priority: number;
  68020. /**
  68021. * 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
  68022. */
  68023. maximumSize: number;
  68024. /**
  68025. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68026. */
  68027. step: number;
  68028. /**
  68029. * Gets a string describing the action executed by the current optimization
  68030. * @returns description string
  68031. */
  68032. getDescription(): string;
  68033. /**
  68034. * Creates the TextureOptimization object
  68035. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68036. * @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
  68037. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68038. */
  68039. constructor(
  68040. /**
  68041. * Defines the priority of this optimization (0 by default which means first in the list)
  68042. */
  68043. priority?: number,
  68044. /**
  68045. * 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
  68046. */
  68047. maximumSize?: number,
  68048. /**
  68049. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68050. */
  68051. step?: number);
  68052. /**
  68053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68054. * @param scene defines the current scene where to apply this optimization
  68055. * @param optimizer defines the current optimizer
  68056. * @returns true if everything that can be done was applied
  68057. */
  68058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68059. }
  68060. /**
  68061. * Defines an optimization used to increase or decrease the rendering resolution
  68062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68063. */
  68064. export class HardwareScalingOptimization extends SceneOptimization {
  68065. /**
  68066. * Defines the priority of this optimization (0 by default which means first in the list)
  68067. */
  68068. priority: number;
  68069. /**
  68070. * Defines the maximum scale to use (2 by default)
  68071. */
  68072. maximumScale: number;
  68073. /**
  68074. * Defines the step to use between two passes (0.5 by default)
  68075. */
  68076. step: number;
  68077. private _currentScale;
  68078. private _directionOffset;
  68079. /**
  68080. * Gets a string describing the action executed by the current optimization
  68081. * @return description string
  68082. */
  68083. getDescription(): string;
  68084. /**
  68085. * Creates the HardwareScalingOptimization object
  68086. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68087. * @param maximumScale defines the maximum scale to use (2 by default)
  68088. * @param step defines the step to use between two passes (0.5 by default)
  68089. */
  68090. constructor(
  68091. /**
  68092. * Defines the priority of this optimization (0 by default which means first in the list)
  68093. */
  68094. priority?: number,
  68095. /**
  68096. * Defines the maximum scale to use (2 by default)
  68097. */
  68098. maximumScale?: number,
  68099. /**
  68100. * Defines the step to use between two passes (0.5 by default)
  68101. */
  68102. step?: number);
  68103. /**
  68104. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68105. * @param scene defines the current scene where to apply this optimization
  68106. * @param optimizer defines the current optimizer
  68107. * @returns true if everything that can be done was applied
  68108. */
  68109. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68110. }
  68111. /**
  68112. * Defines an optimization used to remove shadows
  68113. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68114. */
  68115. export class ShadowsOptimization extends SceneOptimization {
  68116. /**
  68117. * Gets a string describing the action executed by the current optimization
  68118. * @return description string
  68119. */
  68120. getDescription(): string;
  68121. /**
  68122. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68123. * @param scene defines the current scene where to apply this optimization
  68124. * @param optimizer defines the current optimizer
  68125. * @returns true if everything that can be done was applied
  68126. */
  68127. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68128. }
  68129. /**
  68130. * Defines an optimization used to turn post-processes off
  68131. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68132. */
  68133. export class PostProcessesOptimization extends SceneOptimization {
  68134. /**
  68135. * Gets a string describing the action executed by the current optimization
  68136. * @return description string
  68137. */
  68138. getDescription(): string;
  68139. /**
  68140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68141. * @param scene defines the current scene where to apply this optimization
  68142. * @param optimizer defines the current optimizer
  68143. * @returns true if everything that can be done was applied
  68144. */
  68145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68146. }
  68147. /**
  68148. * Defines an optimization used to turn lens flares off
  68149. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68150. */
  68151. export class LensFlaresOptimization extends SceneOptimization {
  68152. /**
  68153. * Gets a string describing the action executed by the current optimization
  68154. * @return description string
  68155. */
  68156. getDescription(): string;
  68157. /**
  68158. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68159. * @param scene defines the current scene where to apply this optimization
  68160. * @param optimizer defines the current optimizer
  68161. * @returns true if everything that can be done was applied
  68162. */
  68163. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68164. }
  68165. /**
  68166. * Defines an optimization based on user defined callback.
  68167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68168. */
  68169. export class CustomOptimization extends SceneOptimization {
  68170. /**
  68171. * Callback called to apply the custom optimization.
  68172. */
  68173. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68174. /**
  68175. * Callback called to get custom description
  68176. */
  68177. onGetDescription: () => string;
  68178. /**
  68179. * Gets a string describing the action executed by the current optimization
  68180. * @returns description string
  68181. */
  68182. getDescription(): string;
  68183. /**
  68184. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68185. * @param scene defines the current scene where to apply this optimization
  68186. * @param optimizer defines the current optimizer
  68187. * @returns true if everything that can be done was applied
  68188. */
  68189. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68190. }
  68191. /**
  68192. * Defines an optimization used to turn particles off
  68193. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68194. */
  68195. export class ParticlesOptimization extends SceneOptimization {
  68196. /**
  68197. * Gets a string describing the action executed by the current optimization
  68198. * @return description string
  68199. */
  68200. getDescription(): string;
  68201. /**
  68202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68203. * @param scene defines the current scene where to apply this optimization
  68204. * @param optimizer defines the current optimizer
  68205. * @returns true if everything that can be done was applied
  68206. */
  68207. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68208. }
  68209. /**
  68210. * Defines an optimization used to turn render targets off
  68211. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68212. */
  68213. export class RenderTargetsOptimization extends SceneOptimization {
  68214. /**
  68215. * Gets a string describing the action executed by the current optimization
  68216. * @return description string
  68217. */
  68218. getDescription(): string;
  68219. /**
  68220. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68221. * @param scene defines the current scene where to apply this optimization
  68222. * @param optimizer defines the current optimizer
  68223. * @returns true if everything that can be done was applied
  68224. */
  68225. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68226. }
  68227. /**
  68228. * Defines an optimization used to merge meshes with compatible materials
  68229. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68230. */
  68231. export class MergeMeshesOptimization extends SceneOptimization {
  68232. private static _UpdateSelectionTree;
  68233. /**
  68234. * Gets or sets a boolean which defines if optimization octree has to be updated
  68235. */
  68236. /**
  68237. * Gets or sets a boolean which defines if optimization octree has to be updated
  68238. */
  68239. static UpdateSelectionTree: boolean;
  68240. /**
  68241. * Gets a string describing the action executed by the current optimization
  68242. * @return description string
  68243. */
  68244. getDescription(): string;
  68245. private _canBeMerged;
  68246. /**
  68247. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68248. * @param scene defines the current scene where to apply this optimization
  68249. * @param optimizer defines the current optimizer
  68250. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68251. * @returns true if everything that can be done was applied
  68252. */
  68253. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68254. }
  68255. /**
  68256. * Defines a list of options used by SceneOptimizer
  68257. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68258. */
  68259. export class SceneOptimizerOptions {
  68260. /**
  68261. * Defines the target frame rate to reach (60 by default)
  68262. */
  68263. targetFrameRate: number;
  68264. /**
  68265. * Defines the interval between two checkes (2000ms by default)
  68266. */
  68267. trackerDuration: number;
  68268. /**
  68269. * Gets the list of optimizations to apply
  68270. */
  68271. optimizations: SceneOptimization[];
  68272. /**
  68273. * Creates a new list of options used by SceneOptimizer
  68274. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68275. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68276. */
  68277. constructor(
  68278. /**
  68279. * Defines the target frame rate to reach (60 by default)
  68280. */
  68281. targetFrameRate?: number,
  68282. /**
  68283. * Defines the interval between two checkes (2000ms by default)
  68284. */
  68285. trackerDuration?: number);
  68286. /**
  68287. * Add a new optimization
  68288. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68289. * @returns the current SceneOptimizerOptions
  68290. */
  68291. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68292. /**
  68293. * Add a new custom optimization
  68294. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68295. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68296. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68297. * @returns the current SceneOptimizerOptions
  68298. */
  68299. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68300. /**
  68301. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68302. * @param targetFrameRate defines the target frame rate (60 by default)
  68303. * @returns a SceneOptimizerOptions object
  68304. */
  68305. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68306. /**
  68307. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68308. * @param targetFrameRate defines the target frame rate (60 by default)
  68309. * @returns a SceneOptimizerOptions object
  68310. */
  68311. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68312. /**
  68313. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68314. * @param targetFrameRate defines the target frame rate (60 by default)
  68315. * @returns a SceneOptimizerOptions object
  68316. */
  68317. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68318. }
  68319. /**
  68320. * Class used to run optimizations in order to reach a target frame rate
  68321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68322. */
  68323. export class SceneOptimizer implements IDisposable {
  68324. private _isRunning;
  68325. private _options;
  68326. private _scene;
  68327. private _currentPriorityLevel;
  68328. private _targetFrameRate;
  68329. private _trackerDuration;
  68330. private _currentFrameRate;
  68331. private _sceneDisposeObserver;
  68332. private _improvementMode;
  68333. /**
  68334. * Defines an observable called when the optimizer reaches the target frame rate
  68335. */
  68336. onSuccessObservable: Observable<SceneOptimizer>;
  68337. /**
  68338. * Defines an observable called when the optimizer enables an optimization
  68339. */
  68340. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68341. /**
  68342. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68343. */
  68344. onFailureObservable: Observable<SceneOptimizer>;
  68345. /**
  68346. * Gets a boolean indicating if the optimizer is in improvement mode
  68347. */
  68348. readonly isInImprovementMode: boolean;
  68349. /**
  68350. * Gets the current priority level (0 at start)
  68351. */
  68352. readonly currentPriorityLevel: number;
  68353. /**
  68354. * Gets the current frame rate checked by the SceneOptimizer
  68355. */
  68356. readonly currentFrameRate: number;
  68357. /**
  68358. * Gets or sets the current target frame rate (60 by default)
  68359. */
  68360. /**
  68361. * Gets or sets the current target frame rate (60 by default)
  68362. */
  68363. targetFrameRate: number;
  68364. /**
  68365. * Gets or sets the current interval between two checks (every 2000ms by default)
  68366. */
  68367. /**
  68368. * Gets or sets the current interval between two checks (every 2000ms by default)
  68369. */
  68370. trackerDuration: number;
  68371. /**
  68372. * Gets the list of active optimizations
  68373. */
  68374. readonly optimizations: SceneOptimization[];
  68375. /**
  68376. * Creates a new SceneOptimizer
  68377. * @param scene defines the scene to work on
  68378. * @param options defines the options to use with the SceneOptimizer
  68379. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68380. * @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)
  68381. */
  68382. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68383. /**
  68384. * Stops the current optimizer
  68385. */
  68386. stop(): void;
  68387. /**
  68388. * Reset the optimizer to initial step (current priority level = 0)
  68389. */
  68390. reset(): void;
  68391. /**
  68392. * Start the optimizer. By default it will try to reach a specific framerate
  68393. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68394. */
  68395. start(): void;
  68396. private _checkCurrentState;
  68397. /**
  68398. * Release all resources
  68399. */
  68400. dispose(): void;
  68401. /**
  68402. * Helper function to create a SceneOptimizer with one single line of code
  68403. * @param scene defines the scene to work on
  68404. * @param options defines the options to use with the SceneOptimizer
  68405. * @param onSuccess defines a callback to call on success
  68406. * @param onFailure defines a callback to call on failure
  68407. * @returns the new SceneOptimizer object
  68408. */
  68409. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68410. }
  68411. }
  68412. declare module "babylonjs/Misc/sceneSerializer" {
  68413. import { Scene } from "babylonjs/scene";
  68414. /**
  68415. * Class used to serialize a scene into a string
  68416. */
  68417. export class SceneSerializer {
  68418. /**
  68419. * Clear cache used by a previous serialization
  68420. */
  68421. static ClearCache(): void;
  68422. /**
  68423. * Serialize a scene into a JSON compatible object
  68424. * @param scene defines the scene to serialize
  68425. * @returns a JSON compatible object
  68426. */
  68427. static Serialize(scene: Scene): any;
  68428. /**
  68429. * Serialize a mesh into a JSON compatible object
  68430. * @param toSerialize defines the mesh to serialize
  68431. * @param withParents defines if parents must be serialized as well
  68432. * @param withChildren defines if children must be serialized as well
  68433. * @returns a JSON compatible object
  68434. */
  68435. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68436. }
  68437. }
  68438. declare module "babylonjs/Misc/textureTools" {
  68439. import { Texture } from "babylonjs/Materials/Textures/texture";
  68440. /**
  68441. * Class used to host texture specific utilities
  68442. */
  68443. export class TextureTools {
  68444. /**
  68445. * Uses the GPU to create a copy texture rescaled at a given size
  68446. * @param texture Texture to copy from
  68447. * @param width defines the desired width
  68448. * @param height defines the desired height
  68449. * @param useBilinearMode defines if bilinear mode has to be used
  68450. * @return the generated texture
  68451. */
  68452. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68453. }
  68454. }
  68455. declare module "babylonjs/Misc/videoRecorder" {
  68456. import { Nullable } from "babylonjs/types";
  68457. import { Engine } from "babylonjs/Engines/engine";
  68458. /**
  68459. * This represents the different options available for the video capture.
  68460. */
  68461. export interface VideoRecorderOptions {
  68462. /** Defines the mime type of the video. */
  68463. mimeType: string;
  68464. /** Defines the FPS the video should be recorded at. */
  68465. fps: number;
  68466. /** Defines the chunk size for the recording data. */
  68467. recordChunckSize: number;
  68468. /** The audio tracks to attach to the recording. */
  68469. audioTracks?: MediaStreamTrack[];
  68470. }
  68471. /**
  68472. * This can help with recording videos from BabylonJS.
  68473. * This is based on the available WebRTC functionalities of the browser.
  68474. *
  68475. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68476. */
  68477. export class VideoRecorder {
  68478. private static readonly _defaultOptions;
  68479. /**
  68480. * Returns whether or not the VideoRecorder is available in your browser.
  68481. * @param engine Defines the Babylon Engine.
  68482. * @returns true if supported otherwise false.
  68483. */
  68484. static IsSupported(engine: Engine): boolean;
  68485. private readonly _options;
  68486. private _canvas;
  68487. private _mediaRecorder;
  68488. private _recordedChunks;
  68489. private _fileName;
  68490. private _resolve;
  68491. private _reject;
  68492. /**
  68493. * True when a recording is already in progress.
  68494. */
  68495. readonly isRecording: boolean;
  68496. /**
  68497. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68498. * @param engine Defines the BabylonJS Engine you wish to record.
  68499. * @param options Defines options that can be used to customize the capture.
  68500. */
  68501. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68502. /**
  68503. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68504. */
  68505. stopRecording(): void;
  68506. /**
  68507. * Starts recording the canvas for a max duration specified in parameters.
  68508. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68509. * If null no automatic download will start and you can rely on the promise to get the data back.
  68510. * @param maxDuration Defines the maximum recording time in seconds.
  68511. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68512. * @return A promise callback at the end of the recording with the video data in Blob.
  68513. */
  68514. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68515. /**
  68516. * Releases internal resources used during the recording.
  68517. */
  68518. dispose(): void;
  68519. private _handleDataAvailable;
  68520. private _handleError;
  68521. private _handleStop;
  68522. }
  68523. }
  68524. declare module "babylonjs/Misc/screenshotTools" {
  68525. import { Camera } from "babylonjs/Cameras/camera";
  68526. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  68527. import { Engine } from "babylonjs/Engines/engine";
  68528. /**
  68529. * Class containing a set of static utilities functions for screenshots
  68530. */
  68531. export class ScreenshotTools {
  68532. /**
  68533. * Captures a screenshot of the current rendering
  68534. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68535. * @param engine defines the rendering engine
  68536. * @param camera defines the source camera
  68537. * @param size This parameter can be set to a single number or to an object with the
  68538. * following (optional) properties: precision, width, height. If a single number is passed,
  68539. * it will be used for both width and height. If an object is passed, the screenshot size
  68540. * will be derived from the parameters. The precision property is a multiplier allowing
  68541. * rendering at a higher or lower resolution
  68542. * @param successCallback defines the callback receives a single parameter which contains the
  68543. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68544. * src parameter of an <img> to display it
  68545. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68546. * Check your browser for supported MIME types
  68547. */
  68548. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68549. /**
  68550. * Captures a screenshot of the current rendering
  68551. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68552. * @param engine defines the rendering engine
  68553. * @param camera defines the source camera
  68554. * @param size This parameter can be set to a single number or to an object with the
  68555. * following (optional) properties: precision, width, height. If a single number is passed,
  68556. * it will be used for both width and height. If an object is passed, the screenshot size
  68557. * will be derived from the parameters. The precision property is a multiplier allowing
  68558. * rendering at a higher or lower resolution
  68559. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68560. * Check your browser for supported MIME types
  68561. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68562. * to the src parameter of an <img> to display it
  68563. */
  68564. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68565. /**
  68566. * Generates an image screenshot from the specified camera.
  68567. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68568. * @param engine The engine to use for rendering
  68569. * @param camera The camera to use for rendering
  68570. * @param size This parameter can be set to a single number or to an object with the
  68571. * following (optional) properties: precision, width, height. If a single number is passed,
  68572. * it will be used for both width and height. If an object is passed, the screenshot size
  68573. * will be derived from the parameters. The precision property is a multiplier allowing
  68574. * rendering at a higher or lower resolution
  68575. * @param successCallback The callback receives a single parameter which contains the
  68576. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68577. * src parameter of an <img> to display it
  68578. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68579. * Check your browser for supported MIME types
  68580. * @param samples Texture samples (default: 1)
  68581. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68582. * @param fileName A name for for the downloaded file.
  68583. */
  68584. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68585. /**
  68586. * Generates an image screenshot from the specified camera.
  68587. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68588. * @param engine The engine to use for rendering
  68589. * @param camera The camera to use for rendering
  68590. * @param size This parameter can be set to a single number or to an object with the
  68591. * following (optional) properties: precision, width, height. If a single number is passed,
  68592. * it will be used for both width and height. If an object is passed, the screenshot size
  68593. * will be derived from the parameters. The precision property is a multiplier allowing
  68594. * rendering at a higher or lower resolution
  68595. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68596. * Check your browser for supported MIME types
  68597. * @param samples Texture samples (default: 1)
  68598. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68599. * @param fileName A name for for the downloaded file.
  68600. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68601. * to the src parameter of an <img> to display it
  68602. */
  68603. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68604. /**
  68605. * Gets height and width for screenshot size
  68606. * @private
  68607. */
  68608. private static _getScreenshotSize;
  68609. }
  68610. }
  68611. declare module "babylonjs/Misc/dataReader" {
  68612. /**
  68613. * Interface for a data buffer
  68614. */
  68615. export interface IDataBuffer {
  68616. /**
  68617. * Reads bytes from the data buffer.
  68618. * @param byteOffset The byte offset to read
  68619. * @param byteLength The byte length to read
  68620. * @returns A promise that resolves when the bytes are read
  68621. */
  68622. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68623. /**
  68624. * The byte length of the buffer.
  68625. */
  68626. readonly byteLength: number;
  68627. }
  68628. /**
  68629. * Utility class for reading from a data buffer
  68630. */
  68631. export class DataReader {
  68632. /**
  68633. * The data buffer associated with this data reader.
  68634. */
  68635. readonly buffer: IDataBuffer;
  68636. /**
  68637. * The current byte offset from the beginning of the data buffer.
  68638. */
  68639. byteOffset: number;
  68640. private _dataView;
  68641. private _dataByteOffset;
  68642. /**
  68643. * Constructor
  68644. * @param buffer The buffer to read
  68645. */
  68646. constructor(buffer: IDataBuffer);
  68647. /**
  68648. * Loads the given byte length.
  68649. * @param byteLength The byte length to load
  68650. * @returns A promise that resolves when the load is complete
  68651. */
  68652. loadAsync(byteLength: number): Promise<void>;
  68653. /**
  68654. * Read a unsigned 32-bit integer from the currently loaded data range.
  68655. * @returns The 32-bit integer read
  68656. */
  68657. readUint32(): number;
  68658. /**
  68659. * Read a byte array from the currently loaded data range.
  68660. * @param byteLength The byte length to read
  68661. * @returns The byte array read
  68662. */
  68663. readUint8Array(byteLength: number): Uint8Array;
  68664. /**
  68665. * Read a string from the currently loaded data range.
  68666. * @param byteLength The byte length to read
  68667. * @returns The string read
  68668. */
  68669. readString(byteLength: number): string;
  68670. /**
  68671. * Skips the given byte length the currently loaded data range.
  68672. * @param byteLength The byte length to skip
  68673. */
  68674. skipBytes(byteLength: number): void;
  68675. }
  68676. }
  68677. declare module "babylonjs/Misc/index" {
  68678. export * from "babylonjs/Misc/andOrNotEvaluator";
  68679. export * from "babylonjs/Misc/assetsManager";
  68680. export * from "babylonjs/Misc/basis";
  68681. export * from "babylonjs/Misc/dds";
  68682. export * from "babylonjs/Misc/decorators";
  68683. export * from "babylonjs/Misc/deferred";
  68684. export * from "babylonjs/Misc/environmentTextureTools";
  68685. export * from "babylonjs/Misc/meshExploder";
  68686. export * from "babylonjs/Misc/filesInput";
  68687. export * from "babylonjs/Misc/HighDynamicRange/index";
  68688. export * from "babylonjs/Misc/khronosTextureContainer";
  68689. export * from "babylonjs/Misc/observable";
  68690. export * from "babylonjs/Misc/performanceMonitor";
  68691. export * from "babylonjs/Misc/promise";
  68692. export * from "babylonjs/Misc/sceneOptimizer";
  68693. export * from "babylonjs/Misc/sceneSerializer";
  68694. export * from "babylonjs/Misc/smartArray";
  68695. export * from "babylonjs/Misc/stringDictionary";
  68696. export * from "babylonjs/Misc/tags";
  68697. export * from "babylonjs/Misc/textureTools";
  68698. export * from "babylonjs/Misc/tga";
  68699. export * from "babylonjs/Misc/tools";
  68700. export * from "babylonjs/Misc/videoRecorder";
  68701. export * from "babylonjs/Misc/virtualJoystick";
  68702. export * from "babylonjs/Misc/workerPool";
  68703. export * from "babylonjs/Misc/logger";
  68704. export * from "babylonjs/Misc/typeStore";
  68705. export * from "babylonjs/Misc/filesInputStore";
  68706. export * from "babylonjs/Misc/deepCopier";
  68707. export * from "babylonjs/Misc/pivotTools";
  68708. export * from "babylonjs/Misc/precisionDate";
  68709. export * from "babylonjs/Misc/screenshotTools";
  68710. export * from "babylonjs/Misc/typeStore";
  68711. export * from "babylonjs/Misc/webRequest";
  68712. export * from "babylonjs/Misc/iInspectable";
  68713. export * from "babylonjs/Misc/brdfTextureTools";
  68714. export * from "babylonjs/Misc/rgbdTextureTools";
  68715. export * from "babylonjs/Misc/gradients";
  68716. export * from "babylonjs/Misc/perfCounter";
  68717. export * from "babylonjs/Misc/fileRequest";
  68718. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68719. export * from "babylonjs/Misc/retryStrategy";
  68720. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68721. export * from "babylonjs/Misc/canvasGenerator";
  68722. export * from "babylonjs/Misc/fileTools";
  68723. export * from "babylonjs/Misc/stringTools";
  68724. export * from "babylonjs/Misc/dataReader";
  68725. }
  68726. declare module "babylonjs/index" {
  68727. export * from "babylonjs/abstractScene";
  68728. export * from "babylonjs/Actions/index";
  68729. export * from "babylonjs/Animations/index";
  68730. export * from "babylonjs/assetContainer";
  68731. export * from "babylonjs/Audio/index";
  68732. export * from "babylonjs/Behaviors/index";
  68733. export * from "babylonjs/Bones/index";
  68734. export * from "babylonjs/Cameras/index";
  68735. export * from "babylonjs/Collisions/index";
  68736. export * from "babylonjs/Culling/index";
  68737. export * from "babylonjs/Debug/index";
  68738. export * from "babylonjs/Engines/index";
  68739. export * from "babylonjs/Events/index";
  68740. export * from "babylonjs/Gamepads/index";
  68741. export * from "babylonjs/Gizmos/index";
  68742. export * from "babylonjs/Helpers/index";
  68743. export * from "babylonjs/Instrumentation/index";
  68744. export * from "babylonjs/Layers/index";
  68745. export * from "babylonjs/LensFlares/index";
  68746. export * from "babylonjs/Lights/index";
  68747. export * from "babylonjs/Loading/index";
  68748. export * from "babylonjs/Materials/index";
  68749. export * from "babylonjs/Maths/index";
  68750. export * from "babylonjs/Meshes/index";
  68751. export * from "babylonjs/Morph/index";
  68752. export * from "babylonjs/Navigation/index";
  68753. export * from "babylonjs/node";
  68754. export * from "babylonjs/Offline/index";
  68755. export * from "babylonjs/Particles/index";
  68756. export * from "babylonjs/Physics/index";
  68757. export * from "babylonjs/PostProcesses/index";
  68758. export * from "babylonjs/Probes/index";
  68759. export * from "babylonjs/Rendering/index";
  68760. export * from "babylonjs/scene";
  68761. export * from "babylonjs/sceneComponent";
  68762. export * from "babylonjs/Sprites/index";
  68763. export * from "babylonjs/States/index";
  68764. export * from "babylonjs/Misc/index";
  68765. export * from "babylonjs/types";
  68766. }
  68767. declare module "babylonjs/Animations/pathCursor" {
  68768. import { Vector3 } from "babylonjs/Maths/math.vector";
  68769. import { Path2 } from "babylonjs/Maths/math.path";
  68770. /**
  68771. * A cursor which tracks a point on a path
  68772. */
  68773. export class PathCursor {
  68774. private path;
  68775. /**
  68776. * Stores path cursor callbacks for when an onchange event is triggered
  68777. */
  68778. private _onchange;
  68779. /**
  68780. * The value of the path cursor
  68781. */
  68782. value: number;
  68783. /**
  68784. * The animation array of the path cursor
  68785. */
  68786. animations: Animation[];
  68787. /**
  68788. * Initializes the path cursor
  68789. * @param path The path to track
  68790. */
  68791. constructor(path: Path2);
  68792. /**
  68793. * Gets the cursor point on the path
  68794. * @returns A point on the path cursor at the cursor location
  68795. */
  68796. getPoint(): Vector3;
  68797. /**
  68798. * Moves the cursor ahead by the step amount
  68799. * @param step The amount to move the cursor forward
  68800. * @returns This path cursor
  68801. */
  68802. moveAhead(step?: number): PathCursor;
  68803. /**
  68804. * Moves the cursor behind by the step amount
  68805. * @param step The amount to move the cursor back
  68806. * @returns This path cursor
  68807. */
  68808. moveBack(step?: number): PathCursor;
  68809. /**
  68810. * Moves the cursor by the step amount
  68811. * If the step amount is greater than one, an exception is thrown
  68812. * @param step The amount to move the cursor
  68813. * @returns This path cursor
  68814. */
  68815. move(step: number): PathCursor;
  68816. /**
  68817. * Ensures that the value is limited between zero and one
  68818. * @returns This path cursor
  68819. */
  68820. private ensureLimits;
  68821. /**
  68822. * Runs onchange callbacks on change (used by the animation engine)
  68823. * @returns This path cursor
  68824. */
  68825. private raiseOnChange;
  68826. /**
  68827. * Executes a function on change
  68828. * @param f A path cursor onchange callback
  68829. * @returns This path cursor
  68830. */
  68831. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68832. }
  68833. }
  68834. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68835. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68836. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68837. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68838. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68839. }
  68840. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68841. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68842. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68843. }
  68844. declare module "babylonjs/Engines/Processors/index" {
  68845. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68846. export * from "babylonjs/Engines/Processors/Expressions/index";
  68847. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68848. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68849. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68850. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68851. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68852. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68853. }
  68854. declare module "babylonjs/Legacy/legacy" {
  68855. import * as Babylon from "babylonjs/index";
  68856. export * from "babylonjs/index";
  68857. }
  68858. declare module "babylonjs/Shaders/blur.fragment" {
  68859. /** @hidden */
  68860. export var blurPixelShader: {
  68861. name: string;
  68862. shader: string;
  68863. };
  68864. }
  68865. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68866. /** @hidden */
  68867. export var pointCloudVertexDeclaration: {
  68868. name: string;
  68869. shader: string;
  68870. };
  68871. }
  68872. declare module "babylonjs" {
  68873. export * from "babylonjs/Legacy/legacy";
  68874. }
  68875. declare module BABYLON {
  68876. /** Alias type for value that can be null */
  68877. export type Nullable<T> = T | null;
  68878. /**
  68879. * Alias type for number that are floats
  68880. * @ignorenaming
  68881. */
  68882. export type float = number;
  68883. /**
  68884. * Alias type for number that are doubles.
  68885. * @ignorenaming
  68886. */
  68887. export type double = number;
  68888. /**
  68889. * Alias type for number that are integer
  68890. * @ignorenaming
  68891. */
  68892. export type int = number;
  68893. /** Alias type for number array or Float32Array */
  68894. export type FloatArray = number[] | Float32Array;
  68895. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68896. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68897. /**
  68898. * Alias for types that can be used by a Buffer or VertexBuffer.
  68899. */
  68900. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68901. /**
  68902. * Alias type for primitive types
  68903. * @ignorenaming
  68904. */
  68905. type Primitive = undefined | null | boolean | string | number | Function;
  68906. /**
  68907. * Type modifier to make all the properties of an object Readonly
  68908. */
  68909. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68910. /**
  68911. * Type modifier to make all the properties of an object Readonly recursively
  68912. */
  68913. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68914. /**
  68915. * Type modifier to make object properties readonly.
  68916. */
  68917. export type DeepImmutableObject<T> = {
  68918. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68919. };
  68920. /** @hidden */
  68921. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68922. }
  68923. }
  68924. declare module BABYLON {
  68925. /**
  68926. * A class serves as a medium between the observable and its observers
  68927. */
  68928. export class EventState {
  68929. /**
  68930. * Create a new EventState
  68931. * @param mask defines the mask associated with this state
  68932. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68933. * @param target defines the original target of the state
  68934. * @param currentTarget defines the current target of the state
  68935. */
  68936. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68937. /**
  68938. * Initialize the current event state
  68939. * @param mask defines the mask associated with this state
  68940. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68941. * @param target defines the original target of the state
  68942. * @param currentTarget defines the current target of the state
  68943. * @returns the current event state
  68944. */
  68945. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68946. /**
  68947. * An Observer can set this property to true to prevent subsequent observers of being notified
  68948. */
  68949. skipNextObservers: boolean;
  68950. /**
  68951. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68952. */
  68953. mask: number;
  68954. /**
  68955. * The object that originally notified the event
  68956. */
  68957. target?: any;
  68958. /**
  68959. * The current object in the bubbling phase
  68960. */
  68961. currentTarget?: any;
  68962. /**
  68963. * This will be populated with the return value of the last function that was executed.
  68964. * If it is the first function in the callback chain it will be the event data.
  68965. */
  68966. lastReturnValue?: any;
  68967. }
  68968. /**
  68969. * Represent an Observer registered to a given Observable object.
  68970. */
  68971. export class Observer<T> {
  68972. /**
  68973. * Defines the callback to call when the observer is notified
  68974. */
  68975. callback: (eventData: T, eventState: EventState) => void;
  68976. /**
  68977. * Defines the mask of the observer (used to filter notifications)
  68978. */
  68979. mask: number;
  68980. /**
  68981. * Defines the current scope used to restore the JS context
  68982. */
  68983. scope: any;
  68984. /** @hidden */
  68985. _willBeUnregistered: boolean;
  68986. /**
  68987. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68988. */
  68989. unregisterOnNextCall: boolean;
  68990. /**
  68991. * Creates a new observer
  68992. * @param callback defines the callback to call when the observer is notified
  68993. * @param mask defines the mask of the observer (used to filter notifications)
  68994. * @param scope defines the current scope used to restore the JS context
  68995. */
  68996. constructor(
  68997. /**
  68998. * Defines the callback to call when the observer is notified
  68999. */
  69000. callback: (eventData: T, eventState: EventState) => void,
  69001. /**
  69002. * Defines the mask of the observer (used to filter notifications)
  69003. */
  69004. mask: number,
  69005. /**
  69006. * Defines the current scope used to restore the JS context
  69007. */
  69008. scope?: any);
  69009. }
  69010. /**
  69011. * Represent a list of observers registered to multiple Observables object.
  69012. */
  69013. export class MultiObserver<T> {
  69014. private _observers;
  69015. private _observables;
  69016. /**
  69017. * Release associated resources
  69018. */
  69019. dispose(): void;
  69020. /**
  69021. * Raise a callback when one of the observable will notify
  69022. * @param observables defines a list of observables to watch
  69023. * @param callback defines the callback to call on notification
  69024. * @param mask defines the mask used to filter notifications
  69025. * @param scope defines the current scope used to restore the JS context
  69026. * @returns the new MultiObserver
  69027. */
  69028. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  69029. }
  69030. /**
  69031. * The Observable class is a simple implementation of the Observable pattern.
  69032. *
  69033. * 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.
  69034. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  69035. * 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).
  69036. * 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.
  69037. */
  69038. export class Observable<T> {
  69039. private _observers;
  69040. private _eventState;
  69041. private _onObserverAdded;
  69042. /**
  69043. * Gets the list of observers
  69044. */
  69045. readonly observers: Array<Observer<T>>;
  69046. /**
  69047. * Creates a new observable
  69048. * @param onObserverAdded defines a callback to call when a new observer is added
  69049. */
  69050. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  69051. /**
  69052. * Create a new Observer with the specified callback
  69053. * @param callback the callback that will be executed for that Observer
  69054. * @param mask the mask used to filter observers
  69055. * @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.
  69056. * @param scope optional scope for the callback to be called from
  69057. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  69058. * @returns the new observer created for the callback
  69059. */
  69060. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  69061. /**
  69062. * Create a new Observer with the specified callback and unregisters after the next notification
  69063. * @param callback the callback that will be executed for that Observer
  69064. * @returns the new observer created for the callback
  69065. */
  69066. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  69067. /**
  69068. * Remove an Observer from the Observable object
  69069. * @param observer the instance of the Observer to remove
  69070. * @returns false if it doesn't belong to this Observable
  69071. */
  69072. remove(observer: Nullable<Observer<T>>): boolean;
  69073. /**
  69074. * Remove a callback from the Observable object
  69075. * @param callback the callback to remove
  69076. * @param scope optional scope. If used only the callbacks with this scope will be removed
  69077. * @returns false if it doesn't belong to this Observable
  69078. */
  69079. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  69080. private _deferUnregister;
  69081. private _remove;
  69082. /**
  69083. * Moves the observable to the top of the observer list making it get called first when notified
  69084. * @param observer the observer to move
  69085. */
  69086. makeObserverTopPriority(observer: Observer<T>): void;
  69087. /**
  69088. * Moves the observable to the bottom of the observer list making it get called last when notified
  69089. * @param observer the observer to move
  69090. */
  69091. makeObserverBottomPriority(observer: Observer<T>): void;
  69092. /**
  69093. * Notify all Observers by calling their respective callback with the given data
  69094. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  69095. * @param eventData defines the data to send to all observers
  69096. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  69097. * @param target defines the original target of the state
  69098. * @param currentTarget defines the current target of the state
  69099. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  69100. */
  69101. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  69102. /**
  69103. * Calling this will execute each callback, expecting it to be a promise or return a value.
  69104. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  69105. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  69106. * and it is crucial that all callbacks will be executed.
  69107. * The order of the callbacks is kept, callbacks are not executed parallel.
  69108. *
  69109. * @param eventData The data to be sent to each callback
  69110. * @param mask is used to filter observers defaults to -1
  69111. * @param target defines the callback target (see EventState)
  69112. * @param currentTarget defines he current object in the bubbling phase
  69113. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  69114. */
  69115. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  69116. /**
  69117. * Notify a specific observer
  69118. * @param observer defines the observer to notify
  69119. * @param eventData defines the data to be sent to each callback
  69120. * @param mask is used to filter observers defaults to -1
  69121. */
  69122. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  69123. /**
  69124. * Gets a boolean indicating if the observable has at least one observer
  69125. * @returns true is the Observable has at least one Observer registered
  69126. */
  69127. hasObservers(): boolean;
  69128. /**
  69129. * Clear the list of observers
  69130. */
  69131. clear(): void;
  69132. /**
  69133. * Clone the current observable
  69134. * @returns a new observable
  69135. */
  69136. clone(): Observable<T>;
  69137. /**
  69138. * Does this observable handles observer registered with a given mask
  69139. * @param mask defines the mask to be tested
  69140. * @return whether or not one observer registered with the given mask is handeled
  69141. **/
  69142. hasSpecificMask(mask?: number): boolean;
  69143. }
  69144. }
  69145. declare module BABYLON {
  69146. /**
  69147. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  69148. * Babylon.js
  69149. */
  69150. export class DomManagement {
  69151. /**
  69152. * Checks if the window object exists
  69153. * @returns true if the window object exists
  69154. */
  69155. static IsWindowObjectExist(): boolean;
  69156. /**
  69157. * Checks if the navigator object exists
  69158. * @returns true if the navigator object exists
  69159. */
  69160. static IsNavigatorAvailable(): boolean;
  69161. /**
  69162. * Extracts text content from a DOM element hierarchy
  69163. * @param element defines the root element
  69164. * @returns a string
  69165. */
  69166. static GetDOMTextContent(element: HTMLElement): string;
  69167. }
  69168. }
  69169. declare module BABYLON {
  69170. /**
  69171. * Logger used througouht the application to allow configuration of
  69172. * the log level required for the messages.
  69173. */
  69174. export class Logger {
  69175. /**
  69176. * No log
  69177. */
  69178. static readonly NoneLogLevel: number;
  69179. /**
  69180. * Only message logs
  69181. */
  69182. static readonly MessageLogLevel: number;
  69183. /**
  69184. * Only warning logs
  69185. */
  69186. static readonly WarningLogLevel: number;
  69187. /**
  69188. * Only error logs
  69189. */
  69190. static readonly ErrorLogLevel: number;
  69191. /**
  69192. * All logs
  69193. */
  69194. static readonly AllLogLevel: number;
  69195. private static _LogCache;
  69196. /**
  69197. * Gets a value indicating the number of loading errors
  69198. * @ignorenaming
  69199. */
  69200. static errorsCount: number;
  69201. /**
  69202. * Callback called when a new log is added
  69203. */
  69204. static OnNewCacheEntry: (entry: string) => void;
  69205. private static _AddLogEntry;
  69206. private static _FormatMessage;
  69207. private static _LogDisabled;
  69208. private static _LogEnabled;
  69209. private static _WarnDisabled;
  69210. private static _WarnEnabled;
  69211. private static _ErrorDisabled;
  69212. private static _ErrorEnabled;
  69213. /**
  69214. * Log a message to the console
  69215. */
  69216. static Log: (message: string) => void;
  69217. /**
  69218. * Write a warning message to the console
  69219. */
  69220. static Warn: (message: string) => void;
  69221. /**
  69222. * Write an error message to the console
  69223. */
  69224. static Error: (message: string) => void;
  69225. /**
  69226. * Gets current log cache (list of logs)
  69227. */
  69228. static readonly LogCache: string;
  69229. /**
  69230. * Clears the log cache
  69231. */
  69232. static ClearLogCache(): void;
  69233. /**
  69234. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  69235. */
  69236. static LogLevels: number;
  69237. }
  69238. }
  69239. declare module BABYLON {
  69240. /** @hidden */
  69241. export class _TypeStore {
  69242. /** @hidden */
  69243. static RegisteredTypes: {
  69244. [key: string]: Object;
  69245. };
  69246. /** @hidden */
  69247. static GetClass(fqdn: string): any;
  69248. }
  69249. }
  69250. declare module BABYLON {
  69251. /**
  69252. * Helper to manipulate strings
  69253. */
  69254. export class StringTools {
  69255. /**
  69256. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69257. * @param str Source string
  69258. * @param suffix Suffix to search for in the source string
  69259. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69260. */
  69261. static EndsWith(str: string, suffix: string): boolean;
  69262. /**
  69263. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69264. * @param str Source string
  69265. * @param suffix Suffix to search for in the source string
  69266. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69267. */
  69268. static StartsWith(str: string, suffix: string): boolean;
  69269. /**
  69270. * Decodes a buffer into a string
  69271. * @param buffer The buffer to decode
  69272. * @returns The decoded string
  69273. */
  69274. static Decode(buffer: Uint8Array | Uint16Array): string;
  69275. /**
  69276. * Encode a buffer to a base64 string
  69277. * @param buffer defines the buffer to encode
  69278. * @returns the encoded string
  69279. */
  69280. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  69281. }
  69282. }
  69283. declare module BABYLON {
  69284. /**
  69285. * Class containing a set of static utilities functions for deep copy.
  69286. */
  69287. export class DeepCopier {
  69288. /**
  69289. * Tries to copy an object by duplicating every property
  69290. * @param source defines the source object
  69291. * @param destination defines the target object
  69292. * @param doNotCopyList defines a list of properties to avoid
  69293. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  69294. */
  69295. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  69296. }
  69297. }
  69298. declare module BABYLON {
  69299. /**
  69300. * Class containing a set of static utilities functions for precision date
  69301. */
  69302. export class PrecisionDate {
  69303. /**
  69304. * Gets either window.performance.now() if supported or Date.now() else
  69305. */
  69306. static readonly Now: number;
  69307. }
  69308. }
  69309. declare module BABYLON {
  69310. /** @hidden */
  69311. export class _DevTools {
  69312. static WarnImport(name: string): string;
  69313. }
  69314. }
  69315. declare module BABYLON {
  69316. /**
  69317. * Interface used to define the mechanism to get data from the network
  69318. */
  69319. export interface IWebRequest {
  69320. /**
  69321. * Returns client's response url
  69322. */
  69323. responseURL: string;
  69324. /**
  69325. * Returns client's status
  69326. */
  69327. status: number;
  69328. /**
  69329. * Returns client's status as a text
  69330. */
  69331. statusText: string;
  69332. }
  69333. }
  69334. declare module BABYLON {
  69335. /**
  69336. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  69337. */
  69338. export class WebRequest implements IWebRequest {
  69339. private _xhr;
  69340. /**
  69341. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  69342. * i.e. when loading files, where the server/service expects an Authorization header
  69343. */
  69344. static CustomRequestHeaders: {
  69345. [key: string]: string;
  69346. };
  69347. /**
  69348. * Add callback functions in this array to update all the requests before they get sent to the network
  69349. */
  69350. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  69351. private _injectCustomRequestHeaders;
  69352. /**
  69353. * Gets or sets a function to be called when loading progress changes
  69354. */
  69355. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  69356. /**
  69357. * Returns client's state
  69358. */
  69359. readonly readyState: number;
  69360. /**
  69361. * Returns client's status
  69362. */
  69363. readonly status: number;
  69364. /**
  69365. * Returns client's status as a text
  69366. */
  69367. readonly statusText: string;
  69368. /**
  69369. * Returns client's response
  69370. */
  69371. readonly response: any;
  69372. /**
  69373. * Returns client's response url
  69374. */
  69375. readonly responseURL: string;
  69376. /**
  69377. * Returns client's response as text
  69378. */
  69379. readonly responseText: string;
  69380. /**
  69381. * Gets or sets the expected response type
  69382. */
  69383. responseType: XMLHttpRequestResponseType;
  69384. /** @hidden */
  69385. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  69386. /** @hidden */
  69387. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  69388. /**
  69389. * Cancels any network activity
  69390. */
  69391. abort(): void;
  69392. /**
  69393. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  69394. * @param body defines an optional request body
  69395. */
  69396. send(body?: Document | BodyInit | null): void;
  69397. /**
  69398. * Sets the request method, request URL
  69399. * @param method defines the method to use (GET, POST, etc..)
  69400. * @param url defines the url to connect with
  69401. */
  69402. open(method: string, url: string): void;
  69403. /**
  69404. * Sets the value of a request header.
  69405. * @param name The name of the header whose value is to be set
  69406. * @param value The value to set as the body of the header
  69407. */
  69408. setRequestHeader(name: string, value: string): void;
  69409. /**
  69410. * Get the string containing the text of a particular header's value.
  69411. * @param name The name of the header
  69412. * @returns The string containing the text of the given header name
  69413. */
  69414. getResponseHeader(name: string): Nullable<string>;
  69415. }
  69416. }
  69417. declare module BABYLON {
  69418. /**
  69419. * File request interface
  69420. */
  69421. export interface IFileRequest {
  69422. /**
  69423. * Raised when the request is complete (success or error).
  69424. */
  69425. onCompleteObservable: Observable<IFileRequest>;
  69426. /**
  69427. * Aborts the request for a file.
  69428. */
  69429. abort: () => void;
  69430. }
  69431. }
  69432. declare module BABYLON {
  69433. /**
  69434. * Define options used to create a render target texture
  69435. */
  69436. export class RenderTargetCreationOptions {
  69437. /**
  69438. * Specifies is mipmaps must be generated
  69439. */
  69440. generateMipMaps?: boolean;
  69441. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69442. generateDepthBuffer?: boolean;
  69443. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69444. generateStencilBuffer?: boolean;
  69445. /** Defines texture type (int by default) */
  69446. type?: number;
  69447. /** Defines sampling mode (trilinear by default) */
  69448. samplingMode?: number;
  69449. /** Defines format (RGBA by default) */
  69450. format?: number;
  69451. }
  69452. }
  69453. declare module BABYLON {
  69454. /**
  69455. * @hidden
  69456. **/
  69457. export class _TimeToken {
  69458. _startTimeQuery: Nullable<WebGLQuery>;
  69459. _endTimeQuery: Nullable<WebGLQuery>;
  69460. _timeElapsedQuery: Nullable<WebGLQuery>;
  69461. _timeElapsedQueryEnded: boolean;
  69462. }
  69463. }
  69464. declare module BABYLON {
  69465. /** Defines the cross module used constants to avoid circular dependncies */
  69466. export class Constants {
  69467. /** Defines that alpha blending is disabled */
  69468. static readonly ALPHA_DISABLE: number;
  69469. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69470. static readonly ALPHA_ADD: number;
  69471. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69472. static readonly ALPHA_COMBINE: number;
  69473. /** Defines that alpha blending to DEST - SRC * DEST */
  69474. static readonly ALPHA_SUBTRACT: number;
  69475. /** Defines that alpha blending to SRC * DEST */
  69476. static readonly ALPHA_MULTIPLY: number;
  69477. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69478. static readonly ALPHA_MAXIMIZED: number;
  69479. /** Defines that alpha blending to SRC + DEST */
  69480. static readonly ALPHA_ONEONE: number;
  69481. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69482. static readonly ALPHA_PREMULTIPLIED: number;
  69483. /**
  69484. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69485. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69486. */
  69487. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69488. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69489. static readonly ALPHA_INTERPOLATE: number;
  69490. /**
  69491. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69492. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69493. */
  69494. static readonly ALPHA_SCREENMODE: number;
  69495. /**
  69496. * Defines that alpha blending to SRC + DST
  69497. * Alpha will be set to SRC ALPHA + DST ALPHA
  69498. */
  69499. static readonly ALPHA_ONEONE_ONEONE: number;
  69500. /**
  69501. * Defines that alpha blending to SRC * DST ALPHA + DST
  69502. * Alpha will be set to 0
  69503. */
  69504. static readonly ALPHA_ALPHATOCOLOR: number;
  69505. /**
  69506. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69507. */
  69508. static readonly ALPHA_REVERSEONEMINUS: number;
  69509. /**
  69510. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69511. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69512. */
  69513. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69514. /**
  69515. * Defines that alpha blending to SRC + DST
  69516. * Alpha will be set to SRC ALPHA
  69517. */
  69518. static readonly ALPHA_ONEONE_ONEZERO: number;
  69519. /** Defines that alpha blending equation a SUM */
  69520. static readonly ALPHA_EQUATION_ADD: number;
  69521. /** Defines that alpha blending equation a SUBSTRACTION */
  69522. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69523. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69524. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69525. /** Defines that alpha blending equation a MAX operation */
  69526. static readonly ALPHA_EQUATION_MAX: number;
  69527. /** Defines that alpha blending equation a MIN operation */
  69528. static readonly ALPHA_EQUATION_MIN: number;
  69529. /**
  69530. * Defines that alpha blending equation a DARKEN operation:
  69531. * It takes the min of the src and sums the alpha channels.
  69532. */
  69533. static readonly ALPHA_EQUATION_DARKEN: number;
  69534. /** Defines that the ressource is not delayed*/
  69535. static readonly DELAYLOADSTATE_NONE: number;
  69536. /** Defines that the ressource was successfully delay loaded */
  69537. static readonly DELAYLOADSTATE_LOADED: number;
  69538. /** Defines that the ressource is currently delay loading */
  69539. static readonly DELAYLOADSTATE_LOADING: number;
  69540. /** Defines that the ressource is delayed and has not started loading */
  69541. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69542. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69543. static readonly NEVER: number;
  69544. /** 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 */
  69545. static readonly ALWAYS: number;
  69546. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69547. static readonly LESS: number;
  69548. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69549. static readonly EQUAL: number;
  69550. /** 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 */
  69551. static readonly LEQUAL: number;
  69552. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69553. static readonly GREATER: number;
  69554. /** 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 */
  69555. static readonly GEQUAL: number;
  69556. /** 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 */
  69557. static readonly NOTEQUAL: number;
  69558. /** Passed to stencilOperation to specify that stencil value must be kept */
  69559. static readonly KEEP: number;
  69560. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69561. static readonly REPLACE: number;
  69562. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69563. static readonly INCR: number;
  69564. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69565. static readonly DECR: number;
  69566. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69567. static readonly INVERT: number;
  69568. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69569. static readonly INCR_WRAP: number;
  69570. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69571. static readonly DECR_WRAP: number;
  69572. /** Texture is not repeating outside of 0..1 UVs */
  69573. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69574. /** Texture is repeating outside of 0..1 UVs */
  69575. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69576. /** Texture is repeating and mirrored */
  69577. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69578. /** ALPHA */
  69579. static readonly TEXTUREFORMAT_ALPHA: number;
  69580. /** LUMINANCE */
  69581. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69582. /** LUMINANCE_ALPHA */
  69583. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69584. /** RGB */
  69585. static readonly TEXTUREFORMAT_RGB: number;
  69586. /** RGBA */
  69587. static readonly TEXTUREFORMAT_RGBA: number;
  69588. /** RED */
  69589. static readonly TEXTUREFORMAT_RED: number;
  69590. /** RED (2nd reference) */
  69591. static readonly TEXTUREFORMAT_R: number;
  69592. /** RG */
  69593. static readonly TEXTUREFORMAT_RG: number;
  69594. /** RED_INTEGER */
  69595. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69596. /** RED_INTEGER (2nd reference) */
  69597. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69598. /** RG_INTEGER */
  69599. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69600. /** RGB_INTEGER */
  69601. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69602. /** RGBA_INTEGER */
  69603. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69604. /** UNSIGNED_BYTE */
  69605. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69606. /** UNSIGNED_BYTE (2nd reference) */
  69607. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69608. /** FLOAT */
  69609. static readonly TEXTURETYPE_FLOAT: number;
  69610. /** HALF_FLOAT */
  69611. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69612. /** BYTE */
  69613. static readonly TEXTURETYPE_BYTE: number;
  69614. /** SHORT */
  69615. static readonly TEXTURETYPE_SHORT: number;
  69616. /** UNSIGNED_SHORT */
  69617. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69618. /** INT */
  69619. static readonly TEXTURETYPE_INT: number;
  69620. /** UNSIGNED_INT */
  69621. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69622. /** UNSIGNED_SHORT_4_4_4_4 */
  69623. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69624. /** UNSIGNED_SHORT_5_5_5_1 */
  69625. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69626. /** UNSIGNED_SHORT_5_6_5 */
  69627. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69628. /** UNSIGNED_INT_2_10_10_10_REV */
  69629. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69630. /** UNSIGNED_INT_24_8 */
  69631. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69632. /** UNSIGNED_INT_10F_11F_11F_REV */
  69633. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69634. /** UNSIGNED_INT_5_9_9_9_REV */
  69635. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69636. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69637. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69638. /** nearest is mag = nearest and min = nearest and mip = nearest */
  69639. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69640. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69641. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69642. /** Trilinear is mag = linear and min = linear and mip = linear */
  69643. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69644. /** nearest is mag = nearest and min = nearest and mip = linear */
  69645. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69646. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69647. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69648. /** Trilinear is mag = linear and min = linear and mip = linear */
  69649. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69650. /** mag = nearest and min = nearest and mip = nearest */
  69651. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69652. /** mag = nearest and min = linear and mip = nearest */
  69653. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69654. /** mag = nearest and min = linear and mip = linear */
  69655. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69656. /** mag = nearest and min = linear and mip = none */
  69657. static readonly TEXTURE_NEAREST_LINEAR: number;
  69658. /** mag = nearest and min = nearest and mip = none */
  69659. static readonly TEXTURE_NEAREST_NEAREST: number;
  69660. /** mag = linear and min = nearest and mip = nearest */
  69661. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69662. /** mag = linear and min = nearest and mip = linear */
  69663. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69664. /** mag = linear and min = linear and mip = none */
  69665. static readonly TEXTURE_LINEAR_LINEAR: number;
  69666. /** mag = linear and min = nearest and mip = none */
  69667. static readonly TEXTURE_LINEAR_NEAREST: number;
  69668. /** Explicit coordinates mode */
  69669. static readonly TEXTURE_EXPLICIT_MODE: number;
  69670. /** Spherical coordinates mode */
  69671. static readonly TEXTURE_SPHERICAL_MODE: number;
  69672. /** Planar coordinates mode */
  69673. static readonly TEXTURE_PLANAR_MODE: number;
  69674. /** Cubic coordinates mode */
  69675. static readonly TEXTURE_CUBIC_MODE: number;
  69676. /** Projection coordinates mode */
  69677. static readonly TEXTURE_PROJECTION_MODE: number;
  69678. /** Skybox coordinates mode */
  69679. static readonly TEXTURE_SKYBOX_MODE: number;
  69680. /** Inverse Cubic coordinates mode */
  69681. static readonly TEXTURE_INVCUBIC_MODE: number;
  69682. /** Equirectangular coordinates mode */
  69683. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69684. /** Equirectangular Fixed coordinates mode */
  69685. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69686. /** Equirectangular Fixed Mirrored coordinates mode */
  69687. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69688. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69689. static readonly SCALEMODE_FLOOR: number;
  69690. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69691. static readonly SCALEMODE_NEAREST: number;
  69692. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69693. static readonly SCALEMODE_CEILING: number;
  69694. /**
  69695. * The dirty texture flag value
  69696. */
  69697. static readonly MATERIAL_TextureDirtyFlag: number;
  69698. /**
  69699. * The dirty light flag value
  69700. */
  69701. static readonly MATERIAL_LightDirtyFlag: number;
  69702. /**
  69703. * The dirty fresnel flag value
  69704. */
  69705. static readonly MATERIAL_FresnelDirtyFlag: number;
  69706. /**
  69707. * The dirty attribute flag value
  69708. */
  69709. static readonly MATERIAL_AttributesDirtyFlag: number;
  69710. /**
  69711. * The dirty misc flag value
  69712. */
  69713. static readonly MATERIAL_MiscDirtyFlag: number;
  69714. /**
  69715. * The all dirty flag value
  69716. */
  69717. static readonly MATERIAL_AllDirtyFlag: number;
  69718. /**
  69719. * Returns the triangle fill mode
  69720. */
  69721. static readonly MATERIAL_TriangleFillMode: number;
  69722. /**
  69723. * Returns the wireframe mode
  69724. */
  69725. static readonly MATERIAL_WireFrameFillMode: number;
  69726. /**
  69727. * Returns the point fill mode
  69728. */
  69729. static readonly MATERIAL_PointFillMode: number;
  69730. /**
  69731. * Returns the point list draw mode
  69732. */
  69733. static readonly MATERIAL_PointListDrawMode: number;
  69734. /**
  69735. * Returns the line list draw mode
  69736. */
  69737. static readonly MATERIAL_LineListDrawMode: number;
  69738. /**
  69739. * Returns the line loop draw mode
  69740. */
  69741. static readonly MATERIAL_LineLoopDrawMode: number;
  69742. /**
  69743. * Returns the line strip draw mode
  69744. */
  69745. static readonly MATERIAL_LineStripDrawMode: number;
  69746. /**
  69747. * Returns the triangle strip draw mode
  69748. */
  69749. static readonly MATERIAL_TriangleStripDrawMode: number;
  69750. /**
  69751. * Returns the triangle fan draw mode
  69752. */
  69753. static readonly MATERIAL_TriangleFanDrawMode: number;
  69754. /**
  69755. * Stores the clock-wise side orientation
  69756. */
  69757. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69758. /**
  69759. * Stores the counter clock-wise side orientation
  69760. */
  69761. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69762. /**
  69763. * Nothing
  69764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69765. */
  69766. static readonly ACTION_NothingTrigger: number;
  69767. /**
  69768. * On pick
  69769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69770. */
  69771. static readonly ACTION_OnPickTrigger: number;
  69772. /**
  69773. * On left pick
  69774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69775. */
  69776. static readonly ACTION_OnLeftPickTrigger: number;
  69777. /**
  69778. * On right pick
  69779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69780. */
  69781. static readonly ACTION_OnRightPickTrigger: number;
  69782. /**
  69783. * On center pick
  69784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69785. */
  69786. static readonly ACTION_OnCenterPickTrigger: number;
  69787. /**
  69788. * On pick down
  69789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69790. */
  69791. static readonly ACTION_OnPickDownTrigger: number;
  69792. /**
  69793. * On double pick
  69794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69795. */
  69796. static readonly ACTION_OnDoublePickTrigger: number;
  69797. /**
  69798. * On pick up
  69799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69800. */
  69801. static readonly ACTION_OnPickUpTrigger: number;
  69802. /**
  69803. * On pick out.
  69804. * This trigger will only be raised if you also declared a OnPickDown
  69805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69806. */
  69807. static readonly ACTION_OnPickOutTrigger: number;
  69808. /**
  69809. * On long press
  69810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69811. */
  69812. static readonly ACTION_OnLongPressTrigger: number;
  69813. /**
  69814. * On pointer over
  69815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69816. */
  69817. static readonly ACTION_OnPointerOverTrigger: number;
  69818. /**
  69819. * On pointer out
  69820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69821. */
  69822. static readonly ACTION_OnPointerOutTrigger: number;
  69823. /**
  69824. * On every frame
  69825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69826. */
  69827. static readonly ACTION_OnEveryFrameTrigger: number;
  69828. /**
  69829. * On intersection enter
  69830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69831. */
  69832. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69833. /**
  69834. * On intersection exit
  69835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69836. */
  69837. static readonly ACTION_OnIntersectionExitTrigger: number;
  69838. /**
  69839. * On key down
  69840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69841. */
  69842. static readonly ACTION_OnKeyDownTrigger: number;
  69843. /**
  69844. * On key up
  69845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69846. */
  69847. static readonly ACTION_OnKeyUpTrigger: number;
  69848. /**
  69849. * Billboard mode will only apply to Y axis
  69850. */
  69851. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69852. /**
  69853. * Billboard mode will apply to all axes
  69854. */
  69855. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69856. /**
  69857. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69858. */
  69859. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69860. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69861. * Test order :
  69862. * Is the bounding sphere outside the frustum ?
  69863. * If not, are the bounding box vertices outside the frustum ?
  69864. * It not, then the cullable object is in the frustum.
  69865. */
  69866. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69867. /** Culling strategy : Bounding Sphere Only.
  69868. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69869. * It's also less accurate than the standard because some not visible objects can still be selected.
  69870. * Test : is the bounding sphere outside the frustum ?
  69871. * If not, then the cullable object is in the frustum.
  69872. */
  69873. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69874. /** Culling strategy : Optimistic Inclusion.
  69875. * This in an inclusion test first, then the standard exclusion test.
  69876. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69877. * 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.
  69878. * Anyway, it's as accurate as the standard strategy.
  69879. * Test :
  69880. * Is the cullable object bounding sphere center in the frustum ?
  69881. * If not, apply the default culling strategy.
  69882. */
  69883. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69884. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69885. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69886. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69887. * 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.
  69888. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69889. * Test :
  69890. * Is the cullable object bounding sphere center in the frustum ?
  69891. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69892. */
  69893. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69894. /**
  69895. * No logging while loading
  69896. */
  69897. static readonly SCENELOADER_NO_LOGGING: number;
  69898. /**
  69899. * Minimal logging while loading
  69900. */
  69901. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69902. /**
  69903. * Summary logging while loading
  69904. */
  69905. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69906. /**
  69907. * Detailled logging while loading
  69908. */
  69909. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69910. }
  69911. }
  69912. declare module BABYLON {
  69913. /**
  69914. * This represents the required contract to create a new type of texture loader.
  69915. */
  69916. export interface IInternalTextureLoader {
  69917. /**
  69918. * Defines wether the loader supports cascade loading the different faces.
  69919. */
  69920. supportCascades: boolean;
  69921. /**
  69922. * This returns if the loader support the current file information.
  69923. * @param extension defines the file extension of the file being loaded
  69924. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69925. * @param fallback defines the fallback internal texture if any
  69926. * @param isBase64 defines whether the texture is encoded as a base64
  69927. * @param isBuffer defines whether the texture data are stored as a buffer
  69928. * @returns true if the loader can load the specified file
  69929. */
  69930. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69931. /**
  69932. * Transform the url before loading if required.
  69933. * @param rootUrl the url of the texture
  69934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69935. * @returns the transformed texture
  69936. */
  69937. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69938. /**
  69939. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69940. * @param rootUrl the url of the texture
  69941. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69942. * @returns the fallback texture
  69943. */
  69944. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69945. /**
  69946. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69947. * @param data contains the texture data
  69948. * @param texture defines the BabylonJS internal texture
  69949. * @param createPolynomials will be true if polynomials have been requested
  69950. * @param onLoad defines the callback to trigger once the texture is ready
  69951. * @param onError defines the callback to trigger in case of error
  69952. */
  69953. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69954. /**
  69955. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69956. * @param data contains the texture data
  69957. * @param texture defines the BabylonJS internal texture
  69958. * @param callback defines the method to call once ready to upload
  69959. */
  69960. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69961. }
  69962. }
  69963. declare module BABYLON {
  69964. /**
  69965. * Class used to store and describe the pipeline context associated with an effect
  69966. */
  69967. export interface IPipelineContext {
  69968. /**
  69969. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69970. */
  69971. isAsync: boolean;
  69972. /**
  69973. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69974. */
  69975. isReady: boolean;
  69976. /** @hidden */
  69977. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69978. }
  69979. }
  69980. declare module BABYLON {
  69981. /**
  69982. * Class used to store gfx data (like WebGLBuffer)
  69983. */
  69984. export class DataBuffer {
  69985. /**
  69986. * Gets or sets the number of objects referencing this buffer
  69987. */
  69988. references: number;
  69989. /** Gets or sets the size of the underlying buffer */
  69990. capacity: number;
  69991. /**
  69992. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69993. */
  69994. is32Bits: boolean;
  69995. /**
  69996. * Gets the underlying buffer
  69997. */
  69998. readonly underlyingResource: any;
  69999. }
  70000. }
  70001. declare module BABYLON {
  70002. /** @hidden */
  70003. export interface IShaderProcessor {
  70004. attributeProcessor?: (attribute: string) => string;
  70005. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70006. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70007. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70008. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70009. lineProcessor?: (line: string, isFragment: boolean) => string;
  70010. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70011. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70012. }
  70013. }
  70014. declare module BABYLON {
  70015. /** @hidden */
  70016. export interface ProcessingOptions {
  70017. defines: string[];
  70018. indexParameters: any;
  70019. isFragment: boolean;
  70020. shouldUseHighPrecisionShader: boolean;
  70021. supportsUniformBuffers: boolean;
  70022. shadersRepository: string;
  70023. includesShadersStore: {
  70024. [key: string]: string;
  70025. };
  70026. processor?: IShaderProcessor;
  70027. version: string;
  70028. platformName: string;
  70029. lookForClosingBracketForUniformBuffer?: boolean;
  70030. }
  70031. }
  70032. declare module BABYLON {
  70033. /** @hidden */
  70034. export class ShaderCodeNode {
  70035. line: string;
  70036. children: ShaderCodeNode[];
  70037. additionalDefineKey?: string;
  70038. additionalDefineValue?: string;
  70039. isValid(preprocessors: {
  70040. [key: string]: string;
  70041. }): boolean;
  70042. process(preprocessors: {
  70043. [key: string]: string;
  70044. }, options: ProcessingOptions): string;
  70045. }
  70046. }
  70047. declare module BABYLON {
  70048. /** @hidden */
  70049. export class ShaderCodeCursor {
  70050. private _lines;
  70051. lineIndex: number;
  70052. readonly currentLine: string;
  70053. readonly canRead: boolean;
  70054. lines: string[];
  70055. }
  70056. }
  70057. declare module BABYLON {
  70058. /** @hidden */
  70059. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70060. process(preprocessors: {
  70061. [key: string]: string;
  70062. }, options: ProcessingOptions): string;
  70063. }
  70064. }
  70065. declare module BABYLON {
  70066. /** @hidden */
  70067. export class ShaderDefineExpression {
  70068. isTrue(preprocessors: {
  70069. [key: string]: string;
  70070. }): boolean;
  70071. }
  70072. }
  70073. declare module BABYLON {
  70074. /** @hidden */
  70075. export class ShaderCodeTestNode extends ShaderCodeNode {
  70076. testExpression: ShaderDefineExpression;
  70077. isValid(preprocessors: {
  70078. [key: string]: string;
  70079. }): boolean;
  70080. }
  70081. }
  70082. declare module BABYLON {
  70083. /** @hidden */
  70084. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70085. define: string;
  70086. not: boolean;
  70087. constructor(define: string, not?: boolean);
  70088. isTrue(preprocessors: {
  70089. [key: string]: string;
  70090. }): boolean;
  70091. }
  70092. }
  70093. declare module BABYLON {
  70094. /** @hidden */
  70095. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70096. leftOperand: ShaderDefineExpression;
  70097. rightOperand: ShaderDefineExpression;
  70098. isTrue(preprocessors: {
  70099. [key: string]: string;
  70100. }): boolean;
  70101. }
  70102. }
  70103. declare module BABYLON {
  70104. /** @hidden */
  70105. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70106. leftOperand: ShaderDefineExpression;
  70107. rightOperand: ShaderDefineExpression;
  70108. isTrue(preprocessors: {
  70109. [key: string]: string;
  70110. }): boolean;
  70111. }
  70112. }
  70113. declare module BABYLON {
  70114. /** @hidden */
  70115. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70116. define: string;
  70117. operand: string;
  70118. testValue: string;
  70119. constructor(define: string, operand: string, testValue: string);
  70120. isTrue(preprocessors: {
  70121. [key: string]: string;
  70122. }): boolean;
  70123. }
  70124. }
  70125. declare module BABYLON {
  70126. /**
  70127. * Class used to enable access to offline support
  70128. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70129. */
  70130. export interface IOfflineProvider {
  70131. /**
  70132. * Gets a boolean indicating if scene must be saved in the database
  70133. */
  70134. enableSceneOffline: boolean;
  70135. /**
  70136. * Gets a boolean indicating if textures must be saved in the database
  70137. */
  70138. enableTexturesOffline: boolean;
  70139. /**
  70140. * Open the offline support and make it available
  70141. * @param successCallback defines the callback to call on success
  70142. * @param errorCallback defines the callback to call on error
  70143. */
  70144. open(successCallback: () => void, errorCallback: () => void): void;
  70145. /**
  70146. * Loads an image from the offline support
  70147. * @param url defines the url to load from
  70148. * @param image defines the target DOM image
  70149. */
  70150. loadImage(url: string, image: HTMLImageElement): void;
  70151. /**
  70152. * Loads a file from offline support
  70153. * @param url defines the URL to load from
  70154. * @param sceneLoaded defines a callback to call on success
  70155. * @param progressCallBack defines a callback to call when progress changed
  70156. * @param errorCallback defines a callback to call on error
  70157. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70158. */
  70159. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70160. }
  70161. }
  70162. declare module BABYLON {
  70163. /**
  70164. * Class used to help managing file picking and drag'n'drop
  70165. * File Storage
  70166. */
  70167. export class FilesInputStore {
  70168. /**
  70169. * List of files ready to be loaded
  70170. */
  70171. static FilesToLoad: {
  70172. [key: string]: File;
  70173. };
  70174. }
  70175. }
  70176. declare module BABYLON {
  70177. /**
  70178. * Class used to define a retry strategy when error happens while loading assets
  70179. */
  70180. export class RetryStrategy {
  70181. /**
  70182. * Function used to defines an exponential back off strategy
  70183. * @param maxRetries defines the maximum number of retries (3 by default)
  70184. * @param baseInterval defines the interval between retries
  70185. * @returns the strategy function to use
  70186. */
  70187. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70188. }
  70189. }
  70190. declare module BABYLON {
  70191. /**
  70192. * @ignore
  70193. * Application error to support additional information when loading a file
  70194. */
  70195. export abstract class BaseError extends Error {
  70196. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  70197. }
  70198. }
  70199. declare module BABYLON {
  70200. /** @ignore */
  70201. export class LoadFileError extends BaseError {
  70202. request?: WebRequest;
  70203. file?: File;
  70204. /**
  70205. * Creates a new LoadFileError
  70206. * @param message defines the message of the error
  70207. * @param request defines the optional web request
  70208. * @param file defines the optional file
  70209. */
  70210. constructor(message: string, object?: WebRequest | File);
  70211. }
  70212. /** @ignore */
  70213. export class RequestFileError extends BaseError {
  70214. request: WebRequest;
  70215. /**
  70216. * Creates a new LoadFileError
  70217. * @param message defines the message of the error
  70218. * @param request defines the optional web request
  70219. */
  70220. constructor(message: string, request: WebRequest);
  70221. }
  70222. /** @ignore */
  70223. export class ReadFileError extends BaseError {
  70224. file: File;
  70225. /**
  70226. * Creates a new ReadFileError
  70227. * @param message defines the message of the error
  70228. * @param file defines the optional file
  70229. */
  70230. constructor(message: string, file: File);
  70231. }
  70232. /**
  70233. * @hidden
  70234. */
  70235. export class FileTools {
  70236. /**
  70237. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70238. */
  70239. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70240. /**
  70241. * Gets or sets the base URL to use to load assets
  70242. */
  70243. static BaseUrl: string;
  70244. /**
  70245. * Default behaviour for cors in the application.
  70246. * It can be a string if the expected behavior is identical in the entire app.
  70247. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70248. */
  70249. static CorsBehavior: string | ((url: string | string[]) => string);
  70250. /**
  70251. * Gets or sets a function used to pre-process url before using them to load assets
  70252. */
  70253. static PreprocessUrl: (url: string) => string;
  70254. /**
  70255. * Removes unwanted characters from an url
  70256. * @param url defines the url to clean
  70257. * @returns the cleaned url
  70258. */
  70259. private static _CleanUrl;
  70260. /**
  70261. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70262. * @param url define the url we are trying
  70263. * @param element define the dom element where to configure the cors policy
  70264. */
  70265. static SetCorsBehavior(url: string | string[], element: {
  70266. crossOrigin: string | null;
  70267. }): void;
  70268. /**
  70269. * Loads an image as an HTMLImageElement.
  70270. * @param input url string, ArrayBuffer, or Blob to load
  70271. * @param onLoad callback called when the image successfully loads
  70272. * @param onError callback called when the image fails to load
  70273. * @param offlineProvider offline provider for caching
  70274. * @param mimeType optional mime type
  70275. * @returns the HTMLImageElement of the loaded image
  70276. */
  70277. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  70278. /**
  70279. * Reads a file from a File object
  70280. * @param file defines the file to load
  70281. * @param onSuccess defines the callback to call when data is loaded
  70282. * @param onProgress defines the callback to call during loading process
  70283. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70284. * @param onError defines the callback to call when an error occurs
  70285. * @returns a file request object
  70286. */
  70287. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  70288. /**
  70289. * Loads a file from a url
  70290. * @param url url to load
  70291. * @param onSuccess callback called when the file successfully loads
  70292. * @param onProgress callback called while file is loading (if the server supports this mode)
  70293. * @param offlineProvider defines the offline provider for caching
  70294. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70295. * @param onError callback called when the file fails to load
  70296. * @returns a file request object
  70297. */
  70298. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  70299. /**
  70300. * Loads a file
  70301. * @param url url to load
  70302. * @param onSuccess callback called when the file successfully loads
  70303. * @param onProgress callback called while file is loading (if the server supports this mode)
  70304. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70305. * @param onError callback called when the file fails to load
  70306. * @param onOpened callback called when the web request is opened
  70307. * @returns a file request object
  70308. */
  70309. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  70310. /**
  70311. * Checks if the loaded document was accessed via `file:`-Protocol.
  70312. * @returns boolean
  70313. */
  70314. static IsFileURL(): boolean;
  70315. }
  70316. }
  70317. declare module BABYLON {
  70318. /** @hidden */
  70319. export class ShaderProcessor {
  70320. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70321. private static _ProcessPrecision;
  70322. private static _ExtractOperation;
  70323. private static _BuildSubExpression;
  70324. private static _BuildExpression;
  70325. private static _MoveCursorWithinIf;
  70326. private static _MoveCursor;
  70327. private static _EvaluatePreProcessors;
  70328. private static _PreparePreProcessors;
  70329. private static _ProcessShaderConversion;
  70330. private static _ProcessIncludes;
  70331. }
  70332. }
  70333. declare module BABYLON {
  70334. /**
  70335. * @hidden
  70336. */
  70337. export interface IColor4Like {
  70338. r: float;
  70339. g: float;
  70340. b: float;
  70341. a: float;
  70342. }
  70343. /**
  70344. * @hidden
  70345. */
  70346. export interface IColor3Like {
  70347. r: float;
  70348. g: float;
  70349. b: float;
  70350. }
  70351. /**
  70352. * @hidden
  70353. */
  70354. export interface IVector4Like {
  70355. x: float;
  70356. y: float;
  70357. z: float;
  70358. w: float;
  70359. }
  70360. /**
  70361. * @hidden
  70362. */
  70363. export interface IVector3Like {
  70364. x: float;
  70365. y: float;
  70366. z: float;
  70367. }
  70368. /**
  70369. * @hidden
  70370. */
  70371. export interface IVector2Like {
  70372. x: float;
  70373. y: float;
  70374. }
  70375. /**
  70376. * @hidden
  70377. */
  70378. export interface IMatrixLike {
  70379. toArray(): DeepImmutable<Float32Array>;
  70380. updateFlag: int;
  70381. }
  70382. /**
  70383. * @hidden
  70384. */
  70385. export interface IViewportLike {
  70386. x: float;
  70387. y: float;
  70388. width: float;
  70389. height: float;
  70390. }
  70391. /**
  70392. * @hidden
  70393. */
  70394. export interface IPlaneLike {
  70395. normal: IVector3Like;
  70396. d: float;
  70397. normalize(): void;
  70398. }
  70399. }
  70400. declare module BABYLON {
  70401. /**
  70402. * Interface used to define common properties for effect fallbacks
  70403. */
  70404. export interface IEffectFallbacks {
  70405. /**
  70406. * Removes the defines that should be removed when falling back.
  70407. * @param currentDefines defines the current define statements for the shader.
  70408. * @param effect defines the current effect we try to compile
  70409. * @returns The resulting defines with defines of the current rank removed.
  70410. */
  70411. reduce(currentDefines: string, effect: Effect): string;
  70412. /**
  70413. * Removes the fallback from the bound mesh.
  70414. */
  70415. unBindMesh(): void;
  70416. /**
  70417. * Checks to see if more fallbacks are still availible.
  70418. */
  70419. hasMoreFallbacks: boolean;
  70420. }
  70421. }
  70422. declare module BABYLON {
  70423. /**
  70424. * Class used to evalaute queries containing `and` and `or` operators
  70425. */
  70426. export class AndOrNotEvaluator {
  70427. /**
  70428. * Evaluate a query
  70429. * @param query defines the query to evaluate
  70430. * @param evaluateCallback defines the callback used to filter result
  70431. * @returns true if the query matches
  70432. */
  70433. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70434. private static _HandleParenthesisContent;
  70435. private static _SimplifyNegation;
  70436. }
  70437. }
  70438. declare module BABYLON {
  70439. /**
  70440. * Class used to store custom tags
  70441. */
  70442. export class Tags {
  70443. /**
  70444. * Adds support for tags on the given object
  70445. * @param obj defines the object to use
  70446. */
  70447. static EnableFor(obj: any): void;
  70448. /**
  70449. * Removes tags support
  70450. * @param obj defines the object to use
  70451. */
  70452. static DisableFor(obj: any): void;
  70453. /**
  70454. * Gets a boolean indicating if the given object has tags
  70455. * @param obj defines the object to use
  70456. * @returns a boolean
  70457. */
  70458. static HasTags(obj: any): boolean;
  70459. /**
  70460. * Gets the tags available on a given object
  70461. * @param obj defines the object to use
  70462. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70463. * @returns the tags
  70464. */
  70465. static GetTags(obj: any, asString?: boolean): any;
  70466. /**
  70467. * Adds tags to an object
  70468. * @param obj defines the object to use
  70469. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70470. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70471. */
  70472. static AddTagsTo(obj: any, tagsString: string): void;
  70473. /**
  70474. * @hidden
  70475. */
  70476. static _AddTagTo(obj: any, tag: string): void;
  70477. /**
  70478. * Removes specific tags from a specific object
  70479. * @param obj defines the object to use
  70480. * @param tagsString defines the tags to remove
  70481. */
  70482. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70483. /**
  70484. * @hidden
  70485. */
  70486. static _RemoveTagFrom(obj: any, tag: string): void;
  70487. /**
  70488. * Defines if tags hosted on an object match a given query
  70489. * @param obj defines the object to use
  70490. * @param tagsQuery defines the tag query
  70491. * @returns a boolean
  70492. */
  70493. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70494. }
  70495. }
  70496. declare module BABYLON {
  70497. /**
  70498. * Scalar computation library
  70499. */
  70500. export class Scalar {
  70501. /**
  70502. * Two pi constants convenient for computation.
  70503. */
  70504. static TwoPi: number;
  70505. /**
  70506. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70507. * @param a number
  70508. * @param b number
  70509. * @param epsilon (default = 1.401298E-45)
  70510. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70511. */
  70512. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  70513. /**
  70514. * Returns a string : the upper case translation of the number i to hexadecimal.
  70515. * @param i number
  70516. * @returns the upper case translation of the number i to hexadecimal.
  70517. */
  70518. static ToHex(i: number): string;
  70519. /**
  70520. * Returns -1 if value is negative and +1 is value is positive.
  70521. * @param value the value
  70522. * @returns the value itself if it's equal to zero.
  70523. */
  70524. static Sign(value: number): number;
  70525. /**
  70526. * Returns the value itself if it's between min and max.
  70527. * Returns min if the value is lower than min.
  70528. * Returns max if the value is greater than max.
  70529. * @param value the value to clmap
  70530. * @param min the min value to clamp to (default: 0)
  70531. * @param max the max value to clamp to (default: 1)
  70532. * @returns the clamped value
  70533. */
  70534. static Clamp(value: number, min?: number, max?: number): number;
  70535. /**
  70536. * the log2 of value.
  70537. * @param value the value to compute log2 of
  70538. * @returns the log2 of value.
  70539. */
  70540. static Log2(value: number): number;
  70541. /**
  70542. * Loops the value, so that it is never larger than length and never smaller than 0.
  70543. *
  70544. * This is similar to the modulo operator but it works with floating point numbers.
  70545. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70546. * With t = 5 and length = 2.5, the result would be 0.0.
  70547. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70548. * @param value the value
  70549. * @param length the length
  70550. * @returns the looped value
  70551. */
  70552. static Repeat(value: number, length: number): number;
  70553. /**
  70554. * Normalize the value between 0.0 and 1.0 using min and max values
  70555. * @param value value to normalize
  70556. * @param min max to normalize between
  70557. * @param max min to normalize between
  70558. * @returns the normalized value
  70559. */
  70560. static Normalize(value: number, min: number, max: number): number;
  70561. /**
  70562. * Denormalize the value from 0.0 and 1.0 using min and max values
  70563. * @param normalized value to denormalize
  70564. * @param min max to denormalize between
  70565. * @param max min to denormalize between
  70566. * @returns the denormalized value
  70567. */
  70568. static Denormalize(normalized: number, min: number, max: number): number;
  70569. /**
  70570. * Calculates the shortest difference between two given angles given in degrees.
  70571. * @param current current angle in degrees
  70572. * @param target target angle in degrees
  70573. * @returns the delta
  70574. */
  70575. static DeltaAngle(current: number, target: number): number;
  70576. /**
  70577. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70578. * @param tx value
  70579. * @param length length
  70580. * @returns The returned value will move back and forth between 0 and length
  70581. */
  70582. static PingPong(tx: number, length: number): number;
  70583. /**
  70584. * Interpolates between min and max with smoothing at the limits.
  70585. *
  70586. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70587. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70588. * @param from from
  70589. * @param to to
  70590. * @param tx value
  70591. * @returns the smooth stepped value
  70592. */
  70593. static SmoothStep(from: number, to: number, tx: number): number;
  70594. /**
  70595. * Moves a value current towards target.
  70596. *
  70597. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70598. * Negative values of maxDelta pushes the value away from target.
  70599. * @param current current value
  70600. * @param target target value
  70601. * @param maxDelta max distance to move
  70602. * @returns resulting value
  70603. */
  70604. static MoveTowards(current: number, target: number, maxDelta: number): number;
  70605. /**
  70606. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70607. *
  70608. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70609. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70610. * @param current current value
  70611. * @param target target value
  70612. * @param maxDelta max distance to move
  70613. * @returns resulting angle
  70614. */
  70615. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70616. /**
  70617. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70618. * @param start start value
  70619. * @param end target value
  70620. * @param amount amount to lerp between
  70621. * @returns the lerped value
  70622. */
  70623. static Lerp(start: number, end: number, amount: number): number;
  70624. /**
  70625. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70626. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70627. * @param start start value
  70628. * @param end target value
  70629. * @param amount amount to lerp between
  70630. * @returns the lerped value
  70631. */
  70632. static LerpAngle(start: number, end: number, amount: number): number;
  70633. /**
  70634. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70635. * @param a start value
  70636. * @param b target value
  70637. * @param value value between a and b
  70638. * @returns the inverseLerp value
  70639. */
  70640. static InverseLerp(a: number, b: number, value: number): number;
  70641. /**
  70642. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70643. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70644. * @param value1 spline value
  70645. * @param tangent1 spline value
  70646. * @param value2 spline value
  70647. * @param tangent2 spline value
  70648. * @param amount input value
  70649. * @returns hermite result
  70650. */
  70651. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  70652. /**
  70653. * Returns a random float number between and min and max values
  70654. * @param min min value of random
  70655. * @param max max value of random
  70656. * @returns random value
  70657. */
  70658. static RandomRange(min: number, max: number): number;
  70659. /**
  70660. * This function returns percentage of a number in a given range.
  70661. *
  70662. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70663. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70664. * @param number to convert to percentage
  70665. * @param min min range
  70666. * @param max max range
  70667. * @returns the percentage
  70668. */
  70669. static RangeToPercent(number: number, min: number, max: number): number;
  70670. /**
  70671. * This function returns number that corresponds to the percentage in a given range.
  70672. *
  70673. * PercentToRange(0.34,0,100) will return 34.
  70674. * @param percent to convert to number
  70675. * @param min min range
  70676. * @param max max range
  70677. * @returns the number
  70678. */
  70679. static PercentToRange(percent: number, min: number, max: number): number;
  70680. /**
  70681. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70682. * @param angle The angle to normalize in radian.
  70683. * @return The converted angle.
  70684. */
  70685. static NormalizeRadians(angle: number): number;
  70686. }
  70687. }
  70688. declare module BABYLON {
  70689. /**
  70690. * Constant used to convert a value to gamma space
  70691. * @ignorenaming
  70692. */
  70693. export const ToGammaSpace: number;
  70694. /**
  70695. * Constant used to convert a value to linear space
  70696. * @ignorenaming
  70697. */
  70698. export const ToLinearSpace = 2.2;
  70699. /**
  70700. * Constant used to define the minimal number value in Babylon.js
  70701. * @ignorenaming
  70702. */
  70703. let Epsilon: number;
  70704. }
  70705. declare module BABYLON {
  70706. /**
  70707. * Class used to represent a viewport on screen
  70708. */
  70709. export class Viewport {
  70710. /** viewport left coordinate */
  70711. x: number;
  70712. /** viewport top coordinate */
  70713. y: number;
  70714. /**viewport width */
  70715. width: number;
  70716. /** viewport height */
  70717. height: number;
  70718. /**
  70719. * Creates a Viewport object located at (x, y) and sized (width, height)
  70720. * @param x defines viewport left coordinate
  70721. * @param y defines viewport top coordinate
  70722. * @param width defines the viewport width
  70723. * @param height defines the viewport height
  70724. */
  70725. constructor(
  70726. /** viewport left coordinate */
  70727. x: number,
  70728. /** viewport top coordinate */
  70729. y: number,
  70730. /**viewport width */
  70731. width: number,
  70732. /** viewport height */
  70733. height: number);
  70734. /**
  70735. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70736. * @param renderWidth defines the rendering width
  70737. * @param renderHeight defines the rendering height
  70738. * @returns a new Viewport
  70739. */
  70740. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70741. /**
  70742. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70743. * @param renderWidth defines the rendering width
  70744. * @param renderHeight defines the rendering height
  70745. * @param ref defines the target viewport
  70746. * @returns the current viewport
  70747. */
  70748. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70749. /**
  70750. * Returns a new Viewport copied from the current one
  70751. * @returns a new Viewport
  70752. */
  70753. clone(): Viewport;
  70754. }
  70755. }
  70756. declare module BABYLON {
  70757. /**
  70758. * Class containing a set of static utilities functions for arrays.
  70759. */
  70760. export class ArrayTools {
  70761. /**
  70762. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70763. * @param size the number of element to construct and put in the array
  70764. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70765. * @returns a new array filled with new objects
  70766. */
  70767. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70768. }
  70769. }
  70770. declare module BABYLON {
  70771. /**
  70772. * Class representing a vector containing 2 coordinates
  70773. */
  70774. export class Vector2 {
  70775. /** defines the first coordinate */
  70776. x: number;
  70777. /** defines the second coordinate */
  70778. y: number;
  70779. /**
  70780. * Creates a new Vector2 from the given x and y coordinates
  70781. * @param x defines the first coordinate
  70782. * @param y defines the second coordinate
  70783. */
  70784. constructor(
  70785. /** defines the first coordinate */
  70786. x?: number,
  70787. /** defines the second coordinate */
  70788. y?: number);
  70789. /**
  70790. * Gets a string with the Vector2 coordinates
  70791. * @returns a string with the Vector2 coordinates
  70792. */
  70793. toString(): string;
  70794. /**
  70795. * Gets class name
  70796. * @returns the string "Vector2"
  70797. */
  70798. getClassName(): string;
  70799. /**
  70800. * Gets current vector hash code
  70801. * @returns the Vector2 hash code as a number
  70802. */
  70803. getHashCode(): number;
  70804. /**
  70805. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70806. * @param array defines the source array
  70807. * @param index defines the offset in source array
  70808. * @returns the current Vector2
  70809. */
  70810. toArray(array: FloatArray, index?: number): Vector2;
  70811. /**
  70812. * Copy the current vector to an array
  70813. * @returns a new array with 2 elements: the Vector2 coordinates.
  70814. */
  70815. asArray(): number[];
  70816. /**
  70817. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70818. * @param source defines the source Vector2
  70819. * @returns the current updated Vector2
  70820. */
  70821. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70822. /**
  70823. * Sets the Vector2 coordinates with the given floats
  70824. * @param x defines the first coordinate
  70825. * @param y defines the second coordinate
  70826. * @returns the current updated Vector2
  70827. */
  70828. copyFromFloats(x: number, y: number): Vector2;
  70829. /**
  70830. * Sets the Vector2 coordinates with the given floats
  70831. * @param x defines the first coordinate
  70832. * @param y defines the second coordinate
  70833. * @returns the current updated Vector2
  70834. */
  70835. set(x: number, y: number): Vector2;
  70836. /**
  70837. * Add another vector with the current one
  70838. * @param otherVector defines the other vector
  70839. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70840. */
  70841. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70842. /**
  70843. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70844. * @param otherVector defines the other vector
  70845. * @param result defines the target vector
  70846. * @returns the unmodified current Vector2
  70847. */
  70848. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70849. /**
  70850. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70851. * @param otherVector defines the other vector
  70852. * @returns the current updated Vector2
  70853. */
  70854. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70855. /**
  70856. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70857. * @param otherVector defines the other vector
  70858. * @returns a new Vector2
  70859. */
  70860. addVector3(otherVector: Vector3): Vector2;
  70861. /**
  70862. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70863. * @param otherVector defines the other vector
  70864. * @returns a new Vector2
  70865. */
  70866. subtract(otherVector: Vector2): Vector2;
  70867. /**
  70868. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70869. * @param otherVector defines the other vector
  70870. * @param result defines the target vector
  70871. * @returns the unmodified current Vector2
  70872. */
  70873. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70874. /**
  70875. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70876. * @param otherVector defines the other vector
  70877. * @returns the current updated Vector2
  70878. */
  70879. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70880. /**
  70881. * Multiplies in place the current Vector2 coordinates by the given ones
  70882. * @param otherVector defines the other vector
  70883. * @returns the current updated Vector2
  70884. */
  70885. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70886. /**
  70887. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70888. * @param otherVector defines the other vector
  70889. * @returns a new Vector2
  70890. */
  70891. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70892. /**
  70893. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70894. * @param otherVector defines the other vector
  70895. * @param result defines the target vector
  70896. * @returns the unmodified current Vector2
  70897. */
  70898. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70899. /**
  70900. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70901. * @param x defines the first coordinate
  70902. * @param y defines the second coordinate
  70903. * @returns a new Vector2
  70904. */
  70905. multiplyByFloats(x: number, y: number): Vector2;
  70906. /**
  70907. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70908. * @param otherVector defines the other vector
  70909. * @returns a new Vector2
  70910. */
  70911. divide(otherVector: Vector2): Vector2;
  70912. /**
  70913. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70914. * @param otherVector defines the other vector
  70915. * @param result defines the target vector
  70916. * @returns the unmodified current Vector2
  70917. */
  70918. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70919. /**
  70920. * Divides the current Vector2 coordinates by the given ones
  70921. * @param otherVector defines the other vector
  70922. * @returns the current updated Vector2
  70923. */
  70924. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70925. /**
  70926. * Gets a new Vector2 with current Vector2 negated coordinates
  70927. * @returns a new Vector2
  70928. */
  70929. negate(): Vector2;
  70930. /**
  70931. * Multiply the Vector2 coordinates by scale
  70932. * @param scale defines the scaling factor
  70933. * @returns the current updated Vector2
  70934. */
  70935. scaleInPlace(scale: number): Vector2;
  70936. /**
  70937. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70938. * @param scale defines the scaling factor
  70939. * @returns a new Vector2
  70940. */
  70941. scale(scale: number): Vector2;
  70942. /**
  70943. * Scale the current Vector2 values by a factor to a given Vector2
  70944. * @param scale defines the scale factor
  70945. * @param result defines the Vector2 object where to store the result
  70946. * @returns the unmodified current Vector2
  70947. */
  70948. scaleToRef(scale: number, result: Vector2): Vector2;
  70949. /**
  70950. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70951. * @param scale defines the scale factor
  70952. * @param result defines the Vector2 object where to store the result
  70953. * @returns the unmodified current Vector2
  70954. */
  70955. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70956. /**
  70957. * Gets a boolean if two vectors are equals
  70958. * @param otherVector defines the other vector
  70959. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70960. */
  70961. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70962. /**
  70963. * Gets a boolean if two vectors are equals (using an epsilon value)
  70964. * @param otherVector defines the other vector
  70965. * @param epsilon defines the minimal distance to consider equality
  70966. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70967. */
  70968. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70969. /**
  70970. * Gets a new Vector2 from current Vector2 floored values
  70971. * @returns a new Vector2
  70972. */
  70973. floor(): Vector2;
  70974. /**
  70975. * Gets a new Vector2 from current Vector2 floored values
  70976. * @returns a new Vector2
  70977. */
  70978. fract(): Vector2;
  70979. /**
  70980. * Gets the length of the vector
  70981. * @returns the vector length (float)
  70982. */
  70983. length(): number;
  70984. /**
  70985. * Gets the vector squared length
  70986. * @returns the vector squared length (float)
  70987. */
  70988. lengthSquared(): number;
  70989. /**
  70990. * Normalize the vector
  70991. * @returns the current updated Vector2
  70992. */
  70993. normalize(): Vector2;
  70994. /**
  70995. * Gets a new Vector2 copied from the Vector2
  70996. * @returns a new Vector2
  70997. */
  70998. clone(): Vector2;
  70999. /**
  71000. * Gets a new Vector2(0, 0)
  71001. * @returns a new Vector2
  71002. */
  71003. static Zero(): Vector2;
  71004. /**
  71005. * Gets a new Vector2(1, 1)
  71006. * @returns a new Vector2
  71007. */
  71008. static One(): Vector2;
  71009. /**
  71010. * Gets a new Vector2 set from the given index element of the given array
  71011. * @param array defines the data source
  71012. * @param offset defines the offset in the data source
  71013. * @returns a new Vector2
  71014. */
  71015. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  71016. /**
  71017. * Sets "result" from the given index element of the given array
  71018. * @param array defines the data source
  71019. * @param offset defines the offset in the data source
  71020. * @param result defines the target vector
  71021. */
  71022. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  71023. /**
  71024. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71025. * @param value1 defines 1st point of control
  71026. * @param value2 defines 2nd point of control
  71027. * @param value3 defines 3rd point of control
  71028. * @param value4 defines 4th point of control
  71029. * @param amount defines the interpolation factor
  71030. * @returns a new Vector2
  71031. */
  71032. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  71033. /**
  71034. * 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".
  71035. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71036. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71037. * @param value defines the value to clamp
  71038. * @param min defines the lower limit
  71039. * @param max defines the upper limit
  71040. * @returns a new Vector2
  71041. */
  71042. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  71043. /**
  71044. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71045. * @param value1 defines the 1st control point
  71046. * @param tangent1 defines the outgoing tangent
  71047. * @param value2 defines the 2nd control point
  71048. * @param tangent2 defines the incoming tangent
  71049. * @param amount defines the interpolation factor
  71050. * @returns a new Vector2
  71051. */
  71052. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  71053. /**
  71054. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71055. * @param start defines the start vector
  71056. * @param end defines the end vector
  71057. * @param amount defines the interpolation factor
  71058. * @returns a new Vector2
  71059. */
  71060. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  71061. /**
  71062. * Gets the dot product of the vector "left" and the vector "right"
  71063. * @param left defines first vector
  71064. * @param right defines second vector
  71065. * @returns the dot product (float)
  71066. */
  71067. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  71068. /**
  71069. * Returns a new Vector2 equal to the normalized given vector
  71070. * @param vector defines the vector to normalize
  71071. * @returns a new Vector2
  71072. */
  71073. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  71074. /**
  71075. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71076. * @param left defines 1st vector
  71077. * @param right defines 2nd vector
  71078. * @returns a new Vector2
  71079. */
  71080. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71081. /**
  71082. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71083. * @param left defines 1st vector
  71084. * @param right defines 2nd vector
  71085. * @returns a new Vector2
  71086. */
  71087. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71088. /**
  71089. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71090. * @param vector defines the vector to transform
  71091. * @param transformation defines the matrix to apply
  71092. * @returns a new Vector2
  71093. */
  71094. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  71095. /**
  71096. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71097. * @param vector defines the vector to transform
  71098. * @param transformation defines the matrix to apply
  71099. * @param result defines the target vector
  71100. */
  71101. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  71102. /**
  71103. * Determines if a given vector is included in a triangle
  71104. * @param p defines the vector to test
  71105. * @param p0 defines 1st triangle point
  71106. * @param p1 defines 2nd triangle point
  71107. * @param p2 defines 3rd triangle point
  71108. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71109. */
  71110. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  71111. /**
  71112. * Gets the distance between the vectors "value1" and "value2"
  71113. * @param value1 defines first vector
  71114. * @param value2 defines second vector
  71115. * @returns the distance between vectors
  71116. */
  71117. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71118. /**
  71119. * Returns the squared distance between the vectors "value1" and "value2"
  71120. * @param value1 defines first vector
  71121. * @param value2 defines second vector
  71122. * @returns the squared distance between vectors
  71123. */
  71124. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71125. /**
  71126. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71127. * @param value1 defines first vector
  71128. * @param value2 defines second vector
  71129. * @returns a new Vector2
  71130. */
  71131. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  71132. /**
  71133. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71134. * @param p defines the middle point
  71135. * @param segA defines one point of the segment
  71136. * @param segB defines the other point of the segment
  71137. * @returns the shortest distance
  71138. */
  71139. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  71140. }
  71141. /**
  71142. * Class used to store (x,y,z) vector representation
  71143. * A Vector3 is the main object used in 3D geometry
  71144. * It can represent etiher the coordinates of a point the space, either a direction
  71145. * Reminder: js uses a left handed forward facing system
  71146. */
  71147. export class Vector3 {
  71148. /**
  71149. * Defines the first coordinates (on X axis)
  71150. */
  71151. x: number;
  71152. /**
  71153. * Defines the second coordinates (on Y axis)
  71154. */
  71155. y: number;
  71156. /**
  71157. * Defines the third coordinates (on Z axis)
  71158. */
  71159. z: number;
  71160. private static _UpReadOnly;
  71161. private static _ZeroReadOnly;
  71162. /**
  71163. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71164. * @param x defines the first coordinates (on X axis)
  71165. * @param y defines the second coordinates (on Y axis)
  71166. * @param z defines the third coordinates (on Z axis)
  71167. */
  71168. constructor(
  71169. /**
  71170. * Defines the first coordinates (on X axis)
  71171. */
  71172. x?: number,
  71173. /**
  71174. * Defines the second coordinates (on Y axis)
  71175. */
  71176. y?: number,
  71177. /**
  71178. * Defines the third coordinates (on Z axis)
  71179. */
  71180. z?: number);
  71181. /**
  71182. * Creates a string representation of the Vector3
  71183. * @returns a string with the Vector3 coordinates.
  71184. */
  71185. toString(): string;
  71186. /**
  71187. * Gets the class name
  71188. * @returns the string "Vector3"
  71189. */
  71190. getClassName(): string;
  71191. /**
  71192. * Creates the Vector3 hash code
  71193. * @returns a number which tends to be unique between Vector3 instances
  71194. */
  71195. getHashCode(): number;
  71196. /**
  71197. * Creates an array containing three elements : the coordinates of the Vector3
  71198. * @returns a new array of numbers
  71199. */
  71200. asArray(): number[];
  71201. /**
  71202. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71203. * @param array defines the destination array
  71204. * @param index defines the offset in the destination array
  71205. * @returns the current Vector3
  71206. */
  71207. toArray(array: FloatArray, index?: number): Vector3;
  71208. /**
  71209. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71210. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71211. */
  71212. toQuaternion(): Quaternion;
  71213. /**
  71214. * Adds the given vector to the current Vector3
  71215. * @param otherVector defines the second operand
  71216. * @returns the current updated Vector3
  71217. */
  71218. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71219. /**
  71220. * Adds the given coordinates to the current Vector3
  71221. * @param x defines the x coordinate of the operand
  71222. * @param y defines the y coordinate of the operand
  71223. * @param z defines the z coordinate of the operand
  71224. * @returns the current updated Vector3
  71225. */
  71226. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71227. /**
  71228. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71229. * @param otherVector defines the second operand
  71230. * @returns the resulting Vector3
  71231. */
  71232. add(otherVector: DeepImmutable<Vector3>): Vector3;
  71233. /**
  71234. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71235. * @param otherVector defines the second operand
  71236. * @param result defines the Vector3 object where to store the result
  71237. * @returns the current Vector3
  71238. */
  71239. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71240. /**
  71241. * Subtract the given vector from the current Vector3
  71242. * @param otherVector defines the second operand
  71243. * @returns the current updated Vector3
  71244. */
  71245. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71246. /**
  71247. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71248. * @param otherVector defines the second operand
  71249. * @returns the resulting Vector3
  71250. */
  71251. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  71252. /**
  71253. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71254. * @param otherVector defines the second operand
  71255. * @param result defines the Vector3 object where to store the result
  71256. * @returns the current Vector3
  71257. */
  71258. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71259. /**
  71260. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71261. * @param x defines the x coordinate of the operand
  71262. * @param y defines the y coordinate of the operand
  71263. * @param z defines the z coordinate of the operand
  71264. * @returns the resulting Vector3
  71265. */
  71266. subtractFromFloats(x: number, y: number, z: number): Vector3;
  71267. /**
  71268. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71269. * @param x defines the x coordinate of the operand
  71270. * @param y defines the y coordinate of the operand
  71271. * @param z defines the z coordinate of the operand
  71272. * @param result defines the Vector3 object where to store the result
  71273. * @returns the current Vector3
  71274. */
  71275. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  71276. /**
  71277. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71278. * @returns a new Vector3
  71279. */
  71280. negate(): Vector3;
  71281. /**
  71282. * Multiplies the Vector3 coordinates by the float "scale"
  71283. * @param scale defines the multiplier factor
  71284. * @returns the current updated Vector3
  71285. */
  71286. scaleInPlace(scale: number): Vector3;
  71287. /**
  71288. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71289. * @param scale defines the multiplier factor
  71290. * @returns a new Vector3
  71291. */
  71292. scale(scale: number): Vector3;
  71293. /**
  71294. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71295. * @param scale defines the multiplier factor
  71296. * @param result defines the Vector3 object where to store the result
  71297. * @returns the current Vector3
  71298. */
  71299. scaleToRef(scale: number, result: Vector3): Vector3;
  71300. /**
  71301. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71302. * @param scale defines the scale factor
  71303. * @param result defines the Vector3 object where to store the result
  71304. * @returns the unmodified current Vector3
  71305. */
  71306. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  71307. /**
  71308. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71309. * @param otherVector defines the second operand
  71310. * @returns true if both vectors are equals
  71311. */
  71312. equals(otherVector: DeepImmutable<Vector3>): boolean;
  71313. /**
  71314. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71315. * @param otherVector defines the second operand
  71316. * @param epsilon defines the minimal distance to define values as equals
  71317. * @returns true if both vectors are distant less than epsilon
  71318. */
  71319. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  71320. /**
  71321. * Returns true if the current Vector3 coordinates equals the given floats
  71322. * @param x defines the x coordinate of the operand
  71323. * @param y defines the y coordinate of the operand
  71324. * @param z defines the z coordinate of the operand
  71325. * @returns true if both vectors are equals
  71326. */
  71327. equalsToFloats(x: number, y: number, z: number): boolean;
  71328. /**
  71329. * Multiplies the current Vector3 coordinates by the given ones
  71330. * @param otherVector defines the second operand
  71331. * @returns the current updated Vector3
  71332. */
  71333. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71334. /**
  71335. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71336. * @param otherVector defines the second operand
  71337. * @returns the new Vector3
  71338. */
  71339. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  71340. /**
  71341. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71342. * @param otherVector defines the second operand
  71343. * @param result defines the Vector3 object where to store the result
  71344. * @returns the current Vector3
  71345. */
  71346. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71347. /**
  71348. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71349. * @param x defines the x coordinate of the operand
  71350. * @param y defines the y coordinate of the operand
  71351. * @param z defines the z coordinate of the operand
  71352. * @returns the new Vector3
  71353. */
  71354. multiplyByFloats(x: number, y: number, z: number): Vector3;
  71355. /**
  71356. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71357. * @param otherVector defines the second operand
  71358. * @returns the new Vector3
  71359. */
  71360. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  71361. /**
  71362. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71363. * @param otherVector defines the second operand
  71364. * @param result defines the Vector3 object where to store the result
  71365. * @returns the current Vector3
  71366. */
  71367. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71368. /**
  71369. * Divides the current Vector3 coordinates by the given ones.
  71370. * @param otherVector defines the second operand
  71371. * @returns the current updated Vector3
  71372. */
  71373. divideInPlace(otherVector: Vector3): Vector3;
  71374. /**
  71375. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71376. * @param other defines the second operand
  71377. * @returns the current updated Vector3
  71378. */
  71379. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71380. /**
  71381. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71382. * @param other defines the second operand
  71383. * @returns the current updated Vector3
  71384. */
  71385. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71386. /**
  71387. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71388. * @param x defines the x coordinate of the operand
  71389. * @param y defines the y coordinate of the operand
  71390. * @param z defines the z coordinate of the operand
  71391. * @returns the current updated Vector3
  71392. */
  71393. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71394. /**
  71395. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71396. * @param x defines the x coordinate of the operand
  71397. * @param y defines the y coordinate of the operand
  71398. * @param z defines the z coordinate of the operand
  71399. * @returns the current updated Vector3
  71400. */
  71401. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71402. /**
  71403. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71404. * Check if is non uniform within a certain amount of decimal places to account for this
  71405. * @param epsilon the amount the values can differ
  71406. * @returns if the the vector is non uniform to a certain number of decimal places
  71407. */
  71408. isNonUniformWithinEpsilon(epsilon: number): boolean;
  71409. /**
  71410. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71411. */
  71412. readonly isNonUniform: boolean;
  71413. /**
  71414. * Gets a new Vector3 from current Vector3 floored values
  71415. * @returns a new Vector3
  71416. */
  71417. floor(): Vector3;
  71418. /**
  71419. * Gets a new Vector3 from current Vector3 floored values
  71420. * @returns a new Vector3
  71421. */
  71422. fract(): Vector3;
  71423. /**
  71424. * Gets the length of the Vector3
  71425. * @returns the length of the Vector3
  71426. */
  71427. length(): number;
  71428. /**
  71429. * Gets the squared length of the Vector3
  71430. * @returns squared length of the Vector3
  71431. */
  71432. lengthSquared(): number;
  71433. /**
  71434. * Normalize the current Vector3.
  71435. * Please note that this is an in place operation.
  71436. * @returns the current updated Vector3
  71437. */
  71438. normalize(): Vector3;
  71439. /**
  71440. * Reorders the x y z properties of the vector in place
  71441. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71442. * @returns the current updated vector
  71443. */
  71444. reorderInPlace(order: string): this;
  71445. /**
  71446. * Rotates the vector around 0,0,0 by a quaternion
  71447. * @param quaternion the rotation quaternion
  71448. * @param result vector to store the result
  71449. * @returns the resulting vector
  71450. */
  71451. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  71452. /**
  71453. * Rotates a vector around a given point
  71454. * @param quaternion the rotation quaternion
  71455. * @param point the point to rotate around
  71456. * @param result vector to store the result
  71457. * @returns the resulting vector
  71458. */
  71459. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  71460. /**
  71461. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  71462. * The cross product is then orthogonal to both current and "other"
  71463. * @param other defines the right operand
  71464. * @returns the cross product
  71465. */
  71466. cross(other: Vector3): Vector3;
  71467. /**
  71468. * Normalize the current Vector3 with the given input length.
  71469. * Please note that this is an in place operation.
  71470. * @param len the length of the vector
  71471. * @returns the current updated Vector3
  71472. */
  71473. normalizeFromLength(len: number): Vector3;
  71474. /**
  71475. * Normalize the current Vector3 to a new vector
  71476. * @returns the new Vector3
  71477. */
  71478. normalizeToNew(): Vector3;
  71479. /**
  71480. * Normalize the current Vector3 to the reference
  71481. * @param reference define the Vector3 to update
  71482. * @returns the updated Vector3
  71483. */
  71484. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  71485. /**
  71486. * Creates a new Vector3 copied from the current Vector3
  71487. * @returns the new Vector3
  71488. */
  71489. clone(): Vector3;
  71490. /**
  71491. * Copies the given vector coordinates to the current Vector3 ones
  71492. * @param source defines the source Vector3
  71493. * @returns the current updated Vector3
  71494. */
  71495. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  71496. /**
  71497. * Copies the given floats to the current Vector3 coordinates
  71498. * @param x defines the x coordinate of the operand
  71499. * @param y defines the y coordinate of the operand
  71500. * @param z defines the z coordinate of the operand
  71501. * @returns the current updated Vector3
  71502. */
  71503. copyFromFloats(x: number, y: number, z: number): Vector3;
  71504. /**
  71505. * Copies the given floats to the current Vector3 coordinates
  71506. * @param x defines the x coordinate of the operand
  71507. * @param y defines the y coordinate of the operand
  71508. * @param z defines the z coordinate of the operand
  71509. * @returns the current updated Vector3
  71510. */
  71511. set(x: number, y: number, z: number): Vector3;
  71512. /**
  71513. * Copies the given float to the current Vector3 coordinates
  71514. * @param v defines the x, y and z coordinates of the operand
  71515. * @returns the current updated Vector3
  71516. */
  71517. setAll(v: number): Vector3;
  71518. /**
  71519. * Get the clip factor between two vectors
  71520. * @param vector0 defines the first operand
  71521. * @param vector1 defines the second operand
  71522. * @param axis defines the axis to use
  71523. * @param size defines the size along the axis
  71524. * @returns the clip factor
  71525. */
  71526. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  71527. /**
  71528. * Get angle between two vectors
  71529. * @param vector0 angle between vector0 and vector1
  71530. * @param vector1 angle between vector0 and vector1
  71531. * @param normal direction of the normal
  71532. * @return the angle between vector0 and vector1
  71533. */
  71534. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  71535. /**
  71536. * Returns a new Vector3 set from the index "offset" of the given array
  71537. * @param array defines the source array
  71538. * @param offset defines the offset in the source array
  71539. * @returns the new Vector3
  71540. */
  71541. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  71542. /**
  71543. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71544. * @param array defines the source array
  71545. * @param offset defines the offset in the source array
  71546. * @returns the new Vector3
  71547. * @deprecated Please use FromArray instead.
  71548. */
  71549. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  71550. /**
  71551. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71552. * @param array defines the source array
  71553. * @param offset defines the offset in the source array
  71554. * @param result defines the Vector3 where to store the result
  71555. */
  71556. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  71557. /**
  71558. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71559. * @param array defines the source array
  71560. * @param offset defines the offset in the source array
  71561. * @param result defines the Vector3 where to store the result
  71562. * @deprecated Please use FromArrayToRef instead.
  71563. */
  71564. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  71565. /**
  71566. * Sets the given vector "result" with the given floats.
  71567. * @param x defines the x coordinate of the source
  71568. * @param y defines the y coordinate of the source
  71569. * @param z defines the z coordinate of the source
  71570. * @param result defines the Vector3 where to store the result
  71571. */
  71572. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  71573. /**
  71574. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71575. * @returns a new empty Vector3
  71576. */
  71577. static Zero(): Vector3;
  71578. /**
  71579. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71580. * @returns a new unit Vector3
  71581. */
  71582. static One(): Vector3;
  71583. /**
  71584. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71585. * @returns a new up Vector3
  71586. */
  71587. static Up(): Vector3;
  71588. /**
  71589. * Gets a up Vector3 that must not be updated
  71590. */
  71591. static readonly UpReadOnly: DeepImmutable<Vector3>;
  71592. /**
  71593. * Gets a zero Vector3 that must not be updated
  71594. */
  71595. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  71596. /**
  71597. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71598. * @returns a new down Vector3
  71599. */
  71600. static Down(): Vector3;
  71601. /**
  71602. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71603. * @returns a new forward Vector3
  71604. */
  71605. static Forward(): Vector3;
  71606. /**
  71607. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71608. * @returns a new forward Vector3
  71609. */
  71610. static Backward(): Vector3;
  71611. /**
  71612. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71613. * @returns a new right Vector3
  71614. */
  71615. static Right(): Vector3;
  71616. /**
  71617. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71618. * @returns a new left Vector3
  71619. */
  71620. static Left(): Vector3;
  71621. /**
  71622. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71623. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71624. * @param vector defines the Vector3 to transform
  71625. * @param transformation defines the transformation matrix
  71626. * @returns the transformed Vector3
  71627. */
  71628. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71629. /**
  71630. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71631. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71632. * @param vector defines the Vector3 to transform
  71633. * @param transformation defines the transformation matrix
  71634. * @param result defines the Vector3 where to store the result
  71635. */
  71636. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71637. /**
  71638. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71639. * This method computes tranformed coordinates only, not transformed direction vectors
  71640. * @param x define the x coordinate of the source vector
  71641. * @param y define the y coordinate of the source vector
  71642. * @param z define the z coordinate of the source vector
  71643. * @param transformation defines the transformation matrix
  71644. * @param result defines the Vector3 where to store the result
  71645. */
  71646. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71647. /**
  71648. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71649. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71650. * @param vector defines the Vector3 to transform
  71651. * @param transformation defines the transformation matrix
  71652. * @returns the new Vector3
  71653. */
  71654. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71655. /**
  71656. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71657. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71658. * @param vector defines the Vector3 to transform
  71659. * @param transformation defines the transformation matrix
  71660. * @param result defines the Vector3 where to store the result
  71661. */
  71662. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71663. /**
  71664. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71665. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71666. * @param x define the x coordinate of the source vector
  71667. * @param y define the y coordinate of the source vector
  71668. * @param z define the z coordinate of the source vector
  71669. * @param transformation defines the transformation matrix
  71670. * @param result defines the Vector3 where to store the result
  71671. */
  71672. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71673. /**
  71674. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71675. * @param value1 defines the first control point
  71676. * @param value2 defines the second control point
  71677. * @param value3 defines the third control point
  71678. * @param value4 defines the fourth control point
  71679. * @param amount defines the amount on the spline to use
  71680. * @returns the new Vector3
  71681. */
  71682. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  71683. /**
  71684. * 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"
  71685. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71686. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71687. * @param value defines the current value
  71688. * @param min defines the lower range value
  71689. * @param max defines the upper range value
  71690. * @returns the new Vector3
  71691. */
  71692. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  71693. /**
  71694. * 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"
  71695. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71696. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71697. * @param value defines the current value
  71698. * @param min defines the lower range value
  71699. * @param max defines the upper range value
  71700. * @param result defines the Vector3 where to store the result
  71701. */
  71702. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71703. /**
  71704. * Checks if a given vector is inside a specific range
  71705. * @param v defines the vector to test
  71706. * @param min defines the minimum range
  71707. * @param max defines the maximum range
  71708. */
  71709. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71710. /**
  71711. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71712. * @param value1 defines the first control point
  71713. * @param tangent1 defines the first tangent vector
  71714. * @param value2 defines the second control point
  71715. * @param tangent2 defines the second tangent vector
  71716. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71717. * @returns the new Vector3
  71718. */
  71719. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71720. /**
  71721. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71722. * @param start defines the start value
  71723. * @param end defines the end value
  71724. * @param amount max defines amount between both (between 0 and 1)
  71725. * @returns the new Vector3
  71726. */
  71727. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71728. /**
  71729. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71730. * @param start defines the start value
  71731. * @param end defines the end value
  71732. * @param amount max defines amount between both (between 0 and 1)
  71733. * @param result defines the Vector3 where to store the result
  71734. */
  71735. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71736. /**
  71737. * Returns the dot product (float) between the vectors "left" and "right"
  71738. * @param left defines the left operand
  71739. * @param right defines the right operand
  71740. * @returns the dot product
  71741. */
  71742. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71743. /**
  71744. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71745. * The cross product is then orthogonal to both "left" and "right"
  71746. * @param left defines the left operand
  71747. * @param right defines the right operand
  71748. * @returns the cross product
  71749. */
  71750. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71751. /**
  71752. * Sets the given vector "result" with the cross product of "left" and "right"
  71753. * The cross product is then orthogonal to both "left" and "right"
  71754. * @param left defines the left operand
  71755. * @param right defines the right operand
  71756. * @param result defines the Vector3 where to store the result
  71757. */
  71758. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71759. /**
  71760. * Returns a new Vector3 as the normalization of the given vector
  71761. * @param vector defines the Vector3 to normalize
  71762. * @returns the new Vector3
  71763. */
  71764. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71765. /**
  71766. * Sets the given vector "result" with the normalization of the given first vector
  71767. * @param vector defines the Vector3 to normalize
  71768. * @param result defines the Vector3 where to store the result
  71769. */
  71770. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71771. /**
  71772. * Project a Vector3 onto screen space
  71773. * @param vector defines the Vector3 to project
  71774. * @param world defines the world matrix to use
  71775. * @param transform defines the transform (view x projection) matrix to use
  71776. * @param viewport defines the screen viewport to use
  71777. * @returns the new Vector3
  71778. */
  71779. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71780. /** @hidden */
  71781. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71782. /**
  71783. * Unproject from screen space to object space
  71784. * @param source defines the screen space Vector3 to use
  71785. * @param viewportWidth defines the current width of the viewport
  71786. * @param viewportHeight defines the current height of the viewport
  71787. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71788. * @param transform defines the transform (view x projection) matrix to use
  71789. * @returns the new Vector3
  71790. */
  71791. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71792. /**
  71793. * Unproject from screen space to object space
  71794. * @param source defines the screen space Vector3 to use
  71795. * @param viewportWidth defines the current width of the viewport
  71796. * @param viewportHeight defines the current height of the viewport
  71797. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71798. * @param view defines the view matrix to use
  71799. * @param projection defines the projection matrix to use
  71800. * @returns the new Vector3
  71801. */
  71802. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71803. /**
  71804. * Unproject from screen space to object space
  71805. * @param source defines the screen space Vector3 to use
  71806. * @param viewportWidth defines the current width of the viewport
  71807. * @param viewportHeight defines the current height of the viewport
  71808. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71809. * @param view defines the view matrix to use
  71810. * @param projection defines the projection matrix to use
  71811. * @param result defines the Vector3 where to store the result
  71812. */
  71813. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71814. /**
  71815. * Unproject from screen space to object space
  71816. * @param sourceX defines the screen space x coordinate to use
  71817. * @param sourceY defines the screen space y coordinate to use
  71818. * @param sourceZ defines the screen space z coordinate to use
  71819. * @param viewportWidth defines the current width of the viewport
  71820. * @param viewportHeight defines the current height of the viewport
  71821. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71822. * @param view defines the view matrix to use
  71823. * @param projection defines the projection matrix to use
  71824. * @param result defines the Vector3 where to store the result
  71825. */
  71826. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71827. /**
  71828. * Gets the minimal coordinate values between two Vector3
  71829. * @param left defines the first operand
  71830. * @param right defines the second operand
  71831. * @returns the new Vector3
  71832. */
  71833. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71834. /**
  71835. * Gets the maximal coordinate values between two Vector3
  71836. * @param left defines the first operand
  71837. * @param right defines the second operand
  71838. * @returns the new Vector3
  71839. */
  71840. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71841. /**
  71842. * Returns the distance between the vectors "value1" and "value2"
  71843. * @param value1 defines the first operand
  71844. * @param value2 defines the second operand
  71845. * @returns the distance
  71846. */
  71847. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71848. /**
  71849. * Returns the squared distance between the vectors "value1" and "value2"
  71850. * @param value1 defines the first operand
  71851. * @param value2 defines the second operand
  71852. * @returns the squared distance
  71853. */
  71854. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71855. /**
  71856. * Returns a new Vector3 located at the center between "value1" and "value2"
  71857. * @param value1 defines the first operand
  71858. * @param value2 defines the second operand
  71859. * @returns the new Vector3
  71860. */
  71861. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71862. /**
  71863. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71864. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71865. * to something in order to rotate it from its local system to the given target system
  71866. * Note: axis1, axis2 and axis3 are normalized during this operation
  71867. * @param axis1 defines the first axis
  71868. * @param axis2 defines the second axis
  71869. * @param axis3 defines the third axis
  71870. * @returns a new Vector3
  71871. */
  71872. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71873. /**
  71874. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71875. * @param axis1 defines the first axis
  71876. * @param axis2 defines the second axis
  71877. * @param axis3 defines the third axis
  71878. * @param ref defines the Vector3 where to store the result
  71879. */
  71880. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71881. }
  71882. /**
  71883. * Vector4 class created for EulerAngle class conversion to Quaternion
  71884. */
  71885. export class Vector4 {
  71886. /** x value of the vector */
  71887. x: number;
  71888. /** y value of the vector */
  71889. y: number;
  71890. /** z value of the vector */
  71891. z: number;
  71892. /** w value of the vector */
  71893. w: number;
  71894. /**
  71895. * Creates a Vector4 object from the given floats.
  71896. * @param x x value of the vector
  71897. * @param y y value of the vector
  71898. * @param z z value of the vector
  71899. * @param w w value of the vector
  71900. */
  71901. constructor(
  71902. /** x value of the vector */
  71903. x: number,
  71904. /** y value of the vector */
  71905. y: number,
  71906. /** z value of the vector */
  71907. z: number,
  71908. /** w value of the vector */
  71909. w: number);
  71910. /**
  71911. * Returns the string with the Vector4 coordinates.
  71912. * @returns a string containing all the vector values
  71913. */
  71914. toString(): string;
  71915. /**
  71916. * Returns the string "Vector4".
  71917. * @returns "Vector4"
  71918. */
  71919. getClassName(): string;
  71920. /**
  71921. * Returns the Vector4 hash code.
  71922. * @returns a unique hash code
  71923. */
  71924. getHashCode(): number;
  71925. /**
  71926. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71927. * @returns the resulting array
  71928. */
  71929. asArray(): number[];
  71930. /**
  71931. * Populates the given array from the given index with the Vector4 coordinates.
  71932. * @param array array to populate
  71933. * @param index index of the array to start at (default: 0)
  71934. * @returns the Vector4.
  71935. */
  71936. toArray(array: FloatArray, index?: number): Vector4;
  71937. /**
  71938. * Adds the given vector to the current Vector4.
  71939. * @param otherVector the vector to add
  71940. * @returns the updated Vector4.
  71941. */
  71942. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71943. /**
  71944. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71945. * @param otherVector the vector to add
  71946. * @returns the resulting vector
  71947. */
  71948. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71949. /**
  71950. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71951. * @param otherVector the vector to add
  71952. * @param result the vector to store the result
  71953. * @returns the current Vector4.
  71954. */
  71955. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71956. /**
  71957. * Subtract in place the given vector from the current Vector4.
  71958. * @param otherVector the vector to subtract
  71959. * @returns the updated Vector4.
  71960. */
  71961. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71962. /**
  71963. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71964. * @param otherVector the vector to add
  71965. * @returns the new vector with the result
  71966. */
  71967. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71968. /**
  71969. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71970. * @param otherVector the vector to subtract
  71971. * @param result the vector to store the result
  71972. * @returns the current Vector4.
  71973. */
  71974. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71975. /**
  71976. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71977. */
  71978. /**
  71979. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71980. * @param x value to subtract
  71981. * @param y value to subtract
  71982. * @param z value to subtract
  71983. * @param w value to subtract
  71984. * @returns new vector containing the result
  71985. */
  71986. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71987. /**
  71988. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71989. * @param x value to subtract
  71990. * @param y value to subtract
  71991. * @param z value to subtract
  71992. * @param w value to subtract
  71993. * @param result the vector to store the result in
  71994. * @returns the current Vector4.
  71995. */
  71996. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71997. /**
  71998. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71999. * @returns a new vector with the negated values
  72000. */
  72001. negate(): Vector4;
  72002. /**
  72003. * Multiplies the current Vector4 coordinates by scale (float).
  72004. * @param scale the number to scale with
  72005. * @returns the updated Vector4.
  72006. */
  72007. scaleInPlace(scale: number): Vector4;
  72008. /**
  72009. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72010. * @param scale the number to scale with
  72011. * @returns a new vector with the result
  72012. */
  72013. scale(scale: number): Vector4;
  72014. /**
  72015. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72016. * @param scale the number to scale with
  72017. * @param result a vector to store the result in
  72018. * @returns the current Vector4.
  72019. */
  72020. scaleToRef(scale: number, result: Vector4): Vector4;
  72021. /**
  72022. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72023. * @param scale defines the scale factor
  72024. * @param result defines the Vector4 object where to store the result
  72025. * @returns the unmodified current Vector4
  72026. */
  72027. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  72028. /**
  72029. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  72030. * @param otherVector the vector to compare against
  72031. * @returns true if they are equal
  72032. */
  72033. equals(otherVector: DeepImmutable<Vector4>): boolean;
  72034. /**
  72035. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  72036. * @param otherVector vector to compare against
  72037. * @param epsilon (Default: very small number)
  72038. * @returns true if they are equal
  72039. */
  72040. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  72041. /**
  72042. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  72043. * @param x x value to compare against
  72044. * @param y y value to compare against
  72045. * @param z z value to compare against
  72046. * @param w w value to compare against
  72047. * @returns true if equal
  72048. */
  72049. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  72050. /**
  72051. * Multiplies in place the current Vector4 by the given one.
  72052. * @param otherVector vector to multiple with
  72053. * @returns the updated Vector4.
  72054. */
  72055. multiplyInPlace(otherVector: Vector4): Vector4;
  72056. /**
  72057. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  72058. * @param otherVector vector to multiple with
  72059. * @returns resulting new vector
  72060. */
  72061. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  72062. /**
  72063. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  72064. * @param otherVector vector to multiple with
  72065. * @param result vector to store the result
  72066. * @returns the current Vector4.
  72067. */
  72068. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72069. /**
  72070. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72071. * @param x x value multiply with
  72072. * @param y y value multiply with
  72073. * @param z z value multiply with
  72074. * @param w w value multiply with
  72075. * @returns resulting new vector
  72076. */
  72077. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  72078. /**
  72079. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72080. * @param otherVector vector to devide with
  72081. * @returns resulting new vector
  72082. */
  72083. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  72084. /**
  72085. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72086. * @param otherVector vector to devide with
  72087. * @param result vector to store the result
  72088. * @returns the current Vector4.
  72089. */
  72090. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72091. /**
  72092. * Divides the current Vector3 coordinates by the given ones.
  72093. * @param otherVector vector to devide with
  72094. * @returns the updated Vector3.
  72095. */
  72096. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72097. /**
  72098. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72099. * @param other defines the second operand
  72100. * @returns the current updated Vector4
  72101. */
  72102. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72103. /**
  72104. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72105. * @param other defines the second operand
  72106. * @returns the current updated Vector4
  72107. */
  72108. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72109. /**
  72110. * Gets a new Vector4 from current Vector4 floored values
  72111. * @returns a new Vector4
  72112. */
  72113. floor(): Vector4;
  72114. /**
  72115. * Gets a new Vector4 from current Vector3 floored values
  72116. * @returns a new Vector4
  72117. */
  72118. fract(): Vector4;
  72119. /**
  72120. * Returns the Vector4 length (float).
  72121. * @returns the length
  72122. */
  72123. length(): number;
  72124. /**
  72125. * Returns the Vector4 squared length (float).
  72126. * @returns the length squared
  72127. */
  72128. lengthSquared(): number;
  72129. /**
  72130. * Normalizes in place the Vector4.
  72131. * @returns the updated Vector4.
  72132. */
  72133. normalize(): Vector4;
  72134. /**
  72135. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72136. * @returns this converted to a new vector3
  72137. */
  72138. toVector3(): Vector3;
  72139. /**
  72140. * Returns a new Vector4 copied from the current one.
  72141. * @returns the new cloned vector
  72142. */
  72143. clone(): Vector4;
  72144. /**
  72145. * Updates the current Vector4 with the given one coordinates.
  72146. * @param source the source vector to copy from
  72147. * @returns the updated Vector4.
  72148. */
  72149. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  72150. /**
  72151. * Updates the current Vector4 coordinates with the given floats.
  72152. * @param x float to copy from
  72153. * @param y float to copy from
  72154. * @param z float to copy from
  72155. * @param w float to copy from
  72156. * @returns the updated Vector4.
  72157. */
  72158. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72159. /**
  72160. * Updates the current Vector4 coordinates with the given floats.
  72161. * @param x float to set from
  72162. * @param y float to set from
  72163. * @param z float to set from
  72164. * @param w float to set from
  72165. * @returns the updated Vector4.
  72166. */
  72167. set(x: number, y: number, z: number, w: number): Vector4;
  72168. /**
  72169. * Copies the given float to the current Vector3 coordinates
  72170. * @param v defines the x, y, z and w coordinates of the operand
  72171. * @returns the current updated Vector3
  72172. */
  72173. setAll(v: number): Vector4;
  72174. /**
  72175. * Returns a new Vector4 set from the starting index of the given array.
  72176. * @param array the array to pull values from
  72177. * @param offset the offset into the array to start at
  72178. * @returns the new vector
  72179. */
  72180. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  72181. /**
  72182. * Updates the given vector "result" from the starting index of the given array.
  72183. * @param array the array to pull values from
  72184. * @param offset the offset into the array to start at
  72185. * @param result the vector to store the result in
  72186. */
  72187. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  72188. /**
  72189. * Updates the given vector "result" from the starting index of the given Float32Array.
  72190. * @param array the array to pull values from
  72191. * @param offset the offset into the array to start at
  72192. * @param result the vector to store the result in
  72193. */
  72194. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  72195. /**
  72196. * Updates the given vector "result" coordinates from the given floats.
  72197. * @param x float to set from
  72198. * @param y float to set from
  72199. * @param z float to set from
  72200. * @param w float to set from
  72201. * @param result the vector to the floats in
  72202. */
  72203. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  72204. /**
  72205. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72206. * @returns the new vector
  72207. */
  72208. static Zero(): Vector4;
  72209. /**
  72210. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72211. * @returns the new vector
  72212. */
  72213. static One(): Vector4;
  72214. /**
  72215. * Returns a new normalized Vector4 from the given one.
  72216. * @param vector the vector to normalize
  72217. * @returns the vector
  72218. */
  72219. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  72220. /**
  72221. * Updates the given vector "result" from the normalization of the given one.
  72222. * @param vector the vector to normalize
  72223. * @param result the vector to store the result in
  72224. */
  72225. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  72226. /**
  72227. * Returns a vector with the minimum values from the left and right vectors
  72228. * @param left left vector to minimize
  72229. * @param right right vector to minimize
  72230. * @returns a new vector with the minimum of the left and right vector values
  72231. */
  72232. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72233. /**
  72234. * Returns a vector with the maximum values from the left and right vectors
  72235. * @param left left vector to maximize
  72236. * @param right right vector to maximize
  72237. * @returns a new vector with the maximum of the left and right vector values
  72238. */
  72239. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72240. /**
  72241. * Returns the distance (float) between the vectors "value1" and "value2".
  72242. * @param value1 value to calulate the distance between
  72243. * @param value2 value to calulate the distance between
  72244. * @return the distance between the two vectors
  72245. */
  72246. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72247. /**
  72248. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72249. * @param value1 value to calulate the distance between
  72250. * @param value2 value to calulate the distance between
  72251. * @return the distance between the two vectors squared
  72252. */
  72253. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72254. /**
  72255. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72256. * @param value1 value to calulate the center between
  72257. * @param value2 value to calulate the center between
  72258. * @return the center between the two vectors
  72259. */
  72260. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  72261. /**
  72262. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72263. * This methods computes transformed normalized direction vectors only.
  72264. * @param vector the vector to transform
  72265. * @param transformation the transformation matrix to apply
  72266. * @returns the new vector
  72267. */
  72268. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  72269. /**
  72270. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72271. * This methods computes transformed normalized direction vectors only.
  72272. * @param vector the vector to transform
  72273. * @param transformation the transformation matrix to apply
  72274. * @param result the vector to store the result in
  72275. */
  72276. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72277. /**
  72278. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72279. * This methods computes transformed normalized direction vectors only.
  72280. * @param x value to transform
  72281. * @param y value to transform
  72282. * @param z value to transform
  72283. * @param w value to transform
  72284. * @param transformation the transformation matrix to apply
  72285. * @param result the vector to store the results in
  72286. */
  72287. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72288. /**
  72289. * Creates a new Vector4 from a Vector3
  72290. * @param source defines the source data
  72291. * @param w defines the 4th component (default is 0)
  72292. * @returns a new Vector4
  72293. */
  72294. static FromVector3(source: Vector3, w?: number): Vector4;
  72295. }
  72296. /**
  72297. * Class used to store quaternion data
  72298. * @see https://en.wikipedia.org/wiki/Quaternion
  72299. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  72300. */
  72301. export class Quaternion {
  72302. /** defines the first component (0 by default) */
  72303. x: number;
  72304. /** defines the second component (0 by default) */
  72305. y: number;
  72306. /** defines the third component (0 by default) */
  72307. z: number;
  72308. /** defines the fourth component (1.0 by default) */
  72309. w: number;
  72310. /**
  72311. * Creates a new Quaternion from the given floats
  72312. * @param x defines the first component (0 by default)
  72313. * @param y defines the second component (0 by default)
  72314. * @param z defines the third component (0 by default)
  72315. * @param w defines the fourth component (1.0 by default)
  72316. */
  72317. constructor(
  72318. /** defines the first component (0 by default) */
  72319. x?: number,
  72320. /** defines the second component (0 by default) */
  72321. y?: number,
  72322. /** defines the third component (0 by default) */
  72323. z?: number,
  72324. /** defines the fourth component (1.0 by default) */
  72325. w?: number);
  72326. /**
  72327. * Gets a string representation for the current quaternion
  72328. * @returns a string with the Quaternion coordinates
  72329. */
  72330. toString(): string;
  72331. /**
  72332. * Gets the class name of the quaternion
  72333. * @returns the string "Quaternion"
  72334. */
  72335. getClassName(): string;
  72336. /**
  72337. * Gets a hash code for this quaternion
  72338. * @returns the quaternion hash code
  72339. */
  72340. getHashCode(): number;
  72341. /**
  72342. * Copy the quaternion to an array
  72343. * @returns a new array populated with 4 elements from the quaternion coordinates
  72344. */
  72345. asArray(): number[];
  72346. /**
  72347. * Check if two quaternions are equals
  72348. * @param otherQuaternion defines the second operand
  72349. * @return true if the current quaternion and the given one coordinates are strictly equals
  72350. */
  72351. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  72352. /**
  72353. * Clone the current quaternion
  72354. * @returns a new quaternion copied from the current one
  72355. */
  72356. clone(): Quaternion;
  72357. /**
  72358. * Copy a quaternion to the current one
  72359. * @param other defines the other quaternion
  72360. * @returns the updated current quaternion
  72361. */
  72362. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  72363. /**
  72364. * Updates the current quaternion with the given float coordinates
  72365. * @param x defines the x coordinate
  72366. * @param y defines the y coordinate
  72367. * @param z defines the z coordinate
  72368. * @param w defines the w coordinate
  72369. * @returns the updated current quaternion
  72370. */
  72371. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  72372. /**
  72373. * Updates the current quaternion from the given float coordinates
  72374. * @param x defines the x coordinate
  72375. * @param y defines the y coordinate
  72376. * @param z defines the z coordinate
  72377. * @param w defines the w coordinate
  72378. * @returns the updated current quaternion
  72379. */
  72380. set(x: number, y: number, z: number, w: number): Quaternion;
  72381. /**
  72382. * Adds two quaternions
  72383. * @param other defines the second operand
  72384. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72385. */
  72386. add(other: DeepImmutable<Quaternion>): Quaternion;
  72387. /**
  72388. * Add a quaternion to the current one
  72389. * @param other defines the quaternion to add
  72390. * @returns the current quaternion
  72391. */
  72392. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  72393. /**
  72394. * Subtract two quaternions
  72395. * @param other defines the second operand
  72396. * @returns a new quaternion as the subtraction result of the given one from the current one
  72397. */
  72398. subtract(other: Quaternion): Quaternion;
  72399. /**
  72400. * Multiplies the current quaternion by a scale factor
  72401. * @param value defines the scale factor
  72402. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72403. */
  72404. scale(value: number): Quaternion;
  72405. /**
  72406. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72407. * @param scale defines the scale factor
  72408. * @param result defines the Quaternion object where to store the result
  72409. * @returns the unmodified current quaternion
  72410. */
  72411. scaleToRef(scale: number, result: Quaternion): Quaternion;
  72412. /**
  72413. * Multiplies in place the current quaternion by a scale factor
  72414. * @param value defines the scale factor
  72415. * @returns the current modified quaternion
  72416. */
  72417. scaleInPlace(value: number): Quaternion;
  72418. /**
  72419. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72420. * @param scale defines the scale factor
  72421. * @param result defines the Quaternion object where to store the result
  72422. * @returns the unmodified current quaternion
  72423. */
  72424. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  72425. /**
  72426. * Multiplies two quaternions
  72427. * @param q1 defines the second operand
  72428. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72429. */
  72430. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  72431. /**
  72432. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72433. * @param q1 defines the second operand
  72434. * @param result defines the target quaternion
  72435. * @returns the current quaternion
  72436. */
  72437. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  72438. /**
  72439. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72440. * @param q1 defines the second operand
  72441. * @returns the currentupdated quaternion
  72442. */
  72443. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  72444. /**
  72445. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72446. * @param ref defines the target quaternion
  72447. * @returns the current quaternion
  72448. */
  72449. conjugateToRef(ref: Quaternion): Quaternion;
  72450. /**
  72451. * Conjugates in place (1-q) the current quaternion
  72452. * @returns the current updated quaternion
  72453. */
  72454. conjugateInPlace(): Quaternion;
  72455. /**
  72456. * Conjugates in place (1-q) the current quaternion
  72457. * @returns a new quaternion
  72458. */
  72459. conjugate(): Quaternion;
  72460. /**
  72461. * Gets length of current quaternion
  72462. * @returns the quaternion length (float)
  72463. */
  72464. length(): number;
  72465. /**
  72466. * Normalize in place the current quaternion
  72467. * @returns the current updated quaternion
  72468. */
  72469. normalize(): Quaternion;
  72470. /**
  72471. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72472. * @param order is a reserved parameter and is ignore for now
  72473. * @returns a new Vector3 containing the Euler angles
  72474. */
  72475. toEulerAngles(order?: string): Vector3;
  72476. /**
  72477. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72478. * @param result defines the vector which will be filled with the Euler angles
  72479. * @param order is a reserved parameter and is ignore for now
  72480. * @returns the current unchanged quaternion
  72481. */
  72482. toEulerAnglesToRef(result: Vector3): Quaternion;
  72483. /**
  72484. * Updates the given rotation matrix with the current quaternion values
  72485. * @param result defines the target matrix
  72486. * @returns the current unchanged quaternion
  72487. */
  72488. toRotationMatrix(result: Matrix): Quaternion;
  72489. /**
  72490. * Updates the current quaternion from the given rotation matrix values
  72491. * @param matrix defines the source matrix
  72492. * @returns the current updated quaternion
  72493. */
  72494. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72495. /**
  72496. * Creates a new quaternion from a rotation matrix
  72497. * @param matrix defines the source matrix
  72498. * @returns a new quaternion created from the given rotation matrix values
  72499. */
  72500. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72501. /**
  72502. * Updates the given quaternion with the given rotation matrix values
  72503. * @param matrix defines the source matrix
  72504. * @param result defines the target quaternion
  72505. */
  72506. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  72507. /**
  72508. * Returns the dot product (float) between the quaternions "left" and "right"
  72509. * @param left defines the left operand
  72510. * @param right defines the right operand
  72511. * @returns the dot product
  72512. */
  72513. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  72514. /**
  72515. * Checks if the two quaternions are close to each other
  72516. * @param quat0 defines the first quaternion to check
  72517. * @param quat1 defines the second quaternion to check
  72518. * @returns true if the two quaternions are close to each other
  72519. */
  72520. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  72521. /**
  72522. * Creates an empty quaternion
  72523. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72524. */
  72525. static Zero(): Quaternion;
  72526. /**
  72527. * Inverse a given quaternion
  72528. * @param q defines the source quaternion
  72529. * @returns a new quaternion as the inverted current quaternion
  72530. */
  72531. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  72532. /**
  72533. * Inverse a given quaternion
  72534. * @param q defines the source quaternion
  72535. * @param result the quaternion the result will be stored in
  72536. * @returns the result quaternion
  72537. */
  72538. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  72539. /**
  72540. * Creates an identity quaternion
  72541. * @returns the identity quaternion
  72542. */
  72543. static Identity(): Quaternion;
  72544. /**
  72545. * Gets a boolean indicating if the given quaternion is identity
  72546. * @param quaternion defines the quaternion to check
  72547. * @returns true if the quaternion is identity
  72548. */
  72549. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  72550. /**
  72551. * Creates a quaternion from a rotation around an axis
  72552. * @param axis defines the axis to use
  72553. * @param angle defines the angle to use
  72554. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72555. */
  72556. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  72557. /**
  72558. * Creates a rotation around an axis and stores it into the given quaternion
  72559. * @param axis defines the axis to use
  72560. * @param angle defines the angle to use
  72561. * @param result defines the target quaternion
  72562. * @returns the target quaternion
  72563. */
  72564. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  72565. /**
  72566. * Creates a new quaternion from data stored into an array
  72567. * @param array defines the data source
  72568. * @param offset defines the offset in the source array where the data starts
  72569. * @returns a new quaternion
  72570. */
  72571. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  72572. /**
  72573. * Create a quaternion from Euler rotation angles
  72574. * @param x Pitch
  72575. * @param y Yaw
  72576. * @param z Roll
  72577. * @returns the new Quaternion
  72578. */
  72579. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  72580. /**
  72581. * Updates a quaternion from Euler rotation angles
  72582. * @param x Pitch
  72583. * @param y Yaw
  72584. * @param z Roll
  72585. * @param result the quaternion to store the result
  72586. * @returns the updated quaternion
  72587. */
  72588. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  72589. /**
  72590. * Create a quaternion from Euler rotation vector
  72591. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72592. * @returns the new Quaternion
  72593. */
  72594. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  72595. /**
  72596. * Updates a quaternion from Euler rotation vector
  72597. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72598. * @param result the quaternion to store the result
  72599. * @returns the updated quaternion
  72600. */
  72601. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  72602. /**
  72603. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72604. * @param yaw defines the rotation around Y axis
  72605. * @param pitch defines the rotation around X axis
  72606. * @param roll defines the rotation around Z axis
  72607. * @returns the new quaternion
  72608. */
  72609. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  72610. /**
  72611. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72612. * @param yaw defines the rotation around Y axis
  72613. * @param pitch defines the rotation around X axis
  72614. * @param roll defines the rotation around Z axis
  72615. * @param result defines the target quaternion
  72616. */
  72617. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72618. /**
  72619. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72620. * @param alpha defines the rotation around first axis
  72621. * @param beta defines the rotation around second axis
  72622. * @param gamma defines the rotation around third axis
  72623. * @returns the new quaternion
  72624. */
  72625. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  72626. /**
  72627. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72628. * @param alpha defines the rotation around first axis
  72629. * @param beta defines the rotation around second axis
  72630. * @param gamma defines the rotation around third axis
  72631. * @param result defines the target quaternion
  72632. */
  72633. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  72634. /**
  72635. * 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)
  72636. * @param axis1 defines the first axis
  72637. * @param axis2 defines the second axis
  72638. * @param axis3 defines the third axis
  72639. * @returns the new quaternion
  72640. */
  72641. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  72642. /**
  72643. * 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
  72644. * @param axis1 defines the first axis
  72645. * @param axis2 defines the second axis
  72646. * @param axis3 defines the third axis
  72647. * @param ref defines the target quaternion
  72648. */
  72649. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  72650. /**
  72651. * Interpolates between two quaternions
  72652. * @param left defines first quaternion
  72653. * @param right defines second quaternion
  72654. * @param amount defines the gradient to use
  72655. * @returns the new interpolated quaternion
  72656. */
  72657. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72658. /**
  72659. * Interpolates between two quaternions and stores it into a target quaternion
  72660. * @param left defines first quaternion
  72661. * @param right defines second quaternion
  72662. * @param amount defines the gradient to use
  72663. * @param result defines the target quaternion
  72664. */
  72665. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  72666. /**
  72667. * Interpolate between two quaternions using Hermite interpolation
  72668. * @param value1 defines first quaternion
  72669. * @param tangent1 defines the incoming tangent
  72670. * @param value2 defines second quaternion
  72671. * @param tangent2 defines the outgoing tangent
  72672. * @param amount defines the target quaternion
  72673. * @returns the new interpolated quaternion
  72674. */
  72675. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72676. }
  72677. /**
  72678. * Class used to store matrix data (4x4)
  72679. */
  72680. export class Matrix {
  72681. private static _updateFlagSeed;
  72682. private static _identityReadOnly;
  72683. private _isIdentity;
  72684. private _isIdentityDirty;
  72685. private _isIdentity3x2;
  72686. private _isIdentity3x2Dirty;
  72687. /**
  72688. * Gets the update flag of the matrix which is an unique number for the matrix.
  72689. * It will be incremented every time the matrix data change.
  72690. * You can use it to speed the comparison between two versions of the same matrix.
  72691. */
  72692. updateFlag: number;
  72693. private readonly _m;
  72694. /**
  72695. * Gets the internal data of the matrix
  72696. */
  72697. readonly m: DeepImmutable<Float32Array>;
  72698. /** @hidden */
  72699. _markAsUpdated(): void;
  72700. /** @hidden */
  72701. private _updateIdentityStatus;
  72702. /**
  72703. * Creates an empty matrix (filled with zeros)
  72704. */
  72705. constructor();
  72706. /**
  72707. * Check if the current matrix is identity
  72708. * @returns true is the matrix is the identity matrix
  72709. */
  72710. isIdentity(): boolean;
  72711. /**
  72712. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72713. * @returns true is the matrix is the identity matrix
  72714. */
  72715. isIdentityAs3x2(): boolean;
  72716. /**
  72717. * Gets the determinant of the matrix
  72718. * @returns the matrix determinant
  72719. */
  72720. determinant(): number;
  72721. /**
  72722. * Returns the matrix as a Float32Array
  72723. * @returns the matrix underlying array
  72724. */
  72725. toArray(): DeepImmutable<Float32Array>;
  72726. /**
  72727. * Returns the matrix as a Float32Array
  72728. * @returns the matrix underlying array.
  72729. */
  72730. asArray(): DeepImmutable<Float32Array>;
  72731. /**
  72732. * Inverts the current matrix in place
  72733. * @returns the current inverted matrix
  72734. */
  72735. invert(): Matrix;
  72736. /**
  72737. * Sets all the matrix elements to zero
  72738. * @returns the current matrix
  72739. */
  72740. reset(): Matrix;
  72741. /**
  72742. * Adds the current matrix with a second one
  72743. * @param other defines the matrix to add
  72744. * @returns a new matrix as the addition of the current matrix and the given one
  72745. */
  72746. add(other: DeepImmutable<Matrix>): Matrix;
  72747. /**
  72748. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72749. * @param other defines the matrix to add
  72750. * @param result defines the target matrix
  72751. * @returns the current matrix
  72752. */
  72753. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72754. /**
  72755. * Adds in place the given matrix to the current matrix
  72756. * @param other defines the second operand
  72757. * @returns the current updated matrix
  72758. */
  72759. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72760. /**
  72761. * Sets the given matrix to the current inverted Matrix
  72762. * @param other defines the target matrix
  72763. * @returns the unmodified current matrix
  72764. */
  72765. invertToRef(other: Matrix): Matrix;
  72766. /**
  72767. * add a value at the specified position in the current Matrix
  72768. * @param index the index of the value within the matrix. between 0 and 15.
  72769. * @param value the value to be added
  72770. * @returns the current updated matrix
  72771. */
  72772. addAtIndex(index: number, value: number): Matrix;
  72773. /**
  72774. * mutiply the specified position in the current Matrix by a value
  72775. * @param index the index of the value within the matrix. between 0 and 15.
  72776. * @param value the value to be added
  72777. * @returns the current updated matrix
  72778. */
  72779. multiplyAtIndex(index: number, value: number): Matrix;
  72780. /**
  72781. * Inserts the translation vector (using 3 floats) in the current matrix
  72782. * @param x defines the 1st component of the translation
  72783. * @param y defines the 2nd component of the translation
  72784. * @param z defines the 3rd component of the translation
  72785. * @returns the current updated matrix
  72786. */
  72787. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72788. /**
  72789. * Adds the translation vector (using 3 floats) in the current matrix
  72790. * @param x defines the 1st component of the translation
  72791. * @param y defines the 2nd component of the translation
  72792. * @param z defines the 3rd component of the translation
  72793. * @returns the current updated matrix
  72794. */
  72795. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72796. /**
  72797. * Inserts the translation vector in the current matrix
  72798. * @param vector3 defines the translation to insert
  72799. * @returns the current updated matrix
  72800. */
  72801. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72802. /**
  72803. * Gets the translation value of the current matrix
  72804. * @returns a new Vector3 as the extracted translation from the matrix
  72805. */
  72806. getTranslation(): Vector3;
  72807. /**
  72808. * Fill a Vector3 with the extracted translation from the matrix
  72809. * @param result defines the Vector3 where to store the translation
  72810. * @returns the current matrix
  72811. */
  72812. getTranslationToRef(result: Vector3): Matrix;
  72813. /**
  72814. * Remove rotation and scaling part from the matrix
  72815. * @returns the updated matrix
  72816. */
  72817. removeRotationAndScaling(): Matrix;
  72818. /**
  72819. * Multiply two matrices
  72820. * @param other defines the second operand
  72821. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72822. */
  72823. multiply(other: DeepImmutable<Matrix>): Matrix;
  72824. /**
  72825. * Copy the current matrix from the given one
  72826. * @param other defines the source matrix
  72827. * @returns the current updated matrix
  72828. */
  72829. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72830. /**
  72831. * Populates the given array from the starting index with the current matrix values
  72832. * @param array defines the target array
  72833. * @param offset defines the offset in the target array where to start storing values
  72834. * @returns the current matrix
  72835. */
  72836. copyToArray(array: Float32Array, offset?: number): Matrix;
  72837. /**
  72838. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72839. * @param other defines the second operand
  72840. * @param result defines the matrix where to store the multiplication
  72841. * @returns the current matrix
  72842. */
  72843. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72844. /**
  72845. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72846. * @param other defines the second operand
  72847. * @param result defines the array where to store the multiplication
  72848. * @param offset defines the offset in the target array where to start storing values
  72849. * @returns the current matrix
  72850. */
  72851. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72852. /**
  72853. * Check equality between this matrix and a second one
  72854. * @param value defines the second matrix to compare
  72855. * @returns true is the current matrix and the given one values are strictly equal
  72856. */
  72857. equals(value: DeepImmutable<Matrix>): boolean;
  72858. /**
  72859. * Clone the current matrix
  72860. * @returns a new matrix from the current matrix
  72861. */
  72862. clone(): Matrix;
  72863. /**
  72864. * Returns the name of the current matrix class
  72865. * @returns the string "Matrix"
  72866. */
  72867. getClassName(): string;
  72868. /**
  72869. * Gets the hash code of the current matrix
  72870. * @returns the hash code
  72871. */
  72872. getHashCode(): number;
  72873. /**
  72874. * Decomposes the current Matrix into a translation, rotation and scaling components
  72875. * @param scale defines the scale vector3 given as a reference to update
  72876. * @param rotation defines the rotation quaternion given as a reference to update
  72877. * @param translation defines the translation vector3 given as a reference to update
  72878. * @returns true if operation was successful
  72879. */
  72880. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72881. /**
  72882. * Gets specific row of the matrix
  72883. * @param index defines the number of the row to get
  72884. * @returns the index-th row of the current matrix as a new Vector4
  72885. */
  72886. getRow(index: number): Nullable<Vector4>;
  72887. /**
  72888. * Sets the index-th row of the current matrix to the vector4 values
  72889. * @param index defines the number of the row to set
  72890. * @param row defines the target vector4
  72891. * @returns the updated current matrix
  72892. */
  72893. setRow(index: number, row: Vector4): Matrix;
  72894. /**
  72895. * Compute the transpose of the matrix
  72896. * @returns the new transposed matrix
  72897. */
  72898. transpose(): Matrix;
  72899. /**
  72900. * Compute the transpose of the matrix and store it in a given matrix
  72901. * @param result defines the target matrix
  72902. * @returns the current matrix
  72903. */
  72904. transposeToRef(result: Matrix): Matrix;
  72905. /**
  72906. * Sets the index-th row of the current matrix with the given 4 x float values
  72907. * @param index defines the row index
  72908. * @param x defines the x component to set
  72909. * @param y defines the y component to set
  72910. * @param z defines the z component to set
  72911. * @param w defines the w component to set
  72912. * @returns the updated current matrix
  72913. */
  72914. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72915. /**
  72916. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72917. * @param scale defines the scale factor
  72918. * @returns a new matrix
  72919. */
  72920. scale(scale: number): Matrix;
  72921. /**
  72922. * Scale the current matrix values by a factor to a given result matrix
  72923. * @param scale defines the scale factor
  72924. * @param result defines the matrix to store the result
  72925. * @returns the current matrix
  72926. */
  72927. scaleToRef(scale: number, result: Matrix): Matrix;
  72928. /**
  72929. * Scale the current matrix values by a factor and add the result to a given matrix
  72930. * @param scale defines the scale factor
  72931. * @param result defines the Matrix to store the result
  72932. * @returns the current matrix
  72933. */
  72934. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72935. /**
  72936. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72937. * @param ref matrix to store the result
  72938. */
  72939. toNormalMatrix(ref: Matrix): void;
  72940. /**
  72941. * Gets only rotation part of the current matrix
  72942. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72943. */
  72944. getRotationMatrix(): Matrix;
  72945. /**
  72946. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72947. * @param result defines the target matrix to store data to
  72948. * @returns the current matrix
  72949. */
  72950. getRotationMatrixToRef(result: Matrix): Matrix;
  72951. /**
  72952. * Toggles model matrix from being right handed to left handed in place and vice versa
  72953. */
  72954. toggleModelMatrixHandInPlace(): void;
  72955. /**
  72956. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72957. */
  72958. toggleProjectionMatrixHandInPlace(): void;
  72959. /**
  72960. * Creates a matrix from an array
  72961. * @param array defines the source array
  72962. * @param offset defines an offset in the source array
  72963. * @returns a new Matrix set from the starting index of the given array
  72964. */
  72965. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72966. /**
  72967. * Copy the content of an array into a given matrix
  72968. * @param array defines the source array
  72969. * @param offset defines an offset in the source array
  72970. * @param result defines the target matrix
  72971. */
  72972. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72973. /**
  72974. * Stores an array into a matrix after having multiplied each component by a given factor
  72975. * @param array defines the source array
  72976. * @param offset defines the offset in the source array
  72977. * @param scale defines the scaling factor
  72978. * @param result defines the target matrix
  72979. */
  72980. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72981. /**
  72982. * Gets an identity matrix that must not be updated
  72983. */
  72984. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72985. /**
  72986. * Stores a list of values (16) inside a given matrix
  72987. * @param initialM11 defines 1st value of 1st row
  72988. * @param initialM12 defines 2nd value of 1st row
  72989. * @param initialM13 defines 3rd value of 1st row
  72990. * @param initialM14 defines 4th value of 1st row
  72991. * @param initialM21 defines 1st value of 2nd row
  72992. * @param initialM22 defines 2nd value of 2nd row
  72993. * @param initialM23 defines 3rd value of 2nd row
  72994. * @param initialM24 defines 4th value of 2nd row
  72995. * @param initialM31 defines 1st value of 3rd row
  72996. * @param initialM32 defines 2nd value of 3rd row
  72997. * @param initialM33 defines 3rd value of 3rd row
  72998. * @param initialM34 defines 4th value of 3rd row
  72999. * @param initialM41 defines 1st value of 4th row
  73000. * @param initialM42 defines 2nd value of 4th row
  73001. * @param initialM43 defines 3rd value of 4th row
  73002. * @param initialM44 defines 4th value of 4th row
  73003. * @param result defines the target matrix
  73004. */
  73005. 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;
  73006. /**
  73007. * Creates new matrix from a list of values (16)
  73008. * @param initialM11 defines 1st value of 1st row
  73009. * @param initialM12 defines 2nd value of 1st row
  73010. * @param initialM13 defines 3rd value of 1st row
  73011. * @param initialM14 defines 4th value of 1st row
  73012. * @param initialM21 defines 1st value of 2nd row
  73013. * @param initialM22 defines 2nd value of 2nd row
  73014. * @param initialM23 defines 3rd value of 2nd row
  73015. * @param initialM24 defines 4th value of 2nd row
  73016. * @param initialM31 defines 1st value of 3rd row
  73017. * @param initialM32 defines 2nd value of 3rd row
  73018. * @param initialM33 defines 3rd value of 3rd row
  73019. * @param initialM34 defines 4th value of 3rd row
  73020. * @param initialM41 defines 1st value of 4th row
  73021. * @param initialM42 defines 2nd value of 4th row
  73022. * @param initialM43 defines 3rd value of 4th row
  73023. * @param initialM44 defines 4th value of 4th row
  73024. * @returns the new matrix
  73025. */
  73026. 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;
  73027. /**
  73028. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73029. * @param scale defines the scale vector3
  73030. * @param rotation defines the rotation quaternion
  73031. * @param translation defines the translation vector3
  73032. * @returns a new matrix
  73033. */
  73034. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  73035. /**
  73036. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73037. * @param scale defines the scale vector3
  73038. * @param rotation defines the rotation quaternion
  73039. * @param translation defines the translation vector3
  73040. * @param result defines the target matrix
  73041. */
  73042. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  73043. /**
  73044. * Creates a new identity matrix
  73045. * @returns a new identity matrix
  73046. */
  73047. static Identity(): Matrix;
  73048. /**
  73049. * Creates a new identity matrix and stores the result in a given matrix
  73050. * @param result defines the target matrix
  73051. */
  73052. static IdentityToRef(result: Matrix): void;
  73053. /**
  73054. * Creates a new zero matrix
  73055. * @returns a new zero matrix
  73056. */
  73057. static Zero(): Matrix;
  73058. /**
  73059. * Creates a new rotation matrix for "angle" radians around the X axis
  73060. * @param angle defines the angle (in radians) to use
  73061. * @return the new matrix
  73062. */
  73063. static RotationX(angle: number): Matrix;
  73064. /**
  73065. * Creates a new matrix as the invert of a given matrix
  73066. * @param source defines the source matrix
  73067. * @returns the new matrix
  73068. */
  73069. static Invert(source: DeepImmutable<Matrix>): Matrix;
  73070. /**
  73071. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  73072. * @param angle defines the angle (in radians) to use
  73073. * @param result defines the target matrix
  73074. */
  73075. static RotationXToRef(angle: number, result: Matrix): void;
  73076. /**
  73077. * Creates a new rotation matrix for "angle" radians around the Y axis
  73078. * @param angle defines the angle (in radians) to use
  73079. * @return the new matrix
  73080. */
  73081. static RotationY(angle: number): Matrix;
  73082. /**
  73083. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  73084. * @param angle defines the angle (in radians) to use
  73085. * @param result defines the target matrix
  73086. */
  73087. static RotationYToRef(angle: number, result: Matrix): void;
  73088. /**
  73089. * Creates a new rotation matrix for "angle" radians around the Z axis
  73090. * @param angle defines the angle (in radians) to use
  73091. * @return the new matrix
  73092. */
  73093. static RotationZ(angle: number): Matrix;
  73094. /**
  73095. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  73096. * @param angle defines the angle (in radians) to use
  73097. * @param result defines the target matrix
  73098. */
  73099. static RotationZToRef(angle: number, result: Matrix): void;
  73100. /**
  73101. * Creates a new rotation matrix for "angle" radians around the given axis
  73102. * @param axis defines the axis to use
  73103. * @param angle defines the angle (in radians) to use
  73104. * @return the new matrix
  73105. */
  73106. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  73107. /**
  73108. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  73109. * @param axis defines the axis to use
  73110. * @param angle defines the angle (in radians) to use
  73111. * @param result defines the target matrix
  73112. */
  73113. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  73114. /**
  73115. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  73116. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  73117. * @param from defines the vector to align
  73118. * @param to defines the vector to align to
  73119. * @param result defines the target matrix
  73120. */
  73121. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  73122. /**
  73123. * Creates a rotation matrix
  73124. * @param yaw defines the yaw angle in radians (Y axis)
  73125. * @param pitch defines the pitch angle in radians (X axis)
  73126. * @param roll defines the roll angle in radians (X axis)
  73127. * @returns the new rotation matrix
  73128. */
  73129. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  73130. /**
  73131. * Creates a rotation matrix and stores it in a given matrix
  73132. * @param yaw defines the yaw angle in radians (Y axis)
  73133. * @param pitch defines the pitch angle in radians (X axis)
  73134. * @param roll defines the roll angle in radians (X axis)
  73135. * @param result defines the target matrix
  73136. */
  73137. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  73138. /**
  73139. * Creates a scaling matrix
  73140. * @param x defines the scale factor on X axis
  73141. * @param y defines the scale factor on Y axis
  73142. * @param z defines the scale factor on Z axis
  73143. * @returns the new matrix
  73144. */
  73145. static Scaling(x: number, y: number, z: number): Matrix;
  73146. /**
  73147. * Creates a scaling matrix and stores it in a given matrix
  73148. * @param x defines the scale factor on X axis
  73149. * @param y defines the scale factor on Y axis
  73150. * @param z defines the scale factor on Z axis
  73151. * @param result defines the target matrix
  73152. */
  73153. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  73154. /**
  73155. * Creates a translation matrix
  73156. * @param x defines the translation on X axis
  73157. * @param y defines the translation on Y axis
  73158. * @param z defines the translationon Z axis
  73159. * @returns the new matrix
  73160. */
  73161. static Translation(x: number, y: number, z: number): Matrix;
  73162. /**
  73163. * Creates a translation matrix and stores it in a given matrix
  73164. * @param x defines the translation on X axis
  73165. * @param y defines the translation on Y axis
  73166. * @param z defines the translationon Z axis
  73167. * @param result defines the target matrix
  73168. */
  73169. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  73170. /**
  73171. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73172. * @param startValue defines the start value
  73173. * @param endValue defines the end value
  73174. * @param gradient defines the gradient factor
  73175. * @returns the new matrix
  73176. */
  73177. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73178. /**
  73179. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73180. * @param startValue defines the start value
  73181. * @param endValue defines the end value
  73182. * @param gradient defines the gradient factor
  73183. * @param result defines the Matrix object where to store data
  73184. */
  73185. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73186. /**
  73187. * Builds a new matrix whose values are computed by:
  73188. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73189. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73190. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73191. * @param startValue defines the first matrix
  73192. * @param endValue defines the second matrix
  73193. * @param gradient defines the gradient between the two matrices
  73194. * @returns the new matrix
  73195. */
  73196. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73197. /**
  73198. * Update a matrix to values which are computed by:
  73199. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73200. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73201. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73202. * @param startValue defines the first matrix
  73203. * @param endValue defines the second matrix
  73204. * @param gradient defines the gradient between the two matrices
  73205. * @param result defines the target matrix
  73206. */
  73207. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73208. /**
  73209. * 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"
  73210. * This function works in left handed mode
  73211. * @param eye defines the final position of the entity
  73212. * @param target defines where the entity should look at
  73213. * @param up defines the up vector for the entity
  73214. * @returns the new matrix
  73215. */
  73216. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73217. /**
  73218. * 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".
  73219. * This function works in left handed mode
  73220. * @param eye defines the final position of the entity
  73221. * @param target defines where the entity should look at
  73222. * @param up defines the up vector for the entity
  73223. * @param result defines the target matrix
  73224. */
  73225. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73226. /**
  73227. * 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"
  73228. * This function works in right handed mode
  73229. * @param eye defines the final position of the entity
  73230. * @param target defines where the entity should look at
  73231. * @param up defines the up vector for the entity
  73232. * @returns the new matrix
  73233. */
  73234. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73235. /**
  73236. * 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".
  73237. * This function works in right handed mode
  73238. * @param eye defines the final position of the entity
  73239. * @param target defines where the entity should look at
  73240. * @param up defines the up vector for the entity
  73241. * @param result defines the target matrix
  73242. */
  73243. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73244. /**
  73245. * Create a left-handed orthographic projection matrix
  73246. * @param width defines the viewport width
  73247. * @param height defines the viewport height
  73248. * @param znear defines the near clip plane
  73249. * @param zfar defines the far clip plane
  73250. * @returns a new matrix as a left-handed orthographic projection matrix
  73251. */
  73252. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73253. /**
  73254. * Store a left-handed orthographic projection to a given matrix
  73255. * @param width defines the viewport width
  73256. * @param height defines the viewport height
  73257. * @param znear defines the near clip plane
  73258. * @param zfar defines the far clip plane
  73259. * @param result defines the target matrix
  73260. */
  73261. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  73262. /**
  73263. * Create a left-handed orthographic projection matrix
  73264. * @param left defines the viewport left coordinate
  73265. * @param right defines the viewport right coordinate
  73266. * @param bottom defines the viewport bottom coordinate
  73267. * @param top defines the viewport top coordinate
  73268. * @param znear defines the near clip plane
  73269. * @param zfar defines the far clip plane
  73270. * @returns a new matrix as a left-handed orthographic projection matrix
  73271. */
  73272. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73273. /**
  73274. * Stores a left-handed orthographic projection into a given matrix
  73275. * @param left defines the viewport left coordinate
  73276. * @param right defines the viewport right coordinate
  73277. * @param bottom defines the viewport bottom coordinate
  73278. * @param top defines the viewport top coordinate
  73279. * @param znear defines the near clip plane
  73280. * @param zfar defines the far clip plane
  73281. * @param result defines the target matrix
  73282. */
  73283. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73284. /**
  73285. * Creates a right-handed orthographic projection matrix
  73286. * @param left defines the viewport left coordinate
  73287. * @param right defines the viewport right coordinate
  73288. * @param bottom defines the viewport bottom coordinate
  73289. * @param top defines the viewport top coordinate
  73290. * @param znear defines the near clip plane
  73291. * @param zfar defines the far clip plane
  73292. * @returns a new matrix as a right-handed orthographic projection matrix
  73293. */
  73294. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73295. /**
  73296. * Stores a right-handed orthographic projection into a given matrix
  73297. * @param left defines the viewport left coordinate
  73298. * @param right defines the viewport right coordinate
  73299. * @param bottom defines the viewport bottom coordinate
  73300. * @param top defines the viewport top coordinate
  73301. * @param znear defines the near clip plane
  73302. * @param zfar defines the far clip plane
  73303. * @param result defines the target matrix
  73304. */
  73305. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73306. /**
  73307. * Creates a left-handed perspective projection matrix
  73308. * @param width defines the viewport width
  73309. * @param height defines the viewport height
  73310. * @param znear defines the near clip plane
  73311. * @param zfar defines the far clip plane
  73312. * @returns a new matrix as a left-handed perspective projection matrix
  73313. */
  73314. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73315. /**
  73316. * Creates a left-handed perspective projection matrix
  73317. * @param fov defines the horizontal field of view
  73318. * @param aspect defines the aspect ratio
  73319. * @param znear defines the near clip plane
  73320. * @param zfar defines the far clip plane
  73321. * @returns a new matrix as a left-handed perspective projection matrix
  73322. */
  73323. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73324. /**
  73325. * Stores a left-handed perspective projection into a given matrix
  73326. * @param fov defines the horizontal field of view
  73327. * @param aspect defines the aspect ratio
  73328. * @param znear defines the near clip plane
  73329. * @param zfar defines the far clip plane
  73330. * @param result defines the target matrix
  73331. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73332. */
  73333. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73334. /**
  73335. * Stores a left-handed perspective projection into a given matrix with depth reversed
  73336. * @param fov defines the horizontal field of view
  73337. * @param aspect defines the aspect ratio
  73338. * @param znear defines the near clip plane
  73339. * @param zfar not used as infinity is used as far clip
  73340. * @param result defines the target matrix
  73341. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73342. */
  73343. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73344. /**
  73345. * Creates a right-handed perspective projection matrix
  73346. * @param fov defines the horizontal field of view
  73347. * @param aspect defines the aspect ratio
  73348. * @param znear defines the near clip plane
  73349. * @param zfar defines the far clip plane
  73350. * @returns a new matrix as a right-handed perspective projection matrix
  73351. */
  73352. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73353. /**
  73354. * Stores a right-handed perspective projection into a given matrix
  73355. * @param fov defines the horizontal field of view
  73356. * @param aspect defines the aspect ratio
  73357. * @param znear defines the near clip plane
  73358. * @param zfar defines the far clip plane
  73359. * @param result defines the target matrix
  73360. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73361. */
  73362. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73363. /**
  73364. * Stores a right-handed perspective projection into a given matrix
  73365. * @param fov defines the horizontal field of view
  73366. * @param aspect defines the aspect ratio
  73367. * @param znear defines the near clip plane
  73368. * @param zfar not used as infinity is used as far clip
  73369. * @param result defines the target matrix
  73370. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73371. */
  73372. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73373. /**
  73374. * Stores a perspective projection for WebVR info a given matrix
  73375. * @param fov defines the field of view
  73376. * @param znear defines the near clip plane
  73377. * @param zfar defines the far clip plane
  73378. * @param result defines the target matrix
  73379. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73380. */
  73381. static PerspectiveFovWebVRToRef(fov: {
  73382. upDegrees: number;
  73383. downDegrees: number;
  73384. leftDegrees: number;
  73385. rightDegrees: number;
  73386. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  73387. /**
  73388. * Computes a complete transformation matrix
  73389. * @param viewport defines the viewport to use
  73390. * @param world defines the world matrix
  73391. * @param view defines the view matrix
  73392. * @param projection defines the projection matrix
  73393. * @param zmin defines the near clip plane
  73394. * @param zmax defines the far clip plane
  73395. * @returns the transformation matrix
  73396. */
  73397. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  73398. /**
  73399. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73400. * @param matrix defines the matrix to use
  73401. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73402. */
  73403. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  73404. /**
  73405. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73406. * @param matrix defines the matrix to use
  73407. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73408. */
  73409. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  73410. /**
  73411. * Compute the transpose of a given matrix
  73412. * @param matrix defines the matrix to transpose
  73413. * @returns the new matrix
  73414. */
  73415. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  73416. /**
  73417. * Compute the transpose of a matrix and store it in a target matrix
  73418. * @param matrix defines the matrix to transpose
  73419. * @param result defines the target matrix
  73420. */
  73421. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  73422. /**
  73423. * Computes a reflection matrix from a plane
  73424. * @param plane defines the reflection plane
  73425. * @returns a new matrix
  73426. */
  73427. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  73428. /**
  73429. * Computes a reflection matrix from a plane
  73430. * @param plane defines the reflection plane
  73431. * @param result defines the target matrix
  73432. */
  73433. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  73434. /**
  73435. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73436. * @param xaxis defines the value of the 1st axis
  73437. * @param yaxis defines the value of the 2nd axis
  73438. * @param zaxis defines the value of the 3rd axis
  73439. * @param result defines the target matrix
  73440. */
  73441. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  73442. /**
  73443. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73444. * @param quat defines the quaternion to use
  73445. * @param result defines the target matrix
  73446. */
  73447. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  73448. }
  73449. /**
  73450. * @hidden
  73451. */
  73452. export class TmpVectors {
  73453. static Vector2: Vector2[];
  73454. static Vector3: Vector3[];
  73455. static Vector4: Vector4[];
  73456. static Quaternion: Quaternion[];
  73457. static Matrix: Matrix[];
  73458. }
  73459. }
  73460. declare module BABYLON {
  73461. /**
  73462. * Defines potential orientation for back face culling
  73463. */
  73464. export enum Orientation {
  73465. /**
  73466. * Clockwise
  73467. */
  73468. CW = 0,
  73469. /** Counter clockwise */
  73470. CCW = 1
  73471. }
  73472. /** Class used to represent a Bezier curve */
  73473. export class BezierCurve {
  73474. /**
  73475. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73476. * @param t defines the time
  73477. * @param x1 defines the left coordinate on X axis
  73478. * @param y1 defines the left coordinate on Y axis
  73479. * @param x2 defines the right coordinate on X axis
  73480. * @param y2 defines the right coordinate on Y axis
  73481. * @returns the interpolated value
  73482. */
  73483. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  73484. }
  73485. /**
  73486. * Defines angle representation
  73487. */
  73488. export class Angle {
  73489. private _radians;
  73490. /**
  73491. * Creates an Angle object of "radians" radians (float).
  73492. * @param radians the angle in radians
  73493. */
  73494. constructor(radians: number);
  73495. /**
  73496. * Get value in degrees
  73497. * @returns the Angle value in degrees (float)
  73498. */
  73499. degrees(): number;
  73500. /**
  73501. * Get value in radians
  73502. * @returns the Angle value in radians (float)
  73503. */
  73504. radians(): number;
  73505. /**
  73506. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73507. * @param a defines first vector
  73508. * @param b defines second vector
  73509. * @returns a new Angle
  73510. */
  73511. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  73512. /**
  73513. * Gets a new Angle object from the given float in radians
  73514. * @param radians defines the angle value in radians
  73515. * @returns a new Angle
  73516. */
  73517. static FromRadians(radians: number): Angle;
  73518. /**
  73519. * Gets a new Angle object from the given float in degrees
  73520. * @param degrees defines the angle value in degrees
  73521. * @returns a new Angle
  73522. */
  73523. static FromDegrees(degrees: number): Angle;
  73524. }
  73525. /**
  73526. * This represents an arc in a 2d space.
  73527. */
  73528. export class Arc2 {
  73529. /** Defines the start point of the arc */
  73530. startPoint: Vector2;
  73531. /** Defines the mid point of the arc */
  73532. midPoint: Vector2;
  73533. /** Defines the end point of the arc */
  73534. endPoint: Vector2;
  73535. /**
  73536. * Defines the center point of the arc.
  73537. */
  73538. centerPoint: Vector2;
  73539. /**
  73540. * Defines the radius of the arc.
  73541. */
  73542. radius: number;
  73543. /**
  73544. * Defines the angle of the arc (from mid point to end point).
  73545. */
  73546. angle: Angle;
  73547. /**
  73548. * Defines the start angle of the arc (from start point to middle point).
  73549. */
  73550. startAngle: Angle;
  73551. /**
  73552. * Defines the orientation of the arc (clock wise/counter clock wise).
  73553. */
  73554. orientation: Orientation;
  73555. /**
  73556. * Creates an Arc object from the three given points : start, middle and end.
  73557. * @param startPoint Defines the start point of the arc
  73558. * @param midPoint Defines the midlle point of the arc
  73559. * @param endPoint Defines the end point of the arc
  73560. */
  73561. constructor(
  73562. /** Defines the start point of the arc */
  73563. startPoint: Vector2,
  73564. /** Defines the mid point of the arc */
  73565. midPoint: Vector2,
  73566. /** Defines the end point of the arc */
  73567. endPoint: Vector2);
  73568. }
  73569. /**
  73570. * Represents a 2D path made up of multiple 2D points
  73571. */
  73572. export class Path2 {
  73573. private _points;
  73574. private _length;
  73575. /**
  73576. * If the path start and end point are the same
  73577. */
  73578. closed: boolean;
  73579. /**
  73580. * Creates a Path2 object from the starting 2D coordinates x and y.
  73581. * @param x the starting points x value
  73582. * @param y the starting points y value
  73583. */
  73584. constructor(x: number, y: number);
  73585. /**
  73586. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73587. * @param x the added points x value
  73588. * @param y the added points y value
  73589. * @returns the updated Path2.
  73590. */
  73591. addLineTo(x: number, y: number): Path2;
  73592. /**
  73593. * 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.
  73594. * @param midX middle point x value
  73595. * @param midY middle point y value
  73596. * @param endX end point x value
  73597. * @param endY end point y value
  73598. * @param numberOfSegments (default: 36)
  73599. * @returns the updated Path2.
  73600. */
  73601. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  73602. /**
  73603. * Closes the Path2.
  73604. * @returns the Path2.
  73605. */
  73606. close(): Path2;
  73607. /**
  73608. * Gets the sum of the distance between each sequential point in the path
  73609. * @returns the Path2 total length (float).
  73610. */
  73611. length(): number;
  73612. /**
  73613. * Gets the points which construct the path
  73614. * @returns the Path2 internal array of points.
  73615. */
  73616. getPoints(): Vector2[];
  73617. /**
  73618. * Retreives the point at the distance aways from the starting point
  73619. * @param normalizedLengthPosition the length along the path to retreive the point from
  73620. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73621. */
  73622. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  73623. /**
  73624. * Creates a new path starting from an x and y position
  73625. * @param x starting x value
  73626. * @param y starting y value
  73627. * @returns a new Path2 starting at the coordinates (x, y).
  73628. */
  73629. static StartingAt(x: number, y: number): Path2;
  73630. }
  73631. /**
  73632. * Represents a 3D path made up of multiple 3D points
  73633. */
  73634. export class Path3D {
  73635. /**
  73636. * an array of Vector3, the curve axis of the Path3D
  73637. */
  73638. path: Vector3[];
  73639. private _curve;
  73640. private _distances;
  73641. private _tangents;
  73642. private _normals;
  73643. private _binormals;
  73644. private _raw;
  73645. private _alignTangentsWithPath;
  73646. private readonly _pointAtData;
  73647. /**
  73648. * new Path3D(path, normal, raw)
  73649. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73650. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73651. * @param path an array of Vector3, the curve axis of the Path3D
  73652. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73653. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73654. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  73655. */
  73656. constructor(
  73657. /**
  73658. * an array of Vector3, the curve axis of the Path3D
  73659. */
  73660. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  73661. /**
  73662. * Returns the Path3D array of successive Vector3 designing its curve.
  73663. * @returns the Path3D array of successive Vector3 designing its curve.
  73664. */
  73665. getCurve(): Vector3[];
  73666. /**
  73667. * Returns the Path3D array of successive Vector3 designing its curve.
  73668. * @returns the Path3D array of successive Vector3 designing its curve.
  73669. */
  73670. getPoints(): Vector3[];
  73671. /**
  73672. * @returns the computed length (float) of the path.
  73673. */
  73674. length(): number;
  73675. /**
  73676. * Returns an array populated with tangent vectors on each Path3D curve point.
  73677. * @returns an array populated with tangent vectors on each Path3D curve point.
  73678. */
  73679. getTangents(): Vector3[];
  73680. /**
  73681. * Returns an array populated with normal vectors on each Path3D curve point.
  73682. * @returns an array populated with normal vectors on each Path3D curve point.
  73683. */
  73684. getNormals(): Vector3[];
  73685. /**
  73686. * Returns an array populated with binormal vectors on each Path3D curve point.
  73687. * @returns an array populated with binormal vectors on each Path3D curve point.
  73688. */
  73689. getBinormals(): Vector3[];
  73690. /**
  73691. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73692. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73693. */
  73694. getDistances(): number[];
  73695. /**
  73696. * Returns an interpolated point along this path
  73697. * @param position the position of the point along this path, from 0.0 to 1.0
  73698. * @returns a new Vector3 as the point
  73699. */
  73700. getPointAt(position: number): Vector3;
  73701. /**
  73702. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73703. * @param position the position of the point along this path, from 0.0 to 1.0
  73704. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  73705. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  73706. */
  73707. getTangentAt(position: number, interpolated?: boolean): Vector3;
  73708. /**
  73709. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73710. * @param position the position of the point along this path, from 0.0 to 1.0
  73711. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  73712. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  73713. */
  73714. getNormalAt(position: number, interpolated?: boolean): Vector3;
  73715. /**
  73716. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73717. * @param position the position of the point along this path, from 0.0 to 1.0
  73718. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73719. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73720. */
  73721. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73722. /**
  73723. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73724. * @param position the position of the point along this path, from 0.0 to 1.0
  73725. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73726. */
  73727. getDistanceAt(position: number): number;
  73728. /**
  73729. * Returns the array index of the previous point of an interpolated point along this path
  73730. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73731. * @returns the array index
  73732. */
  73733. getPreviousPointIndexAt(position: number): number;
  73734. /**
  73735. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  73736. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73737. * @returns the sub position
  73738. */
  73739. getSubPositionAt(position: number): number;
  73740. /**
  73741. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73742. * @param target the vector of which to get the closest position to
  73743. * @returns the position of the closest virtual point on this path to the target vector
  73744. */
  73745. getClosestPositionTo(target: Vector3): number;
  73746. /**
  73747. * Returns a sub path (slice) of this path
  73748. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  73749. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  73750. * @returns a sub path (slice) of this path
  73751. */
  73752. slice(start?: number, end?: number): Path3D;
  73753. /**
  73754. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73755. * @param path path which all values are copied into the curves points
  73756. * @param firstNormal which should be projected onto the curve
  73757. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73758. * @returns the same object updated.
  73759. */
  73760. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73761. private _compute;
  73762. private _getFirstNonNullVector;
  73763. private _getLastNonNullVector;
  73764. private _normalVector;
  73765. /**
  73766. * Updates the point at data for an interpolated point along this curve
  73767. * @param position the position of the point along this curve, from 0.0 to 1.0
  73768. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73769. * @returns the (updated) point at data
  73770. */
  73771. private _updatePointAtData;
  73772. /**
  73773. * Updates the point at data from the specified parameters
  73774. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73775. * @param point the interpolated point
  73776. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73777. */
  73778. private _setPointAtData;
  73779. /**
  73780. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73781. */
  73782. private _updateInterpolationMatrix;
  73783. }
  73784. /**
  73785. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73786. * A Curve3 is designed from a series of successive Vector3.
  73787. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73788. */
  73789. export class Curve3 {
  73790. private _points;
  73791. private _length;
  73792. /**
  73793. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73794. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73795. * @param v1 (Vector3) the control point
  73796. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73797. * @param nbPoints (integer) the wanted number of points in the curve
  73798. * @returns the created Curve3
  73799. */
  73800. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73801. /**
  73802. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73803. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73804. * @param v1 (Vector3) the first control point
  73805. * @param v2 (Vector3) the second control point
  73806. * @param v3 (Vector3) the end point of the Cubic Bezier
  73807. * @param nbPoints (integer) the wanted number of points in the curve
  73808. * @returns the created Curve3
  73809. */
  73810. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73811. /**
  73812. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73813. * @param p1 (Vector3) the origin point of the Hermite Spline
  73814. * @param t1 (Vector3) the tangent vector at the origin point
  73815. * @param p2 (Vector3) the end point of the Hermite Spline
  73816. * @param t2 (Vector3) the tangent vector at the end point
  73817. * @param nbPoints (integer) the wanted number of points in the curve
  73818. * @returns the created Curve3
  73819. */
  73820. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73821. /**
  73822. * Returns a Curve3 object along a CatmullRom Spline curve :
  73823. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73824. * @param nbPoints (integer) the wanted number of points between each curve control points
  73825. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73826. * @returns the created Curve3
  73827. */
  73828. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73829. /**
  73830. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73831. * A Curve3 is designed from a series of successive Vector3.
  73832. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73833. * @param points points which make up the curve
  73834. */
  73835. constructor(points: Vector3[]);
  73836. /**
  73837. * @returns the Curve3 stored array of successive Vector3
  73838. */
  73839. getPoints(): Vector3[];
  73840. /**
  73841. * @returns the computed length (float) of the curve.
  73842. */
  73843. length(): number;
  73844. /**
  73845. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73846. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73847. * curveA and curveB keep unchanged.
  73848. * @param curve the curve to continue from this curve
  73849. * @returns the newly constructed curve
  73850. */
  73851. continue(curve: DeepImmutable<Curve3>): Curve3;
  73852. private _computeLength;
  73853. }
  73854. }
  73855. declare module BABYLON {
  73856. /**
  73857. * This represents the main contract an easing function should follow.
  73858. * Easing functions are used throughout the animation system.
  73859. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73860. */
  73861. export interface IEasingFunction {
  73862. /**
  73863. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73864. * of the easing function.
  73865. * The link below provides some of the most common examples of easing functions.
  73866. * @see https://easings.net/
  73867. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73868. * @returns the corresponding value on the curve defined by the easing function
  73869. */
  73870. ease(gradient: number): number;
  73871. }
  73872. /**
  73873. * Base class used for every default easing function.
  73874. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73875. */
  73876. export class EasingFunction implements IEasingFunction {
  73877. /**
  73878. * Interpolation follows the mathematical formula associated with the easing function.
  73879. */
  73880. static readonly EASINGMODE_EASEIN: number;
  73881. /**
  73882. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73883. */
  73884. static readonly EASINGMODE_EASEOUT: number;
  73885. /**
  73886. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73887. */
  73888. static readonly EASINGMODE_EASEINOUT: number;
  73889. private _easingMode;
  73890. /**
  73891. * Sets the easing mode of the current function.
  73892. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73893. */
  73894. setEasingMode(easingMode: number): void;
  73895. /**
  73896. * Gets the current easing mode.
  73897. * @returns the easing mode
  73898. */
  73899. getEasingMode(): number;
  73900. /**
  73901. * @hidden
  73902. */
  73903. easeInCore(gradient: number): number;
  73904. /**
  73905. * Given an input gradient between 0 and 1, this returns the corresponding value
  73906. * of the easing function.
  73907. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73908. * @returns the corresponding value on the curve defined by the easing function
  73909. */
  73910. ease(gradient: number): number;
  73911. }
  73912. /**
  73913. * Easing function with a circle shape (see link below).
  73914. * @see https://easings.net/#easeInCirc
  73915. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73916. */
  73917. export class CircleEase extends EasingFunction implements IEasingFunction {
  73918. /** @hidden */
  73919. easeInCore(gradient: number): number;
  73920. }
  73921. /**
  73922. * Easing function with a ease back shape (see link below).
  73923. * @see https://easings.net/#easeInBack
  73924. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73925. */
  73926. export class BackEase extends EasingFunction implements IEasingFunction {
  73927. /** Defines the amplitude of the function */
  73928. amplitude: number;
  73929. /**
  73930. * Instantiates a back ease easing
  73931. * @see https://easings.net/#easeInBack
  73932. * @param amplitude Defines the amplitude of the function
  73933. */
  73934. constructor(
  73935. /** Defines the amplitude of the function */
  73936. amplitude?: number);
  73937. /** @hidden */
  73938. easeInCore(gradient: number): number;
  73939. }
  73940. /**
  73941. * Easing function with a bouncing shape (see link below).
  73942. * @see https://easings.net/#easeInBounce
  73943. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73944. */
  73945. export class BounceEase extends EasingFunction implements IEasingFunction {
  73946. /** Defines the number of bounces */
  73947. bounces: number;
  73948. /** Defines the amplitude of the bounce */
  73949. bounciness: number;
  73950. /**
  73951. * Instantiates a bounce easing
  73952. * @see https://easings.net/#easeInBounce
  73953. * @param bounces Defines the number of bounces
  73954. * @param bounciness Defines the amplitude of the bounce
  73955. */
  73956. constructor(
  73957. /** Defines the number of bounces */
  73958. bounces?: number,
  73959. /** Defines the amplitude of the bounce */
  73960. bounciness?: number);
  73961. /** @hidden */
  73962. easeInCore(gradient: number): number;
  73963. }
  73964. /**
  73965. * Easing function with a power of 3 shape (see link below).
  73966. * @see https://easings.net/#easeInCubic
  73967. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73968. */
  73969. export class CubicEase extends EasingFunction implements IEasingFunction {
  73970. /** @hidden */
  73971. easeInCore(gradient: number): number;
  73972. }
  73973. /**
  73974. * Easing function with an elastic shape (see link below).
  73975. * @see https://easings.net/#easeInElastic
  73976. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73977. */
  73978. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73979. /** Defines the number of oscillations*/
  73980. oscillations: number;
  73981. /** Defines the amplitude of the oscillations*/
  73982. springiness: number;
  73983. /**
  73984. * Instantiates an elastic easing function
  73985. * @see https://easings.net/#easeInElastic
  73986. * @param oscillations Defines the number of oscillations
  73987. * @param springiness Defines the amplitude of the oscillations
  73988. */
  73989. constructor(
  73990. /** Defines the number of oscillations*/
  73991. oscillations?: number,
  73992. /** Defines the amplitude of the oscillations*/
  73993. springiness?: number);
  73994. /** @hidden */
  73995. easeInCore(gradient: number): number;
  73996. }
  73997. /**
  73998. * Easing function with an exponential shape (see link below).
  73999. * @see https://easings.net/#easeInExpo
  74000. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74001. */
  74002. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  74003. /** Defines the exponent of the function */
  74004. exponent: number;
  74005. /**
  74006. * Instantiates an exponential easing function
  74007. * @see https://easings.net/#easeInExpo
  74008. * @param exponent Defines the exponent of the function
  74009. */
  74010. constructor(
  74011. /** Defines the exponent of the function */
  74012. exponent?: number);
  74013. /** @hidden */
  74014. easeInCore(gradient: number): number;
  74015. }
  74016. /**
  74017. * Easing function with a power shape (see link below).
  74018. * @see https://easings.net/#easeInQuad
  74019. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74020. */
  74021. export class PowerEase extends EasingFunction implements IEasingFunction {
  74022. /** Defines the power of the function */
  74023. power: number;
  74024. /**
  74025. * Instantiates an power base easing function
  74026. * @see https://easings.net/#easeInQuad
  74027. * @param power Defines the power of the function
  74028. */
  74029. constructor(
  74030. /** Defines the power of the function */
  74031. power?: number);
  74032. /** @hidden */
  74033. easeInCore(gradient: number): number;
  74034. }
  74035. /**
  74036. * Easing function with a power of 2 shape (see link below).
  74037. * @see https://easings.net/#easeInQuad
  74038. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74039. */
  74040. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  74041. /** @hidden */
  74042. easeInCore(gradient: number): number;
  74043. }
  74044. /**
  74045. * Easing function with a power of 4 shape (see link below).
  74046. * @see https://easings.net/#easeInQuart
  74047. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74048. */
  74049. export class QuarticEase extends EasingFunction implements IEasingFunction {
  74050. /** @hidden */
  74051. easeInCore(gradient: number): number;
  74052. }
  74053. /**
  74054. * Easing function with a power of 5 shape (see link below).
  74055. * @see https://easings.net/#easeInQuint
  74056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74057. */
  74058. export class QuinticEase extends EasingFunction implements IEasingFunction {
  74059. /** @hidden */
  74060. easeInCore(gradient: number): number;
  74061. }
  74062. /**
  74063. * Easing function with a sin shape (see link below).
  74064. * @see https://easings.net/#easeInSine
  74065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74066. */
  74067. export class SineEase extends EasingFunction implements IEasingFunction {
  74068. /** @hidden */
  74069. easeInCore(gradient: number): number;
  74070. }
  74071. /**
  74072. * Easing function with a bezier shape (see link below).
  74073. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74074. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74075. */
  74076. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  74077. /** Defines the x component of the start tangent in the bezier curve */
  74078. x1: number;
  74079. /** Defines the y component of the start tangent in the bezier curve */
  74080. y1: number;
  74081. /** Defines the x component of the end tangent in the bezier curve */
  74082. x2: number;
  74083. /** Defines the y component of the end tangent in the bezier curve */
  74084. y2: number;
  74085. /**
  74086. * Instantiates a bezier function
  74087. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74088. * @param x1 Defines the x component of the start tangent in the bezier curve
  74089. * @param y1 Defines the y component of the start tangent in the bezier curve
  74090. * @param x2 Defines the x component of the end tangent in the bezier curve
  74091. * @param y2 Defines the y component of the end tangent in the bezier curve
  74092. */
  74093. constructor(
  74094. /** Defines the x component of the start tangent in the bezier curve */
  74095. x1?: number,
  74096. /** Defines the y component of the start tangent in the bezier curve */
  74097. y1?: number,
  74098. /** Defines the x component of the end tangent in the bezier curve */
  74099. x2?: number,
  74100. /** Defines the y component of the end tangent in the bezier curve */
  74101. y2?: number);
  74102. /** @hidden */
  74103. easeInCore(gradient: number): number;
  74104. }
  74105. }
  74106. declare module BABYLON {
  74107. /**
  74108. * Class used to hold a RBG color
  74109. */
  74110. export class Color3 {
  74111. /**
  74112. * Defines the red component (between 0 and 1, default is 0)
  74113. */
  74114. r: number;
  74115. /**
  74116. * Defines the green component (between 0 and 1, default is 0)
  74117. */
  74118. g: number;
  74119. /**
  74120. * Defines the blue component (between 0 and 1, default is 0)
  74121. */
  74122. b: number;
  74123. /**
  74124. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  74125. * @param r defines the red component (between 0 and 1, default is 0)
  74126. * @param g defines the green component (between 0 and 1, default is 0)
  74127. * @param b defines the blue component (between 0 and 1, default is 0)
  74128. */
  74129. constructor(
  74130. /**
  74131. * Defines the red component (between 0 and 1, default is 0)
  74132. */
  74133. r?: number,
  74134. /**
  74135. * Defines the green component (between 0 and 1, default is 0)
  74136. */
  74137. g?: number,
  74138. /**
  74139. * Defines the blue component (between 0 and 1, default is 0)
  74140. */
  74141. b?: number);
  74142. /**
  74143. * Creates a string with the Color3 current values
  74144. * @returns the string representation of the Color3 object
  74145. */
  74146. toString(): string;
  74147. /**
  74148. * Returns the string "Color3"
  74149. * @returns "Color3"
  74150. */
  74151. getClassName(): string;
  74152. /**
  74153. * Compute the Color3 hash code
  74154. * @returns an unique number that can be used to hash Color3 objects
  74155. */
  74156. getHashCode(): number;
  74157. /**
  74158. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  74159. * @param array defines the array where to store the r,g,b components
  74160. * @param index defines an optional index in the target array to define where to start storing values
  74161. * @returns the current Color3 object
  74162. */
  74163. toArray(array: FloatArray, index?: number): Color3;
  74164. /**
  74165. * Returns a new Color4 object from the current Color3 and the given alpha
  74166. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  74167. * @returns a new Color4 object
  74168. */
  74169. toColor4(alpha?: number): Color4;
  74170. /**
  74171. * Returns a new array populated with 3 numeric elements : red, green and blue values
  74172. * @returns the new array
  74173. */
  74174. asArray(): number[];
  74175. /**
  74176. * Returns the luminance value
  74177. * @returns a float value
  74178. */
  74179. toLuminance(): number;
  74180. /**
  74181. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  74182. * @param otherColor defines the second operand
  74183. * @returns the new Color3 object
  74184. */
  74185. multiply(otherColor: DeepImmutable<Color3>): Color3;
  74186. /**
  74187. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  74188. * @param otherColor defines the second operand
  74189. * @param result defines the Color3 object where to store the result
  74190. * @returns the current Color3
  74191. */
  74192. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74193. /**
  74194. * Determines equality between Color3 objects
  74195. * @param otherColor defines the second operand
  74196. * @returns true if the rgb values are equal to the given ones
  74197. */
  74198. equals(otherColor: DeepImmutable<Color3>): boolean;
  74199. /**
  74200. * Determines equality between the current Color3 object and a set of r,b,g values
  74201. * @param r defines the red component to check
  74202. * @param g defines the green component to check
  74203. * @param b defines the blue component to check
  74204. * @returns true if the rgb values are equal to the given ones
  74205. */
  74206. equalsFloats(r: number, g: number, b: number): boolean;
  74207. /**
  74208. * Multiplies in place each rgb value by scale
  74209. * @param scale defines the scaling factor
  74210. * @returns the updated Color3
  74211. */
  74212. scale(scale: number): Color3;
  74213. /**
  74214. * Multiplies the rgb values by scale and stores the result into "result"
  74215. * @param scale defines the scaling factor
  74216. * @param result defines the Color3 object where to store the result
  74217. * @returns the unmodified current Color3
  74218. */
  74219. scaleToRef(scale: number, result: Color3): Color3;
  74220. /**
  74221. * Scale the current Color3 values by a factor and add the result to a given Color3
  74222. * @param scale defines the scale factor
  74223. * @param result defines color to store the result into
  74224. * @returns the unmodified current Color3
  74225. */
  74226. scaleAndAddToRef(scale: number, result: Color3): Color3;
  74227. /**
  74228. * Clamps the rgb values by the min and max values and stores the result into "result"
  74229. * @param min defines minimum clamping value (default is 0)
  74230. * @param max defines maximum clamping value (default is 1)
  74231. * @param result defines color to store the result into
  74232. * @returns the original Color3
  74233. */
  74234. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  74235. /**
  74236. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  74237. * @param otherColor defines the second operand
  74238. * @returns the new Color3
  74239. */
  74240. add(otherColor: DeepImmutable<Color3>): Color3;
  74241. /**
  74242. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  74243. * @param otherColor defines the second operand
  74244. * @param result defines Color3 object to store the result into
  74245. * @returns the unmodified current Color3
  74246. */
  74247. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74248. /**
  74249. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  74250. * @param otherColor defines the second operand
  74251. * @returns the new Color3
  74252. */
  74253. subtract(otherColor: DeepImmutable<Color3>): Color3;
  74254. /**
  74255. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  74256. * @param otherColor defines the second operand
  74257. * @param result defines Color3 object to store the result into
  74258. * @returns the unmodified current Color3
  74259. */
  74260. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74261. /**
  74262. * Copy the current object
  74263. * @returns a new Color3 copied the current one
  74264. */
  74265. clone(): Color3;
  74266. /**
  74267. * Copies the rgb values from the source in the current Color3
  74268. * @param source defines the source Color3 object
  74269. * @returns the updated Color3 object
  74270. */
  74271. copyFrom(source: DeepImmutable<Color3>): Color3;
  74272. /**
  74273. * Updates the Color3 rgb values from the given floats
  74274. * @param r defines the red component to read from
  74275. * @param g defines the green component to read from
  74276. * @param b defines the blue component to read from
  74277. * @returns the current Color3 object
  74278. */
  74279. copyFromFloats(r: number, g: number, b: number): Color3;
  74280. /**
  74281. * Updates the Color3 rgb values from the given floats
  74282. * @param r defines the red component to read from
  74283. * @param g defines the green component to read from
  74284. * @param b defines the blue component to read from
  74285. * @returns the current Color3 object
  74286. */
  74287. set(r: number, g: number, b: number): Color3;
  74288. /**
  74289. * Compute the Color3 hexadecimal code as a string
  74290. * @returns a string containing the hexadecimal representation of the Color3 object
  74291. */
  74292. toHexString(): string;
  74293. /**
  74294. * Computes a new Color3 converted from the current one to linear space
  74295. * @returns a new Color3 object
  74296. */
  74297. toLinearSpace(): Color3;
  74298. /**
  74299. * Converts current color in rgb space to HSV values
  74300. * @returns a new color3 representing the HSV values
  74301. */
  74302. toHSV(): Color3;
  74303. /**
  74304. * Converts current color in rgb space to HSV values
  74305. * @param result defines the Color3 where to store the HSV values
  74306. */
  74307. toHSVToRef(result: Color3): void;
  74308. /**
  74309. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  74310. * @param convertedColor defines the Color3 object where to store the linear space version
  74311. * @returns the unmodified Color3
  74312. */
  74313. toLinearSpaceToRef(convertedColor: Color3): Color3;
  74314. /**
  74315. * Computes a new Color3 converted from the current one to gamma space
  74316. * @returns a new Color3 object
  74317. */
  74318. toGammaSpace(): Color3;
  74319. /**
  74320. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  74321. * @param convertedColor defines the Color3 object where to store the gamma space version
  74322. * @returns the unmodified Color3
  74323. */
  74324. toGammaSpaceToRef(convertedColor: Color3): Color3;
  74325. private static _BlackReadOnly;
  74326. /**
  74327. * Convert Hue, saturation and value to a Color3 (RGB)
  74328. * @param hue defines the hue
  74329. * @param saturation defines the saturation
  74330. * @param value defines the value
  74331. * @param result defines the Color3 where to store the RGB values
  74332. */
  74333. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  74334. /**
  74335. * Creates a new Color3 from the string containing valid hexadecimal values
  74336. * @param hex defines a string containing valid hexadecimal values
  74337. * @returns a new Color3 object
  74338. */
  74339. static FromHexString(hex: string): Color3;
  74340. /**
  74341. * Creates a new Color3 from the starting index of the given array
  74342. * @param array defines the source array
  74343. * @param offset defines an offset in the source array
  74344. * @returns a new Color3 object
  74345. */
  74346. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  74347. /**
  74348. * Creates a new Color3 from integer values (< 256)
  74349. * @param r defines the red component to read from (value between 0 and 255)
  74350. * @param g defines the green component to read from (value between 0 and 255)
  74351. * @param b defines the blue component to read from (value between 0 and 255)
  74352. * @returns a new Color3 object
  74353. */
  74354. static FromInts(r: number, g: number, b: number): Color3;
  74355. /**
  74356. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74357. * @param start defines the start Color3 value
  74358. * @param end defines the end Color3 value
  74359. * @param amount defines the gradient value between start and end
  74360. * @returns a new Color3 object
  74361. */
  74362. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  74363. /**
  74364. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74365. * @param left defines the start value
  74366. * @param right defines the end value
  74367. * @param amount defines the gradient factor
  74368. * @param result defines the Color3 object where to store the result
  74369. */
  74370. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  74371. /**
  74372. * Returns a Color3 value containing a red color
  74373. * @returns a new Color3 object
  74374. */
  74375. static Red(): Color3;
  74376. /**
  74377. * Returns a Color3 value containing a green color
  74378. * @returns a new Color3 object
  74379. */
  74380. static Green(): Color3;
  74381. /**
  74382. * Returns a Color3 value containing a blue color
  74383. * @returns a new Color3 object
  74384. */
  74385. static Blue(): Color3;
  74386. /**
  74387. * Returns a Color3 value containing a black color
  74388. * @returns a new Color3 object
  74389. */
  74390. static Black(): Color3;
  74391. /**
  74392. * Gets a Color3 value containing a black color that must not be updated
  74393. */
  74394. static readonly BlackReadOnly: DeepImmutable<Color3>;
  74395. /**
  74396. * Returns a Color3 value containing a white color
  74397. * @returns a new Color3 object
  74398. */
  74399. static White(): Color3;
  74400. /**
  74401. * Returns a Color3 value containing a purple color
  74402. * @returns a new Color3 object
  74403. */
  74404. static Purple(): Color3;
  74405. /**
  74406. * Returns a Color3 value containing a magenta color
  74407. * @returns a new Color3 object
  74408. */
  74409. static Magenta(): Color3;
  74410. /**
  74411. * Returns a Color3 value containing a yellow color
  74412. * @returns a new Color3 object
  74413. */
  74414. static Yellow(): Color3;
  74415. /**
  74416. * Returns a Color3 value containing a gray color
  74417. * @returns a new Color3 object
  74418. */
  74419. static Gray(): Color3;
  74420. /**
  74421. * Returns a Color3 value containing a teal color
  74422. * @returns a new Color3 object
  74423. */
  74424. static Teal(): Color3;
  74425. /**
  74426. * Returns a Color3 value containing a random color
  74427. * @returns a new Color3 object
  74428. */
  74429. static Random(): Color3;
  74430. }
  74431. /**
  74432. * Class used to hold a RBGA color
  74433. */
  74434. export class Color4 {
  74435. /**
  74436. * Defines the red component (between 0 and 1, default is 0)
  74437. */
  74438. r: number;
  74439. /**
  74440. * Defines the green component (between 0 and 1, default is 0)
  74441. */
  74442. g: number;
  74443. /**
  74444. * Defines the blue component (between 0 and 1, default is 0)
  74445. */
  74446. b: number;
  74447. /**
  74448. * Defines the alpha component (between 0 and 1, default is 1)
  74449. */
  74450. a: number;
  74451. /**
  74452. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  74453. * @param r defines the red component (between 0 and 1, default is 0)
  74454. * @param g defines the green component (between 0 and 1, default is 0)
  74455. * @param b defines the blue component (between 0 and 1, default is 0)
  74456. * @param a defines the alpha component (between 0 and 1, default is 1)
  74457. */
  74458. constructor(
  74459. /**
  74460. * Defines the red component (between 0 and 1, default is 0)
  74461. */
  74462. r?: number,
  74463. /**
  74464. * Defines the green component (between 0 and 1, default is 0)
  74465. */
  74466. g?: number,
  74467. /**
  74468. * Defines the blue component (between 0 and 1, default is 0)
  74469. */
  74470. b?: number,
  74471. /**
  74472. * Defines the alpha component (between 0 and 1, default is 1)
  74473. */
  74474. a?: number);
  74475. /**
  74476. * Adds in place the given Color4 values to the current Color4 object
  74477. * @param right defines the second operand
  74478. * @returns the current updated Color4 object
  74479. */
  74480. addInPlace(right: DeepImmutable<Color4>): Color4;
  74481. /**
  74482. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  74483. * @returns the new array
  74484. */
  74485. asArray(): number[];
  74486. /**
  74487. * Stores from the starting index in the given array the Color4 successive values
  74488. * @param array defines the array where to store the r,g,b components
  74489. * @param index defines an optional index in the target array to define where to start storing values
  74490. * @returns the current Color4 object
  74491. */
  74492. toArray(array: number[], index?: number): Color4;
  74493. /**
  74494. * Determines equality between Color4 objects
  74495. * @param otherColor defines the second operand
  74496. * @returns true if the rgba values are equal to the given ones
  74497. */
  74498. equals(otherColor: DeepImmutable<Color4>): boolean;
  74499. /**
  74500. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  74501. * @param right defines the second operand
  74502. * @returns a new Color4 object
  74503. */
  74504. add(right: DeepImmutable<Color4>): Color4;
  74505. /**
  74506. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  74507. * @param right defines the second operand
  74508. * @returns a new Color4 object
  74509. */
  74510. subtract(right: DeepImmutable<Color4>): Color4;
  74511. /**
  74512. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  74513. * @param right defines the second operand
  74514. * @param result defines the Color4 object where to store the result
  74515. * @returns the current Color4 object
  74516. */
  74517. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  74518. /**
  74519. * Creates a new Color4 with the current Color4 values multiplied by scale
  74520. * @param scale defines the scaling factor to apply
  74521. * @returns a new Color4 object
  74522. */
  74523. scale(scale: number): Color4;
  74524. /**
  74525. * Multiplies the current Color4 values by scale and stores the result in "result"
  74526. * @param scale defines the scaling factor to apply
  74527. * @param result defines the Color4 object where to store the result
  74528. * @returns the current unmodified Color4
  74529. */
  74530. scaleToRef(scale: number, result: Color4): Color4;
  74531. /**
  74532. * Scale the current Color4 values by a factor and add the result to a given Color4
  74533. * @param scale defines the scale factor
  74534. * @param result defines the Color4 object where to store the result
  74535. * @returns the unmodified current Color4
  74536. */
  74537. scaleAndAddToRef(scale: number, result: Color4): Color4;
  74538. /**
  74539. * Clamps the rgb values by the min and max values and stores the result into "result"
  74540. * @param min defines minimum clamping value (default is 0)
  74541. * @param max defines maximum clamping value (default is 1)
  74542. * @param result defines color to store the result into.
  74543. * @returns the cuurent Color4
  74544. */
  74545. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  74546. /**
  74547. * Multipy an Color4 value by another and return a new Color4 object
  74548. * @param color defines the Color4 value to multiply by
  74549. * @returns a new Color4 object
  74550. */
  74551. multiply(color: Color4): Color4;
  74552. /**
  74553. * Multipy a Color4 value by another and push the result in a reference value
  74554. * @param color defines the Color4 value to multiply by
  74555. * @param result defines the Color4 to fill the result in
  74556. * @returns the result Color4
  74557. */
  74558. multiplyToRef(color: Color4, result: Color4): Color4;
  74559. /**
  74560. * Creates a string with the Color4 current values
  74561. * @returns the string representation of the Color4 object
  74562. */
  74563. toString(): string;
  74564. /**
  74565. * Returns the string "Color4"
  74566. * @returns "Color4"
  74567. */
  74568. getClassName(): string;
  74569. /**
  74570. * Compute the Color4 hash code
  74571. * @returns an unique number that can be used to hash Color4 objects
  74572. */
  74573. getHashCode(): number;
  74574. /**
  74575. * Creates a new Color4 copied from the current one
  74576. * @returns a new Color4 object
  74577. */
  74578. clone(): Color4;
  74579. /**
  74580. * Copies the given Color4 values into the current one
  74581. * @param source defines the source Color4 object
  74582. * @returns the current updated Color4 object
  74583. */
  74584. copyFrom(source: Color4): Color4;
  74585. /**
  74586. * Copies the given float values into the current one
  74587. * @param r defines the red component to read from
  74588. * @param g defines the green component to read from
  74589. * @param b defines the blue component to read from
  74590. * @param a defines the alpha component to read from
  74591. * @returns the current updated Color4 object
  74592. */
  74593. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  74594. /**
  74595. * Copies the given float values into the current one
  74596. * @param r defines the red component to read from
  74597. * @param g defines the green component to read from
  74598. * @param b defines the blue component to read from
  74599. * @param a defines the alpha component to read from
  74600. * @returns the current updated Color4 object
  74601. */
  74602. set(r: number, g: number, b: number, a: number): Color4;
  74603. /**
  74604. * Compute the Color4 hexadecimal code as a string
  74605. * @returns a string containing the hexadecimal representation of the Color4 object
  74606. */
  74607. toHexString(): string;
  74608. /**
  74609. * Computes a new Color4 converted from the current one to linear space
  74610. * @returns a new Color4 object
  74611. */
  74612. toLinearSpace(): Color4;
  74613. /**
  74614. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  74615. * @param convertedColor defines the Color4 object where to store the linear space version
  74616. * @returns the unmodified Color4
  74617. */
  74618. toLinearSpaceToRef(convertedColor: Color4): Color4;
  74619. /**
  74620. * Computes a new Color4 converted from the current one to gamma space
  74621. * @returns a new Color4 object
  74622. */
  74623. toGammaSpace(): Color4;
  74624. /**
  74625. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  74626. * @param convertedColor defines the Color4 object where to store the gamma space version
  74627. * @returns the unmodified Color4
  74628. */
  74629. toGammaSpaceToRef(convertedColor: Color4): Color4;
  74630. /**
  74631. * Creates a new Color4 from the string containing valid hexadecimal values
  74632. * @param hex defines a string containing valid hexadecimal values
  74633. * @returns a new Color4 object
  74634. */
  74635. static FromHexString(hex: string): Color4;
  74636. /**
  74637. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74638. * @param left defines the start value
  74639. * @param right defines the end value
  74640. * @param amount defines the gradient factor
  74641. * @returns a new Color4 object
  74642. */
  74643. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  74644. /**
  74645. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74646. * @param left defines the start value
  74647. * @param right defines the end value
  74648. * @param amount defines the gradient factor
  74649. * @param result defines the Color4 object where to store data
  74650. */
  74651. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  74652. /**
  74653. * Creates a new Color4 from a Color3 and an alpha value
  74654. * @param color3 defines the source Color3 to read from
  74655. * @param alpha defines the alpha component (1.0 by default)
  74656. * @returns a new Color4 object
  74657. */
  74658. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  74659. /**
  74660. * Creates a new Color4 from the starting index element of the given array
  74661. * @param array defines the source array to read from
  74662. * @param offset defines the offset in the source array
  74663. * @returns a new Color4 object
  74664. */
  74665. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  74666. /**
  74667. * Creates a new Color3 from integer values (< 256)
  74668. * @param r defines the red component to read from (value between 0 and 255)
  74669. * @param g defines the green component to read from (value between 0 and 255)
  74670. * @param b defines the blue component to read from (value between 0 and 255)
  74671. * @param a defines the alpha component to read from (value between 0 and 255)
  74672. * @returns a new Color3 object
  74673. */
  74674. static FromInts(r: number, g: number, b: number, a: number): Color4;
  74675. /**
  74676. * Check the content of a given array and convert it to an array containing RGBA data
  74677. * If the original array was already containing count * 4 values then it is returned directly
  74678. * @param colors defines the array to check
  74679. * @param count defines the number of RGBA data to expect
  74680. * @returns an array containing count * 4 values (RGBA)
  74681. */
  74682. static CheckColors4(colors: number[], count: number): number[];
  74683. }
  74684. /**
  74685. * @hidden
  74686. */
  74687. export class TmpColors {
  74688. static Color3: Color3[];
  74689. static Color4: Color4[];
  74690. }
  74691. }
  74692. declare module BABYLON {
  74693. /**
  74694. * Defines an interface which represents an animation key frame
  74695. */
  74696. export interface IAnimationKey {
  74697. /**
  74698. * Frame of the key frame
  74699. */
  74700. frame: number;
  74701. /**
  74702. * Value at the specifies key frame
  74703. */
  74704. value: any;
  74705. /**
  74706. * The input tangent for the cubic hermite spline
  74707. */
  74708. inTangent?: any;
  74709. /**
  74710. * The output tangent for the cubic hermite spline
  74711. */
  74712. outTangent?: any;
  74713. /**
  74714. * The animation interpolation type
  74715. */
  74716. interpolation?: AnimationKeyInterpolation;
  74717. }
  74718. /**
  74719. * Enum for the animation key frame interpolation type
  74720. */
  74721. export enum AnimationKeyInterpolation {
  74722. /**
  74723. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74724. */
  74725. STEP = 1
  74726. }
  74727. }
  74728. declare module BABYLON {
  74729. /**
  74730. * Represents the range of an animation
  74731. */
  74732. export class AnimationRange {
  74733. /**The name of the animation range**/
  74734. name: string;
  74735. /**The starting frame of the animation */
  74736. from: number;
  74737. /**The ending frame of the animation*/
  74738. to: number;
  74739. /**
  74740. * Initializes the range of an animation
  74741. * @param name The name of the animation range
  74742. * @param from The starting frame of the animation
  74743. * @param to The ending frame of the animation
  74744. */
  74745. constructor(
  74746. /**The name of the animation range**/
  74747. name: string,
  74748. /**The starting frame of the animation */
  74749. from: number,
  74750. /**The ending frame of the animation*/
  74751. to: number);
  74752. /**
  74753. * Makes a copy of the animation range
  74754. * @returns A copy of the animation range
  74755. */
  74756. clone(): AnimationRange;
  74757. }
  74758. }
  74759. declare module BABYLON {
  74760. /**
  74761. * Composed of a frame, and an action function
  74762. */
  74763. export class AnimationEvent {
  74764. /** The frame for which the event is triggered **/
  74765. frame: number;
  74766. /** The event to perform when triggered **/
  74767. action: (currentFrame: number) => void;
  74768. /** Specifies if the event should be triggered only once**/
  74769. onlyOnce?: boolean | undefined;
  74770. /**
  74771. * Specifies if the animation event is done
  74772. */
  74773. isDone: boolean;
  74774. /**
  74775. * Initializes the animation event
  74776. * @param frame The frame for which the event is triggered
  74777. * @param action The event to perform when triggered
  74778. * @param onlyOnce Specifies if the event should be triggered only once
  74779. */
  74780. constructor(
  74781. /** The frame for which the event is triggered **/
  74782. frame: number,
  74783. /** The event to perform when triggered **/
  74784. action: (currentFrame: number) => void,
  74785. /** Specifies if the event should be triggered only once**/
  74786. onlyOnce?: boolean | undefined);
  74787. /** @hidden */
  74788. _clone(): AnimationEvent;
  74789. }
  74790. }
  74791. declare module BABYLON {
  74792. /**
  74793. * Interface used to define a behavior
  74794. */
  74795. export interface Behavior<T> {
  74796. /** gets or sets behavior's name */
  74797. name: string;
  74798. /**
  74799. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74800. */
  74801. init(): void;
  74802. /**
  74803. * Called when the behavior is attached to a target
  74804. * @param target defines the target where the behavior is attached to
  74805. */
  74806. attach(target: T): void;
  74807. /**
  74808. * Called when the behavior is detached from its target
  74809. */
  74810. detach(): void;
  74811. }
  74812. /**
  74813. * Interface implemented by classes supporting behaviors
  74814. */
  74815. export interface IBehaviorAware<T> {
  74816. /**
  74817. * Attach a behavior
  74818. * @param behavior defines the behavior to attach
  74819. * @returns the current host
  74820. */
  74821. addBehavior(behavior: Behavior<T>): T;
  74822. /**
  74823. * Remove a behavior from the current object
  74824. * @param behavior defines the behavior to detach
  74825. * @returns the current host
  74826. */
  74827. removeBehavior(behavior: Behavior<T>): T;
  74828. /**
  74829. * Gets a behavior using its name to search
  74830. * @param name defines the name to search
  74831. * @returns the behavior or null if not found
  74832. */
  74833. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74834. }
  74835. }
  74836. declare module BABYLON {
  74837. /**
  74838. * Defines an array and its length.
  74839. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74840. */
  74841. export interface ISmartArrayLike<T> {
  74842. /**
  74843. * The data of the array.
  74844. */
  74845. data: Array<T>;
  74846. /**
  74847. * The active length of the array.
  74848. */
  74849. length: number;
  74850. }
  74851. /**
  74852. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74853. */
  74854. export class SmartArray<T> implements ISmartArrayLike<T> {
  74855. /**
  74856. * The full set of data from the array.
  74857. */
  74858. data: Array<T>;
  74859. /**
  74860. * The active length of the array.
  74861. */
  74862. length: number;
  74863. protected _id: number;
  74864. /**
  74865. * Instantiates a Smart Array.
  74866. * @param capacity defines the default capacity of the array.
  74867. */
  74868. constructor(capacity: number);
  74869. /**
  74870. * Pushes a value at the end of the active data.
  74871. * @param value defines the object to push in the array.
  74872. */
  74873. push(value: T): void;
  74874. /**
  74875. * Iterates over the active data and apply the lambda to them.
  74876. * @param func defines the action to apply on each value.
  74877. */
  74878. forEach(func: (content: T) => void): void;
  74879. /**
  74880. * Sorts the full sets of data.
  74881. * @param compareFn defines the comparison function to apply.
  74882. */
  74883. sort(compareFn: (a: T, b: T) => number): void;
  74884. /**
  74885. * Resets the active data to an empty array.
  74886. */
  74887. reset(): void;
  74888. /**
  74889. * Releases all the data from the array as well as the array.
  74890. */
  74891. dispose(): void;
  74892. /**
  74893. * Concats the active data with a given array.
  74894. * @param array defines the data to concatenate with.
  74895. */
  74896. concat(array: any): void;
  74897. /**
  74898. * Returns the position of a value in the active data.
  74899. * @param value defines the value to find the index for
  74900. * @returns the index if found in the active data otherwise -1
  74901. */
  74902. indexOf(value: T): number;
  74903. /**
  74904. * Returns whether an element is part of the active data.
  74905. * @param value defines the value to look for
  74906. * @returns true if found in the active data otherwise false
  74907. */
  74908. contains(value: T): boolean;
  74909. private static _GlobalId;
  74910. }
  74911. /**
  74912. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74913. * The data in this array can only be present once
  74914. */
  74915. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74916. private _duplicateId;
  74917. /**
  74918. * Pushes a value at the end of the active data.
  74919. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74920. * @param value defines the object to push in the array.
  74921. */
  74922. push(value: T): void;
  74923. /**
  74924. * Pushes a value at the end of the active data.
  74925. * If the data is already present, it won t be added again
  74926. * @param value defines the object to push in the array.
  74927. * @returns true if added false if it was already present
  74928. */
  74929. pushNoDuplicate(value: T): boolean;
  74930. /**
  74931. * Resets the active data to an empty array.
  74932. */
  74933. reset(): void;
  74934. /**
  74935. * Concats the active data with a given array.
  74936. * This ensures no dupplicate will be present in the result.
  74937. * @param array defines the data to concatenate with.
  74938. */
  74939. concatWithNoDuplicate(array: any): void;
  74940. }
  74941. }
  74942. declare module BABYLON {
  74943. /**
  74944. * @ignore
  74945. * This is a list of all the different input types that are available in the application.
  74946. * Fo instance: ArcRotateCameraGamepadInput...
  74947. */
  74948. export var CameraInputTypes: {};
  74949. /**
  74950. * This is the contract to implement in order to create a new input class.
  74951. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74952. */
  74953. export interface ICameraInput<TCamera extends Camera> {
  74954. /**
  74955. * Defines the camera the input is attached to.
  74956. */
  74957. camera: Nullable<TCamera>;
  74958. /**
  74959. * Gets the class name of the current intput.
  74960. * @returns the class name
  74961. */
  74962. getClassName(): string;
  74963. /**
  74964. * Get the friendly name associated with the input class.
  74965. * @returns the input friendly name
  74966. */
  74967. getSimpleName(): string;
  74968. /**
  74969. * Attach the input controls to a specific dom element to get the input from.
  74970. * @param element Defines the element the controls should be listened from
  74971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74972. */
  74973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74974. /**
  74975. * Detach the current controls from the specified dom element.
  74976. * @param element Defines the element to stop listening the inputs from
  74977. */
  74978. detachControl(element: Nullable<HTMLElement>): void;
  74979. /**
  74980. * Update the current camera state depending on the inputs that have been used this frame.
  74981. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74982. */
  74983. checkInputs?: () => void;
  74984. }
  74985. /**
  74986. * Represents a map of input types to input instance or input index to input instance.
  74987. */
  74988. export interface CameraInputsMap<TCamera extends Camera> {
  74989. /**
  74990. * Accessor to the input by input type.
  74991. */
  74992. [name: string]: ICameraInput<TCamera>;
  74993. /**
  74994. * Accessor to the input by input index.
  74995. */
  74996. [idx: number]: ICameraInput<TCamera>;
  74997. }
  74998. /**
  74999. * This represents the input manager used within a camera.
  75000. * It helps dealing with all the different kind of input attached to a camera.
  75001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75002. */
  75003. export class CameraInputsManager<TCamera extends Camera> {
  75004. /**
  75005. * Defines the list of inputs attahed to the camera.
  75006. */
  75007. attached: CameraInputsMap<TCamera>;
  75008. /**
  75009. * Defines the dom element the camera is collecting inputs from.
  75010. * This is null if the controls have not been attached.
  75011. */
  75012. attachedElement: Nullable<HTMLElement>;
  75013. /**
  75014. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75015. */
  75016. noPreventDefault: boolean;
  75017. /**
  75018. * Defined the camera the input manager belongs to.
  75019. */
  75020. camera: TCamera;
  75021. /**
  75022. * Update the current camera state depending on the inputs that have been used this frame.
  75023. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75024. */
  75025. checkInputs: () => void;
  75026. /**
  75027. * Instantiate a new Camera Input Manager.
  75028. * @param camera Defines the camera the input manager blongs to
  75029. */
  75030. constructor(camera: TCamera);
  75031. /**
  75032. * Add an input method to a camera
  75033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75034. * @param input camera input method
  75035. */
  75036. add(input: ICameraInput<TCamera>): void;
  75037. /**
  75038. * Remove a specific input method from a camera
  75039. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  75040. * @param inputToRemove camera input method
  75041. */
  75042. remove(inputToRemove: ICameraInput<TCamera>): void;
  75043. /**
  75044. * Remove a specific input type from a camera
  75045. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  75046. * @param inputType the type of the input to remove
  75047. */
  75048. removeByType(inputType: string): void;
  75049. private _addCheckInputs;
  75050. /**
  75051. * Attach the input controls to the currently attached dom element to listen the events from.
  75052. * @param input Defines the input to attach
  75053. */
  75054. attachInput(input: ICameraInput<TCamera>): void;
  75055. /**
  75056. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  75057. * @param element Defines the dom element to collect the events from
  75058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75059. */
  75060. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  75061. /**
  75062. * Detach the current manager inputs controls from a specific dom element.
  75063. * @param element Defines the dom element to collect the events from
  75064. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  75065. */
  75066. detachElement(element: HTMLElement, disconnect?: boolean): void;
  75067. /**
  75068. * Rebuild the dynamic inputCheck function from the current list of
  75069. * defined inputs in the manager.
  75070. */
  75071. rebuildInputCheck(): void;
  75072. /**
  75073. * Remove all attached input methods from a camera
  75074. */
  75075. clear(): void;
  75076. /**
  75077. * Serialize the current input manager attached to a camera.
  75078. * This ensures than once parsed,
  75079. * the input associated to the camera will be identical to the current ones
  75080. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  75081. */
  75082. serialize(serializedCamera: any): void;
  75083. /**
  75084. * Parses an input manager serialized JSON to restore the previous list of inputs
  75085. * and states associated to a camera.
  75086. * @param parsedCamera Defines the JSON to parse
  75087. */
  75088. parse(parsedCamera: any): void;
  75089. }
  75090. }
  75091. declare module BABYLON {
  75092. /**
  75093. * Class used to store data that will be store in GPU memory
  75094. */
  75095. export class Buffer {
  75096. private _engine;
  75097. private _buffer;
  75098. /** @hidden */
  75099. _data: Nullable<DataArray>;
  75100. private _updatable;
  75101. private _instanced;
  75102. private _divisor;
  75103. /**
  75104. * Gets the byte stride.
  75105. */
  75106. readonly byteStride: number;
  75107. /**
  75108. * Constructor
  75109. * @param engine the engine
  75110. * @param data the data to use for this buffer
  75111. * @param updatable whether the data is updatable
  75112. * @param stride the stride (optional)
  75113. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75114. * @param instanced whether the buffer is instanced (optional)
  75115. * @param useBytes set to true if the stride in in bytes (optional)
  75116. * @param divisor sets an optional divisor for instances (1 by default)
  75117. */
  75118. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  75119. /**
  75120. * Create a new VertexBuffer based on the current buffer
  75121. * @param kind defines the vertex buffer kind (position, normal, etc.)
  75122. * @param offset defines offset in the buffer (0 by default)
  75123. * @param size defines the size in floats of attributes (position is 3 for instance)
  75124. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  75125. * @param instanced defines if the vertex buffer contains indexed data
  75126. * @param useBytes defines if the offset and stride are in bytes *
  75127. * @param divisor sets an optional divisor for instances (1 by default)
  75128. * @returns the new vertex buffer
  75129. */
  75130. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  75131. /**
  75132. * Gets a boolean indicating if the Buffer is updatable?
  75133. * @returns true if the buffer is updatable
  75134. */
  75135. isUpdatable(): boolean;
  75136. /**
  75137. * Gets current buffer's data
  75138. * @returns a DataArray or null
  75139. */
  75140. getData(): Nullable<DataArray>;
  75141. /**
  75142. * Gets underlying native buffer
  75143. * @returns underlying native buffer
  75144. */
  75145. getBuffer(): Nullable<DataBuffer>;
  75146. /**
  75147. * Gets the stride in float32 units (i.e. byte stride / 4).
  75148. * May not be an integer if the byte stride is not divisible by 4.
  75149. * @returns the stride in float32 units
  75150. * @deprecated Please use byteStride instead.
  75151. */
  75152. getStrideSize(): number;
  75153. /**
  75154. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75155. * @param data defines the data to store
  75156. */
  75157. create(data?: Nullable<DataArray>): void;
  75158. /** @hidden */
  75159. _rebuild(): void;
  75160. /**
  75161. * Update current buffer data
  75162. * @param data defines the data to store
  75163. */
  75164. update(data: DataArray): void;
  75165. /**
  75166. * Updates the data directly.
  75167. * @param data the new data
  75168. * @param offset the new offset
  75169. * @param vertexCount the vertex count (optional)
  75170. * @param useBytes set to true if the offset is in bytes
  75171. */
  75172. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  75173. /**
  75174. * Release all resources
  75175. */
  75176. dispose(): void;
  75177. }
  75178. /**
  75179. * Specialized buffer used to store vertex data
  75180. */
  75181. export class VertexBuffer {
  75182. /** @hidden */
  75183. _buffer: Buffer;
  75184. private _kind;
  75185. private _size;
  75186. private _ownsBuffer;
  75187. private _instanced;
  75188. private _instanceDivisor;
  75189. /**
  75190. * The byte type.
  75191. */
  75192. static readonly BYTE: number;
  75193. /**
  75194. * The unsigned byte type.
  75195. */
  75196. static readonly UNSIGNED_BYTE: number;
  75197. /**
  75198. * The short type.
  75199. */
  75200. static readonly SHORT: number;
  75201. /**
  75202. * The unsigned short type.
  75203. */
  75204. static readonly UNSIGNED_SHORT: number;
  75205. /**
  75206. * The integer type.
  75207. */
  75208. static readonly INT: number;
  75209. /**
  75210. * The unsigned integer type.
  75211. */
  75212. static readonly UNSIGNED_INT: number;
  75213. /**
  75214. * The float type.
  75215. */
  75216. static readonly FLOAT: number;
  75217. /**
  75218. * Gets or sets the instance divisor when in instanced mode
  75219. */
  75220. instanceDivisor: number;
  75221. /**
  75222. * Gets the byte stride.
  75223. */
  75224. readonly byteStride: number;
  75225. /**
  75226. * Gets the byte offset.
  75227. */
  75228. readonly byteOffset: number;
  75229. /**
  75230. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  75231. */
  75232. readonly normalized: boolean;
  75233. /**
  75234. * Gets the data type of each component in the array.
  75235. */
  75236. readonly type: number;
  75237. /**
  75238. * Constructor
  75239. * @param engine the engine
  75240. * @param data the data to use for this vertex buffer
  75241. * @param kind the vertex buffer kind
  75242. * @param updatable whether the data is updatable
  75243. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75244. * @param stride the stride (optional)
  75245. * @param instanced whether the buffer is instanced (optional)
  75246. * @param offset the offset of the data (optional)
  75247. * @param size the number of components (optional)
  75248. * @param type the type of the component (optional)
  75249. * @param normalized whether the data contains normalized data (optional)
  75250. * @param useBytes set to true if stride and offset are in bytes (optional)
  75251. * @param divisor defines the instance divisor to use (1 by default)
  75252. */
  75253. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  75254. /** @hidden */
  75255. _rebuild(): void;
  75256. /**
  75257. * Returns the kind of the VertexBuffer (string)
  75258. * @returns a string
  75259. */
  75260. getKind(): string;
  75261. /**
  75262. * Gets a boolean indicating if the VertexBuffer is updatable?
  75263. * @returns true if the buffer is updatable
  75264. */
  75265. isUpdatable(): boolean;
  75266. /**
  75267. * Gets current buffer's data
  75268. * @returns a DataArray or null
  75269. */
  75270. getData(): Nullable<DataArray>;
  75271. /**
  75272. * Gets underlying native buffer
  75273. * @returns underlying native buffer
  75274. */
  75275. getBuffer(): Nullable<DataBuffer>;
  75276. /**
  75277. * Gets the stride in float32 units (i.e. byte stride / 4).
  75278. * May not be an integer if the byte stride is not divisible by 4.
  75279. * @returns the stride in float32 units
  75280. * @deprecated Please use byteStride instead.
  75281. */
  75282. getStrideSize(): number;
  75283. /**
  75284. * Returns the offset as a multiple of the type byte length.
  75285. * @returns the offset in bytes
  75286. * @deprecated Please use byteOffset instead.
  75287. */
  75288. getOffset(): number;
  75289. /**
  75290. * Returns the number of components per vertex attribute (integer)
  75291. * @returns the size in float
  75292. */
  75293. getSize(): number;
  75294. /**
  75295. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  75296. * @returns true if this buffer is instanced
  75297. */
  75298. getIsInstanced(): boolean;
  75299. /**
  75300. * Returns the instancing divisor, zero for non-instanced (integer).
  75301. * @returns a number
  75302. */
  75303. getInstanceDivisor(): number;
  75304. /**
  75305. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75306. * @param data defines the data to store
  75307. */
  75308. create(data?: DataArray): void;
  75309. /**
  75310. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  75311. * This function will create a new buffer if the current one is not updatable
  75312. * @param data defines the data to store
  75313. */
  75314. update(data: DataArray): void;
  75315. /**
  75316. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  75317. * Returns the directly updated WebGLBuffer.
  75318. * @param data the new data
  75319. * @param offset the new offset
  75320. * @param useBytes set to true if the offset is in bytes
  75321. */
  75322. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  75323. /**
  75324. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  75325. */
  75326. dispose(): void;
  75327. /**
  75328. * Enumerates each value of this vertex buffer as numbers.
  75329. * @param count the number of values to enumerate
  75330. * @param callback the callback function called for each value
  75331. */
  75332. forEach(count: number, callback: (value: number, index: number) => void): void;
  75333. /**
  75334. * Positions
  75335. */
  75336. static readonly PositionKind: string;
  75337. /**
  75338. * Normals
  75339. */
  75340. static readonly NormalKind: string;
  75341. /**
  75342. * Tangents
  75343. */
  75344. static readonly TangentKind: string;
  75345. /**
  75346. * Texture coordinates
  75347. */
  75348. static readonly UVKind: string;
  75349. /**
  75350. * Texture coordinates 2
  75351. */
  75352. static readonly UV2Kind: string;
  75353. /**
  75354. * Texture coordinates 3
  75355. */
  75356. static readonly UV3Kind: string;
  75357. /**
  75358. * Texture coordinates 4
  75359. */
  75360. static readonly UV4Kind: string;
  75361. /**
  75362. * Texture coordinates 5
  75363. */
  75364. static readonly UV5Kind: string;
  75365. /**
  75366. * Texture coordinates 6
  75367. */
  75368. static readonly UV6Kind: string;
  75369. /**
  75370. * Colors
  75371. */
  75372. static readonly ColorKind: string;
  75373. /**
  75374. * Matrix indices (for bones)
  75375. */
  75376. static readonly MatricesIndicesKind: string;
  75377. /**
  75378. * Matrix weights (for bones)
  75379. */
  75380. static readonly MatricesWeightsKind: string;
  75381. /**
  75382. * Additional matrix indices (for bones)
  75383. */
  75384. static readonly MatricesIndicesExtraKind: string;
  75385. /**
  75386. * Additional matrix weights (for bones)
  75387. */
  75388. static readonly MatricesWeightsExtraKind: string;
  75389. /**
  75390. * Deduces the stride given a kind.
  75391. * @param kind The kind string to deduce
  75392. * @returns The deduced stride
  75393. */
  75394. static DeduceStride(kind: string): number;
  75395. /**
  75396. * Gets the byte length of the given type.
  75397. * @param type the type
  75398. * @returns the number of bytes
  75399. */
  75400. static GetTypeByteLength(type: number): number;
  75401. /**
  75402. * Enumerates each value of the given parameters as numbers.
  75403. * @param data the data to enumerate
  75404. * @param byteOffset the byte offset of the data
  75405. * @param byteStride the byte stride of the data
  75406. * @param componentCount the number of components per element
  75407. * @param componentType the type of the component
  75408. * @param count the number of values to enumerate
  75409. * @param normalized whether the data is normalized
  75410. * @param callback the callback function called for each value
  75411. */
  75412. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  75413. private static _GetFloatValue;
  75414. }
  75415. }
  75416. declare module BABYLON {
  75417. /**
  75418. * @hidden
  75419. */
  75420. export class IntersectionInfo {
  75421. bu: Nullable<number>;
  75422. bv: Nullable<number>;
  75423. distance: number;
  75424. faceId: number;
  75425. subMeshId: number;
  75426. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  75427. }
  75428. }
  75429. declare module BABYLON {
  75430. /**
  75431. * Represens a plane by the equation ax + by + cz + d = 0
  75432. */
  75433. export class Plane {
  75434. private static _TmpMatrix;
  75435. /**
  75436. * Normal of the plane (a,b,c)
  75437. */
  75438. normal: Vector3;
  75439. /**
  75440. * d component of the plane
  75441. */
  75442. d: number;
  75443. /**
  75444. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75445. * @param a a component of the plane
  75446. * @param b b component of the plane
  75447. * @param c c component of the plane
  75448. * @param d d component of the plane
  75449. */
  75450. constructor(a: number, b: number, c: number, d: number);
  75451. /**
  75452. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75453. */
  75454. asArray(): number[];
  75455. /**
  75456. * @returns a new plane copied from the current Plane.
  75457. */
  75458. clone(): Plane;
  75459. /**
  75460. * @returns the string "Plane".
  75461. */
  75462. getClassName(): string;
  75463. /**
  75464. * @returns the Plane hash code.
  75465. */
  75466. getHashCode(): number;
  75467. /**
  75468. * Normalize the current Plane in place.
  75469. * @returns the updated Plane.
  75470. */
  75471. normalize(): Plane;
  75472. /**
  75473. * Applies a transformation the plane and returns the result
  75474. * @param transformation the transformation matrix to be applied to the plane
  75475. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75476. */
  75477. transform(transformation: DeepImmutable<Matrix>): Plane;
  75478. /**
  75479. * Calcualtte the dot product between the point and the plane normal
  75480. * @param point point to calculate the dot product with
  75481. * @returns the dot product (float) of the point coordinates and the plane normal.
  75482. */
  75483. dotCoordinate(point: DeepImmutable<Vector3>): number;
  75484. /**
  75485. * Updates the current Plane from the plane defined by the three given points.
  75486. * @param point1 one of the points used to contruct the plane
  75487. * @param point2 one of the points used to contruct the plane
  75488. * @param point3 one of the points used to contruct the plane
  75489. * @returns the updated Plane.
  75490. */
  75491. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75492. /**
  75493. * Checks if the plane is facing a given direction
  75494. * @param direction the direction to check if the plane is facing
  75495. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75496. * @returns True is the vector "direction" is the same side than the plane normal.
  75497. */
  75498. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  75499. /**
  75500. * Calculates the distance to a point
  75501. * @param point point to calculate distance to
  75502. * @returns the signed distance (float) from the given point to the Plane.
  75503. */
  75504. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  75505. /**
  75506. * Creates a plane from an array
  75507. * @param array the array to create a plane from
  75508. * @returns a new Plane from the given array.
  75509. */
  75510. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  75511. /**
  75512. * Creates a plane from three points
  75513. * @param point1 point used to create the plane
  75514. * @param point2 point used to create the plane
  75515. * @param point3 point used to create the plane
  75516. * @returns a new Plane defined by the three given points.
  75517. */
  75518. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75519. /**
  75520. * Creates a plane from an origin point and a normal
  75521. * @param origin origin of the plane to be constructed
  75522. * @param normal normal of the plane to be constructed
  75523. * @returns a new Plane the normal vector to this plane at the given origin point.
  75524. * Note : the vector "normal" is updated because normalized.
  75525. */
  75526. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  75527. /**
  75528. * Calculates the distance from a plane and a point
  75529. * @param origin origin of the plane to be constructed
  75530. * @param normal normal of the plane to be constructed
  75531. * @param point point to calculate distance to
  75532. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75533. */
  75534. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  75535. }
  75536. }
  75537. declare module BABYLON {
  75538. /**
  75539. * Class used to store bounding sphere information
  75540. */
  75541. export class BoundingSphere {
  75542. /**
  75543. * Gets the center of the bounding sphere in local space
  75544. */
  75545. readonly center: Vector3;
  75546. /**
  75547. * Radius of the bounding sphere in local space
  75548. */
  75549. radius: number;
  75550. /**
  75551. * Gets the center of the bounding sphere in world space
  75552. */
  75553. readonly centerWorld: Vector3;
  75554. /**
  75555. * Radius of the bounding sphere in world space
  75556. */
  75557. radiusWorld: number;
  75558. /**
  75559. * Gets the minimum vector in local space
  75560. */
  75561. readonly minimum: Vector3;
  75562. /**
  75563. * Gets the maximum vector in local space
  75564. */
  75565. readonly maximum: Vector3;
  75566. private _worldMatrix;
  75567. private static readonly TmpVector3;
  75568. /**
  75569. * Creates a new bounding sphere
  75570. * @param min defines the minimum vector (in local space)
  75571. * @param max defines the maximum vector (in local space)
  75572. * @param worldMatrix defines the new world matrix
  75573. */
  75574. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75575. /**
  75576. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  75577. * @param min defines the new minimum vector (in local space)
  75578. * @param max defines the new maximum vector (in local space)
  75579. * @param worldMatrix defines the new world matrix
  75580. */
  75581. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75582. /**
  75583. * Scale the current bounding sphere by applying a scale factor
  75584. * @param factor defines the scale factor to apply
  75585. * @returns the current bounding box
  75586. */
  75587. scale(factor: number): BoundingSphere;
  75588. /**
  75589. * Gets the world matrix of the bounding box
  75590. * @returns a matrix
  75591. */
  75592. getWorldMatrix(): DeepImmutable<Matrix>;
  75593. /** @hidden */
  75594. _update(worldMatrix: DeepImmutable<Matrix>): void;
  75595. /**
  75596. * Tests if the bounding sphere is intersecting the frustum planes
  75597. * @param frustumPlanes defines the frustum planes to test
  75598. * @returns true if there is an intersection
  75599. */
  75600. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75601. /**
  75602. * Tests if the bounding sphere center is in between the frustum planes.
  75603. * Used for optimistic fast inclusion.
  75604. * @param frustumPlanes defines the frustum planes to test
  75605. * @returns true if the sphere center is in between the frustum planes
  75606. */
  75607. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75608. /**
  75609. * Tests if a point is inside the bounding sphere
  75610. * @param point defines the point to test
  75611. * @returns true if the point is inside the bounding sphere
  75612. */
  75613. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75614. /**
  75615. * Checks if two sphere intersct
  75616. * @param sphere0 sphere 0
  75617. * @param sphere1 sphere 1
  75618. * @returns true if the speres intersect
  75619. */
  75620. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  75621. }
  75622. }
  75623. declare module BABYLON {
  75624. /**
  75625. * Class used to store bounding box information
  75626. */
  75627. export class BoundingBox implements ICullable {
  75628. /**
  75629. * Gets the 8 vectors representing the bounding box in local space
  75630. */
  75631. readonly vectors: Vector3[];
  75632. /**
  75633. * Gets the center of the bounding box in local space
  75634. */
  75635. readonly center: Vector3;
  75636. /**
  75637. * Gets the center of the bounding box in world space
  75638. */
  75639. readonly centerWorld: Vector3;
  75640. /**
  75641. * Gets the extend size in local space
  75642. */
  75643. readonly extendSize: Vector3;
  75644. /**
  75645. * Gets the extend size in world space
  75646. */
  75647. readonly extendSizeWorld: Vector3;
  75648. /**
  75649. * Gets the OBB (object bounding box) directions
  75650. */
  75651. readonly directions: Vector3[];
  75652. /**
  75653. * Gets the 8 vectors representing the bounding box in world space
  75654. */
  75655. readonly vectorsWorld: Vector3[];
  75656. /**
  75657. * Gets the minimum vector in world space
  75658. */
  75659. readonly minimumWorld: Vector3;
  75660. /**
  75661. * Gets the maximum vector in world space
  75662. */
  75663. readonly maximumWorld: Vector3;
  75664. /**
  75665. * Gets the minimum vector in local space
  75666. */
  75667. readonly minimum: Vector3;
  75668. /**
  75669. * Gets the maximum vector in local space
  75670. */
  75671. readonly maximum: Vector3;
  75672. private _worldMatrix;
  75673. private static readonly TmpVector3;
  75674. /**
  75675. * @hidden
  75676. */
  75677. _tag: number;
  75678. /**
  75679. * Creates a new bounding box
  75680. * @param min defines the minimum vector (in local space)
  75681. * @param max defines the maximum vector (in local space)
  75682. * @param worldMatrix defines the new world matrix
  75683. */
  75684. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75685. /**
  75686. * Recreates the entire bounding box from scratch as if we call the constructor in place
  75687. * @param min defines the new minimum vector (in local space)
  75688. * @param max defines the new maximum vector (in local space)
  75689. * @param worldMatrix defines the new world matrix
  75690. */
  75691. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75692. /**
  75693. * Scale the current bounding box by applying a scale factor
  75694. * @param factor defines the scale factor to apply
  75695. * @returns the current bounding box
  75696. */
  75697. scale(factor: number): BoundingBox;
  75698. /**
  75699. * Gets the world matrix of the bounding box
  75700. * @returns a matrix
  75701. */
  75702. getWorldMatrix(): DeepImmutable<Matrix>;
  75703. /** @hidden */
  75704. _update(world: DeepImmutable<Matrix>): void;
  75705. /**
  75706. * Tests if the bounding box is intersecting the frustum planes
  75707. * @param frustumPlanes defines the frustum planes to test
  75708. * @returns true if there is an intersection
  75709. */
  75710. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75711. /**
  75712. * Tests if the bounding box is entirely inside the frustum planes
  75713. * @param frustumPlanes defines the frustum planes to test
  75714. * @returns true if there is an inclusion
  75715. */
  75716. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75717. /**
  75718. * Tests if a point is inside the bounding box
  75719. * @param point defines the point to test
  75720. * @returns true if the point is inside the bounding box
  75721. */
  75722. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75723. /**
  75724. * Tests if the bounding box intersects with a bounding sphere
  75725. * @param sphere defines the sphere to test
  75726. * @returns true if there is an intersection
  75727. */
  75728. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75729. /**
  75730. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75731. * @param min defines the min vector to use
  75732. * @param max defines the max vector to use
  75733. * @returns true if there is an intersection
  75734. */
  75735. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75736. /**
  75737. * Tests if two bounding boxes are intersections
  75738. * @param box0 defines the first box to test
  75739. * @param box1 defines the second box to test
  75740. * @returns true if there is an intersection
  75741. */
  75742. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75743. /**
  75744. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75745. * @param minPoint defines the minimum vector of the bounding box
  75746. * @param maxPoint defines the maximum vector of the bounding box
  75747. * @param sphereCenter defines the sphere center
  75748. * @param sphereRadius defines the sphere radius
  75749. * @returns true if there is an intersection
  75750. */
  75751. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75752. /**
  75753. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75754. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75755. * @param frustumPlanes defines the frustum planes to test
  75756. * @return true if there is an inclusion
  75757. */
  75758. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75759. /**
  75760. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75761. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75762. * @param frustumPlanes defines the frustum planes to test
  75763. * @return true if there is an intersection
  75764. */
  75765. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75766. }
  75767. }
  75768. declare module BABYLON {
  75769. /** @hidden */
  75770. export class Collider {
  75771. /** Define if a collision was found */
  75772. collisionFound: boolean;
  75773. /**
  75774. * Define last intersection point in local space
  75775. */
  75776. intersectionPoint: Vector3;
  75777. /**
  75778. * Define last collided mesh
  75779. */
  75780. collidedMesh: Nullable<AbstractMesh>;
  75781. private _collisionPoint;
  75782. private _planeIntersectionPoint;
  75783. private _tempVector;
  75784. private _tempVector2;
  75785. private _tempVector3;
  75786. private _tempVector4;
  75787. private _edge;
  75788. private _baseToVertex;
  75789. private _destinationPoint;
  75790. private _slidePlaneNormal;
  75791. private _displacementVector;
  75792. /** @hidden */
  75793. _radius: Vector3;
  75794. /** @hidden */
  75795. _retry: number;
  75796. private _velocity;
  75797. private _basePoint;
  75798. private _epsilon;
  75799. /** @hidden */
  75800. _velocityWorldLength: number;
  75801. /** @hidden */
  75802. _basePointWorld: Vector3;
  75803. private _velocityWorld;
  75804. private _normalizedVelocity;
  75805. /** @hidden */
  75806. _initialVelocity: Vector3;
  75807. /** @hidden */
  75808. _initialPosition: Vector3;
  75809. private _nearestDistance;
  75810. private _collisionMask;
  75811. collisionMask: number;
  75812. /**
  75813. * Gets the plane normal used to compute the sliding response (in local space)
  75814. */
  75815. readonly slidePlaneNormal: Vector3;
  75816. /** @hidden */
  75817. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75818. /** @hidden */
  75819. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75820. /** @hidden */
  75821. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75822. /** @hidden */
  75823. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75824. /** @hidden */
  75825. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75826. /** @hidden */
  75827. _getResponse(pos: Vector3, vel: Vector3): void;
  75828. }
  75829. }
  75830. declare module BABYLON {
  75831. /**
  75832. * Interface for cullable objects
  75833. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75834. */
  75835. export interface ICullable {
  75836. /**
  75837. * Checks if the object or part of the object is in the frustum
  75838. * @param frustumPlanes Camera near/planes
  75839. * @returns true if the object is in frustum otherwise false
  75840. */
  75841. isInFrustum(frustumPlanes: Plane[]): boolean;
  75842. /**
  75843. * Checks if a cullable object (mesh...) is in the camera frustum
  75844. * Unlike isInFrustum this cheks the full bounding box
  75845. * @param frustumPlanes Camera near/planes
  75846. * @returns true if the object is in frustum otherwise false
  75847. */
  75848. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75849. }
  75850. /**
  75851. * Info for a bounding data of a mesh
  75852. */
  75853. export class BoundingInfo implements ICullable {
  75854. /**
  75855. * Bounding box for the mesh
  75856. */
  75857. readonly boundingBox: BoundingBox;
  75858. /**
  75859. * Bounding sphere for the mesh
  75860. */
  75861. readonly boundingSphere: BoundingSphere;
  75862. private _isLocked;
  75863. private static readonly TmpVector3;
  75864. /**
  75865. * Constructs bounding info
  75866. * @param minimum min vector of the bounding box/sphere
  75867. * @param maximum max vector of the bounding box/sphere
  75868. * @param worldMatrix defines the new world matrix
  75869. */
  75870. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75871. /**
  75872. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75873. * @param min defines the new minimum vector (in local space)
  75874. * @param max defines the new maximum vector (in local space)
  75875. * @param worldMatrix defines the new world matrix
  75876. */
  75877. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75878. /**
  75879. * min vector of the bounding box/sphere
  75880. */
  75881. readonly minimum: Vector3;
  75882. /**
  75883. * max vector of the bounding box/sphere
  75884. */
  75885. readonly maximum: Vector3;
  75886. /**
  75887. * If the info is locked and won't be updated to avoid perf overhead
  75888. */
  75889. isLocked: boolean;
  75890. /**
  75891. * Updates the bounding sphere and box
  75892. * @param world world matrix to be used to update
  75893. */
  75894. update(world: DeepImmutable<Matrix>): void;
  75895. /**
  75896. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75897. * @param center New center of the bounding info
  75898. * @param extend New extend of the bounding info
  75899. * @returns the current bounding info
  75900. */
  75901. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75902. /**
  75903. * Scale the current bounding info by applying a scale factor
  75904. * @param factor defines the scale factor to apply
  75905. * @returns the current bounding info
  75906. */
  75907. scale(factor: number): BoundingInfo;
  75908. /**
  75909. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75910. * @param frustumPlanes defines the frustum to test
  75911. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75912. * @returns true if the bounding info is in the frustum planes
  75913. */
  75914. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75915. /**
  75916. * Gets the world distance between the min and max points of the bounding box
  75917. */
  75918. readonly diagonalLength: number;
  75919. /**
  75920. * Checks if a cullable object (mesh...) is in the camera frustum
  75921. * Unlike isInFrustum this cheks the full bounding box
  75922. * @param frustumPlanes Camera near/planes
  75923. * @returns true if the object is in frustum otherwise false
  75924. */
  75925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75926. /** @hidden */
  75927. _checkCollision(collider: Collider): boolean;
  75928. /**
  75929. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75930. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75931. * @param point the point to check intersection with
  75932. * @returns if the point intersects
  75933. */
  75934. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75935. /**
  75936. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75937. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75938. * @param boundingInfo the bounding info to check intersection with
  75939. * @param precise if the intersection should be done using OBB
  75940. * @returns if the bounding info intersects
  75941. */
  75942. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75943. }
  75944. }
  75945. declare module BABYLON {
  75946. /**
  75947. * Extracts minimum and maximum values from a list of indexed positions
  75948. * @param positions defines the positions to use
  75949. * @param indices defines the indices to the positions
  75950. * @param indexStart defines the start index
  75951. * @param indexCount defines the end index
  75952. * @param bias defines bias value to add to the result
  75953. * @return minimum and maximum values
  75954. */
  75955. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75956. minimum: Vector3;
  75957. maximum: Vector3;
  75958. };
  75959. /**
  75960. * Extracts minimum and maximum values from a list of positions
  75961. * @param positions defines the positions to use
  75962. * @param start defines the start index in the positions array
  75963. * @param count defines the number of positions to handle
  75964. * @param bias defines bias value to add to the result
  75965. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75966. * @return minimum and maximum values
  75967. */
  75968. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75969. minimum: Vector3;
  75970. maximum: Vector3;
  75971. };
  75972. }
  75973. declare module BABYLON {
  75974. /** @hidden */
  75975. export class WebGLDataBuffer extends DataBuffer {
  75976. private _buffer;
  75977. constructor(resource: WebGLBuffer);
  75978. readonly underlyingResource: any;
  75979. }
  75980. }
  75981. declare module BABYLON {
  75982. /** @hidden */
  75983. export class WebGLPipelineContext implements IPipelineContext {
  75984. engine: ThinEngine;
  75985. program: Nullable<WebGLProgram>;
  75986. context?: WebGLRenderingContext;
  75987. vertexShader?: WebGLShader;
  75988. fragmentShader?: WebGLShader;
  75989. isParallelCompiled: boolean;
  75990. onCompiled?: () => void;
  75991. transformFeedback?: WebGLTransformFeedback | null;
  75992. readonly isAsync: boolean;
  75993. readonly isReady: boolean;
  75994. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75995. }
  75996. }
  75997. declare module BABYLON {
  75998. interface ThinEngine {
  75999. /**
  76000. * Create an uniform buffer
  76001. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76002. * @param elements defines the content of the uniform buffer
  76003. * @returns the webGL uniform buffer
  76004. */
  76005. createUniformBuffer(elements: FloatArray): DataBuffer;
  76006. /**
  76007. * Create a dynamic uniform buffer
  76008. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76009. * @param elements defines the content of the uniform buffer
  76010. * @returns the webGL uniform buffer
  76011. */
  76012. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  76013. /**
  76014. * Update an existing uniform buffer
  76015. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76016. * @param uniformBuffer defines the target uniform buffer
  76017. * @param elements defines the content to update
  76018. * @param offset defines the offset in the uniform buffer where update should start
  76019. * @param count defines the size of the data to update
  76020. */
  76021. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  76022. /**
  76023. * Bind an uniform buffer to the current webGL context
  76024. * @param buffer defines the buffer to bind
  76025. */
  76026. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  76027. /**
  76028. * Bind a buffer to the current webGL context at a given location
  76029. * @param buffer defines the buffer to bind
  76030. * @param location defines the index where to bind the buffer
  76031. */
  76032. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  76033. /**
  76034. * Bind a specific block at a given index in a specific shader program
  76035. * @param pipelineContext defines the pipeline context to use
  76036. * @param blockName defines the block name
  76037. * @param index defines the index where to bind the block
  76038. */
  76039. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  76040. }
  76041. }
  76042. declare module BABYLON {
  76043. /**
  76044. * Uniform buffer objects.
  76045. *
  76046. * Handles blocks of uniform on the GPU.
  76047. *
  76048. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76049. *
  76050. * For more information, please refer to :
  76051. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76052. */
  76053. export class UniformBuffer {
  76054. private _engine;
  76055. private _buffer;
  76056. private _data;
  76057. private _bufferData;
  76058. private _dynamic?;
  76059. private _uniformLocations;
  76060. private _uniformSizes;
  76061. private _uniformLocationPointer;
  76062. private _needSync;
  76063. private _noUBO;
  76064. private _currentEffect;
  76065. /** @hidden */
  76066. _alreadyBound: boolean;
  76067. private static _MAX_UNIFORM_SIZE;
  76068. private static _tempBuffer;
  76069. /**
  76070. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  76071. * This is dynamic to allow compat with webgl 1 and 2.
  76072. * You will need to pass the name of the uniform as well as the value.
  76073. */
  76074. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  76075. /**
  76076. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  76077. * This is dynamic to allow compat with webgl 1 and 2.
  76078. * You will need to pass the name of the uniform as well as the value.
  76079. */
  76080. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  76081. /**
  76082. * Lambda to Update a single float in a uniform buffer.
  76083. * This is dynamic to allow compat with webgl 1 and 2.
  76084. * You will need to pass the name of the uniform as well as the value.
  76085. */
  76086. updateFloat: (name: string, x: number) => void;
  76087. /**
  76088. * Lambda to Update a vec2 of float in a uniform buffer.
  76089. * This is dynamic to allow compat with webgl 1 and 2.
  76090. * You will need to pass the name of the uniform as well as the value.
  76091. */
  76092. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  76093. /**
  76094. * Lambda to Update a vec3 of float in a uniform buffer.
  76095. * This is dynamic to allow compat with webgl 1 and 2.
  76096. * You will need to pass the name of the uniform as well as the value.
  76097. */
  76098. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  76099. /**
  76100. * Lambda to Update a vec4 of float in a uniform buffer.
  76101. * This is dynamic to allow compat with webgl 1 and 2.
  76102. * You will need to pass the name of the uniform as well as the value.
  76103. */
  76104. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  76105. /**
  76106. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  76107. * This is dynamic to allow compat with webgl 1 and 2.
  76108. * You will need to pass the name of the uniform as well as the value.
  76109. */
  76110. updateMatrix: (name: string, mat: Matrix) => void;
  76111. /**
  76112. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  76113. * This is dynamic to allow compat with webgl 1 and 2.
  76114. * You will need to pass the name of the uniform as well as the value.
  76115. */
  76116. updateVector3: (name: string, vector: Vector3) => void;
  76117. /**
  76118. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  76119. * This is dynamic to allow compat with webgl 1 and 2.
  76120. * You will need to pass the name of the uniform as well as the value.
  76121. */
  76122. updateVector4: (name: string, vector: Vector4) => void;
  76123. /**
  76124. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  76125. * This is dynamic to allow compat with webgl 1 and 2.
  76126. * You will need to pass the name of the uniform as well as the value.
  76127. */
  76128. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  76129. /**
  76130. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  76131. * This is dynamic to allow compat with webgl 1 and 2.
  76132. * You will need to pass the name of the uniform as well as the value.
  76133. */
  76134. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  76135. /**
  76136. * Instantiates a new Uniform buffer objects.
  76137. *
  76138. * Handles blocks of uniform on the GPU.
  76139. *
  76140. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76141. *
  76142. * For more information, please refer to :
  76143. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76144. * @param engine Define the engine the buffer is associated with
  76145. * @param data Define the data contained in the buffer
  76146. * @param dynamic Define if the buffer is updatable
  76147. */
  76148. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  76149. /**
  76150. * Indicates if the buffer is using the WebGL2 UBO implementation,
  76151. * or just falling back on setUniformXXX calls.
  76152. */
  76153. readonly useUbo: boolean;
  76154. /**
  76155. * Indicates if the WebGL underlying uniform buffer is in sync
  76156. * with the javascript cache data.
  76157. */
  76158. readonly isSync: boolean;
  76159. /**
  76160. * Indicates if the WebGL underlying uniform buffer is dynamic.
  76161. * Also, a dynamic UniformBuffer will disable cache verification and always
  76162. * update the underlying WebGL uniform buffer to the GPU.
  76163. * @returns if Dynamic, otherwise false
  76164. */
  76165. isDynamic(): boolean;
  76166. /**
  76167. * The data cache on JS side.
  76168. * @returns the underlying data as a float array
  76169. */
  76170. getData(): Float32Array;
  76171. /**
  76172. * The underlying WebGL Uniform buffer.
  76173. * @returns the webgl buffer
  76174. */
  76175. getBuffer(): Nullable<DataBuffer>;
  76176. /**
  76177. * std140 layout specifies how to align data within an UBO structure.
  76178. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  76179. * for specs.
  76180. */
  76181. private _fillAlignment;
  76182. /**
  76183. * Adds an uniform in the buffer.
  76184. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  76185. * for the layout to be correct !
  76186. * @param name Name of the uniform, as used in the uniform block in the shader.
  76187. * @param size Data size, or data directly.
  76188. */
  76189. addUniform(name: string, size: number | number[]): void;
  76190. /**
  76191. * Adds a Matrix 4x4 to the uniform buffer.
  76192. * @param name Name of the uniform, as used in the uniform block in the shader.
  76193. * @param mat A 4x4 matrix.
  76194. */
  76195. addMatrix(name: string, mat: Matrix): void;
  76196. /**
  76197. * Adds a vec2 to the uniform buffer.
  76198. * @param name Name of the uniform, as used in the uniform block in the shader.
  76199. * @param x Define the x component value of the vec2
  76200. * @param y Define the y component value of the vec2
  76201. */
  76202. addFloat2(name: string, x: number, y: number): void;
  76203. /**
  76204. * Adds a vec3 to the uniform buffer.
  76205. * @param name Name of the uniform, as used in the uniform block in the shader.
  76206. * @param x Define the x component value of the vec3
  76207. * @param y Define the y component value of the vec3
  76208. * @param z Define the z component value of the vec3
  76209. */
  76210. addFloat3(name: string, x: number, y: number, z: number): void;
  76211. /**
  76212. * Adds a vec3 to the uniform buffer.
  76213. * @param name Name of the uniform, as used in the uniform block in the shader.
  76214. * @param color Define the vec3 from a Color
  76215. */
  76216. addColor3(name: string, color: Color3): void;
  76217. /**
  76218. * Adds a vec4 to the uniform buffer.
  76219. * @param name Name of the uniform, as used in the uniform block in the shader.
  76220. * @param color Define the rgb components from a Color
  76221. * @param alpha Define the a component of the vec4
  76222. */
  76223. addColor4(name: string, color: Color3, alpha: number): void;
  76224. /**
  76225. * Adds a vec3 to the uniform buffer.
  76226. * @param name Name of the uniform, as used in the uniform block in the shader.
  76227. * @param vector Define the vec3 components from a Vector
  76228. */
  76229. addVector3(name: string, vector: Vector3): void;
  76230. /**
  76231. * Adds a Matrix 3x3 to the uniform buffer.
  76232. * @param name Name of the uniform, as used in the uniform block in the shader.
  76233. */
  76234. addMatrix3x3(name: string): void;
  76235. /**
  76236. * Adds a Matrix 2x2 to the uniform buffer.
  76237. * @param name Name of the uniform, as used in the uniform block in the shader.
  76238. */
  76239. addMatrix2x2(name: string): void;
  76240. /**
  76241. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  76242. */
  76243. create(): void;
  76244. /** @hidden */
  76245. _rebuild(): void;
  76246. /**
  76247. * Updates the WebGL Uniform Buffer on the GPU.
  76248. * If the `dynamic` flag is set to true, no cache comparison is done.
  76249. * Otherwise, the buffer will be updated only if the cache differs.
  76250. */
  76251. update(): void;
  76252. /**
  76253. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  76254. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76255. * @param data Define the flattened data
  76256. * @param size Define the size of the data.
  76257. */
  76258. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  76259. private _valueCache;
  76260. private _cacheMatrix;
  76261. private _updateMatrix3x3ForUniform;
  76262. private _updateMatrix3x3ForEffect;
  76263. private _updateMatrix2x2ForEffect;
  76264. private _updateMatrix2x2ForUniform;
  76265. private _updateFloatForEffect;
  76266. private _updateFloatForUniform;
  76267. private _updateFloat2ForEffect;
  76268. private _updateFloat2ForUniform;
  76269. private _updateFloat3ForEffect;
  76270. private _updateFloat3ForUniform;
  76271. private _updateFloat4ForEffect;
  76272. private _updateFloat4ForUniform;
  76273. private _updateMatrixForEffect;
  76274. private _updateMatrixForUniform;
  76275. private _updateVector3ForEffect;
  76276. private _updateVector3ForUniform;
  76277. private _updateVector4ForEffect;
  76278. private _updateVector4ForUniform;
  76279. private _updateColor3ForEffect;
  76280. private _updateColor3ForUniform;
  76281. private _updateColor4ForEffect;
  76282. private _updateColor4ForUniform;
  76283. /**
  76284. * Sets a sampler uniform on the effect.
  76285. * @param name Define the name of the sampler.
  76286. * @param texture Define the texture to set in the sampler
  76287. */
  76288. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  76289. /**
  76290. * Directly updates the value of the uniform in the cache AND on the GPU.
  76291. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76292. * @param data Define the flattened data
  76293. */
  76294. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  76295. /**
  76296. * Binds this uniform buffer to an effect.
  76297. * @param effect Define the effect to bind the buffer to
  76298. * @param name Name of the uniform block in the shader.
  76299. */
  76300. bindToEffect(effect: Effect, name: string): void;
  76301. /**
  76302. * Disposes the uniform buffer.
  76303. */
  76304. dispose(): void;
  76305. }
  76306. }
  76307. declare module BABYLON {
  76308. /**
  76309. * Enum that determines the text-wrapping mode to use.
  76310. */
  76311. export enum InspectableType {
  76312. /**
  76313. * Checkbox for booleans
  76314. */
  76315. Checkbox = 0,
  76316. /**
  76317. * Sliders for numbers
  76318. */
  76319. Slider = 1,
  76320. /**
  76321. * Vector3
  76322. */
  76323. Vector3 = 2,
  76324. /**
  76325. * Quaternions
  76326. */
  76327. Quaternion = 3,
  76328. /**
  76329. * Color3
  76330. */
  76331. Color3 = 4,
  76332. /**
  76333. * String
  76334. */
  76335. String = 5
  76336. }
  76337. /**
  76338. * Interface used to define custom inspectable properties.
  76339. * This interface is used by the inspector to display custom property grids
  76340. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76341. */
  76342. export interface IInspectable {
  76343. /**
  76344. * Gets the label to display
  76345. */
  76346. label: string;
  76347. /**
  76348. * Gets the name of the property to edit
  76349. */
  76350. propertyName: string;
  76351. /**
  76352. * Gets the type of the editor to use
  76353. */
  76354. type: InspectableType;
  76355. /**
  76356. * Gets the minimum value of the property when using in "slider" mode
  76357. */
  76358. min?: number;
  76359. /**
  76360. * Gets the maximum value of the property when using in "slider" mode
  76361. */
  76362. max?: number;
  76363. /**
  76364. * Gets the setp to use when using in "slider" mode
  76365. */
  76366. step?: number;
  76367. }
  76368. }
  76369. declare module BABYLON {
  76370. /**
  76371. * Class used to provide helper for timing
  76372. */
  76373. export class TimingTools {
  76374. /**
  76375. * Polyfill for setImmediate
  76376. * @param action defines the action to execute after the current execution block
  76377. */
  76378. static SetImmediate(action: () => void): void;
  76379. }
  76380. }
  76381. declare module BABYLON {
  76382. /**
  76383. * Class used to enable instatition of objects by class name
  76384. */
  76385. export class InstantiationTools {
  76386. /**
  76387. * Use this object to register external classes like custom textures or material
  76388. * to allow the laoders to instantiate them
  76389. */
  76390. static RegisteredExternalClasses: {
  76391. [key: string]: Object;
  76392. };
  76393. /**
  76394. * Tries to instantiate a new object from a given class name
  76395. * @param className defines the class name to instantiate
  76396. * @returns the new object or null if the system was not able to do the instantiation
  76397. */
  76398. static Instantiate(className: string): any;
  76399. }
  76400. }
  76401. declare module BABYLON {
  76402. /**
  76403. * Define options used to create a depth texture
  76404. */
  76405. export class DepthTextureCreationOptions {
  76406. /** Specifies whether or not a stencil should be allocated in the texture */
  76407. generateStencil?: boolean;
  76408. /** Specifies whether or not bilinear filtering is enable on the texture */
  76409. bilinearFiltering?: boolean;
  76410. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  76411. comparisonFunction?: number;
  76412. /** Specifies if the created texture is a cube texture */
  76413. isCube?: boolean;
  76414. }
  76415. }
  76416. declare module BABYLON {
  76417. interface ThinEngine {
  76418. /**
  76419. * Creates a depth stencil cube texture.
  76420. * This is only available in WebGL 2.
  76421. * @param size The size of face edge in the cube texture.
  76422. * @param options The options defining the cube texture.
  76423. * @returns The cube texture
  76424. */
  76425. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  76426. /**
  76427. * Creates a cube texture
  76428. * @param rootUrl defines the url where the files to load is located
  76429. * @param scene defines the current scene
  76430. * @param files defines the list of files to load (1 per face)
  76431. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76432. * @param onLoad defines an optional callback raised when the texture is loaded
  76433. * @param onError defines an optional callback raised if there is an issue to load the texture
  76434. * @param format defines the format of the data
  76435. * @param forcedExtension defines the extension to use to pick the right loader
  76436. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76437. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76438. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76439. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  76440. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  76441. * @returns the cube texture as an InternalTexture
  76442. */
  76443. 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;
  76444. /**
  76445. * Creates a cube texture
  76446. * @param rootUrl defines the url where the files to load is located
  76447. * @param scene defines the current scene
  76448. * @param files defines the list of files to load (1 per face)
  76449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76450. * @param onLoad defines an optional callback raised when the texture is loaded
  76451. * @param onError defines an optional callback raised if there is an issue to load the texture
  76452. * @param format defines the format of the data
  76453. * @param forcedExtension defines the extension to use to pick the right loader
  76454. * @returns the cube texture as an InternalTexture
  76455. */
  76456. 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;
  76457. /**
  76458. * Creates a cube texture
  76459. * @param rootUrl defines the url where the files to load is located
  76460. * @param scene defines the current scene
  76461. * @param files defines the list of files to load (1 per face)
  76462. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76463. * @param onLoad defines an optional callback raised when the texture is loaded
  76464. * @param onError defines an optional callback raised if there is an issue to load the texture
  76465. * @param format defines the format of the data
  76466. * @param forcedExtension defines the extension to use to pick the right loader
  76467. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76468. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76469. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76470. * @returns the cube texture as an InternalTexture
  76471. */
  76472. 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;
  76473. /** @hidden */
  76474. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  76475. /** @hidden */
  76476. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  76477. /** @hidden */
  76478. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76479. /** @hidden */
  76480. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76481. /**
  76482. * @hidden
  76483. */
  76484. _setCubeMapTextureParams(loadMipmap: boolean): void;
  76485. }
  76486. }
  76487. declare module BABYLON {
  76488. /**
  76489. * Class for creating a cube texture
  76490. */
  76491. export class CubeTexture extends BaseTexture {
  76492. private _delayedOnLoad;
  76493. /**
  76494. * The url of the texture
  76495. */
  76496. url: string;
  76497. /**
  76498. * Gets or sets the center of the bounding box associated with the cube texture.
  76499. * It must define where the camera used to render the texture was set
  76500. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76501. */
  76502. boundingBoxPosition: Vector3;
  76503. private _boundingBoxSize;
  76504. /**
  76505. * Gets or sets the size of the bounding box associated with the cube texture
  76506. * When defined, the cubemap will switch to local mode
  76507. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76508. * @example https://www.babylonjs-playground.com/#RNASML
  76509. */
  76510. /**
  76511. * Returns the bounding box size
  76512. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76513. */
  76514. boundingBoxSize: Vector3;
  76515. protected _rotationY: number;
  76516. /**
  76517. * Sets texture matrix rotation angle around Y axis in radians.
  76518. */
  76519. /**
  76520. * Gets texture matrix rotation angle around Y axis radians.
  76521. */
  76522. rotationY: number;
  76523. /**
  76524. * Are mip maps generated for this texture or not.
  76525. */
  76526. readonly noMipmap: boolean;
  76527. private _noMipmap;
  76528. private _files;
  76529. protected _forcedExtension: Nullable<string>;
  76530. private _extensions;
  76531. private _textureMatrix;
  76532. private _format;
  76533. private _createPolynomials;
  76534. /** @hidden */
  76535. _prefiltered: boolean;
  76536. /**
  76537. * Creates a cube texture from an array of image urls
  76538. * @param files defines an array of image urls
  76539. * @param scene defines the hosting scene
  76540. * @param noMipmap specifies if mip maps are not used
  76541. * @returns a cube texture
  76542. */
  76543. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  76544. /**
  76545. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  76546. * @param url defines the url of the prefiltered texture
  76547. * @param scene defines the scene the texture is attached to
  76548. * @param forcedExtension defines the extension of the file if different from the url
  76549. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76550. * @return the prefiltered texture
  76551. */
  76552. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  76553. /**
  76554. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  76555. * as prefiltered data.
  76556. * @param rootUrl defines the url of the texture or the root name of the six images
  76557. * @param scene defines the scene the texture is attached to
  76558. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  76559. * @param noMipmap defines if mipmaps should be created or not
  76560. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  76561. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  76562. * @param onError defines a callback triggered in case of error during load
  76563. * @param format defines the internal format to use for the texture once loaded
  76564. * @param prefiltered defines whether or not the texture is created from prefiltered data
  76565. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  76566. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76567. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76568. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76569. * @return the cube texture
  76570. */
  76571. 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);
  76572. /**
  76573. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  76574. */
  76575. readonly isPrefiltered: boolean;
  76576. /**
  76577. * Get the current class name of the texture useful for serialization or dynamic coding.
  76578. * @returns "CubeTexture"
  76579. */
  76580. getClassName(): string;
  76581. /**
  76582. * Update the url (and optional buffer) of this texture if url was null during construction.
  76583. * @param url the url of the texture
  76584. * @param forcedExtension defines the extension to use
  76585. * @param onLoad callback called when the texture is loaded (defaults to null)
  76586. */
  76587. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  76588. /**
  76589. * Delays loading of the cube texture
  76590. * @param forcedExtension defines the extension to use
  76591. */
  76592. delayLoad(forcedExtension?: string): void;
  76593. /**
  76594. * Returns the reflection texture matrix
  76595. * @returns the reflection texture matrix
  76596. */
  76597. getReflectionTextureMatrix(): Matrix;
  76598. /**
  76599. * Sets the reflection texture matrix
  76600. * @param value Reflection texture matrix
  76601. */
  76602. setReflectionTextureMatrix(value: Matrix): void;
  76603. /**
  76604. * Parses text to create a cube texture
  76605. * @param parsedTexture define the serialized text to read from
  76606. * @param scene defines the hosting scene
  76607. * @param rootUrl defines the root url of the cube texture
  76608. * @returns a cube texture
  76609. */
  76610. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  76611. /**
  76612. * Makes a clone, or deep copy, of the cube texture
  76613. * @returns a new cube texture
  76614. */
  76615. clone(): CubeTexture;
  76616. }
  76617. }
  76618. declare module BABYLON {
  76619. /**
  76620. * Manages the defines for the Material
  76621. */
  76622. export class MaterialDefines {
  76623. /** @hidden */
  76624. protected _keys: string[];
  76625. private _isDirty;
  76626. /** @hidden */
  76627. _renderId: number;
  76628. /** @hidden */
  76629. _areLightsDirty: boolean;
  76630. /** @hidden */
  76631. _areLightsDisposed: boolean;
  76632. /** @hidden */
  76633. _areAttributesDirty: boolean;
  76634. /** @hidden */
  76635. _areTexturesDirty: boolean;
  76636. /** @hidden */
  76637. _areFresnelDirty: boolean;
  76638. /** @hidden */
  76639. _areMiscDirty: boolean;
  76640. /** @hidden */
  76641. _areImageProcessingDirty: boolean;
  76642. /** @hidden */
  76643. _normals: boolean;
  76644. /** @hidden */
  76645. _uvs: boolean;
  76646. /** @hidden */
  76647. _needNormals: boolean;
  76648. /** @hidden */
  76649. _needUVs: boolean;
  76650. [id: string]: any;
  76651. /**
  76652. * Specifies if the material needs to be re-calculated
  76653. */
  76654. readonly isDirty: boolean;
  76655. /**
  76656. * Marks the material to indicate that it has been re-calculated
  76657. */
  76658. markAsProcessed(): void;
  76659. /**
  76660. * Marks the material to indicate that it needs to be re-calculated
  76661. */
  76662. markAsUnprocessed(): void;
  76663. /**
  76664. * Marks the material to indicate all of its defines need to be re-calculated
  76665. */
  76666. markAllAsDirty(): void;
  76667. /**
  76668. * Marks the material to indicate that image processing needs to be re-calculated
  76669. */
  76670. markAsImageProcessingDirty(): void;
  76671. /**
  76672. * Marks the material to indicate the lights need to be re-calculated
  76673. * @param disposed Defines whether the light is dirty due to dispose or not
  76674. */
  76675. markAsLightDirty(disposed?: boolean): void;
  76676. /**
  76677. * Marks the attribute state as changed
  76678. */
  76679. markAsAttributesDirty(): void;
  76680. /**
  76681. * Marks the texture state as changed
  76682. */
  76683. markAsTexturesDirty(): void;
  76684. /**
  76685. * Marks the fresnel state as changed
  76686. */
  76687. markAsFresnelDirty(): void;
  76688. /**
  76689. * Marks the misc state as changed
  76690. */
  76691. markAsMiscDirty(): void;
  76692. /**
  76693. * Rebuilds the material defines
  76694. */
  76695. rebuild(): void;
  76696. /**
  76697. * Specifies if two material defines are equal
  76698. * @param other - A material define instance to compare to
  76699. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  76700. */
  76701. isEqual(other: MaterialDefines): boolean;
  76702. /**
  76703. * Clones this instance's defines to another instance
  76704. * @param other - material defines to clone values to
  76705. */
  76706. cloneTo(other: MaterialDefines): void;
  76707. /**
  76708. * Resets the material define values
  76709. */
  76710. reset(): void;
  76711. /**
  76712. * Converts the material define values to a string
  76713. * @returns - String of material define information
  76714. */
  76715. toString(): string;
  76716. }
  76717. }
  76718. declare module BABYLON {
  76719. /**
  76720. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76721. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76722. * 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;
  76723. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76724. */
  76725. export class ColorCurves {
  76726. private _dirty;
  76727. private _tempColor;
  76728. private _globalCurve;
  76729. private _highlightsCurve;
  76730. private _midtonesCurve;
  76731. private _shadowsCurve;
  76732. private _positiveCurve;
  76733. private _negativeCurve;
  76734. private _globalHue;
  76735. private _globalDensity;
  76736. private _globalSaturation;
  76737. private _globalExposure;
  76738. /**
  76739. * Gets the global Hue value.
  76740. * 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).
  76741. */
  76742. /**
  76743. * Sets the global Hue value.
  76744. * 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).
  76745. */
  76746. globalHue: number;
  76747. /**
  76748. * Gets the global Density value.
  76749. * 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.
  76750. * Values less than zero provide a filter of opposite hue.
  76751. */
  76752. /**
  76753. * Sets the global Density value.
  76754. * 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.
  76755. * Values less than zero provide a filter of opposite hue.
  76756. */
  76757. globalDensity: number;
  76758. /**
  76759. * Gets the global Saturation value.
  76760. * 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.
  76761. */
  76762. /**
  76763. * Sets the global Saturation value.
  76764. * 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.
  76765. */
  76766. globalSaturation: number;
  76767. /**
  76768. * Gets the global Exposure value.
  76769. * 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.
  76770. */
  76771. /**
  76772. * Sets the global Exposure value.
  76773. * 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.
  76774. */
  76775. globalExposure: number;
  76776. private _highlightsHue;
  76777. private _highlightsDensity;
  76778. private _highlightsSaturation;
  76779. private _highlightsExposure;
  76780. /**
  76781. * Gets the highlights Hue value.
  76782. * 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).
  76783. */
  76784. /**
  76785. * Sets the highlights Hue value.
  76786. * 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).
  76787. */
  76788. highlightsHue: number;
  76789. /**
  76790. * Gets the highlights Density value.
  76791. * 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.
  76792. * Values less than zero provide a filter of opposite hue.
  76793. */
  76794. /**
  76795. * Sets the highlights Density value.
  76796. * 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.
  76797. * Values less than zero provide a filter of opposite hue.
  76798. */
  76799. highlightsDensity: number;
  76800. /**
  76801. * Gets the highlights Saturation value.
  76802. * 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.
  76803. */
  76804. /**
  76805. * Sets the highlights Saturation value.
  76806. * 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.
  76807. */
  76808. highlightsSaturation: number;
  76809. /**
  76810. * Gets the highlights Exposure value.
  76811. * 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.
  76812. */
  76813. /**
  76814. * Sets the highlights Exposure value.
  76815. * 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.
  76816. */
  76817. highlightsExposure: number;
  76818. private _midtonesHue;
  76819. private _midtonesDensity;
  76820. private _midtonesSaturation;
  76821. private _midtonesExposure;
  76822. /**
  76823. * Gets the midtones Hue value.
  76824. * 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).
  76825. */
  76826. /**
  76827. * Sets the midtones Hue value.
  76828. * 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).
  76829. */
  76830. midtonesHue: number;
  76831. /**
  76832. * Gets the midtones Density value.
  76833. * 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.
  76834. * Values less than zero provide a filter of opposite hue.
  76835. */
  76836. /**
  76837. * Sets the midtones Density value.
  76838. * 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.
  76839. * Values less than zero provide a filter of opposite hue.
  76840. */
  76841. midtonesDensity: number;
  76842. /**
  76843. * Gets the midtones Saturation value.
  76844. * 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.
  76845. */
  76846. /**
  76847. * Sets the midtones Saturation value.
  76848. * 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.
  76849. */
  76850. midtonesSaturation: number;
  76851. /**
  76852. * Gets the midtones Exposure value.
  76853. * 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.
  76854. */
  76855. /**
  76856. * Sets the midtones Exposure value.
  76857. * 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.
  76858. */
  76859. midtonesExposure: number;
  76860. private _shadowsHue;
  76861. private _shadowsDensity;
  76862. private _shadowsSaturation;
  76863. private _shadowsExposure;
  76864. /**
  76865. * Gets the shadows Hue value.
  76866. * 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).
  76867. */
  76868. /**
  76869. * Sets the shadows Hue value.
  76870. * 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).
  76871. */
  76872. shadowsHue: number;
  76873. /**
  76874. * Gets the shadows Density value.
  76875. * 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.
  76876. * Values less than zero provide a filter of opposite hue.
  76877. */
  76878. /**
  76879. * Sets the shadows Density value.
  76880. * 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.
  76881. * Values less than zero provide a filter of opposite hue.
  76882. */
  76883. shadowsDensity: number;
  76884. /**
  76885. * Gets the shadows Saturation value.
  76886. * 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.
  76887. */
  76888. /**
  76889. * Sets the shadows Saturation value.
  76890. * 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.
  76891. */
  76892. shadowsSaturation: number;
  76893. /**
  76894. * Gets the shadows Exposure value.
  76895. * 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.
  76896. */
  76897. /**
  76898. * Sets the shadows Exposure value.
  76899. * 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.
  76900. */
  76901. shadowsExposure: number;
  76902. /**
  76903. * Returns the class name
  76904. * @returns The class name
  76905. */
  76906. getClassName(): string;
  76907. /**
  76908. * Binds the color curves to the shader.
  76909. * @param colorCurves The color curve to bind
  76910. * @param effect The effect to bind to
  76911. * @param positiveUniform The positive uniform shader parameter
  76912. * @param neutralUniform The neutral uniform shader parameter
  76913. * @param negativeUniform The negative uniform shader parameter
  76914. */
  76915. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76916. /**
  76917. * Prepare the list of uniforms associated with the ColorCurves effects.
  76918. * @param uniformsList The list of uniforms used in the effect
  76919. */
  76920. static PrepareUniforms(uniformsList: string[]): void;
  76921. /**
  76922. * Returns color grading data based on a hue, density, saturation and exposure value.
  76923. * @param filterHue The hue of the color filter.
  76924. * @param filterDensity The density of the color filter.
  76925. * @param saturation The saturation.
  76926. * @param exposure The exposure.
  76927. * @param result The result data container.
  76928. */
  76929. private getColorGradingDataToRef;
  76930. /**
  76931. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76932. * @param value The input slider value in range [-100,100].
  76933. * @returns Adjusted value.
  76934. */
  76935. private static applyColorGradingSliderNonlinear;
  76936. /**
  76937. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76938. * @param hue The hue (H) input.
  76939. * @param saturation The saturation (S) input.
  76940. * @param brightness The brightness (B) input.
  76941. * @result An RGBA color represented as Vector4.
  76942. */
  76943. private static fromHSBToRef;
  76944. /**
  76945. * Returns a value clamped between min and max
  76946. * @param value The value to clamp
  76947. * @param min The minimum of value
  76948. * @param max The maximum of value
  76949. * @returns The clamped value.
  76950. */
  76951. private static clamp;
  76952. /**
  76953. * Clones the current color curve instance.
  76954. * @return The cloned curves
  76955. */
  76956. clone(): ColorCurves;
  76957. /**
  76958. * Serializes the current color curve instance to a json representation.
  76959. * @return a JSON representation
  76960. */
  76961. serialize(): any;
  76962. /**
  76963. * Parses the color curve from a json representation.
  76964. * @param source the JSON source to parse
  76965. * @return The parsed curves
  76966. */
  76967. static Parse(source: any): ColorCurves;
  76968. }
  76969. }
  76970. declare module BABYLON {
  76971. /**
  76972. * Interface to follow in your material defines to integrate easily the
  76973. * Image proccessing functions.
  76974. * @hidden
  76975. */
  76976. export interface IImageProcessingConfigurationDefines {
  76977. IMAGEPROCESSING: boolean;
  76978. VIGNETTE: boolean;
  76979. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76980. VIGNETTEBLENDMODEOPAQUE: boolean;
  76981. TONEMAPPING: boolean;
  76982. TONEMAPPING_ACES: boolean;
  76983. CONTRAST: boolean;
  76984. EXPOSURE: boolean;
  76985. COLORCURVES: boolean;
  76986. COLORGRADING: boolean;
  76987. COLORGRADING3D: boolean;
  76988. SAMPLER3DGREENDEPTH: boolean;
  76989. SAMPLER3DBGRMAP: boolean;
  76990. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76991. }
  76992. /**
  76993. * @hidden
  76994. */
  76995. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76996. IMAGEPROCESSING: boolean;
  76997. VIGNETTE: boolean;
  76998. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76999. VIGNETTEBLENDMODEOPAQUE: boolean;
  77000. TONEMAPPING: boolean;
  77001. TONEMAPPING_ACES: boolean;
  77002. CONTRAST: boolean;
  77003. COLORCURVES: boolean;
  77004. COLORGRADING: boolean;
  77005. COLORGRADING3D: boolean;
  77006. SAMPLER3DGREENDEPTH: boolean;
  77007. SAMPLER3DBGRMAP: boolean;
  77008. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77009. EXPOSURE: boolean;
  77010. constructor();
  77011. }
  77012. /**
  77013. * This groups together the common properties used for image processing either in direct forward pass
  77014. * or through post processing effect depending on the use of the image processing pipeline in your scene
  77015. * or not.
  77016. */
  77017. export class ImageProcessingConfiguration {
  77018. /**
  77019. * Default tone mapping applied in BabylonJS.
  77020. */
  77021. static readonly TONEMAPPING_STANDARD: number;
  77022. /**
  77023. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  77024. * to other engines rendering to increase portability.
  77025. */
  77026. static readonly TONEMAPPING_ACES: number;
  77027. /**
  77028. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  77029. */
  77030. colorCurves: Nullable<ColorCurves>;
  77031. private _colorCurvesEnabled;
  77032. /**
  77033. * Gets wether the color curves effect is enabled.
  77034. */
  77035. /**
  77036. * Sets wether the color curves effect is enabled.
  77037. */
  77038. colorCurvesEnabled: boolean;
  77039. private _colorGradingTexture;
  77040. /**
  77041. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77042. */
  77043. /**
  77044. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77045. */
  77046. colorGradingTexture: Nullable<BaseTexture>;
  77047. private _colorGradingEnabled;
  77048. /**
  77049. * Gets wether the color grading effect is enabled.
  77050. */
  77051. /**
  77052. * Sets wether the color grading effect is enabled.
  77053. */
  77054. colorGradingEnabled: boolean;
  77055. private _colorGradingWithGreenDepth;
  77056. /**
  77057. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  77058. */
  77059. /**
  77060. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  77061. */
  77062. colorGradingWithGreenDepth: boolean;
  77063. private _colorGradingBGR;
  77064. /**
  77065. * Gets wether the color grading texture contains BGR values.
  77066. */
  77067. /**
  77068. * Sets wether the color grading texture contains BGR values.
  77069. */
  77070. colorGradingBGR: boolean;
  77071. /** @hidden */
  77072. _exposure: number;
  77073. /**
  77074. * Gets the Exposure used in the effect.
  77075. */
  77076. /**
  77077. * Sets the Exposure used in the effect.
  77078. */
  77079. exposure: number;
  77080. private _toneMappingEnabled;
  77081. /**
  77082. * Gets wether the tone mapping effect is enabled.
  77083. */
  77084. /**
  77085. * Sets wether the tone mapping effect is enabled.
  77086. */
  77087. toneMappingEnabled: boolean;
  77088. private _toneMappingType;
  77089. /**
  77090. * Gets the type of tone mapping effect.
  77091. */
  77092. /**
  77093. * Sets the type of tone mapping effect used in BabylonJS.
  77094. */
  77095. toneMappingType: number;
  77096. protected _contrast: number;
  77097. /**
  77098. * Gets the contrast used in the effect.
  77099. */
  77100. /**
  77101. * Sets the contrast used in the effect.
  77102. */
  77103. contrast: number;
  77104. /**
  77105. * Vignette stretch size.
  77106. */
  77107. vignetteStretch: number;
  77108. /**
  77109. * Vignette centre X Offset.
  77110. */
  77111. vignetteCentreX: number;
  77112. /**
  77113. * Vignette centre Y Offset.
  77114. */
  77115. vignetteCentreY: number;
  77116. /**
  77117. * Vignette weight or intensity of the vignette effect.
  77118. */
  77119. vignetteWeight: number;
  77120. /**
  77121. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  77122. * if vignetteEnabled is set to true.
  77123. */
  77124. vignetteColor: Color4;
  77125. /**
  77126. * Camera field of view used by the Vignette effect.
  77127. */
  77128. vignetteCameraFov: number;
  77129. private _vignetteBlendMode;
  77130. /**
  77131. * Gets the vignette blend mode allowing different kind of effect.
  77132. */
  77133. /**
  77134. * Sets the vignette blend mode allowing different kind of effect.
  77135. */
  77136. vignetteBlendMode: number;
  77137. private _vignetteEnabled;
  77138. /**
  77139. * Gets wether the vignette effect is enabled.
  77140. */
  77141. /**
  77142. * Sets wether the vignette effect is enabled.
  77143. */
  77144. vignetteEnabled: boolean;
  77145. private _applyByPostProcess;
  77146. /**
  77147. * Gets wether the image processing is applied through a post process or not.
  77148. */
  77149. /**
  77150. * Sets wether the image processing is applied through a post process or not.
  77151. */
  77152. applyByPostProcess: boolean;
  77153. private _isEnabled;
  77154. /**
  77155. * Gets wether the image processing is enabled or not.
  77156. */
  77157. /**
  77158. * Sets wether the image processing is enabled or not.
  77159. */
  77160. isEnabled: boolean;
  77161. /**
  77162. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  77163. */
  77164. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  77165. /**
  77166. * Method called each time the image processing information changes requires to recompile the effect.
  77167. */
  77168. protected _updateParameters(): void;
  77169. /**
  77170. * Gets the current class name.
  77171. * @return "ImageProcessingConfiguration"
  77172. */
  77173. getClassName(): string;
  77174. /**
  77175. * Prepare the list of uniforms associated with the Image Processing effects.
  77176. * @param uniforms The list of uniforms used in the effect
  77177. * @param defines the list of defines currently in use
  77178. */
  77179. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  77180. /**
  77181. * Prepare the list of samplers associated with the Image Processing effects.
  77182. * @param samplersList The list of uniforms used in the effect
  77183. * @param defines the list of defines currently in use
  77184. */
  77185. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  77186. /**
  77187. * Prepare the list of defines associated to the shader.
  77188. * @param defines the list of defines to complete
  77189. * @param forPostProcess Define if we are currently in post process mode or not
  77190. */
  77191. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  77192. /**
  77193. * Returns true if all the image processing information are ready.
  77194. * @returns True if ready, otherwise, false
  77195. */
  77196. isReady(): boolean;
  77197. /**
  77198. * Binds the image processing to the shader.
  77199. * @param effect The effect to bind to
  77200. * @param overrideAspectRatio Override the aspect ratio of the effect
  77201. */
  77202. bind(effect: Effect, overrideAspectRatio?: number): void;
  77203. /**
  77204. * Clones the current image processing instance.
  77205. * @return The cloned image processing
  77206. */
  77207. clone(): ImageProcessingConfiguration;
  77208. /**
  77209. * Serializes the current image processing instance to a json representation.
  77210. * @return a JSON representation
  77211. */
  77212. serialize(): any;
  77213. /**
  77214. * Parses the image processing from a json representation.
  77215. * @param source the JSON source to parse
  77216. * @return The parsed image processing
  77217. */
  77218. static Parse(source: any): ImageProcessingConfiguration;
  77219. private static _VIGNETTEMODE_MULTIPLY;
  77220. private static _VIGNETTEMODE_OPAQUE;
  77221. /**
  77222. * Used to apply the vignette as a mix with the pixel color.
  77223. */
  77224. static readonly VIGNETTEMODE_MULTIPLY: number;
  77225. /**
  77226. * Used to apply the vignette as a replacement of the pixel color.
  77227. */
  77228. static readonly VIGNETTEMODE_OPAQUE: number;
  77229. }
  77230. }
  77231. declare module BABYLON {
  77232. /** @hidden */
  77233. export var postprocessVertexShader: {
  77234. name: string;
  77235. shader: string;
  77236. };
  77237. }
  77238. declare module BABYLON {
  77239. interface ThinEngine {
  77240. /**
  77241. * Creates a new render target texture
  77242. * @param size defines the size of the texture
  77243. * @param options defines the options used to create the texture
  77244. * @returns a new render target texture stored in an InternalTexture
  77245. */
  77246. createRenderTargetTexture(size: number | {
  77247. width: number;
  77248. height: number;
  77249. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  77250. /**
  77251. * Creates a depth stencil texture.
  77252. * This is only available in WebGL 2 or with the depth texture extension available.
  77253. * @param size The size of face edge in the texture.
  77254. * @param options The options defining the texture.
  77255. * @returns The texture
  77256. */
  77257. createDepthStencilTexture(size: number | {
  77258. width: number;
  77259. height: number;
  77260. }, options: DepthTextureCreationOptions): InternalTexture;
  77261. /** @hidden */
  77262. _createDepthStencilTexture(size: number | {
  77263. width: number;
  77264. height: number;
  77265. }, options: DepthTextureCreationOptions): InternalTexture;
  77266. }
  77267. }
  77268. declare module BABYLON {
  77269. /** Defines supported spaces */
  77270. export enum Space {
  77271. /** Local (object) space */
  77272. LOCAL = 0,
  77273. /** World space */
  77274. WORLD = 1,
  77275. /** Bone space */
  77276. BONE = 2
  77277. }
  77278. /** Defines the 3 main axes */
  77279. export class Axis {
  77280. /** X axis */
  77281. static X: Vector3;
  77282. /** Y axis */
  77283. static Y: Vector3;
  77284. /** Z axis */
  77285. static Z: Vector3;
  77286. }
  77287. }
  77288. declare module BABYLON {
  77289. /**
  77290. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  77291. * This is the base of the follow, arc rotate cameras and Free camera
  77292. * @see http://doc.babylonjs.com/features/cameras
  77293. */
  77294. export class TargetCamera extends Camera {
  77295. private static _RigCamTransformMatrix;
  77296. private static _TargetTransformMatrix;
  77297. private static _TargetFocalPoint;
  77298. /**
  77299. * Define the current direction the camera is moving to
  77300. */
  77301. cameraDirection: Vector3;
  77302. /**
  77303. * Define the current rotation the camera is rotating to
  77304. */
  77305. cameraRotation: Vector2;
  77306. /**
  77307. * When set, the up vector of the camera will be updated by the rotation of the camera
  77308. */
  77309. updateUpVectorFromRotation: boolean;
  77310. private _tmpQuaternion;
  77311. /**
  77312. * Define the current rotation of the camera
  77313. */
  77314. rotation: Vector3;
  77315. /**
  77316. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  77317. */
  77318. rotationQuaternion: Quaternion;
  77319. /**
  77320. * Define the current speed of the camera
  77321. */
  77322. speed: number;
  77323. /**
  77324. * Add constraint to the camera to prevent it to move freely in all directions and
  77325. * around all axis.
  77326. */
  77327. noRotationConstraint: boolean;
  77328. /**
  77329. * Define the current target of the camera as an object or a position.
  77330. */
  77331. lockedTarget: any;
  77332. /** @hidden */
  77333. _currentTarget: Vector3;
  77334. /** @hidden */
  77335. _initialFocalDistance: number;
  77336. /** @hidden */
  77337. _viewMatrix: Matrix;
  77338. /** @hidden */
  77339. _camMatrix: Matrix;
  77340. /** @hidden */
  77341. _cameraTransformMatrix: Matrix;
  77342. /** @hidden */
  77343. _cameraRotationMatrix: Matrix;
  77344. /** @hidden */
  77345. _referencePoint: Vector3;
  77346. /** @hidden */
  77347. _transformedReferencePoint: Vector3;
  77348. protected _globalCurrentTarget: Vector3;
  77349. protected _globalCurrentUpVector: Vector3;
  77350. /** @hidden */
  77351. _reset: () => void;
  77352. private _defaultUp;
  77353. /**
  77354. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  77355. * This is the base of the follow, arc rotate cameras and Free camera
  77356. * @see http://doc.babylonjs.com/features/cameras
  77357. * @param name Defines the name of the camera in the scene
  77358. * @param position Defines the start position of the camera in the scene
  77359. * @param scene Defines the scene the camera belongs to
  77360. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77361. */
  77362. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77363. /**
  77364. * Gets the position in front of the camera at a given distance.
  77365. * @param distance The distance from the camera we want the position to be
  77366. * @returns the position
  77367. */
  77368. getFrontPosition(distance: number): Vector3;
  77369. /** @hidden */
  77370. _getLockedTargetPosition(): Nullable<Vector3>;
  77371. private _storedPosition;
  77372. private _storedRotation;
  77373. private _storedRotationQuaternion;
  77374. /**
  77375. * Store current camera state of the camera (fov, position, rotation, etc..)
  77376. * @returns the camera
  77377. */
  77378. storeState(): Camera;
  77379. /**
  77380. * Restored camera state. You must call storeState() first
  77381. * @returns whether it was successful or not
  77382. * @hidden
  77383. */
  77384. _restoreStateValues(): boolean;
  77385. /** @hidden */
  77386. _initCache(): void;
  77387. /** @hidden */
  77388. _updateCache(ignoreParentClass?: boolean): void;
  77389. /** @hidden */
  77390. _isSynchronizedViewMatrix(): boolean;
  77391. /** @hidden */
  77392. _computeLocalCameraSpeed(): number;
  77393. /**
  77394. * Defines the target the camera should look at.
  77395. * @param target Defines the new target as a Vector or a mesh
  77396. */
  77397. setTarget(target: Vector3): void;
  77398. /**
  77399. * Return the current target position of the camera. This value is expressed in local space.
  77400. * @returns the target position
  77401. */
  77402. getTarget(): Vector3;
  77403. /** @hidden */
  77404. _decideIfNeedsToMove(): boolean;
  77405. /** @hidden */
  77406. _updatePosition(): void;
  77407. /** @hidden */
  77408. _checkInputs(): void;
  77409. protected _updateCameraRotationMatrix(): void;
  77410. /**
  77411. * 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)
  77412. * @returns the current camera
  77413. */
  77414. private _rotateUpVectorWithCameraRotationMatrix;
  77415. private _cachedRotationZ;
  77416. private _cachedQuaternionRotationZ;
  77417. /** @hidden */
  77418. _getViewMatrix(): Matrix;
  77419. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  77420. /**
  77421. * @hidden
  77422. */
  77423. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  77424. /**
  77425. * @hidden
  77426. */
  77427. _updateRigCameras(): void;
  77428. private _getRigCamPositionAndTarget;
  77429. /**
  77430. * Gets the current object class name.
  77431. * @return the class name
  77432. */
  77433. getClassName(): string;
  77434. }
  77435. }
  77436. declare module BABYLON {
  77437. /**
  77438. * Gather the list of keyboard event types as constants.
  77439. */
  77440. export class KeyboardEventTypes {
  77441. /**
  77442. * The keydown event is fired when a key becomes active (pressed).
  77443. */
  77444. static readonly KEYDOWN: number;
  77445. /**
  77446. * The keyup event is fired when a key has been released.
  77447. */
  77448. static readonly KEYUP: number;
  77449. }
  77450. /**
  77451. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77452. */
  77453. export class KeyboardInfo {
  77454. /**
  77455. * Defines the type of event (KeyboardEventTypes)
  77456. */
  77457. type: number;
  77458. /**
  77459. * Defines the related dom event
  77460. */
  77461. event: KeyboardEvent;
  77462. /**
  77463. * Instantiates a new keyboard info.
  77464. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77465. * @param type Defines the type of event (KeyboardEventTypes)
  77466. * @param event Defines the related dom event
  77467. */
  77468. constructor(
  77469. /**
  77470. * Defines the type of event (KeyboardEventTypes)
  77471. */
  77472. type: number,
  77473. /**
  77474. * Defines the related dom event
  77475. */
  77476. event: KeyboardEvent);
  77477. }
  77478. /**
  77479. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77480. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  77481. */
  77482. export class KeyboardInfoPre extends KeyboardInfo {
  77483. /**
  77484. * Defines the type of event (KeyboardEventTypes)
  77485. */
  77486. type: number;
  77487. /**
  77488. * Defines the related dom event
  77489. */
  77490. event: KeyboardEvent;
  77491. /**
  77492. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  77493. */
  77494. skipOnPointerObservable: boolean;
  77495. /**
  77496. * Instantiates a new keyboard pre info.
  77497. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77498. * @param type Defines the type of event (KeyboardEventTypes)
  77499. * @param event Defines the related dom event
  77500. */
  77501. constructor(
  77502. /**
  77503. * Defines the type of event (KeyboardEventTypes)
  77504. */
  77505. type: number,
  77506. /**
  77507. * Defines the related dom event
  77508. */
  77509. event: KeyboardEvent);
  77510. }
  77511. }
  77512. declare module BABYLON {
  77513. /**
  77514. * Manage the keyboard inputs to control the movement of a free camera.
  77515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77516. */
  77517. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  77518. /**
  77519. * Defines the camera the input is attached to.
  77520. */
  77521. camera: FreeCamera;
  77522. /**
  77523. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77524. */
  77525. keysUp: number[];
  77526. /**
  77527. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77528. */
  77529. keysDown: number[];
  77530. /**
  77531. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77532. */
  77533. keysLeft: number[];
  77534. /**
  77535. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77536. */
  77537. keysRight: number[];
  77538. private _keys;
  77539. private _onCanvasBlurObserver;
  77540. private _onKeyboardObserver;
  77541. private _engine;
  77542. private _scene;
  77543. /**
  77544. * Attach the input controls to a specific dom element to get the input from.
  77545. * @param element Defines the element the controls should be listened from
  77546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77547. */
  77548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77549. /**
  77550. * Detach the current controls from the specified dom element.
  77551. * @param element Defines the element to stop listening the inputs from
  77552. */
  77553. detachControl(element: Nullable<HTMLElement>): void;
  77554. /**
  77555. * Update the current camera state depending on the inputs that have been used this frame.
  77556. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77557. */
  77558. checkInputs(): void;
  77559. /**
  77560. * Gets the class name of the current intput.
  77561. * @returns the class name
  77562. */
  77563. getClassName(): string;
  77564. /** @hidden */
  77565. _onLostFocus(): void;
  77566. /**
  77567. * Get the friendly name associated with the input class.
  77568. * @returns the input friendly name
  77569. */
  77570. getSimpleName(): string;
  77571. }
  77572. }
  77573. declare module BABYLON {
  77574. /**
  77575. * Interface describing all the common properties and methods a shadow light needs to implement.
  77576. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  77577. * as well as binding the different shadow properties to the effects.
  77578. */
  77579. export interface IShadowLight extends Light {
  77580. /**
  77581. * The light id in the scene (used in scene.findLighById for instance)
  77582. */
  77583. id: string;
  77584. /**
  77585. * The position the shdow will be casted from.
  77586. */
  77587. position: Vector3;
  77588. /**
  77589. * In 2d mode (needCube being false), the direction used to cast the shadow.
  77590. */
  77591. direction: Vector3;
  77592. /**
  77593. * The transformed position. Position of the light in world space taking parenting in account.
  77594. */
  77595. transformedPosition: Vector3;
  77596. /**
  77597. * The transformed direction. Direction of the light in world space taking parenting in account.
  77598. */
  77599. transformedDirection: Vector3;
  77600. /**
  77601. * The friendly name of the light in the scene.
  77602. */
  77603. name: string;
  77604. /**
  77605. * Defines the shadow projection clipping minimum z value.
  77606. */
  77607. shadowMinZ: number;
  77608. /**
  77609. * Defines the shadow projection clipping maximum z value.
  77610. */
  77611. shadowMaxZ: number;
  77612. /**
  77613. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77614. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77615. */
  77616. computeTransformedInformation(): boolean;
  77617. /**
  77618. * Gets the scene the light belongs to.
  77619. * @returns The scene
  77620. */
  77621. getScene(): Scene;
  77622. /**
  77623. * Callback defining a custom Projection Matrix Builder.
  77624. * This can be used to override the default projection matrix computation.
  77625. */
  77626. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77627. /**
  77628. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77629. * @param matrix The materix to updated with the projection information
  77630. * @param viewMatrix The transform matrix of the light
  77631. * @param renderList The list of mesh to render in the map
  77632. * @returns The current light
  77633. */
  77634. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77635. /**
  77636. * Gets the current depth scale used in ESM.
  77637. * @returns The scale
  77638. */
  77639. getDepthScale(): number;
  77640. /**
  77641. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77642. * @returns true if a cube texture needs to be use
  77643. */
  77644. needCube(): boolean;
  77645. /**
  77646. * Detects if the projection matrix requires to be recomputed this frame.
  77647. * @returns true if it requires to be recomputed otherwise, false.
  77648. */
  77649. needProjectionMatrixCompute(): boolean;
  77650. /**
  77651. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77652. */
  77653. forceProjectionMatrixCompute(): void;
  77654. /**
  77655. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77656. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77657. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77658. */
  77659. getShadowDirection(faceIndex?: number): Vector3;
  77660. /**
  77661. * Gets the minZ used for shadow according to both the scene and the light.
  77662. * @param activeCamera The camera we are returning the min for
  77663. * @returns the depth min z
  77664. */
  77665. getDepthMinZ(activeCamera: Camera): number;
  77666. /**
  77667. * Gets the maxZ used for shadow according to both the scene and the light.
  77668. * @param activeCamera The camera we are returning the max for
  77669. * @returns the depth max z
  77670. */
  77671. getDepthMaxZ(activeCamera: Camera): number;
  77672. }
  77673. /**
  77674. * Base implementation IShadowLight
  77675. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  77676. */
  77677. export abstract class ShadowLight extends Light implements IShadowLight {
  77678. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  77679. protected _position: Vector3;
  77680. protected _setPosition(value: Vector3): void;
  77681. /**
  77682. * Sets the position the shadow will be casted from. Also use as the light position for both
  77683. * point and spot lights.
  77684. */
  77685. /**
  77686. * Sets the position the shadow will be casted from. Also use as the light position for both
  77687. * point and spot lights.
  77688. */
  77689. position: Vector3;
  77690. protected _direction: Vector3;
  77691. protected _setDirection(value: Vector3): void;
  77692. /**
  77693. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  77694. * Also use as the light direction on spot and directional lights.
  77695. */
  77696. /**
  77697. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  77698. * Also use as the light direction on spot and directional lights.
  77699. */
  77700. direction: Vector3;
  77701. private _shadowMinZ;
  77702. /**
  77703. * Gets the shadow projection clipping minimum z value.
  77704. */
  77705. /**
  77706. * Sets the shadow projection clipping minimum z value.
  77707. */
  77708. shadowMinZ: number;
  77709. private _shadowMaxZ;
  77710. /**
  77711. * Sets the shadow projection clipping maximum z value.
  77712. */
  77713. /**
  77714. * Gets the shadow projection clipping maximum z value.
  77715. */
  77716. shadowMaxZ: number;
  77717. /**
  77718. * Callback defining a custom Projection Matrix Builder.
  77719. * This can be used to override the default projection matrix computation.
  77720. */
  77721. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77722. /**
  77723. * The transformed position. Position of the light in world space taking parenting in account.
  77724. */
  77725. transformedPosition: Vector3;
  77726. /**
  77727. * The transformed direction. Direction of the light in world space taking parenting in account.
  77728. */
  77729. transformedDirection: Vector3;
  77730. private _needProjectionMatrixCompute;
  77731. /**
  77732. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77733. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77734. */
  77735. computeTransformedInformation(): boolean;
  77736. /**
  77737. * Return the depth scale used for the shadow map.
  77738. * @returns the depth scale.
  77739. */
  77740. getDepthScale(): number;
  77741. /**
  77742. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77743. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77744. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77745. */
  77746. getShadowDirection(faceIndex?: number): Vector3;
  77747. /**
  77748. * Returns the ShadowLight absolute position in the World.
  77749. * @returns the position vector in world space
  77750. */
  77751. getAbsolutePosition(): Vector3;
  77752. /**
  77753. * Sets the ShadowLight direction toward the passed target.
  77754. * @param target The point to target in local space
  77755. * @returns the updated ShadowLight direction
  77756. */
  77757. setDirectionToTarget(target: Vector3): Vector3;
  77758. /**
  77759. * Returns the light rotation in euler definition.
  77760. * @returns the x y z rotation in local space.
  77761. */
  77762. getRotation(): Vector3;
  77763. /**
  77764. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77765. * @returns true if a cube texture needs to be use
  77766. */
  77767. needCube(): boolean;
  77768. /**
  77769. * Detects if the projection matrix requires to be recomputed this frame.
  77770. * @returns true if it requires to be recomputed otherwise, false.
  77771. */
  77772. needProjectionMatrixCompute(): boolean;
  77773. /**
  77774. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77775. */
  77776. forceProjectionMatrixCompute(): void;
  77777. /** @hidden */
  77778. _initCache(): void;
  77779. /** @hidden */
  77780. _isSynchronized(): boolean;
  77781. /**
  77782. * Computes the world matrix of the node
  77783. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77784. * @returns the world matrix
  77785. */
  77786. computeWorldMatrix(force?: boolean): Matrix;
  77787. /**
  77788. * Gets the minZ used for shadow according to both the scene and the light.
  77789. * @param activeCamera The camera we are returning the min for
  77790. * @returns the depth min z
  77791. */
  77792. getDepthMinZ(activeCamera: Camera): number;
  77793. /**
  77794. * Gets the maxZ used for shadow according to both the scene and the light.
  77795. * @param activeCamera The camera we are returning the max for
  77796. * @returns the depth max z
  77797. */
  77798. getDepthMaxZ(activeCamera: Camera): number;
  77799. /**
  77800. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77801. * @param matrix The materix to updated with the projection information
  77802. * @param viewMatrix The transform matrix of the light
  77803. * @param renderList The list of mesh to render in the map
  77804. * @returns The current light
  77805. */
  77806. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77807. }
  77808. }
  77809. declare module BABYLON {
  77810. /**
  77811. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77812. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77813. */
  77814. export class EffectFallbacks implements IEffectFallbacks {
  77815. private _defines;
  77816. private _currentRank;
  77817. private _maxRank;
  77818. private _mesh;
  77819. /**
  77820. * Removes the fallback from the bound mesh.
  77821. */
  77822. unBindMesh(): void;
  77823. /**
  77824. * Adds a fallback on the specified property.
  77825. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77826. * @param define The name of the define in the shader
  77827. */
  77828. addFallback(rank: number, define: string): void;
  77829. /**
  77830. * Sets the mesh to use CPU skinning when needing to fallback.
  77831. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77832. * @param mesh The mesh to use the fallbacks.
  77833. */
  77834. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77835. /**
  77836. * Checks to see if more fallbacks are still availible.
  77837. */
  77838. readonly hasMoreFallbacks: boolean;
  77839. /**
  77840. * Removes the defines that should be removed when falling back.
  77841. * @param currentDefines defines the current define statements for the shader.
  77842. * @param effect defines the current effect we try to compile
  77843. * @returns The resulting defines with defines of the current rank removed.
  77844. */
  77845. reduce(currentDefines: string, effect: Effect): string;
  77846. }
  77847. }
  77848. declare module BABYLON {
  77849. /**
  77850. * "Static Class" containing the most commonly used helper while dealing with material for
  77851. * rendering purpose.
  77852. *
  77853. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77854. *
  77855. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77856. */
  77857. export class MaterialHelper {
  77858. /**
  77859. * Bind the current view position to an effect.
  77860. * @param effect The effect to be bound
  77861. * @param scene The scene the eyes position is used from
  77862. */
  77863. static BindEyePosition(effect: Effect, scene: Scene): void;
  77864. /**
  77865. * Helps preparing the defines values about the UVs in used in the effect.
  77866. * UVs are shared as much as we can accross channels in the shaders.
  77867. * @param texture The texture we are preparing the UVs for
  77868. * @param defines The defines to update
  77869. * @param key The channel key "diffuse", "specular"... used in the shader
  77870. */
  77871. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77872. /**
  77873. * Binds a texture matrix value to its corrsponding uniform
  77874. * @param texture The texture to bind the matrix for
  77875. * @param uniformBuffer The uniform buffer receivin the data
  77876. * @param key The channel key "diffuse", "specular"... used in the shader
  77877. */
  77878. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77879. /**
  77880. * Gets the current status of the fog (should it be enabled?)
  77881. * @param mesh defines the mesh to evaluate for fog support
  77882. * @param scene defines the hosting scene
  77883. * @returns true if fog must be enabled
  77884. */
  77885. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77886. /**
  77887. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77888. * @param mesh defines the current mesh
  77889. * @param scene defines the current scene
  77890. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77891. * @param pointsCloud defines if point cloud rendering has to be turned on
  77892. * @param fogEnabled defines if fog has to be turned on
  77893. * @param alphaTest defines if alpha testing has to be turned on
  77894. * @param defines defines the current list of defines
  77895. */
  77896. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77897. /**
  77898. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77899. * @param scene defines the current scene
  77900. * @param engine defines the current engine
  77901. * @param defines specifies the list of active defines
  77902. * @param useInstances defines if instances have to be turned on
  77903. * @param useClipPlane defines if clip plane have to be turned on
  77904. */
  77905. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77906. /**
  77907. * Prepares the defines for bones
  77908. * @param mesh The mesh containing the geometry data we will draw
  77909. * @param defines The defines to update
  77910. */
  77911. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77912. /**
  77913. * Prepares the defines for morph targets
  77914. * @param mesh The mesh containing the geometry data we will draw
  77915. * @param defines The defines to update
  77916. */
  77917. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77918. /**
  77919. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77920. * @param mesh The mesh containing the geometry data we will draw
  77921. * @param defines The defines to update
  77922. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77923. * @param useBones Precise whether bones should be used or not (override mesh info)
  77924. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77925. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77926. * @returns false if defines are considered not dirty and have not been checked
  77927. */
  77928. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77929. /**
  77930. * Prepares the defines related to multiview
  77931. * @param scene The scene we are intending to draw
  77932. * @param defines The defines to update
  77933. */
  77934. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77935. /**
  77936. * Prepares the defines related to the light information passed in parameter
  77937. * @param scene The scene we are intending to draw
  77938. * @param mesh The mesh the effect is compiling for
  77939. * @param light The light the effect is compiling for
  77940. * @param lightIndex The index of the light
  77941. * @param defines The defines to update
  77942. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77943. * @param state Defines the current state regarding what is needed (normals, etc...)
  77944. */
  77945. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77946. needNormals: boolean;
  77947. needRebuild: boolean;
  77948. shadowEnabled: boolean;
  77949. specularEnabled: boolean;
  77950. lightmapMode: boolean;
  77951. }): void;
  77952. /**
  77953. * Prepares the defines related to the light information passed in parameter
  77954. * @param scene The scene we are intending to draw
  77955. * @param mesh The mesh the effect is compiling for
  77956. * @param defines The defines to update
  77957. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77958. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77959. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77960. * @returns true if normals will be required for the rest of the effect
  77961. */
  77962. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77963. /**
  77964. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77965. * @param lightIndex defines the light index
  77966. * @param uniformsList The uniform list
  77967. * @param samplersList The sampler list
  77968. * @param projectedLightTexture defines if projected texture must be used
  77969. * @param uniformBuffersList defines an optional list of uniform buffers
  77970. */
  77971. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77972. /**
  77973. * Prepares the uniforms and samplers list to be used in the effect
  77974. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77975. * @param samplersList The sampler list
  77976. * @param defines The defines helping in the list generation
  77977. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77978. */
  77979. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77980. /**
  77981. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77982. * @param defines The defines to update while falling back
  77983. * @param fallbacks The authorized effect fallbacks
  77984. * @param maxSimultaneousLights The maximum number of lights allowed
  77985. * @param rank the current rank of the Effect
  77986. * @returns The newly affected rank
  77987. */
  77988. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77989. private static _TmpMorphInfluencers;
  77990. /**
  77991. * Prepares the list of attributes required for morph targets according to the effect defines.
  77992. * @param attribs The current list of supported attribs
  77993. * @param mesh The mesh to prepare the morph targets attributes for
  77994. * @param influencers The number of influencers
  77995. */
  77996. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77997. /**
  77998. * Prepares the list of attributes required for morph targets according to the effect defines.
  77999. * @param attribs The current list of supported attribs
  78000. * @param mesh The mesh to prepare the morph targets attributes for
  78001. * @param defines The current Defines of the effect
  78002. */
  78003. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  78004. /**
  78005. * Prepares the list of attributes required for bones according to the effect defines.
  78006. * @param attribs The current list of supported attribs
  78007. * @param mesh The mesh to prepare the bones attributes for
  78008. * @param defines The current Defines of the effect
  78009. * @param fallbacks The current efffect fallback strategy
  78010. */
  78011. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  78012. /**
  78013. * Check and prepare the list of attributes required for instances according to the effect defines.
  78014. * @param attribs The current list of supported attribs
  78015. * @param defines The current MaterialDefines of the effect
  78016. */
  78017. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  78018. /**
  78019. * Add the list of attributes required for instances to the attribs array.
  78020. * @param attribs The current list of supported attribs
  78021. */
  78022. static PushAttributesForInstances(attribs: string[]): void;
  78023. /**
  78024. * Binds the light information to the effect.
  78025. * @param light The light containing the generator
  78026. * @param effect The effect we are binding the data to
  78027. * @param lightIndex The light index in the effect used to render
  78028. */
  78029. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  78030. /**
  78031. * Binds the lights information from the scene to the effect for the given mesh.
  78032. * @param light Light to bind
  78033. * @param lightIndex Light index
  78034. * @param scene The scene where the light belongs to
  78035. * @param effect The effect we are binding the data to
  78036. * @param useSpecular Defines if specular is supported
  78037. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78038. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78039. */
  78040. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78041. /**
  78042. * Binds the lights information from the scene to the effect for the given mesh.
  78043. * @param scene The scene the lights belongs to
  78044. * @param mesh The mesh we are binding the information to render
  78045. * @param effect The effect we are binding the data to
  78046. * @param defines The generated defines for the effect
  78047. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  78048. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78049. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78050. */
  78051. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78052. private static _tempFogColor;
  78053. /**
  78054. * Binds the fog information from the scene to the effect for the given mesh.
  78055. * @param scene The scene the lights belongs to
  78056. * @param mesh The mesh we are binding the information to render
  78057. * @param effect The effect we are binding the data to
  78058. * @param linearSpace Defines if the fog effect is applied in linear space
  78059. */
  78060. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  78061. /**
  78062. * Binds the bones information from the mesh to the effect.
  78063. * @param mesh The mesh we are binding the information to render
  78064. * @param effect The effect we are binding the data to
  78065. */
  78066. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  78067. /**
  78068. * Binds the morph targets information from the mesh to the effect.
  78069. * @param abstractMesh The mesh we are binding the information to render
  78070. * @param effect The effect we are binding the data to
  78071. */
  78072. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  78073. /**
  78074. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  78075. * @param defines The generated defines used in the effect
  78076. * @param effect The effect we are binding the data to
  78077. * @param scene The scene we are willing to render with logarithmic scale for
  78078. */
  78079. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  78080. /**
  78081. * Binds the clip plane information from the scene to the effect.
  78082. * @param scene The scene the clip plane information are extracted from
  78083. * @param effect The effect we are binding the data to
  78084. */
  78085. static BindClipPlane(effect: Effect, scene: Scene): void;
  78086. }
  78087. }
  78088. declare module BABYLON {
  78089. /** @hidden */
  78090. export var packingFunctions: {
  78091. name: string;
  78092. shader: string;
  78093. };
  78094. }
  78095. declare module BABYLON {
  78096. /** @hidden */
  78097. export var shadowMapPixelShader: {
  78098. name: string;
  78099. shader: string;
  78100. };
  78101. }
  78102. declare module BABYLON {
  78103. /** @hidden */
  78104. export var bonesDeclaration: {
  78105. name: string;
  78106. shader: string;
  78107. };
  78108. }
  78109. declare module BABYLON {
  78110. /** @hidden */
  78111. export var morphTargetsVertexGlobalDeclaration: {
  78112. name: string;
  78113. shader: string;
  78114. };
  78115. }
  78116. declare module BABYLON {
  78117. /** @hidden */
  78118. export var morphTargetsVertexDeclaration: {
  78119. name: string;
  78120. shader: string;
  78121. };
  78122. }
  78123. declare module BABYLON {
  78124. /** @hidden */
  78125. export var instancesDeclaration: {
  78126. name: string;
  78127. shader: string;
  78128. };
  78129. }
  78130. declare module BABYLON {
  78131. /** @hidden */
  78132. export var helperFunctions: {
  78133. name: string;
  78134. shader: string;
  78135. };
  78136. }
  78137. declare module BABYLON {
  78138. /** @hidden */
  78139. export var morphTargetsVertex: {
  78140. name: string;
  78141. shader: string;
  78142. };
  78143. }
  78144. declare module BABYLON {
  78145. /** @hidden */
  78146. export var instancesVertex: {
  78147. name: string;
  78148. shader: string;
  78149. };
  78150. }
  78151. declare module BABYLON {
  78152. /** @hidden */
  78153. export var bonesVertex: {
  78154. name: string;
  78155. shader: string;
  78156. };
  78157. }
  78158. declare module BABYLON {
  78159. /** @hidden */
  78160. export var shadowMapVertexShader: {
  78161. name: string;
  78162. shader: string;
  78163. };
  78164. }
  78165. declare module BABYLON {
  78166. /** @hidden */
  78167. export var depthBoxBlurPixelShader: {
  78168. name: string;
  78169. shader: string;
  78170. };
  78171. }
  78172. declare module BABYLON {
  78173. /**
  78174. * Defines the options associated with the creation of a custom shader for a shadow generator.
  78175. */
  78176. export interface ICustomShaderOptions {
  78177. /**
  78178. * Gets or sets the custom shader name to use
  78179. */
  78180. shaderName: string;
  78181. /**
  78182. * The list of attribute names used in the shader
  78183. */
  78184. attributes?: string[];
  78185. /**
  78186. * The list of unifrom names used in the shader
  78187. */
  78188. uniforms?: string[];
  78189. /**
  78190. * The list of sampler names used in the shader
  78191. */
  78192. samplers?: string[];
  78193. /**
  78194. * The list of defines used in the shader
  78195. */
  78196. defines?: string[];
  78197. }
  78198. /**
  78199. * Interface to implement to create a shadow generator compatible with BJS.
  78200. */
  78201. export interface IShadowGenerator {
  78202. /**
  78203. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78204. * @returns The render target texture if present otherwise, null
  78205. */
  78206. getShadowMap(): Nullable<RenderTargetTexture>;
  78207. /**
  78208. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78209. * @returns The render target texture if the shadow map is present otherwise, null
  78210. */
  78211. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78212. /**
  78213. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78214. * @param subMesh The submesh we want to render in the shadow map
  78215. * @param useInstances Defines wether will draw in the map using instances
  78216. * @returns true if ready otherwise, false
  78217. */
  78218. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78219. /**
  78220. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78221. * @param defines Defines of the material we want to update
  78222. * @param lightIndex Index of the light in the enabled light list of the material
  78223. */
  78224. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  78225. /**
  78226. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78227. * defined in the generator but impacting the effect).
  78228. * It implies the unifroms available on the materials are the standard BJS ones.
  78229. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78230. * @param effect The effect we are binfing the information for
  78231. */
  78232. bindShadowLight(lightIndex: string, effect: Effect): void;
  78233. /**
  78234. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78235. * (eq to shadow prjection matrix * light transform matrix)
  78236. * @returns The transform matrix used to create the shadow map
  78237. */
  78238. getTransformMatrix(): Matrix;
  78239. /**
  78240. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78241. * Cube and 2D textures for instance.
  78242. */
  78243. recreateShadowMap(): void;
  78244. /**
  78245. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78246. * @param onCompiled Callback triggered at the and of the effects compilation
  78247. * @param options Sets of optional options forcing the compilation with different modes
  78248. */
  78249. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78250. useInstances: boolean;
  78251. }>): void;
  78252. /**
  78253. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78254. * @param options Sets of optional options forcing the compilation with different modes
  78255. * @returns A promise that resolves when the compilation completes
  78256. */
  78257. forceCompilationAsync(options?: Partial<{
  78258. useInstances: boolean;
  78259. }>): Promise<void>;
  78260. /**
  78261. * Serializes the shadow generator setup to a json object.
  78262. * @returns The serialized JSON object
  78263. */
  78264. serialize(): any;
  78265. /**
  78266. * Disposes the Shadow map and related Textures and effects.
  78267. */
  78268. dispose(): void;
  78269. }
  78270. /**
  78271. * Default implementation IShadowGenerator.
  78272. * This is the main object responsible of generating shadows in the framework.
  78273. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  78274. */
  78275. export class ShadowGenerator implements IShadowGenerator {
  78276. /**
  78277. * Shadow generator mode None: no filtering applied.
  78278. */
  78279. static readonly FILTER_NONE: number;
  78280. /**
  78281. * Shadow generator mode ESM: Exponential Shadow Mapping.
  78282. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78283. */
  78284. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  78285. /**
  78286. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  78287. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  78288. */
  78289. static readonly FILTER_POISSONSAMPLING: number;
  78290. /**
  78291. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  78292. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78293. */
  78294. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  78295. /**
  78296. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  78297. * edge artifacts on steep falloff.
  78298. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78299. */
  78300. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  78301. /**
  78302. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  78303. * edge artifacts on steep falloff.
  78304. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78305. */
  78306. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  78307. /**
  78308. * Shadow generator mode PCF: Percentage Closer Filtering
  78309. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78310. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  78311. */
  78312. static readonly FILTER_PCF: number;
  78313. /**
  78314. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  78315. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78316. * Contact Hardening
  78317. */
  78318. static readonly FILTER_PCSS: number;
  78319. /**
  78320. * Reserved for PCF and PCSS
  78321. * Highest Quality.
  78322. *
  78323. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  78324. *
  78325. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  78326. */
  78327. static readonly QUALITY_HIGH: number;
  78328. /**
  78329. * Reserved for PCF and PCSS
  78330. * Good tradeoff for quality/perf cross devices
  78331. *
  78332. * Execute PCF on a 3*3 kernel.
  78333. *
  78334. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  78335. */
  78336. static readonly QUALITY_MEDIUM: number;
  78337. /**
  78338. * Reserved for PCF and PCSS
  78339. * The lowest quality but the fastest.
  78340. *
  78341. * Execute PCF on a 1*1 kernel.
  78342. *
  78343. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  78344. */
  78345. static readonly QUALITY_LOW: number;
  78346. /** Gets or sets the custom shader name to use */
  78347. customShaderOptions: ICustomShaderOptions;
  78348. /**
  78349. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  78350. */
  78351. onBeforeShadowMapRenderObservable: Observable<Effect>;
  78352. /**
  78353. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  78354. */
  78355. onAfterShadowMapRenderObservable: Observable<Effect>;
  78356. /**
  78357. * Observable triggered before a mesh is rendered in the shadow map.
  78358. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  78359. */
  78360. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  78361. /**
  78362. * Observable triggered after a mesh is rendered in the shadow map.
  78363. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  78364. */
  78365. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  78366. private _bias;
  78367. /**
  78368. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  78369. */
  78370. /**
  78371. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  78372. */
  78373. bias: number;
  78374. private _normalBias;
  78375. /**
  78376. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78377. */
  78378. /**
  78379. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78380. */
  78381. normalBias: number;
  78382. private _blurBoxOffset;
  78383. /**
  78384. * Gets the blur box offset: offset applied during the blur pass.
  78385. * Only useful if useKernelBlur = false
  78386. */
  78387. /**
  78388. * Sets the blur box offset: offset applied during the blur pass.
  78389. * Only useful if useKernelBlur = false
  78390. */
  78391. blurBoxOffset: number;
  78392. private _blurScale;
  78393. /**
  78394. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  78395. * 2 means half of the size.
  78396. */
  78397. /**
  78398. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  78399. * 2 means half of the size.
  78400. */
  78401. blurScale: number;
  78402. private _blurKernel;
  78403. /**
  78404. * Gets the blur kernel: kernel size of the blur pass.
  78405. * Only useful if useKernelBlur = true
  78406. */
  78407. /**
  78408. * Sets the blur kernel: kernel size of the blur pass.
  78409. * Only useful if useKernelBlur = true
  78410. */
  78411. blurKernel: number;
  78412. private _useKernelBlur;
  78413. /**
  78414. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  78415. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78416. */
  78417. /**
  78418. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  78419. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78420. */
  78421. useKernelBlur: boolean;
  78422. private _depthScale;
  78423. /**
  78424. * Gets the depth scale used in ESM mode.
  78425. */
  78426. /**
  78427. * Sets the depth scale used in ESM mode.
  78428. * This can override the scale stored on the light.
  78429. */
  78430. depthScale: number;
  78431. private _filter;
  78432. /**
  78433. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  78434. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78435. */
  78436. /**
  78437. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  78438. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78439. */
  78440. filter: number;
  78441. /**
  78442. * Gets if the current filter is set to Poisson Sampling.
  78443. */
  78444. /**
  78445. * Sets the current filter to Poisson Sampling.
  78446. */
  78447. usePoissonSampling: boolean;
  78448. /**
  78449. * Gets if the current filter is set to ESM.
  78450. */
  78451. /**
  78452. * Sets the current filter is to ESM.
  78453. */
  78454. useExponentialShadowMap: boolean;
  78455. /**
  78456. * Gets if the current filter is set to filtered ESM.
  78457. */
  78458. /**
  78459. * Gets if the current filter is set to filtered ESM.
  78460. */
  78461. useBlurExponentialShadowMap: boolean;
  78462. /**
  78463. * Gets if the current filter is set to "close ESM" (using the inverse of the
  78464. * exponential to prevent steep falloff artifacts).
  78465. */
  78466. /**
  78467. * Sets the current filter to "close ESM" (using the inverse of the
  78468. * exponential to prevent steep falloff artifacts).
  78469. */
  78470. useCloseExponentialShadowMap: boolean;
  78471. /**
  78472. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  78473. * exponential to prevent steep falloff artifacts).
  78474. */
  78475. /**
  78476. * Sets the current filter to filtered "close ESM" (using the inverse of the
  78477. * exponential to prevent steep falloff artifacts).
  78478. */
  78479. useBlurCloseExponentialShadowMap: boolean;
  78480. /**
  78481. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  78482. */
  78483. /**
  78484. * Sets the current filter to "PCF" (percentage closer filtering).
  78485. */
  78486. usePercentageCloserFiltering: boolean;
  78487. private _filteringQuality;
  78488. /**
  78489. * Gets the PCF or PCSS Quality.
  78490. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78491. */
  78492. /**
  78493. * Sets the PCF or PCSS Quality.
  78494. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78495. */
  78496. filteringQuality: number;
  78497. /**
  78498. * Gets if the current filter is set to "PCSS" (contact hardening).
  78499. */
  78500. /**
  78501. * Sets the current filter to "PCSS" (contact hardening).
  78502. */
  78503. useContactHardeningShadow: boolean;
  78504. private _contactHardeningLightSizeUVRatio;
  78505. /**
  78506. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78507. * Using a ratio helps keeping shape stability independently of the map size.
  78508. *
  78509. * It does not account for the light projection as it was having too much
  78510. * instability during the light setup or during light position changes.
  78511. *
  78512. * Only valid if useContactHardeningShadow is true.
  78513. */
  78514. /**
  78515. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78516. * Using a ratio helps keeping shape stability independently of the map size.
  78517. *
  78518. * It does not account for the light projection as it was having too much
  78519. * instability during the light setup or during light position changes.
  78520. *
  78521. * Only valid if useContactHardeningShadow is true.
  78522. */
  78523. contactHardeningLightSizeUVRatio: number;
  78524. private _darkness;
  78525. /** Gets or sets the actual darkness of a shadow */
  78526. darkness: number;
  78527. /**
  78528. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  78529. * 0 means strongest and 1 would means no shadow.
  78530. * @returns the darkness.
  78531. */
  78532. getDarkness(): number;
  78533. /**
  78534. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  78535. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  78536. * @returns the shadow generator allowing fluent coding.
  78537. */
  78538. setDarkness(darkness: number): ShadowGenerator;
  78539. private _transparencyShadow;
  78540. /** Gets or sets the ability to have transparent shadow */
  78541. transparencyShadow: boolean;
  78542. /**
  78543. * Sets the ability to have transparent shadow (boolean).
  78544. * @param transparent True if transparent else False
  78545. * @returns the shadow generator allowing fluent coding
  78546. */
  78547. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  78548. private _shadowMap;
  78549. private _shadowMap2;
  78550. /**
  78551. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78552. * @returns The render target texture if present otherwise, null
  78553. */
  78554. getShadowMap(): Nullable<RenderTargetTexture>;
  78555. /**
  78556. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78557. * @returns The render target texture if the shadow map is present otherwise, null
  78558. */
  78559. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78560. /**
  78561. * Gets the class name of that object
  78562. * @returns "ShadowGenerator"
  78563. */
  78564. getClassName(): string;
  78565. /**
  78566. * Helper function to add a mesh and its descendants to the list of shadow casters.
  78567. * @param mesh Mesh to add
  78568. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  78569. * @returns the Shadow Generator itself
  78570. */
  78571. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78572. /**
  78573. * Helper function to remove a mesh and its descendants from the list of shadow casters
  78574. * @param mesh Mesh to remove
  78575. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  78576. * @returns the Shadow Generator itself
  78577. */
  78578. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78579. /**
  78580. * Controls the extent to which the shadows fade out at the edge of the frustum
  78581. * Used only by directionals and spots
  78582. */
  78583. frustumEdgeFalloff: number;
  78584. private _light;
  78585. /**
  78586. * Returns the associated light object.
  78587. * @returns the light generating the shadow
  78588. */
  78589. getLight(): IShadowLight;
  78590. /**
  78591. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  78592. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  78593. * It might on the other hand introduce peter panning.
  78594. */
  78595. forceBackFacesOnly: boolean;
  78596. private _scene;
  78597. private _lightDirection;
  78598. private _effect;
  78599. private _viewMatrix;
  78600. private _projectionMatrix;
  78601. private _transformMatrix;
  78602. private _cachedPosition;
  78603. private _cachedDirection;
  78604. private _cachedDefines;
  78605. private _currentRenderID;
  78606. private _boxBlurPostprocess;
  78607. private _kernelBlurXPostprocess;
  78608. private _kernelBlurYPostprocess;
  78609. private _blurPostProcesses;
  78610. private _mapSize;
  78611. private _currentFaceIndex;
  78612. private _currentFaceIndexCache;
  78613. private _textureType;
  78614. private _defaultTextureMatrix;
  78615. private _storedUniqueId;
  78616. /** @hidden */
  78617. static _SceneComponentInitialization: (scene: Scene) => void;
  78618. /**
  78619. * Creates a ShadowGenerator object.
  78620. * A ShadowGenerator is the required tool to use the shadows.
  78621. * Each light casting shadows needs to use its own ShadowGenerator.
  78622. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  78623. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  78624. * @param light The light object generating the shadows.
  78625. * @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.
  78626. */
  78627. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  78628. private _initializeGenerator;
  78629. private _initializeShadowMap;
  78630. private _initializeBlurRTTAndPostProcesses;
  78631. private _renderForShadowMap;
  78632. private _renderSubMeshForShadowMap;
  78633. private _applyFilterValues;
  78634. /**
  78635. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78636. * @param onCompiled Callback triggered at the and of the effects compilation
  78637. * @param options Sets of optional options forcing the compilation with different modes
  78638. */
  78639. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78640. useInstances: boolean;
  78641. }>): void;
  78642. /**
  78643. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78644. * @param options Sets of optional options forcing the compilation with different modes
  78645. * @returns A promise that resolves when the compilation completes
  78646. */
  78647. forceCompilationAsync(options?: Partial<{
  78648. useInstances: boolean;
  78649. }>): Promise<void>;
  78650. /**
  78651. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78652. * @param subMesh The submesh we want to render in the shadow map
  78653. * @param useInstances Defines wether will draw in the map using instances
  78654. * @returns true if ready otherwise, false
  78655. */
  78656. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78657. /**
  78658. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78659. * @param defines Defines of the material we want to update
  78660. * @param lightIndex Index of the light in the enabled light list of the material
  78661. */
  78662. prepareDefines(defines: any, lightIndex: number): void;
  78663. /**
  78664. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78665. * defined in the generator but impacting the effect).
  78666. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78667. * @param effect The effect we are binfing the information for
  78668. */
  78669. bindShadowLight(lightIndex: string, effect: Effect): void;
  78670. /**
  78671. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78672. * (eq to shadow prjection matrix * light transform matrix)
  78673. * @returns The transform matrix used to create the shadow map
  78674. */
  78675. getTransformMatrix(): Matrix;
  78676. /**
  78677. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78678. * Cube and 2D textures for instance.
  78679. */
  78680. recreateShadowMap(): void;
  78681. private _disposeBlurPostProcesses;
  78682. private _disposeRTTandPostProcesses;
  78683. /**
  78684. * Disposes the ShadowGenerator.
  78685. * Returns nothing.
  78686. */
  78687. dispose(): void;
  78688. /**
  78689. * Serializes the shadow generator setup to a json object.
  78690. * @returns The serialized JSON object
  78691. */
  78692. serialize(): any;
  78693. /**
  78694. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  78695. * @param parsedShadowGenerator The JSON object to parse
  78696. * @param scene The scene to create the shadow map for
  78697. * @returns The parsed shadow generator
  78698. */
  78699. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  78700. }
  78701. }
  78702. declare module BABYLON {
  78703. /**
  78704. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  78705. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  78706. * 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.
  78707. */
  78708. export abstract class Light extends Node {
  78709. /**
  78710. * Falloff Default: light is falling off following the material specification:
  78711. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  78712. */
  78713. static readonly FALLOFF_DEFAULT: number;
  78714. /**
  78715. * Falloff Physical: light is falling off following the inverse squared distance law.
  78716. */
  78717. static readonly FALLOFF_PHYSICAL: number;
  78718. /**
  78719. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78720. * to enhance interoperability with other engines.
  78721. */
  78722. static readonly FALLOFF_GLTF: number;
  78723. /**
  78724. * Falloff Standard: light is falling off like in the standard material
  78725. * to enhance interoperability with other materials.
  78726. */
  78727. static readonly FALLOFF_STANDARD: number;
  78728. /**
  78729. * If every light affecting the material is in this lightmapMode,
  78730. * material.lightmapTexture adds or multiplies
  78731. * (depends on material.useLightmapAsShadowmap)
  78732. * after every other light calculations.
  78733. */
  78734. static readonly LIGHTMAP_DEFAULT: number;
  78735. /**
  78736. * material.lightmapTexture as only diffuse lighting from this light
  78737. * adds only specular lighting from this light
  78738. * adds dynamic shadows
  78739. */
  78740. static readonly LIGHTMAP_SPECULAR: number;
  78741. /**
  78742. * material.lightmapTexture as only lighting
  78743. * no light calculation from this light
  78744. * only adds dynamic shadows from this light
  78745. */
  78746. static readonly LIGHTMAP_SHADOWSONLY: number;
  78747. /**
  78748. * Each light type uses the default quantity according to its type:
  78749. * point/spot lights use luminous intensity
  78750. * directional lights use illuminance
  78751. */
  78752. static readonly INTENSITYMODE_AUTOMATIC: number;
  78753. /**
  78754. * lumen (lm)
  78755. */
  78756. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78757. /**
  78758. * candela (lm/sr)
  78759. */
  78760. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78761. /**
  78762. * lux (lm/m^2)
  78763. */
  78764. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78765. /**
  78766. * nit (cd/m^2)
  78767. */
  78768. static readonly INTENSITYMODE_LUMINANCE: number;
  78769. /**
  78770. * Light type const id of the point light.
  78771. */
  78772. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78773. /**
  78774. * Light type const id of the directional light.
  78775. */
  78776. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78777. /**
  78778. * Light type const id of the spot light.
  78779. */
  78780. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78781. /**
  78782. * Light type const id of the hemispheric light.
  78783. */
  78784. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78785. /**
  78786. * Diffuse gives the basic color to an object.
  78787. */
  78788. diffuse: Color3;
  78789. /**
  78790. * Specular produces a highlight color on an object.
  78791. * Note: This is note affecting PBR materials.
  78792. */
  78793. specular: Color3;
  78794. /**
  78795. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78796. * falling off base on range or angle.
  78797. * This can be set to any values in Light.FALLOFF_x.
  78798. *
  78799. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78800. * other types of materials.
  78801. */
  78802. falloffType: number;
  78803. /**
  78804. * Strength of the light.
  78805. * Note: By default it is define in the framework own unit.
  78806. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78807. */
  78808. intensity: number;
  78809. private _range;
  78810. protected _inverseSquaredRange: number;
  78811. /**
  78812. * Defines how far from the source the light is impacting in scene units.
  78813. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78814. */
  78815. /**
  78816. * Defines how far from the source the light is impacting in scene units.
  78817. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78818. */
  78819. range: number;
  78820. /**
  78821. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78822. * of light.
  78823. */
  78824. private _photometricScale;
  78825. private _intensityMode;
  78826. /**
  78827. * Gets the photometric scale used to interpret the intensity.
  78828. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78829. */
  78830. /**
  78831. * Sets the photometric scale used to interpret the intensity.
  78832. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78833. */
  78834. intensityMode: number;
  78835. private _radius;
  78836. /**
  78837. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78838. */
  78839. /**
  78840. * sets the light radius used by PBR Materials to simulate soft area lights.
  78841. */
  78842. radius: number;
  78843. private _renderPriority;
  78844. /**
  78845. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78846. * exceeding the number allowed of the materials.
  78847. */
  78848. renderPriority: number;
  78849. private _shadowEnabled;
  78850. /**
  78851. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78852. * the current shadow generator.
  78853. */
  78854. /**
  78855. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78856. * the current shadow generator.
  78857. */
  78858. shadowEnabled: boolean;
  78859. private _includedOnlyMeshes;
  78860. /**
  78861. * Gets the only meshes impacted by this light.
  78862. */
  78863. /**
  78864. * Sets the only meshes impacted by this light.
  78865. */
  78866. includedOnlyMeshes: AbstractMesh[];
  78867. private _excludedMeshes;
  78868. /**
  78869. * Gets the meshes not impacted by this light.
  78870. */
  78871. /**
  78872. * Sets the meshes not impacted by this light.
  78873. */
  78874. excludedMeshes: AbstractMesh[];
  78875. private _excludeWithLayerMask;
  78876. /**
  78877. * Gets the layer id use to find what meshes are not impacted by the light.
  78878. * Inactive if 0
  78879. */
  78880. /**
  78881. * Sets the layer id use to find what meshes are not impacted by the light.
  78882. * Inactive if 0
  78883. */
  78884. excludeWithLayerMask: number;
  78885. private _includeOnlyWithLayerMask;
  78886. /**
  78887. * Gets the layer id use to find what meshes are impacted by the light.
  78888. * Inactive if 0
  78889. */
  78890. /**
  78891. * Sets the layer id use to find what meshes are impacted by the light.
  78892. * Inactive if 0
  78893. */
  78894. includeOnlyWithLayerMask: number;
  78895. private _lightmapMode;
  78896. /**
  78897. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78898. */
  78899. /**
  78900. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78901. */
  78902. lightmapMode: number;
  78903. /**
  78904. * Shadow generator associted to the light.
  78905. * @hidden Internal use only.
  78906. */
  78907. _shadowGenerator: Nullable<IShadowGenerator>;
  78908. /**
  78909. * @hidden Internal use only.
  78910. */
  78911. _excludedMeshesIds: string[];
  78912. /**
  78913. * @hidden Internal use only.
  78914. */
  78915. _includedOnlyMeshesIds: string[];
  78916. /**
  78917. * The current light unifom buffer.
  78918. * @hidden Internal use only.
  78919. */
  78920. _uniformBuffer: UniformBuffer;
  78921. /** @hidden */
  78922. _renderId: number;
  78923. /**
  78924. * Creates a Light object in the scene.
  78925. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78926. * @param name The firendly name of the light
  78927. * @param scene The scene the light belongs too
  78928. */
  78929. constructor(name: string, scene: Scene);
  78930. protected abstract _buildUniformLayout(): void;
  78931. /**
  78932. * Sets the passed Effect "effect" with the Light information.
  78933. * @param effect The effect to update
  78934. * @param lightIndex The index of the light in the effect to update
  78935. * @returns The light
  78936. */
  78937. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78938. /**
  78939. * Sets the passed Effect "effect" with the Light information.
  78940. * @param effect The effect to update
  78941. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78942. * @returns The light
  78943. */
  78944. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78945. /**
  78946. * Returns the string "Light".
  78947. * @returns the class name
  78948. */
  78949. getClassName(): string;
  78950. /** @hidden */
  78951. readonly _isLight: boolean;
  78952. /**
  78953. * Converts the light information to a readable string for debug purpose.
  78954. * @param fullDetails Supports for multiple levels of logging within scene loading
  78955. * @returns the human readable light info
  78956. */
  78957. toString(fullDetails?: boolean): string;
  78958. /** @hidden */
  78959. protected _syncParentEnabledState(): void;
  78960. /**
  78961. * Set the enabled state of this node.
  78962. * @param value - the new enabled state
  78963. */
  78964. setEnabled(value: boolean): void;
  78965. /**
  78966. * Returns the Light associated shadow generator if any.
  78967. * @return the associated shadow generator.
  78968. */
  78969. getShadowGenerator(): Nullable<IShadowGenerator>;
  78970. /**
  78971. * Returns a Vector3, the absolute light position in the World.
  78972. * @returns the world space position of the light
  78973. */
  78974. getAbsolutePosition(): Vector3;
  78975. /**
  78976. * Specifies if the light will affect the passed mesh.
  78977. * @param mesh The mesh to test against the light
  78978. * @return true the mesh is affected otherwise, false.
  78979. */
  78980. canAffectMesh(mesh: AbstractMesh): boolean;
  78981. /**
  78982. * Sort function to order lights for rendering.
  78983. * @param a First Light object to compare to second.
  78984. * @param b Second Light object to compare first.
  78985. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78986. */
  78987. static CompareLightsPriority(a: Light, b: Light): number;
  78988. /**
  78989. * Releases resources associated with this node.
  78990. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78991. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78992. */
  78993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78994. /**
  78995. * Returns the light type ID (integer).
  78996. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78997. */
  78998. getTypeID(): number;
  78999. /**
  79000. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  79001. * @returns the scaled intensity in intensity mode unit
  79002. */
  79003. getScaledIntensity(): number;
  79004. /**
  79005. * Returns a new Light object, named "name", from the current one.
  79006. * @param name The name of the cloned light
  79007. * @returns the new created light
  79008. */
  79009. clone(name: string): Nullable<Light>;
  79010. /**
  79011. * Serializes the current light into a Serialization object.
  79012. * @returns the serialized object.
  79013. */
  79014. serialize(): any;
  79015. /**
  79016. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  79017. * This new light is named "name" and added to the passed scene.
  79018. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  79019. * @param name The friendly name of the light
  79020. * @param scene The scene the new light will belong to
  79021. * @returns the constructor function
  79022. */
  79023. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  79024. /**
  79025. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  79026. * @param parsedLight The JSON representation of the light
  79027. * @param scene The scene to create the parsed light in
  79028. * @returns the created light after parsing
  79029. */
  79030. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  79031. private _hookArrayForExcluded;
  79032. private _hookArrayForIncludedOnly;
  79033. private _resyncMeshes;
  79034. /**
  79035. * Forces the meshes to update their light related information in their rendering used effects
  79036. * @hidden Internal Use Only
  79037. */
  79038. _markMeshesAsLightDirty(): void;
  79039. /**
  79040. * Recomputes the cached photometric scale if needed.
  79041. */
  79042. private _computePhotometricScale;
  79043. /**
  79044. * Returns the Photometric Scale according to the light type and intensity mode.
  79045. */
  79046. private _getPhotometricScale;
  79047. /**
  79048. * Reorder the light in the scene according to their defined priority.
  79049. * @hidden Internal Use Only
  79050. */
  79051. _reorderLightsInScene(): void;
  79052. /**
  79053. * Prepares the list of defines specific to the light type.
  79054. * @param defines the list of defines
  79055. * @param lightIndex defines the index of the light for the effect
  79056. */
  79057. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79058. }
  79059. }
  79060. declare module BABYLON {
  79061. /**
  79062. * Interface used to define Action
  79063. */
  79064. export interface IAction {
  79065. /**
  79066. * Trigger for the action
  79067. */
  79068. trigger: number;
  79069. /** Options of the trigger */
  79070. triggerOptions: any;
  79071. /**
  79072. * Gets the trigger parameters
  79073. * @returns the trigger parameters
  79074. */
  79075. getTriggerParameter(): any;
  79076. /**
  79077. * Internal only - executes current action event
  79078. * @hidden
  79079. */
  79080. _executeCurrent(evt?: ActionEvent): void;
  79081. /**
  79082. * Serialize placeholder for child classes
  79083. * @param parent of child
  79084. * @returns the serialized object
  79085. */
  79086. serialize(parent: any): any;
  79087. /**
  79088. * Internal only
  79089. * @hidden
  79090. */
  79091. _prepare(): void;
  79092. /**
  79093. * Internal only - manager for action
  79094. * @hidden
  79095. */
  79096. _actionManager: AbstractActionManager;
  79097. /**
  79098. * Adds action to chain of actions, may be a DoNothingAction
  79099. * @param action defines the next action to execute
  79100. * @returns The action passed in
  79101. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79102. */
  79103. then(action: IAction): IAction;
  79104. }
  79105. /**
  79106. * The action to be carried out following a trigger
  79107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  79108. */
  79109. export class Action implements IAction {
  79110. /** the trigger, with or without parameters, for the action */
  79111. triggerOptions: any;
  79112. /**
  79113. * Trigger for the action
  79114. */
  79115. trigger: number;
  79116. /**
  79117. * Internal only - manager for action
  79118. * @hidden
  79119. */
  79120. _actionManager: ActionManager;
  79121. private _nextActiveAction;
  79122. private _child;
  79123. private _condition?;
  79124. private _triggerParameter;
  79125. /**
  79126. * An event triggered prior to action being executed.
  79127. */
  79128. onBeforeExecuteObservable: Observable<Action>;
  79129. /**
  79130. * Creates a new Action
  79131. * @param triggerOptions the trigger, with or without parameters, for the action
  79132. * @param condition an optional determinant of action
  79133. */
  79134. constructor(
  79135. /** the trigger, with or without parameters, for the action */
  79136. triggerOptions: any, condition?: Condition);
  79137. /**
  79138. * Internal only
  79139. * @hidden
  79140. */
  79141. _prepare(): void;
  79142. /**
  79143. * Gets the trigger parameters
  79144. * @returns the trigger parameters
  79145. */
  79146. getTriggerParameter(): any;
  79147. /**
  79148. * Internal only - executes current action event
  79149. * @hidden
  79150. */
  79151. _executeCurrent(evt?: ActionEvent): void;
  79152. /**
  79153. * Execute placeholder for child classes
  79154. * @param evt optional action event
  79155. */
  79156. execute(evt?: ActionEvent): void;
  79157. /**
  79158. * Skips to next active action
  79159. */
  79160. skipToNextActiveAction(): void;
  79161. /**
  79162. * Adds action to chain of actions, may be a DoNothingAction
  79163. * @param action defines the next action to execute
  79164. * @returns The action passed in
  79165. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79166. */
  79167. then(action: Action): Action;
  79168. /**
  79169. * Internal only
  79170. * @hidden
  79171. */
  79172. _getProperty(propertyPath: string): string;
  79173. /**
  79174. * Internal only
  79175. * @hidden
  79176. */
  79177. _getEffectiveTarget(target: any, propertyPath: string): any;
  79178. /**
  79179. * Serialize placeholder for child classes
  79180. * @param parent of child
  79181. * @returns the serialized object
  79182. */
  79183. serialize(parent: any): any;
  79184. /**
  79185. * Internal only called by serialize
  79186. * @hidden
  79187. */
  79188. protected _serialize(serializedAction: any, parent?: any): any;
  79189. /**
  79190. * Internal only
  79191. * @hidden
  79192. */
  79193. static _SerializeValueAsString: (value: any) => string;
  79194. /**
  79195. * Internal only
  79196. * @hidden
  79197. */
  79198. static _GetTargetProperty: (target: Node | Scene) => {
  79199. name: string;
  79200. targetType: string;
  79201. value: string;
  79202. };
  79203. }
  79204. }
  79205. declare module BABYLON {
  79206. /**
  79207. * A Condition applied to an Action
  79208. */
  79209. export class Condition {
  79210. /**
  79211. * Internal only - manager for action
  79212. * @hidden
  79213. */
  79214. _actionManager: ActionManager;
  79215. /**
  79216. * Internal only
  79217. * @hidden
  79218. */
  79219. _evaluationId: number;
  79220. /**
  79221. * Internal only
  79222. * @hidden
  79223. */
  79224. _currentResult: boolean;
  79225. /**
  79226. * Creates a new Condition
  79227. * @param actionManager the manager of the action the condition is applied to
  79228. */
  79229. constructor(actionManager: ActionManager);
  79230. /**
  79231. * Check if the current condition is valid
  79232. * @returns a boolean
  79233. */
  79234. isValid(): boolean;
  79235. /**
  79236. * Internal only
  79237. * @hidden
  79238. */
  79239. _getProperty(propertyPath: string): string;
  79240. /**
  79241. * Internal only
  79242. * @hidden
  79243. */
  79244. _getEffectiveTarget(target: any, propertyPath: string): any;
  79245. /**
  79246. * Serialize placeholder for child classes
  79247. * @returns the serialized object
  79248. */
  79249. serialize(): any;
  79250. /**
  79251. * Internal only
  79252. * @hidden
  79253. */
  79254. protected _serialize(serializedCondition: any): any;
  79255. }
  79256. /**
  79257. * Defines specific conditional operators as extensions of Condition
  79258. */
  79259. export class ValueCondition extends Condition {
  79260. /** path to specify the property of the target the conditional operator uses */
  79261. propertyPath: string;
  79262. /** the value compared by the conditional operator against the current value of the property */
  79263. value: any;
  79264. /** the conditional operator, default ValueCondition.IsEqual */
  79265. operator: number;
  79266. /**
  79267. * Internal only
  79268. * @hidden
  79269. */
  79270. private static _IsEqual;
  79271. /**
  79272. * Internal only
  79273. * @hidden
  79274. */
  79275. private static _IsDifferent;
  79276. /**
  79277. * Internal only
  79278. * @hidden
  79279. */
  79280. private static _IsGreater;
  79281. /**
  79282. * Internal only
  79283. * @hidden
  79284. */
  79285. private static _IsLesser;
  79286. /**
  79287. * returns the number for IsEqual
  79288. */
  79289. static readonly IsEqual: number;
  79290. /**
  79291. * Returns the number for IsDifferent
  79292. */
  79293. static readonly IsDifferent: number;
  79294. /**
  79295. * Returns the number for IsGreater
  79296. */
  79297. static readonly IsGreater: number;
  79298. /**
  79299. * Returns the number for IsLesser
  79300. */
  79301. static readonly IsLesser: number;
  79302. /**
  79303. * Internal only The action manager for the condition
  79304. * @hidden
  79305. */
  79306. _actionManager: ActionManager;
  79307. /**
  79308. * Internal only
  79309. * @hidden
  79310. */
  79311. private _target;
  79312. /**
  79313. * Internal only
  79314. * @hidden
  79315. */
  79316. private _effectiveTarget;
  79317. /**
  79318. * Internal only
  79319. * @hidden
  79320. */
  79321. private _property;
  79322. /**
  79323. * Creates a new ValueCondition
  79324. * @param actionManager manager for the action the condition applies to
  79325. * @param target for the action
  79326. * @param propertyPath path to specify the property of the target the conditional operator uses
  79327. * @param value the value compared by the conditional operator against the current value of the property
  79328. * @param operator the conditional operator, default ValueCondition.IsEqual
  79329. */
  79330. constructor(actionManager: ActionManager, target: any,
  79331. /** path to specify the property of the target the conditional operator uses */
  79332. propertyPath: string,
  79333. /** the value compared by the conditional operator against the current value of the property */
  79334. value: any,
  79335. /** the conditional operator, default ValueCondition.IsEqual */
  79336. operator?: number);
  79337. /**
  79338. * Compares the given value with the property value for the specified conditional operator
  79339. * @returns the result of the comparison
  79340. */
  79341. isValid(): boolean;
  79342. /**
  79343. * Serialize the ValueCondition into a JSON compatible object
  79344. * @returns serialization object
  79345. */
  79346. serialize(): any;
  79347. /**
  79348. * Gets the name of the conditional operator for the ValueCondition
  79349. * @param operator the conditional operator
  79350. * @returns the name
  79351. */
  79352. static GetOperatorName(operator: number): string;
  79353. }
  79354. /**
  79355. * Defines a predicate condition as an extension of Condition
  79356. */
  79357. export class PredicateCondition extends Condition {
  79358. /** defines the predicate function used to validate the condition */
  79359. predicate: () => boolean;
  79360. /**
  79361. * Internal only - manager for action
  79362. * @hidden
  79363. */
  79364. _actionManager: ActionManager;
  79365. /**
  79366. * Creates a new PredicateCondition
  79367. * @param actionManager manager for the action the condition applies to
  79368. * @param predicate defines the predicate function used to validate the condition
  79369. */
  79370. constructor(actionManager: ActionManager,
  79371. /** defines the predicate function used to validate the condition */
  79372. predicate: () => boolean);
  79373. /**
  79374. * @returns the validity of the predicate condition
  79375. */
  79376. isValid(): boolean;
  79377. }
  79378. /**
  79379. * Defines a state condition as an extension of Condition
  79380. */
  79381. export class StateCondition extends Condition {
  79382. /** Value to compare with target state */
  79383. value: string;
  79384. /**
  79385. * Internal only - manager for action
  79386. * @hidden
  79387. */
  79388. _actionManager: ActionManager;
  79389. /**
  79390. * Internal only
  79391. * @hidden
  79392. */
  79393. private _target;
  79394. /**
  79395. * Creates a new StateCondition
  79396. * @param actionManager manager for the action the condition applies to
  79397. * @param target of the condition
  79398. * @param value to compare with target state
  79399. */
  79400. constructor(actionManager: ActionManager, target: any,
  79401. /** Value to compare with target state */
  79402. value: string);
  79403. /**
  79404. * Gets a boolean indicating if the current condition is met
  79405. * @returns the validity of the state
  79406. */
  79407. isValid(): boolean;
  79408. /**
  79409. * Serialize the StateCondition into a JSON compatible object
  79410. * @returns serialization object
  79411. */
  79412. serialize(): any;
  79413. }
  79414. }
  79415. declare module BABYLON {
  79416. /**
  79417. * This defines an action responsible to toggle a boolean once triggered.
  79418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79419. */
  79420. export class SwitchBooleanAction extends Action {
  79421. /**
  79422. * The path to the boolean property in the target object
  79423. */
  79424. propertyPath: string;
  79425. private _target;
  79426. private _effectiveTarget;
  79427. private _property;
  79428. /**
  79429. * Instantiate the action
  79430. * @param triggerOptions defines the trigger options
  79431. * @param target defines the object containing the boolean
  79432. * @param propertyPath defines the path to the boolean property in the target object
  79433. * @param condition defines the trigger related conditions
  79434. */
  79435. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  79436. /** @hidden */
  79437. _prepare(): void;
  79438. /**
  79439. * Execute the action toggle the boolean value.
  79440. */
  79441. execute(): void;
  79442. /**
  79443. * Serializes the actions and its related information.
  79444. * @param parent defines the object to serialize in
  79445. * @returns the serialized object
  79446. */
  79447. serialize(parent: any): any;
  79448. }
  79449. /**
  79450. * This defines an action responsible to set a the state field of the target
  79451. * to a desired value once triggered.
  79452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79453. */
  79454. export class SetStateAction extends Action {
  79455. /**
  79456. * The value to store in the state field.
  79457. */
  79458. value: string;
  79459. private _target;
  79460. /**
  79461. * Instantiate the action
  79462. * @param triggerOptions defines the trigger options
  79463. * @param target defines the object containing the state property
  79464. * @param value defines the value to store in the state field
  79465. * @param condition defines the trigger related conditions
  79466. */
  79467. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  79468. /**
  79469. * Execute the action and store the value on the target state property.
  79470. */
  79471. execute(): void;
  79472. /**
  79473. * Serializes the actions and its related information.
  79474. * @param parent defines the object to serialize in
  79475. * @returns the serialized object
  79476. */
  79477. serialize(parent: any): any;
  79478. }
  79479. /**
  79480. * This defines an action responsible to set a property of the target
  79481. * to a desired value once triggered.
  79482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79483. */
  79484. export class SetValueAction extends Action {
  79485. /**
  79486. * The path of the property to set in the target.
  79487. */
  79488. propertyPath: string;
  79489. /**
  79490. * The value to set in the property
  79491. */
  79492. value: any;
  79493. private _target;
  79494. private _effectiveTarget;
  79495. private _property;
  79496. /**
  79497. * Instantiate the action
  79498. * @param triggerOptions defines the trigger options
  79499. * @param target defines the object containing the property
  79500. * @param propertyPath defines the path of the property to set in the target
  79501. * @param value defines the value to set in the property
  79502. * @param condition defines the trigger related conditions
  79503. */
  79504. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79505. /** @hidden */
  79506. _prepare(): void;
  79507. /**
  79508. * Execute the action and set the targetted property to the desired value.
  79509. */
  79510. execute(): void;
  79511. /**
  79512. * Serializes the actions and its related information.
  79513. * @param parent defines the object to serialize in
  79514. * @returns the serialized object
  79515. */
  79516. serialize(parent: any): any;
  79517. }
  79518. /**
  79519. * This defines an action responsible to increment the target value
  79520. * to a desired value once triggered.
  79521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79522. */
  79523. export class IncrementValueAction extends Action {
  79524. /**
  79525. * The path of the property to increment in the target.
  79526. */
  79527. propertyPath: string;
  79528. /**
  79529. * The value we should increment the property by.
  79530. */
  79531. value: any;
  79532. private _target;
  79533. private _effectiveTarget;
  79534. private _property;
  79535. /**
  79536. * Instantiate the action
  79537. * @param triggerOptions defines the trigger options
  79538. * @param target defines the object containing the property
  79539. * @param propertyPath defines the path of the property to increment in the target
  79540. * @param value defines the value value we should increment the property by
  79541. * @param condition defines the trigger related conditions
  79542. */
  79543. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79544. /** @hidden */
  79545. _prepare(): void;
  79546. /**
  79547. * Execute the action and increment the target of the value amount.
  79548. */
  79549. execute(): void;
  79550. /**
  79551. * Serializes the actions and its related information.
  79552. * @param parent defines the object to serialize in
  79553. * @returns the serialized object
  79554. */
  79555. serialize(parent: any): any;
  79556. }
  79557. /**
  79558. * This defines an action responsible to start an animation once triggered.
  79559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79560. */
  79561. export class PlayAnimationAction extends Action {
  79562. /**
  79563. * Where the animation should start (animation frame)
  79564. */
  79565. from: number;
  79566. /**
  79567. * Where the animation should stop (animation frame)
  79568. */
  79569. to: number;
  79570. /**
  79571. * Define if the animation should loop or stop after the first play.
  79572. */
  79573. loop?: boolean;
  79574. private _target;
  79575. /**
  79576. * Instantiate the action
  79577. * @param triggerOptions defines the trigger options
  79578. * @param target defines the target animation or animation name
  79579. * @param from defines from where the animation should start (animation frame)
  79580. * @param end defines where the animation should stop (animation frame)
  79581. * @param loop defines if the animation should loop or stop after the first play
  79582. * @param condition defines the trigger related conditions
  79583. */
  79584. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  79585. /** @hidden */
  79586. _prepare(): void;
  79587. /**
  79588. * Execute the action and play the animation.
  79589. */
  79590. execute(): void;
  79591. /**
  79592. * Serializes the actions and its related information.
  79593. * @param parent defines the object to serialize in
  79594. * @returns the serialized object
  79595. */
  79596. serialize(parent: any): any;
  79597. }
  79598. /**
  79599. * This defines an action responsible to stop an animation once triggered.
  79600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79601. */
  79602. export class StopAnimationAction extends Action {
  79603. private _target;
  79604. /**
  79605. * Instantiate the action
  79606. * @param triggerOptions defines the trigger options
  79607. * @param target defines the target animation or animation name
  79608. * @param condition defines the trigger related conditions
  79609. */
  79610. constructor(triggerOptions: any, target: any, condition?: Condition);
  79611. /** @hidden */
  79612. _prepare(): void;
  79613. /**
  79614. * Execute the action and stop the animation.
  79615. */
  79616. execute(): void;
  79617. /**
  79618. * Serializes the actions and its related information.
  79619. * @param parent defines the object to serialize in
  79620. * @returns the serialized object
  79621. */
  79622. serialize(parent: any): any;
  79623. }
  79624. /**
  79625. * This defines an action responsible that does nothing once triggered.
  79626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79627. */
  79628. export class DoNothingAction extends Action {
  79629. /**
  79630. * Instantiate the action
  79631. * @param triggerOptions defines the trigger options
  79632. * @param condition defines the trigger related conditions
  79633. */
  79634. constructor(triggerOptions?: any, condition?: Condition);
  79635. /**
  79636. * Execute the action and do nothing.
  79637. */
  79638. execute(): void;
  79639. /**
  79640. * Serializes the actions and its related information.
  79641. * @param parent defines the object to serialize in
  79642. * @returns the serialized object
  79643. */
  79644. serialize(parent: any): any;
  79645. }
  79646. /**
  79647. * This defines an action responsible to trigger several actions once triggered.
  79648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79649. */
  79650. export class CombineAction extends Action {
  79651. /**
  79652. * The list of aggregated animations to run.
  79653. */
  79654. children: Action[];
  79655. /**
  79656. * Instantiate the action
  79657. * @param triggerOptions defines the trigger options
  79658. * @param children defines the list of aggregated animations to run
  79659. * @param condition defines the trigger related conditions
  79660. */
  79661. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  79662. /** @hidden */
  79663. _prepare(): void;
  79664. /**
  79665. * Execute the action and executes all the aggregated actions.
  79666. */
  79667. execute(evt: ActionEvent): void;
  79668. /**
  79669. * Serializes the actions and its related information.
  79670. * @param parent defines the object to serialize in
  79671. * @returns the serialized object
  79672. */
  79673. serialize(parent: any): any;
  79674. }
  79675. /**
  79676. * This defines an action responsible to run code (external event) once triggered.
  79677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79678. */
  79679. export class ExecuteCodeAction extends Action {
  79680. /**
  79681. * The callback function to run.
  79682. */
  79683. func: (evt: ActionEvent) => void;
  79684. /**
  79685. * Instantiate the action
  79686. * @param triggerOptions defines the trigger options
  79687. * @param func defines the callback function to run
  79688. * @param condition defines the trigger related conditions
  79689. */
  79690. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  79691. /**
  79692. * Execute the action and run the attached code.
  79693. */
  79694. execute(evt: ActionEvent): void;
  79695. }
  79696. /**
  79697. * This defines an action responsible to set the parent property of the target once triggered.
  79698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79699. */
  79700. export class SetParentAction extends Action {
  79701. private _parent;
  79702. private _target;
  79703. /**
  79704. * Instantiate the action
  79705. * @param triggerOptions defines the trigger options
  79706. * @param target defines the target containing the parent property
  79707. * @param parent defines from where the animation should start (animation frame)
  79708. * @param condition defines the trigger related conditions
  79709. */
  79710. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  79711. /** @hidden */
  79712. _prepare(): void;
  79713. /**
  79714. * Execute the action and set the parent property.
  79715. */
  79716. execute(): void;
  79717. /**
  79718. * Serializes the actions and its related information.
  79719. * @param parent defines the object to serialize in
  79720. * @returns the serialized object
  79721. */
  79722. serialize(parent: any): any;
  79723. }
  79724. }
  79725. declare module BABYLON {
  79726. /**
  79727. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79728. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79730. */
  79731. export class ActionManager extends AbstractActionManager {
  79732. /**
  79733. * Nothing
  79734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79735. */
  79736. static readonly NothingTrigger: number;
  79737. /**
  79738. * On pick
  79739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79740. */
  79741. static readonly OnPickTrigger: number;
  79742. /**
  79743. * On left pick
  79744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79745. */
  79746. static readonly OnLeftPickTrigger: number;
  79747. /**
  79748. * On right pick
  79749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79750. */
  79751. static readonly OnRightPickTrigger: number;
  79752. /**
  79753. * On center pick
  79754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79755. */
  79756. static readonly OnCenterPickTrigger: number;
  79757. /**
  79758. * On pick down
  79759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79760. */
  79761. static readonly OnPickDownTrigger: number;
  79762. /**
  79763. * On double pick
  79764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79765. */
  79766. static readonly OnDoublePickTrigger: number;
  79767. /**
  79768. * On pick up
  79769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79770. */
  79771. static readonly OnPickUpTrigger: number;
  79772. /**
  79773. * On pick out.
  79774. * This trigger will only be raised if you also declared a OnPickDown
  79775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79776. */
  79777. static readonly OnPickOutTrigger: number;
  79778. /**
  79779. * On long press
  79780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79781. */
  79782. static readonly OnLongPressTrigger: number;
  79783. /**
  79784. * On pointer over
  79785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79786. */
  79787. static readonly OnPointerOverTrigger: number;
  79788. /**
  79789. * On pointer out
  79790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79791. */
  79792. static readonly OnPointerOutTrigger: number;
  79793. /**
  79794. * On every frame
  79795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79796. */
  79797. static readonly OnEveryFrameTrigger: number;
  79798. /**
  79799. * On intersection enter
  79800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79801. */
  79802. static readonly OnIntersectionEnterTrigger: number;
  79803. /**
  79804. * On intersection exit
  79805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79806. */
  79807. static readonly OnIntersectionExitTrigger: number;
  79808. /**
  79809. * On key down
  79810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79811. */
  79812. static readonly OnKeyDownTrigger: number;
  79813. /**
  79814. * On key up
  79815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79816. */
  79817. static readonly OnKeyUpTrigger: number;
  79818. private _scene;
  79819. /**
  79820. * Creates a new action manager
  79821. * @param scene defines the hosting scene
  79822. */
  79823. constructor(scene: Scene);
  79824. /**
  79825. * Releases all associated resources
  79826. */
  79827. dispose(): void;
  79828. /**
  79829. * Gets hosting scene
  79830. * @returns the hosting scene
  79831. */
  79832. getScene(): Scene;
  79833. /**
  79834. * Does this action manager handles actions of any of the given triggers
  79835. * @param triggers defines the triggers to be tested
  79836. * @return a boolean indicating whether one (or more) of the triggers is handled
  79837. */
  79838. hasSpecificTriggers(triggers: number[]): boolean;
  79839. /**
  79840. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79841. * speed.
  79842. * @param triggerA defines the trigger to be tested
  79843. * @param triggerB defines the trigger to be tested
  79844. * @return a boolean indicating whether one (or more) of the triggers is handled
  79845. */
  79846. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79847. /**
  79848. * Does this action manager handles actions of a given trigger
  79849. * @param trigger defines the trigger to be tested
  79850. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79851. * @return whether the trigger is handled
  79852. */
  79853. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79854. /**
  79855. * Does this action manager has pointer triggers
  79856. */
  79857. readonly hasPointerTriggers: boolean;
  79858. /**
  79859. * Does this action manager has pick triggers
  79860. */
  79861. readonly hasPickTriggers: boolean;
  79862. /**
  79863. * Registers an action to this action manager
  79864. * @param action defines the action to be registered
  79865. * @return the action amended (prepared) after registration
  79866. */
  79867. registerAction(action: IAction): Nullable<IAction>;
  79868. /**
  79869. * Unregisters an action to this action manager
  79870. * @param action defines the action to be unregistered
  79871. * @return a boolean indicating whether the action has been unregistered
  79872. */
  79873. unregisterAction(action: IAction): Boolean;
  79874. /**
  79875. * Process a specific trigger
  79876. * @param trigger defines the trigger to process
  79877. * @param evt defines the event details to be processed
  79878. */
  79879. processTrigger(trigger: number, evt?: IActionEvent): void;
  79880. /** @hidden */
  79881. _getEffectiveTarget(target: any, propertyPath: string): any;
  79882. /** @hidden */
  79883. _getProperty(propertyPath: string): string;
  79884. /**
  79885. * Serialize this manager to a JSON object
  79886. * @param name defines the property name to store this manager
  79887. * @returns a JSON representation of this manager
  79888. */
  79889. serialize(name: string): any;
  79890. /**
  79891. * Creates a new ActionManager from a JSON data
  79892. * @param parsedActions defines the JSON data to read from
  79893. * @param object defines the hosting mesh
  79894. * @param scene defines the hosting scene
  79895. */
  79896. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79897. /**
  79898. * Get a trigger name by index
  79899. * @param trigger defines the trigger index
  79900. * @returns a trigger name
  79901. */
  79902. static GetTriggerName(trigger: number): string;
  79903. }
  79904. }
  79905. declare module BABYLON {
  79906. /**
  79907. * Class representing a ray with position and direction
  79908. */
  79909. export class Ray {
  79910. /** origin point */
  79911. origin: Vector3;
  79912. /** direction */
  79913. direction: Vector3;
  79914. /** length of the ray */
  79915. length: number;
  79916. private static readonly TmpVector3;
  79917. private _tmpRay;
  79918. /**
  79919. * Creates a new ray
  79920. * @param origin origin point
  79921. * @param direction direction
  79922. * @param length length of the ray
  79923. */
  79924. constructor(
  79925. /** origin point */
  79926. origin: Vector3,
  79927. /** direction */
  79928. direction: Vector3,
  79929. /** length of the ray */
  79930. length?: number);
  79931. /**
  79932. * Checks if the ray intersects a box
  79933. * @param minimum bound of the box
  79934. * @param maximum bound of the box
  79935. * @param intersectionTreshold extra extend to be added to the box in all direction
  79936. * @returns if the box was hit
  79937. */
  79938. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79939. /**
  79940. * Checks if the ray intersects a box
  79941. * @param box the bounding box to check
  79942. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79943. * @returns if the box was hit
  79944. */
  79945. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79946. /**
  79947. * If the ray hits a sphere
  79948. * @param sphere the bounding sphere to check
  79949. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79950. * @returns true if it hits the sphere
  79951. */
  79952. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79953. /**
  79954. * If the ray hits a triange
  79955. * @param vertex0 triangle vertex
  79956. * @param vertex1 triangle vertex
  79957. * @param vertex2 triangle vertex
  79958. * @returns intersection information if hit
  79959. */
  79960. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79961. /**
  79962. * Checks if ray intersects a plane
  79963. * @param plane the plane to check
  79964. * @returns the distance away it was hit
  79965. */
  79966. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79967. /**
  79968. * Calculate the intercept of a ray on a given axis
  79969. * @param axis to check 'x' | 'y' | 'z'
  79970. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79971. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79972. */
  79973. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79974. /**
  79975. * Checks if ray intersects a mesh
  79976. * @param mesh the mesh to check
  79977. * @param fastCheck if only the bounding box should checked
  79978. * @returns picking info of the intersecton
  79979. */
  79980. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79981. /**
  79982. * Checks if ray intersects a mesh
  79983. * @param meshes the meshes to check
  79984. * @param fastCheck if only the bounding box should checked
  79985. * @param results array to store result in
  79986. * @returns Array of picking infos
  79987. */
  79988. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79989. private _comparePickingInfo;
  79990. private static smallnum;
  79991. private static rayl;
  79992. /**
  79993. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79994. * @param sega the first point of the segment to test the intersection against
  79995. * @param segb the second point of the segment to test the intersection against
  79996. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79997. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79998. */
  79999. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  80000. /**
  80001. * Update the ray from viewport position
  80002. * @param x position
  80003. * @param y y position
  80004. * @param viewportWidth viewport width
  80005. * @param viewportHeight viewport height
  80006. * @param world world matrix
  80007. * @param view view matrix
  80008. * @param projection projection matrix
  80009. * @returns this ray updated
  80010. */
  80011. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80012. /**
  80013. * Creates a ray with origin and direction of 0,0,0
  80014. * @returns the new ray
  80015. */
  80016. static Zero(): Ray;
  80017. /**
  80018. * Creates a new ray from screen space and viewport
  80019. * @param x position
  80020. * @param y y position
  80021. * @param viewportWidth viewport width
  80022. * @param viewportHeight viewport height
  80023. * @param world world matrix
  80024. * @param view view matrix
  80025. * @param projection projection matrix
  80026. * @returns new ray
  80027. */
  80028. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80029. /**
  80030. * 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
  80031. * transformed to the given world matrix.
  80032. * @param origin The origin point
  80033. * @param end The end point
  80034. * @param world a matrix to transform the ray to. Default is the identity matrix.
  80035. * @returns the new ray
  80036. */
  80037. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  80038. /**
  80039. * Transforms a ray by a matrix
  80040. * @param ray ray to transform
  80041. * @param matrix matrix to apply
  80042. * @returns the resulting new ray
  80043. */
  80044. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  80045. /**
  80046. * Transforms a ray by a matrix
  80047. * @param ray ray to transform
  80048. * @param matrix matrix to apply
  80049. * @param result ray to store result in
  80050. */
  80051. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  80052. /**
  80053. * Unproject a ray from screen space to object space
  80054. * @param sourceX defines the screen space x coordinate to use
  80055. * @param sourceY defines the screen space y coordinate to use
  80056. * @param viewportWidth defines the current width of the viewport
  80057. * @param viewportHeight defines the current height of the viewport
  80058. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80059. * @param view defines the view matrix to use
  80060. * @param projection defines the projection matrix to use
  80061. */
  80062. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  80063. }
  80064. /**
  80065. * Type used to define predicate used to select faces when a mesh intersection is detected
  80066. */
  80067. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  80068. interface Scene {
  80069. /** @hidden */
  80070. _tempPickingRay: Nullable<Ray>;
  80071. /** @hidden */
  80072. _cachedRayForTransform: Ray;
  80073. /** @hidden */
  80074. _pickWithRayInverseMatrix: Matrix;
  80075. /** @hidden */
  80076. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  80077. /** @hidden */
  80078. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  80079. }
  80080. }
  80081. declare module BABYLON {
  80082. /**
  80083. * Groups all the scene component constants in one place to ease maintenance.
  80084. * @hidden
  80085. */
  80086. export class SceneComponentConstants {
  80087. static readonly NAME_EFFECTLAYER: string;
  80088. static readonly NAME_LAYER: string;
  80089. static readonly NAME_LENSFLARESYSTEM: string;
  80090. static readonly NAME_BOUNDINGBOXRENDERER: string;
  80091. static readonly NAME_PARTICLESYSTEM: string;
  80092. static readonly NAME_GAMEPAD: string;
  80093. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  80094. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  80095. static readonly NAME_DEPTHRENDERER: string;
  80096. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  80097. static readonly NAME_SPRITE: string;
  80098. static readonly NAME_OUTLINERENDERER: string;
  80099. static readonly NAME_PROCEDURALTEXTURE: string;
  80100. static readonly NAME_SHADOWGENERATOR: string;
  80101. static readonly NAME_OCTREE: string;
  80102. static readonly NAME_PHYSICSENGINE: string;
  80103. static readonly NAME_AUDIO: string;
  80104. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  80105. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80106. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  80107. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80108. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  80109. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  80110. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  80111. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  80112. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  80113. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  80114. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  80115. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  80116. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  80117. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  80118. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  80119. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  80120. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  80121. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  80122. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  80123. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  80124. static readonly STEP_AFTERRENDER_AUDIO: number;
  80125. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  80126. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  80127. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  80128. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  80129. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  80130. static readonly STEP_POINTERMOVE_SPRITE: number;
  80131. static readonly STEP_POINTERDOWN_SPRITE: number;
  80132. static readonly STEP_POINTERUP_SPRITE: number;
  80133. }
  80134. /**
  80135. * This represents a scene component.
  80136. *
  80137. * This is used to decouple the dependency the scene is having on the different workloads like
  80138. * layers, post processes...
  80139. */
  80140. export interface ISceneComponent {
  80141. /**
  80142. * The name of the component. Each component must have a unique name.
  80143. */
  80144. name: string;
  80145. /**
  80146. * The scene the component belongs to.
  80147. */
  80148. scene: Scene;
  80149. /**
  80150. * Register the component to one instance of a scene.
  80151. */
  80152. register(): void;
  80153. /**
  80154. * Rebuilds the elements related to this component in case of
  80155. * context lost for instance.
  80156. */
  80157. rebuild(): void;
  80158. /**
  80159. * Disposes the component and the associated ressources.
  80160. */
  80161. dispose(): void;
  80162. }
  80163. /**
  80164. * This represents a SERIALIZABLE scene component.
  80165. *
  80166. * This extends Scene Component to add Serialization methods on top.
  80167. */
  80168. export interface ISceneSerializableComponent extends ISceneComponent {
  80169. /**
  80170. * Adds all the elements from the container to the scene
  80171. * @param container the container holding the elements
  80172. */
  80173. addFromContainer(container: AbstractScene): void;
  80174. /**
  80175. * Removes all the elements in the container from the scene
  80176. * @param container contains the elements to remove
  80177. * @param dispose if the removed element should be disposed (default: false)
  80178. */
  80179. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80180. /**
  80181. * Serializes the component data to the specified json object
  80182. * @param serializationObject The object to serialize to
  80183. */
  80184. serialize(serializationObject: any): void;
  80185. }
  80186. /**
  80187. * Strong typing of a Mesh related stage step action
  80188. */
  80189. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  80190. /**
  80191. * Strong typing of a Evaluate Sub Mesh related stage step action
  80192. */
  80193. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  80194. /**
  80195. * Strong typing of a Active Mesh related stage step action
  80196. */
  80197. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  80198. /**
  80199. * Strong typing of a Camera related stage step action
  80200. */
  80201. export type CameraStageAction = (camera: Camera) => void;
  80202. /**
  80203. * Strong typing of a Camera Frame buffer related stage step action
  80204. */
  80205. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  80206. /**
  80207. * Strong typing of a Render Target related stage step action
  80208. */
  80209. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  80210. /**
  80211. * Strong typing of a RenderingGroup related stage step action
  80212. */
  80213. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  80214. /**
  80215. * Strong typing of a Mesh Render related stage step action
  80216. */
  80217. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  80218. /**
  80219. * Strong typing of a simple stage step action
  80220. */
  80221. export type SimpleStageAction = () => void;
  80222. /**
  80223. * Strong typing of a render target action.
  80224. */
  80225. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  80226. /**
  80227. * Strong typing of a pointer move action.
  80228. */
  80229. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  80230. /**
  80231. * Strong typing of a pointer up/down action.
  80232. */
  80233. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  80234. /**
  80235. * Representation of a stage in the scene (Basically a list of ordered steps)
  80236. * @hidden
  80237. */
  80238. export class Stage<T extends Function> extends Array<{
  80239. index: number;
  80240. component: ISceneComponent;
  80241. action: T;
  80242. }> {
  80243. /**
  80244. * Hide ctor from the rest of the world.
  80245. * @param items The items to add.
  80246. */
  80247. private constructor();
  80248. /**
  80249. * Creates a new Stage.
  80250. * @returns A new instance of a Stage
  80251. */
  80252. static Create<T extends Function>(): Stage<T>;
  80253. /**
  80254. * Registers a step in an ordered way in the targeted stage.
  80255. * @param index Defines the position to register the step in
  80256. * @param component Defines the component attached to the step
  80257. * @param action Defines the action to launch during the step
  80258. */
  80259. registerStep(index: number, component: ISceneComponent, action: T): void;
  80260. /**
  80261. * Clears all the steps from the stage.
  80262. */
  80263. clear(): void;
  80264. }
  80265. }
  80266. declare module BABYLON {
  80267. interface Scene {
  80268. /** @hidden */
  80269. _pointerOverSprite: Nullable<Sprite>;
  80270. /** @hidden */
  80271. _pickedDownSprite: Nullable<Sprite>;
  80272. /** @hidden */
  80273. _tempSpritePickingRay: Nullable<Ray>;
  80274. /**
  80275. * All of the sprite managers added to this scene
  80276. * @see http://doc.babylonjs.com/babylon101/sprites
  80277. */
  80278. spriteManagers: Array<ISpriteManager>;
  80279. /**
  80280. * An event triggered when sprites rendering is about to start
  80281. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80282. */
  80283. onBeforeSpritesRenderingObservable: Observable<Scene>;
  80284. /**
  80285. * An event triggered when sprites rendering is done
  80286. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80287. */
  80288. onAfterSpritesRenderingObservable: Observable<Scene>;
  80289. /** @hidden */
  80290. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80291. /** Launch a ray to try to pick a sprite in the scene
  80292. * @param x position on screen
  80293. * @param y position on screen
  80294. * @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
  80295. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80296. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80297. * @returns a PickingInfo
  80298. */
  80299. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80300. /** Use the given ray to pick a sprite in the scene
  80301. * @param ray The ray (in world space) to use to pick meshes
  80302. * @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
  80303. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80304. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80305. * @returns a PickingInfo
  80306. */
  80307. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80308. /** @hidden */
  80309. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80310. /** Launch a ray to try to pick sprites in the scene
  80311. * @param x position on screen
  80312. * @param y position on screen
  80313. * @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
  80314. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80315. * @returns a PickingInfo array
  80316. */
  80317. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80318. /** Use the given ray to pick sprites in the scene
  80319. * @param ray The ray (in world space) to use to pick meshes
  80320. * @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
  80321. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80322. * @returns a PickingInfo array
  80323. */
  80324. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80325. /**
  80326. * Force the sprite under the pointer
  80327. * @param sprite defines the sprite to use
  80328. */
  80329. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  80330. /**
  80331. * Gets the sprite under the pointer
  80332. * @returns a Sprite or null if no sprite is under the pointer
  80333. */
  80334. getPointerOverSprite(): Nullable<Sprite>;
  80335. }
  80336. /**
  80337. * Defines the sprite scene component responsible to manage sprites
  80338. * in a given scene.
  80339. */
  80340. export class SpriteSceneComponent implements ISceneComponent {
  80341. /**
  80342. * The component name helpfull to identify the component in the list of scene components.
  80343. */
  80344. readonly name: string;
  80345. /**
  80346. * The scene the component belongs to.
  80347. */
  80348. scene: Scene;
  80349. /** @hidden */
  80350. private _spritePredicate;
  80351. /**
  80352. * Creates a new instance of the component for the given scene
  80353. * @param scene Defines the scene to register the component in
  80354. */
  80355. constructor(scene: Scene);
  80356. /**
  80357. * Registers the component in a given scene
  80358. */
  80359. register(): void;
  80360. /**
  80361. * Rebuilds the elements related to this component in case of
  80362. * context lost for instance.
  80363. */
  80364. rebuild(): void;
  80365. /**
  80366. * Disposes the component and the associated ressources.
  80367. */
  80368. dispose(): void;
  80369. private _pickSpriteButKeepRay;
  80370. private _pointerMove;
  80371. private _pointerDown;
  80372. private _pointerUp;
  80373. }
  80374. }
  80375. declare module BABYLON {
  80376. /** @hidden */
  80377. export var fogFragmentDeclaration: {
  80378. name: string;
  80379. shader: string;
  80380. };
  80381. }
  80382. declare module BABYLON {
  80383. /** @hidden */
  80384. export var fogFragment: {
  80385. name: string;
  80386. shader: string;
  80387. };
  80388. }
  80389. declare module BABYLON {
  80390. /** @hidden */
  80391. export var spritesPixelShader: {
  80392. name: string;
  80393. shader: string;
  80394. };
  80395. }
  80396. declare module BABYLON {
  80397. /** @hidden */
  80398. export var fogVertexDeclaration: {
  80399. name: string;
  80400. shader: string;
  80401. };
  80402. }
  80403. declare module BABYLON {
  80404. /** @hidden */
  80405. export var spritesVertexShader: {
  80406. name: string;
  80407. shader: string;
  80408. };
  80409. }
  80410. declare module BABYLON {
  80411. /**
  80412. * Defines the minimum interface to fullfil in order to be a sprite manager.
  80413. */
  80414. export interface ISpriteManager extends IDisposable {
  80415. /**
  80416. * Restricts the camera to viewing objects with the same layerMask.
  80417. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  80418. */
  80419. layerMask: number;
  80420. /**
  80421. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80422. */
  80423. isPickable: boolean;
  80424. /**
  80425. * Specifies the rendering group id for this mesh (0 by default)
  80426. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80427. */
  80428. renderingGroupId: number;
  80429. /**
  80430. * Defines the list of sprites managed by the manager.
  80431. */
  80432. sprites: Array<Sprite>;
  80433. /**
  80434. * Tests the intersection of a sprite with a specific ray.
  80435. * @param ray The ray we are sending to test the collision
  80436. * @param camera The camera space we are sending rays in
  80437. * @param predicate A predicate allowing excluding sprites from the list of object to test
  80438. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  80439. * @returns picking info or null.
  80440. */
  80441. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80442. /**
  80443. * Intersects the sprites with a ray
  80444. * @param ray defines the ray to intersect with
  80445. * @param camera defines the current active camera
  80446. * @param predicate defines a predicate used to select candidate sprites
  80447. * @returns null if no hit or a PickingInfo array
  80448. */
  80449. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80450. /**
  80451. * Renders the list of sprites on screen.
  80452. */
  80453. render(): void;
  80454. }
  80455. /**
  80456. * Class used to manage multiple sprites on the same spritesheet
  80457. * @see http://doc.babylonjs.com/babylon101/sprites
  80458. */
  80459. export class SpriteManager implements ISpriteManager {
  80460. /** defines the manager's name */
  80461. name: string;
  80462. /** Gets the list of sprites */
  80463. sprites: Sprite[];
  80464. /** Gets or sets the rendering group id (0 by default) */
  80465. renderingGroupId: number;
  80466. /** Gets or sets camera layer mask */
  80467. layerMask: number;
  80468. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  80469. fogEnabled: boolean;
  80470. /** Gets or sets a boolean indicating if the sprites are pickable */
  80471. isPickable: boolean;
  80472. /** Defines the default width of a cell in the spritesheet */
  80473. cellWidth: number;
  80474. /** Defines the default height of a cell in the spritesheet */
  80475. cellHeight: number;
  80476. /** Associative array from JSON sprite data file */
  80477. private _cellData;
  80478. /** Array of sprite names from JSON sprite data file */
  80479. private _spriteMap;
  80480. /** True when packed cell data from JSON file is ready*/
  80481. private _packedAndReady;
  80482. /**
  80483. * An event triggered when the manager is disposed.
  80484. */
  80485. onDisposeObservable: Observable<SpriteManager>;
  80486. private _onDisposeObserver;
  80487. /**
  80488. * Callback called when the manager is disposed
  80489. */
  80490. onDispose: () => void;
  80491. private _capacity;
  80492. private _fromPacked;
  80493. private _spriteTexture;
  80494. private _epsilon;
  80495. private _scene;
  80496. private _vertexData;
  80497. private _buffer;
  80498. private _vertexBuffers;
  80499. private _indexBuffer;
  80500. private _effectBase;
  80501. private _effectFog;
  80502. /**
  80503. * Gets or sets the spritesheet texture
  80504. */
  80505. texture: Texture;
  80506. /**
  80507. * Creates a new sprite manager
  80508. * @param name defines the manager's name
  80509. * @param imgUrl defines the sprite sheet url
  80510. * @param capacity defines the maximum allowed number of sprites
  80511. * @param cellSize defines the size of a sprite cell
  80512. * @param scene defines the hosting scene
  80513. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80514. * @param samplingMode defines the smapling mode to use with spritesheet
  80515. * @param fromPacked set to false; do not alter
  80516. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  80517. */
  80518. constructor(
  80519. /** defines the manager's name */
  80520. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  80521. private _makePacked;
  80522. private _appendSpriteVertex;
  80523. /**
  80524. * Intersects the sprites with a ray
  80525. * @param ray defines the ray to intersect with
  80526. * @param camera defines the current active camera
  80527. * @param predicate defines a predicate used to select candidate sprites
  80528. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  80529. * @returns null if no hit or a PickingInfo
  80530. */
  80531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80532. /**
  80533. * Intersects the sprites with a ray
  80534. * @param ray defines the ray to intersect with
  80535. * @param camera defines the current active camera
  80536. * @param predicate defines a predicate used to select candidate sprites
  80537. * @returns null if no hit or a PickingInfo array
  80538. */
  80539. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80540. /**
  80541. * Render all child sprites
  80542. */
  80543. render(): void;
  80544. /**
  80545. * Release associated resources
  80546. */
  80547. dispose(): void;
  80548. }
  80549. }
  80550. declare module BABYLON {
  80551. /**
  80552. * Class used to represent a sprite
  80553. * @see http://doc.babylonjs.com/babylon101/sprites
  80554. */
  80555. export class Sprite {
  80556. /** defines the name */
  80557. name: string;
  80558. /** Gets or sets the current world position */
  80559. position: Vector3;
  80560. /** Gets or sets the main color */
  80561. color: Color4;
  80562. /** Gets or sets the width */
  80563. width: number;
  80564. /** Gets or sets the height */
  80565. height: number;
  80566. /** Gets or sets rotation angle */
  80567. angle: number;
  80568. /** Gets or sets the cell index in the sprite sheet */
  80569. cellIndex: number;
  80570. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  80571. cellRef: string;
  80572. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  80573. invertU: number;
  80574. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  80575. invertV: number;
  80576. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  80577. disposeWhenFinishedAnimating: boolean;
  80578. /** Gets the list of attached animations */
  80579. animations: Animation[];
  80580. /** Gets or sets a boolean indicating if the sprite can be picked */
  80581. isPickable: boolean;
  80582. /**
  80583. * Gets or sets the associated action manager
  80584. */
  80585. actionManager: Nullable<ActionManager>;
  80586. private _animationStarted;
  80587. private _loopAnimation;
  80588. private _fromIndex;
  80589. private _toIndex;
  80590. private _delay;
  80591. private _direction;
  80592. private _manager;
  80593. private _time;
  80594. private _onAnimationEnd;
  80595. /**
  80596. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  80597. */
  80598. isVisible: boolean;
  80599. /**
  80600. * Gets or sets the sprite size
  80601. */
  80602. size: number;
  80603. /**
  80604. * Creates a new Sprite
  80605. * @param name defines the name
  80606. * @param manager defines the manager
  80607. */
  80608. constructor(
  80609. /** defines the name */
  80610. name: string, manager: ISpriteManager);
  80611. /**
  80612. * Starts an animation
  80613. * @param from defines the initial key
  80614. * @param to defines the end key
  80615. * @param loop defines if the animation must loop
  80616. * @param delay defines the start delay (in ms)
  80617. * @param onAnimationEnd defines a callback to call when animation ends
  80618. */
  80619. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  80620. /** Stops current animation (if any) */
  80621. stopAnimation(): void;
  80622. /** @hidden */
  80623. _animate(deltaTime: number): void;
  80624. /** Release associated resources */
  80625. dispose(): void;
  80626. }
  80627. }
  80628. declare module BABYLON {
  80629. /**
  80630. * Information about the result of picking within a scene
  80631. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  80632. */
  80633. export class PickingInfo {
  80634. /** @hidden */
  80635. _pickingUnavailable: boolean;
  80636. /**
  80637. * If the pick collided with an object
  80638. */
  80639. hit: boolean;
  80640. /**
  80641. * Distance away where the pick collided
  80642. */
  80643. distance: number;
  80644. /**
  80645. * The location of pick collision
  80646. */
  80647. pickedPoint: Nullable<Vector3>;
  80648. /**
  80649. * The mesh corresponding the the pick collision
  80650. */
  80651. pickedMesh: Nullable<AbstractMesh>;
  80652. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  80653. bu: number;
  80654. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  80655. bv: number;
  80656. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  80657. faceId: number;
  80658. /** Id of the the submesh that was picked */
  80659. subMeshId: number;
  80660. /** If a sprite was picked, this will be the sprite the pick collided with */
  80661. pickedSprite: Nullable<Sprite>;
  80662. /**
  80663. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  80664. */
  80665. originMesh: Nullable<AbstractMesh>;
  80666. /**
  80667. * The ray that was used to perform the picking.
  80668. */
  80669. ray: Nullable<Ray>;
  80670. /**
  80671. * Gets the normal correspodning to the face the pick collided with
  80672. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  80673. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  80674. * @returns The normal correspodning to the face the pick collided with
  80675. */
  80676. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  80677. /**
  80678. * Gets the texture coordinates of where the pick occured
  80679. * @returns the vector containing the coordnates of the texture
  80680. */
  80681. getTextureCoordinates(): Nullable<Vector2>;
  80682. }
  80683. }
  80684. declare module BABYLON {
  80685. /**
  80686. * Gather the list of pointer event types as constants.
  80687. */
  80688. export class PointerEventTypes {
  80689. /**
  80690. * 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.
  80691. */
  80692. static readonly POINTERDOWN: number;
  80693. /**
  80694. * The pointerup event is fired when a pointer is no longer active.
  80695. */
  80696. static readonly POINTERUP: number;
  80697. /**
  80698. * The pointermove event is fired when a pointer changes coordinates.
  80699. */
  80700. static readonly POINTERMOVE: number;
  80701. /**
  80702. * The pointerwheel event is fired when a mouse wheel has been rotated.
  80703. */
  80704. static readonly POINTERWHEEL: number;
  80705. /**
  80706. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  80707. */
  80708. static readonly POINTERPICK: number;
  80709. /**
  80710. * The pointertap event is fired when a the object has been touched and released without drag.
  80711. */
  80712. static readonly POINTERTAP: number;
  80713. /**
  80714. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  80715. */
  80716. static readonly POINTERDOUBLETAP: number;
  80717. }
  80718. /**
  80719. * Base class of pointer info types.
  80720. */
  80721. export class PointerInfoBase {
  80722. /**
  80723. * Defines the type of event (PointerEventTypes)
  80724. */
  80725. type: number;
  80726. /**
  80727. * Defines the related dom event
  80728. */
  80729. event: PointerEvent | MouseWheelEvent;
  80730. /**
  80731. * Instantiates the base class of pointers info.
  80732. * @param type Defines the type of event (PointerEventTypes)
  80733. * @param event Defines the related dom event
  80734. */
  80735. constructor(
  80736. /**
  80737. * Defines the type of event (PointerEventTypes)
  80738. */
  80739. type: number,
  80740. /**
  80741. * Defines the related dom event
  80742. */
  80743. event: PointerEvent | MouseWheelEvent);
  80744. }
  80745. /**
  80746. * This class is used to store pointer related info for the onPrePointerObservable event.
  80747. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80748. */
  80749. export class PointerInfoPre extends PointerInfoBase {
  80750. /**
  80751. * Ray from a pointer if availible (eg. 6dof controller)
  80752. */
  80753. ray: Nullable<Ray>;
  80754. /**
  80755. * Defines the local position of the pointer on the canvas.
  80756. */
  80757. localPosition: Vector2;
  80758. /**
  80759. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80760. */
  80761. skipOnPointerObservable: boolean;
  80762. /**
  80763. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80764. * @param type Defines the type of event (PointerEventTypes)
  80765. * @param event Defines the related dom event
  80766. * @param localX Defines the local x coordinates of the pointer when the event occured
  80767. * @param localY Defines the local y coordinates of the pointer when the event occured
  80768. */
  80769. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80770. }
  80771. /**
  80772. * This type contains all the data related to a pointer event in Babylon.js.
  80773. * 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.
  80774. */
  80775. export class PointerInfo extends PointerInfoBase {
  80776. /**
  80777. * Defines the picking info associated to the info (if any)\
  80778. */
  80779. pickInfo: Nullable<PickingInfo>;
  80780. /**
  80781. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80782. * @param type Defines the type of event (PointerEventTypes)
  80783. * @param event Defines the related dom event
  80784. * @param pickInfo Defines the picking info associated to the info (if any)\
  80785. */
  80786. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80787. /**
  80788. * Defines the picking info associated to the info (if any)\
  80789. */
  80790. pickInfo: Nullable<PickingInfo>);
  80791. }
  80792. /**
  80793. * Data relating to a touch event on the screen.
  80794. */
  80795. export interface PointerTouch {
  80796. /**
  80797. * X coordinate of touch.
  80798. */
  80799. x: number;
  80800. /**
  80801. * Y coordinate of touch.
  80802. */
  80803. y: number;
  80804. /**
  80805. * Id of touch. Unique for each finger.
  80806. */
  80807. pointerId: number;
  80808. /**
  80809. * Event type passed from DOM.
  80810. */
  80811. type: any;
  80812. }
  80813. }
  80814. declare module BABYLON {
  80815. /**
  80816. * Manage the mouse inputs to control the movement of a free camera.
  80817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80818. */
  80819. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80820. /**
  80821. * Define if touch is enabled in the mouse input
  80822. */
  80823. touchEnabled: boolean;
  80824. /**
  80825. * Defines the camera the input is attached to.
  80826. */
  80827. camera: FreeCamera;
  80828. /**
  80829. * Defines the buttons associated with the input to handle camera move.
  80830. */
  80831. buttons: number[];
  80832. /**
  80833. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80834. */
  80835. angularSensibility: number;
  80836. private _pointerInput;
  80837. private _onMouseMove;
  80838. private _observer;
  80839. private previousPosition;
  80840. /**
  80841. * Observable for when a pointer move event occurs containing the move offset
  80842. */
  80843. onPointerMovedObservable: Observable<{
  80844. offsetX: number;
  80845. offsetY: number;
  80846. }>;
  80847. /**
  80848. * @hidden
  80849. * If the camera should be rotated automatically based on pointer movement
  80850. */
  80851. _allowCameraRotation: boolean;
  80852. /**
  80853. * Manage the mouse inputs to control the movement of a free camera.
  80854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80855. * @param touchEnabled Defines if touch is enabled or not
  80856. */
  80857. constructor(
  80858. /**
  80859. * Define if touch is enabled in the mouse input
  80860. */
  80861. touchEnabled?: boolean);
  80862. /**
  80863. * Attach the input controls to a specific dom element to get the input from.
  80864. * @param element Defines the element the controls should be listened from
  80865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80866. */
  80867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80868. /**
  80869. * Called on JS contextmenu event.
  80870. * Override this method to provide functionality.
  80871. */
  80872. protected onContextMenu(evt: PointerEvent): void;
  80873. /**
  80874. * Detach the current controls from the specified dom element.
  80875. * @param element Defines the element to stop listening the inputs from
  80876. */
  80877. detachControl(element: Nullable<HTMLElement>): void;
  80878. /**
  80879. * Gets the class name of the current intput.
  80880. * @returns the class name
  80881. */
  80882. getClassName(): string;
  80883. /**
  80884. * Get the friendly name associated with the input class.
  80885. * @returns the input friendly name
  80886. */
  80887. getSimpleName(): string;
  80888. }
  80889. }
  80890. declare module BABYLON {
  80891. /**
  80892. * Manage the touch inputs to control the movement of a free camera.
  80893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80894. */
  80895. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80896. /**
  80897. * Defines the camera the input is attached to.
  80898. */
  80899. camera: FreeCamera;
  80900. /**
  80901. * Defines the touch sensibility for rotation.
  80902. * The higher the faster.
  80903. */
  80904. touchAngularSensibility: number;
  80905. /**
  80906. * Defines the touch sensibility for move.
  80907. * The higher the faster.
  80908. */
  80909. touchMoveSensibility: number;
  80910. private _offsetX;
  80911. private _offsetY;
  80912. private _pointerPressed;
  80913. private _pointerInput;
  80914. private _observer;
  80915. private _onLostFocus;
  80916. /**
  80917. * Attach the input controls to a specific dom element to get the input from.
  80918. * @param element Defines the element the controls should be listened from
  80919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80920. */
  80921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80922. /**
  80923. * Detach the current controls from the specified dom element.
  80924. * @param element Defines the element to stop listening the inputs from
  80925. */
  80926. detachControl(element: Nullable<HTMLElement>): void;
  80927. /**
  80928. * Update the current camera state depending on the inputs that have been used this frame.
  80929. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80930. */
  80931. checkInputs(): void;
  80932. /**
  80933. * Gets the class name of the current intput.
  80934. * @returns the class name
  80935. */
  80936. getClassName(): string;
  80937. /**
  80938. * Get the friendly name associated with the input class.
  80939. * @returns the input friendly name
  80940. */
  80941. getSimpleName(): string;
  80942. }
  80943. }
  80944. declare module BABYLON {
  80945. /**
  80946. * Default Inputs manager for the FreeCamera.
  80947. * It groups all the default supported inputs for ease of use.
  80948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80949. */
  80950. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80951. /**
  80952. * @hidden
  80953. */
  80954. _mouseInput: Nullable<FreeCameraMouseInput>;
  80955. /**
  80956. * Instantiates a new FreeCameraInputsManager.
  80957. * @param camera Defines the camera the inputs belong to
  80958. */
  80959. constructor(camera: FreeCamera);
  80960. /**
  80961. * Add keyboard input support to the input manager.
  80962. * @returns the current input manager
  80963. */
  80964. addKeyboard(): FreeCameraInputsManager;
  80965. /**
  80966. * Add mouse input support to the input manager.
  80967. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80968. * @returns the current input manager
  80969. */
  80970. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80971. /**
  80972. * Removes the mouse input support from the manager
  80973. * @returns the current input manager
  80974. */
  80975. removeMouse(): FreeCameraInputsManager;
  80976. /**
  80977. * Add touch input support to the input manager.
  80978. * @returns the current input manager
  80979. */
  80980. addTouch(): FreeCameraInputsManager;
  80981. /**
  80982. * Remove all attached input methods from a camera
  80983. */
  80984. clear(): void;
  80985. }
  80986. }
  80987. declare module BABYLON {
  80988. /**
  80989. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80990. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80991. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80992. */
  80993. export class FreeCamera extends TargetCamera {
  80994. /**
  80995. * Define the collision ellipsoid of the camera.
  80996. * This is helpful to simulate a camera body like the player body around the camera
  80997. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80998. */
  80999. ellipsoid: Vector3;
  81000. /**
  81001. * Define an offset for the position of the ellipsoid around the camera.
  81002. * This can be helpful to determine the center of the body near the gravity center of the body
  81003. * instead of its head.
  81004. */
  81005. ellipsoidOffset: Vector3;
  81006. /**
  81007. * Enable or disable collisions of the camera with the rest of the scene objects.
  81008. */
  81009. checkCollisions: boolean;
  81010. /**
  81011. * Enable or disable gravity on the camera.
  81012. */
  81013. applyGravity: boolean;
  81014. /**
  81015. * Define the input manager associated to the camera.
  81016. */
  81017. inputs: FreeCameraInputsManager;
  81018. /**
  81019. * Gets the input sensibility for a mouse input. (default is 2000.0)
  81020. * Higher values reduce sensitivity.
  81021. */
  81022. /**
  81023. * Sets the input sensibility for a mouse input. (default is 2000.0)
  81024. * Higher values reduce sensitivity.
  81025. */
  81026. angularSensibility: number;
  81027. /**
  81028. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81029. */
  81030. keysUp: number[];
  81031. /**
  81032. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81033. */
  81034. keysDown: number[];
  81035. /**
  81036. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81037. */
  81038. keysLeft: number[];
  81039. /**
  81040. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81041. */
  81042. keysRight: number[];
  81043. /**
  81044. * Event raised when the camera collide with a mesh in the scene.
  81045. */
  81046. onCollide: (collidedMesh: AbstractMesh) => void;
  81047. private _collider;
  81048. private _needMoveForGravity;
  81049. private _oldPosition;
  81050. private _diffPosition;
  81051. private _newPosition;
  81052. /** @hidden */
  81053. _localDirection: Vector3;
  81054. /** @hidden */
  81055. _transformedDirection: Vector3;
  81056. /**
  81057. * Instantiates a Free Camera.
  81058. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81059. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  81060. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81061. * @param name Define the name of the camera in the scene
  81062. * @param position Define the start position of the camera in the scene
  81063. * @param scene Define the scene the camera belongs to
  81064. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81065. */
  81066. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81067. /**
  81068. * Attached controls to the current camera.
  81069. * @param element Defines the element the controls should be listened from
  81070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81071. */
  81072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81073. /**
  81074. * Detach the current controls from the camera.
  81075. * The camera will stop reacting to inputs.
  81076. * @param element Defines the element to stop listening the inputs from
  81077. */
  81078. detachControl(element: HTMLElement): void;
  81079. private _collisionMask;
  81080. /**
  81081. * Define a collision mask to limit the list of object the camera can collide with
  81082. */
  81083. collisionMask: number;
  81084. /** @hidden */
  81085. _collideWithWorld(displacement: Vector3): void;
  81086. private _onCollisionPositionChange;
  81087. /** @hidden */
  81088. _checkInputs(): void;
  81089. /** @hidden */
  81090. _decideIfNeedsToMove(): boolean;
  81091. /** @hidden */
  81092. _updatePosition(): void;
  81093. /**
  81094. * Destroy the camera and release the current resources hold by it.
  81095. */
  81096. dispose(): void;
  81097. /**
  81098. * Gets the current object class name.
  81099. * @return the class name
  81100. */
  81101. getClassName(): string;
  81102. }
  81103. }
  81104. declare module BABYLON {
  81105. /**
  81106. * Represents a gamepad control stick position
  81107. */
  81108. export class StickValues {
  81109. /**
  81110. * The x component of the control stick
  81111. */
  81112. x: number;
  81113. /**
  81114. * The y component of the control stick
  81115. */
  81116. y: number;
  81117. /**
  81118. * Initializes the gamepad x and y control stick values
  81119. * @param x The x component of the gamepad control stick value
  81120. * @param y The y component of the gamepad control stick value
  81121. */
  81122. constructor(
  81123. /**
  81124. * The x component of the control stick
  81125. */
  81126. x: number,
  81127. /**
  81128. * The y component of the control stick
  81129. */
  81130. y: number);
  81131. }
  81132. /**
  81133. * An interface which manages callbacks for gamepad button changes
  81134. */
  81135. export interface GamepadButtonChanges {
  81136. /**
  81137. * Called when a gamepad has been changed
  81138. */
  81139. changed: boolean;
  81140. /**
  81141. * Called when a gamepad press event has been triggered
  81142. */
  81143. pressChanged: boolean;
  81144. /**
  81145. * Called when a touch event has been triggered
  81146. */
  81147. touchChanged: boolean;
  81148. /**
  81149. * Called when a value has changed
  81150. */
  81151. valueChanged: boolean;
  81152. }
  81153. /**
  81154. * Represents a gamepad
  81155. */
  81156. export class Gamepad {
  81157. /**
  81158. * The id of the gamepad
  81159. */
  81160. id: string;
  81161. /**
  81162. * The index of the gamepad
  81163. */
  81164. index: number;
  81165. /**
  81166. * The browser gamepad
  81167. */
  81168. browserGamepad: any;
  81169. /**
  81170. * Specifies what type of gamepad this represents
  81171. */
  81172. type: number;
  81173. private _leftStick;
  81174. private _rightStick;
  81175. /** @hidden */
  81176. _isConnected: boolean;
  81177. private _leftStickAxisX;
  81178. private _leftStickAxisY;
  81179. private _rightStickAxisX;
  81180. private _rightStickAxisY;
  81181. /**
  81182. * Triggered when the left control stick has been changed
  81183. */
  81184. private _onleftstickchanged;
  81185. /**
  81186. * Triggered when the right control stick has been changed
  81187. */
  81188. private _onrightstickchanged;
  81189. /**
  81190. * Represents a gamepad controller
  81191. */
  81192. static GAMEPAD: number;
  81193. /**
  81194. * Represents a generic controller
  81195. */
  81196. static GENERIC: number;
  81197. /**
  81198. * Represents an XBox controller
  81199. */
  81200. static XBOX: number;
  81201. /**
  81202. * Represents a pose-enabled controller
  81203. */
  81204. static POSE_ENABLED: number;
  81205. /**
  81206. * Represents an Dual Shock controller
  81207. */
  81208. static DUALSHOCK: number;
  81209. /**
  81210. * Specifies whether the left control stick should be Y-inverted
  81211. */
  81212. protected _invertLeftStickY: boolean;
  81213. /**
  81214. * Specifies if the gamepad has been connected
  81215. */
  81216. readonly isConnected: boolean;
  81217. /**
  81218. * Initializes the gamepad
  81219. * @param id The id of the gamepad
  81220. * @param index The index of the gamepad
  81221. * @param browserGamepad The browser gamepad
  81222. * @param leftStickX The x component of the left joystick
  81223. * @param leftStickY The y component of the left joystick
  81224. * @param rightStickX The x component of the right joystick
  81225. * @param rightStickY The y component of the right joystick
  81226. */
  81227. constructor(
  81228. /**
  81229. * The id of the gamepad
  81230. */
  81231. id: string,
  81232. /**
  81233. * The index of the gamepad
  81234. */
  81235. index: number,
  81236. /**
  81237. * The browser gamepad
  81238. */
  81239. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  81240. /**
  81241. * Callback triggered when the left joystick has changed
  81242. * @param callback
  81243. */
  81244. onleftstickchanged(callback: (values: StickValues) => void): void;
  81245. /**
  81246. * Callback triggered when the right joystick has changed
  81247. * @param callback
  81248. */
  81249. onrightstickchanged(callback: (values: StickValues) => void): void;
  81250. /**
  81251. * Gets the left joystick
  81252. */
  81253. /**
  81254. * Sets the left joystick values
  81255. */
  81256. leftStick: StickValues;
  81257. /**
  81258. * Gets the right joystick
  81259. */
  81260. /**
  81261. * Sets the right joystick value
  81262. */
  81263. rightStick: StickValues;
  81264. /**
  81265. * Updates the gamepad joystick positions
  81266. */
  81267. update(): void;
  81268. /**
  81269. * Disposes the gamepad
  81270. */
  81271. dispose(): void;
  81272. }
  81273. /**
  81274. * Represents a generic gamepad
  81275. */
  81276. export class GenericPad extends Gamepad {
  81277. private _buttons;
  81278. private _onbuttondown;
  81279. private _onbuttonup;
  81280. /**
  81281. * Observable triggered when a button has been pressed
  81282. */
  81283. onButtonDownObservable: Observable<number>;
  81284. /**
  81285. * Observable triggered when a button has been released
  81286. */
  81287. onButtonUpObservable: Observable<number>;
  81288. /**
  81289. * Callback triggered when a button has been pressed
  81290. * @param callback Called when a button has been pressed
  81291. */
  81292. onbuttondown(callback: (buttonPressed: number) => void): void;
  81293. /**
  81294. * Callback triggered when a button has been released
  81295. * @param callback Called when a button has been released
  81296. */
  81297. onbuttonup(callback: (buttonReleased: number) => void): void;
  81298. /**
  81299. * Initializes the generic gamepad
  81300. * @param id The id of the generic gamepad
  81301. * @param index The index of the generic gamepad
  81302. * @param browserGamepad The browser gamepad
  81303. */
  81304. constructor(id: string, index: number, browserGamepad: any);
  81305. private _setButtonValue;
  81306. /**
  81307. * Updates the generic gamepad
  81308. */
  81309. update(): void;
  81310. /**
  81311. * Disposes the generic gamepad
  81312. */
  81313. dispose(): void;
  81314. }
  81315. }
  81316. declare module BABYLON {
  81317. interface Engine {
  81318. /**
  81319. * Creates a raw texture
  81320. * @param data defines the data to store in the texture
  81321. * @param width defines the width of the texture
  81322. * @param height defines the height of the texture
  81323. * @param format defines the format of the data
  81324. * @param generateMipMaps defines if the engine should generate the mip levels
  81325. * @param invertY defines if data must be stored with Y axis inverted
  81326. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  81327. * @param compression defines the compression used (null by default)
  81328. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81329. * @returns the raw texture inside an InternalTexture
  81330. */
  81331. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  81332. /**
  81333. * Update a raw texture
  81334. * @param texture defines the texture to update
  81335. * @param data defines the data to store in the texture
  81336. * @param format defines the format of the data
  81337. * @param invertY defines if data must be stored with Y axis inverted
  81338. */
  81339. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81340. /**
  81341. * Update a raw texture
  81342. * @param texture defines the texture to update
  81343. * @param data defines the data to store in the texture
  81344. * @param format defines the format of the data
  81345. * @param invertY defines if data must be stored with Y axis inverted
  81346. * @param compression defines the compression used (null by default)
  81347. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81348. */
  81349. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  81350. /**
  81351. * Creates a new raw cube texture
  81352. * @param data defines the array of data to use to create each face
  81353. * @param size defines the size of the textures
  81354. * @param format defines the format of the data
  81355. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81356. * @param generateMipMaps defines if the engine should generate the mip levels
  81357. * @param invertY defines if data must be stored with Y axis inverted
  81358. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81359. * @param compression defines the compression used (null by default)
  81360. * @returns the cube texture as an InternalTexture
  81361. */
  81362. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  81363. /**
  81364. * Update a raw cube texture
  81365. * @param texture defines the texture to udpdate
  81366. * @param data defines the data to store
  81367. * @param format defines the data format
  81368. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81369. * @param invertY defines if data must be stored with Y axis inverted
  81370. */
  81371. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  81372. /**
  81373. * Update a raw cube texture
  81374. * @param texture defines the texture to udpdate
  81375. * @param data defines the data to store
  81376. * @param format defines the data format
  81377. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81378. * @param invertY defines if data must be stored with Y axis inverted
  81379. * @param compression defines the compression used (null by default)
  81380. */
  81381. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  81382. /**
  81383. * Update a raw cube texture
  81384. * @param texture defines the texture to udpdate
  81385. * @param data defines the data to store
  81386. * @param format defines the data format
  81387. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81388. * @param invertY defines if data must be stored with Y axis inverted
  81389. * @param compression defines the compression used (null by default)
  81390. * @param level defines which level of the texture to update
  81391. */
  81392. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  81393. /**
  81394. * Creates a new raw cube texture from a specified url
  81395. * @param url defines the url where the data is located
  81396. * @param scene defines the current scene
  81397. * @param size defines the size of the textures
  81398. * @param format defines the format of the data
  81399. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81400. * @param noMipmap defines if the engine should avoid generating the mip levels
  81401. * @param callback defines a callback used to extract texture data from loaded data
  81402. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81403. * @param onLoad defines a callback called when texture is loaded
  81404. * @param onError defines a callback called if there is an error
  81405. * @returns the cube texture as an InternalTexture
  81406. */
  81407. 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;
  81408. /**
  81409. * Creates a new raw cube texture from a specified url
  81410. * @param url defines the url where the data is located
  81411. * @param scene defines the current scene
  81412. * @param size defines the size of the textures
  81413. * @param format defines the format of the data
  81414. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81415. * @param noMipmap defines if the engine should avoid generating the mip levels
  81416. * @param callback defines a callback used to extract texture data from loaded data
  81417. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81418. * @param onLoad defines a callback called when texture is loaded
  81419. * @param onError defines a callback called if there is an error
  81420. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81421. * @param invertY defines if data must be stored with Y axis inverted
  81422. * @returns the cube texture as an InternalTexture
  81423. */
  81424. 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;
  81425. /**
  81426. * Creates a new raw 3D texture
  81427. * @param data defines the data used to create the texture
  81428. * @param width defines the width of the texture
  81429. * @param height defines the height of the texture
  81430. * @param depth defines the depth of the texture
  81431. * @param format defines the format of the texture
  81432. * @param generateMipMaps defines if the engine must generate mip levels
  81433. * @param invertY defines if data must be stored with Y axis inverted
  81434. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81435. * @param compression defines the compressed used (can be null)
  81436. * @param textureType defines the compressed used (can be null)
  81437. * @returns a new raw 3D texture (stored in an InternalTexture)
  81438. */
  81439. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81440. /**
  81441. * Update a raw 3D texture
  81442. * @param texture defines the texture to update
  81443. * @param data defines the data to store
  81444. * @param format defines the data format
  81445. * @param invertY defines if data must be stored with Y axis inverted
  81446. */
  81447. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81448. /**
  81449. * Update a raw 3D texture
  81450. * @param texture defines the texture to update
  81451. * @param data defines the data to store
  81452. * @param format defines the data format
  81453. * @param invertY defines if data must be stored with Y axis inverted
  81454. * @param compression defines the used compression (can be null)
  81455. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81456. */
  81457. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81458. /**
  81459. * Creates a new raw 2D array texture
  81460. * @param data defines the data used to create the texture
  81461. * @param width defines the width of the texture
  81462. * @param height defines the height of the texture
  81463. * @param depth defines the number of layers of the texture
  81464. * @param format defines the format of the texture
  81465. * @param generateMipMaps defines if the engine must generate mip levels
  81466. * @param invertY defines if data must be stored with Y axis inverted
  81467. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81468. * @param compression defines the compressed used (can be null)
  81469. * @param textureType defines the compressed used (can be null)
  81470. * @returns a new raw 2D array texture (stored in an InternalTexture)
  81471. */
  81472. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81473. /**
  81474. * Update a raw 2D array texture
  81475. * @param texture defines the texture to update
  81476. * @param data defines the data to store
  81477. * @param format defines the data format
  81478. * @param invertY defines if data must be stored with Y axis inverted
  81479. */
  81480. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81481. /**
  81482. * Update a raw 2D array texture
  81483. * @param texture defines the texture to update
  81484. * @param data defines the data to store
  81485. * @param format defines the data format
  81486. * @param invertY defines if data must be stored with Y axis inverted
  81487. * @param compression defines the used compression (can be null)
  81488. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81489. */
  81490. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81491. }
  81492. }
  81493. declare module BABYLON {
  81494. /**
  81495. * Raw texture can help creating a texture directly from an array of data.
  81496. * This can be super useful if you either get the data from an uncompressed source or
  81497. * if you wish to create your texture pixel by pixel.
  81498. */
  81499. export class RawTexture extends Texture {
  81500. /**
  81501. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81502. */
  81503. format: number;
  81504. private _engine;
  81505. /**
  81506. * Instantiates a new RawTexture.
  81507. * Raw texture can help creating a texture directly from an array of data.
  81508. * This can be super useful if you either get the data from an uncompressed source or
  81509. * if you wish to create your texture pixel by pixel.
  81510. * @param data define the array of data to use to create the texture
  81511. * @param width define the width of the texture
  81512. * @param height define the height of the texture
  81513. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81514. * @param scene define the scene the texture belongs to
  81515. * @param generateMipMaps define whether mip maps should be generated or not
  81516. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81517. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81518. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81519. */
  81520. constructor(data: ArrayBufferView, width: number, height: number,
  81521. /**
  81522. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81523. */
  81524. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  81525. /**
  81526. * Updates the texture underlying data.
  81527. * @param data Define the new data of the texture
  81528. */
  81529. update(data: ArrayBufferView): void;
  81530. /**
  81531. * Creates a luminance texture from some data.
  81532. * @param data Define the texture data
  81533. * @param width Define the width of the texture
  81534. * @param height Define the height of the texture
  81535. * @param scene Define the scene the texture belongs to
  81536. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81537. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81538. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81539. * @returns the luminance texture
  81540. */
  81541. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81542. /**
  81543. * Creates a luminance alpha texture from some data.
  81544. * @param data Define the texture data
  81545. * @param width Define the width of the texture
  81546. * @param height Define the height of the texture
  81547. * @param scene Define the scene the texture belongs to
  81548. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81549. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81550. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81551. * @returns the luminance alpha texture
  81552. */
  81553. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81554. /**
  81555. * Creates an alpha texture from some data.
  81556. * @param data Define the texture data
  81557. * @param width Define the width of the texture
  81558. * @param height Define the height of the texture
  81559. * @param scene Define the scene the texture belongs to
  81560. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81561. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81562. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81563. * @returns the alpha texture
  81564. */
  81565. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81566. /**
  81567. * Creates a RGB texture from some data.
  81568. * @param data Define the texture data
  81569. * @param width Define the width of the texture
  81570. * @param height Define the height of the texture
  81571. * @param scene Define the scene the texture belongs to
  81572. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81573. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81574. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81575. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81576. * @returns the RGB alpha texture
  81577. */
  81578. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81579. /**
  81580. * Creates a RGBA texture from some data.
  81581. * @param data Define the texture data
  81582. * @param width Define the width of the texture
  81583. * @param height Define the height of the texture
  81584. * @param scene Define the scene the texture belongs to
  81585. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81586. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81587. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81588. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81589. * @returns the RGBA texture
  81590. */
  81591. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81592. /**
  81593. * Creates a R texture from some data.
  81594. * @param data Define the texture data
  81595. * @param width Define the width of the texture
  81596. * @param height Define the height of the texture
  81597. * @param scene Define the scene the texture belongs to
  81598. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81599. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81600. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81601. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81602. * @returns the R texture
  81603. */
  81604. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81605. }
  81606. }
  81607. declare module BABYLON {
  81608. /**
  81609. * Interface for the size containing width and height
  81610. */
  81611. export interface ISize {
  81612. /**
  81613. * Width
  81614. */
  81615. width: number;
  81616. /**
  81617. * Heighht
  81618. */
  81619. height: number;
  81620. }
  81621. /**
  81622. * Size containing widht and height
  81623. */
  81624. export class Size implements ISize {
  81625. /**
  81626. * Width
  81627. */
  81628. width: number;
  81629. /**
  81630. * Height
  81631. */
  81632. height: number;
  81633. /**
  81634. * Creates a Size object from the given width and height (floats).
  81635. * @param width width of the new size
  81636. * @param height height of the new size
  81637. */
  81638. constructor(width: number, height: number);
  81639. /**
  81640. * Returns a string with the Size width and height
  81641. * @returns a string with the Size width and height
  81642. */
  81643. toString(): string;
  81644. /**
  81645. * "Size"
  81646. * @returns the string "Size"
  81647. */
  81648. getClassName(): string;
  81649. /**
  81650. * Returns the Size hash code.
  81651. * @returns a hash code for a unique width and height
  81652. */
  81653. getHashCode(): number;
  81654. /**
  81655. * Updates the current size from the given one.
  81656. * @param src the given size
  81657. */
  81658. copyFrom(src: Size): void;
  81659. /**
  81660. * Updates in place the current Size from the given floats.
  81661. * @param width width of the new size
  81662. * @param height height of the new size
  81663. * @returns the updated Size.
  81664. */
  81665. copyFromFloats(width: number, height: number): Size;
  81666. /**
  81667. * Updates in place the current Size from the given floats.
  81668. * @param width width to set
  81669. * @param height height to set
  81670. * @returns the updated Size.
  81671. */
  81672. set(width: number, height: number): Size;
  81673. /**
  81674. * Multiplies the width and height by numbers
  81675. * @param w factor to multiple the width by
  81676. * @param h factor to multiple the height by
  81677. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  81678. */
  81679. multiplyByFloats(w: number, h: number): Size;
  81680. /**
  81681. * Clones the size
  81682. * @returns a new Size copied from the given one.
  81683. */
  81684. clone(): Size;
  81685. /**
  81686. * True if the current Size and the given one width and height are strictly equal.
  81687. * @param other the other size to compare against
  81688. * @returns True if the current Size and the given one width and height are strictly equal.
  81689. */
  81690. equals(other: Size): boolean;
  81691. /**
  81692. * The surface of the Size : width * height (float).
  81693. */
  81694. readonly surface: number;
  81695. /**
  81696. * Create a new size of zero
  81697. * @returns a new Size set to (0.0, 0.0)
  81698. */
  81699. static Zero(): Size;
  81700. /**
  81701. * Sums the width and height of two sizes
  81702. * @param otherSize size to add to this size
  81703. * @returns a new Size set as the addition result of the current Size and the given one.
  81704. */
  81705. add(otherSize: Size): Size;
  81706. /**
  81707. * Subtracts the width and height of two
  81708. * @param otherSize size to subtract to this size
  81709. * @returns a new Size set as the subtraction result of the given one from the current Size.
  81710. */
  81711. subtract(otherSize: Size): Size;
  81712. /**
  81713. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  81714. * @param start starting size to lerp between
  81715. * @param end end size to lerp between
  81716. * @param amount amount to lerp between the start and end values
  81717. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81718. */
  81719. static Lerp(start: Size, end: Size, amount: number): Size;
  81720. }
  81721. }
  81722. declare module BABYLON {
  81723. /**
  81724. * Defines a runtime animation
  81725. */
  81726. export class RuntimeAnimation {
  81727. private _events;
  81728. /**
  81729. * The current frame of the runtime animation
  81730. */
  81731. private _currentFrame;
  81732. /**
  81733. * The animation used by the runtime animation
  81734. */
  81735. private _animation;
  81736. /**
  81737. * The target of the runtime animation
  81738. */
  81739. private _target;
  81740. /**
  81741. * The initiating animatable
  81742. */
  81743. private _host;
  81744. /**
  81745. * The original value of the runtime animation
  81746. */
  81747. private _originalValue;
  81748. /**
  81749. * The original blend value of the runtime animation
  81750. */
  81751. private _originalBlendValue;
  81752. /**
  81753. * The offsets cache of the runtime animation
  81754. */
  81755. private _offsetsCache;
  81756. /**
  81757. * The high limits cache of the runtime animation
  81758. */
  81759. private _highLimitsCache;
  81760. /**
  81761. * Specifies if the runtime animation has been stopped
  81762. */
  81763. private _stopped;
  81764. /**
  81765. * The blending factor of the runtime animation
  81766. */
  81767. private _blendingFactor;
  81768. /**
  81769. * The BabylonJS scene
  81770. */
  81771. private _scene;
  81772. /**
  81773. * The current value of the runtime animation
  81774. */
  81775. private _currentValue;
  81776. /** @hidden */
  81777. _animationState: _IAnimationState;
  81778. /**
  81779. * The active target of the runtime animation
  81780. */
  81781. private _activeTargets;
  81782. private _currentActiveTarget;
  81783. private _directTarget;
  81784. /**
  81785. * The target path of the runtime animation
  81786. */
  81787. private _targetPath;
  81788. /**
  81789. * The weight of the runtime animation
  81790. */
  81791. private _weight;
  81792. /**
  81793. * The ratio offset of the runtime animation
  81794. */
  81795. private _ratioOffset;
  81796. /**
  81797. * The previous delay of the runtime animation
  81798. */
  81799. private _previousDelay;
  81800. /**
  81801. * The previous ratio of the runtime animation
  81802. */
  81803. private _previousRatio;
  81804. private _enableBlending;
  81805. private _keys;
  81806. private _minFrame;
  81807. private _maxFrame;
  81808. private _minValue;
  81809. private _maxValue;
  81810. private _targetIsArray;
  81811. /**
  81812. * Gets the current frame of the runtime animation
  81813. */
  81814. readonly currentFrame: number;
  81815. /**
  81816. * Gets the weight of the runtime animation
  81817. */
  81818. readonly weight: number;
  81819. /**
  81820. * Gets the current value of the runtime animation
  81821. */
  81822. readonly currentValue: any;
  81823. /**
  81824. * Gets the target path of the runtime animation
  81825. */
  81826. readonly targetPath: string;
  81827. /**
  81828. * Gets the actual target of the runtime animation
  81829. */
  81830. readonly target: any;
  81831. /** @hidden */
  81832. _onLoop: () => void;
  81833. /**
  81834. * Create a new RuntimeAnimation object
  81835. * @param target defines the target of the animation
  81836. * @param animation defines the source animation object
  81837. * @param scene defines the hosting scene
  81838. * @param host defines the initiating Animatable
  81839. */
  81840. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81841. private _preparePath;
  81842. /**
  81843. * Gets the animation from the runtime animation
  81844. */
  81845. readonly animation: Animation;
  81846. /**
  81847. * Resets the runtime animation to the beginning
  81848. * @param restoreOriginal defines whether to restore the target property to the original value
  81849. */
  81850. reset(restoreOriginal?: boolean): void;
  81851. /**
  81852. * Specifies if the runtime animation is stopped
  81853. * @returns Boolean specifying if the runtime animation is stopped
  81854. */
  81855. isStopped(): boolean;
  81856. /**
  81857. * Disposes of the runtime animation
  81858. */
  81859. dispose(): void;
  81860. /**
  81861. * Apply the interpolated value to the target
  81862. * @param currentValue defines the value computed by the animation
  81863. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81864. */
  81865. setValue(currentValue: any, weight: number): void;
  81866. private _getOriginalValues;
  81867. private _setValue;
  81868. /**
  81869. * Gets the loop pmode of the runtime animation
  81870. * @returns Loop Mode
  81871. */
  81872. private _getCorrectLoopMode;
  81873. /**
  81874. * Move the current animation to a given frame
  81875. * @param frame defines the frame to move to
  81876. */
  81877. goToFrame(frame: number): void;
  81878. /**
  81879. * @hidden Internal use only
  81880. */
  81881. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81882. /**
  81883. * Execute the current animation
  81884. * @param delay defines the delay to add to the current frame
  81885. * @param from defines the lower bound of the animation range
  81886. * @param to defines the upper bound of the animation range
  81887. * @param loop defines if the current animation must loop
  81888. * @param speedRatio defines the current speed ratio
  81889. * @param weight defines the weight of the animation (default is -1 so no weight)
  81890. * @param onLoop optional callback called when animation loops
  81891. * @returns a boolean indicating if the animation is running
  81892. */
  81893. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81894. }
  81895. }
  81896. declare module BABYLON {
  81897. /**
  81898. * Class used to store an actual running animation
  81899. */
  81900. export class Animatable {
  81901. /** defines the target object */
  81902. target: any;
  81903. /** defines the starting frame number (default is 0) */
  81904. fromFrame: number;
  81905. /** defines the ending frame number (default is 100) */
  81906. toFrame: number;
  81907. /** defines if the animation must loop (default is false) */
  81908. loopAnimation: boolean;
  81909. /** defines a callback to call when animation ends if it is not looping */
  81910. onAnimationEnd?: (() => void) | null | undefined;
  81911. /** defines a callback to call when animation loops */
  81912. onAnimationLoop?: (() => void) | null | undefined;
  81913. private _localDelayOffset;
  81914. private _pausedDelay;
  81915. private _runtimeAnimations;
  81916. private _paused;
  81917. private _scene;
  81918. private _speedRatio;
  81919. private _weight;
  81920. private _syncRoot;
  81921. /**
  81922. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81923. * This will only apply for non looping animation (default is true)
  81924. */
  81925. disposeOnEnd: boolean;
  81926. /**
  81927. * Gets a boolean indicating if the animation has started
  81928. */
  81929. animationStarted: boolean;
  81930. /**
  81931. * Observer raised when the animation ends
  81932. */
  81933. onAnimationEndObservable: Observable<Animatable>;
  81934. /**
  81935. * Observer raised when the animation loops
  81936. */
  81937. onAnimationLoopObservable: Observable<Animatable>;
  81938. /**
  81939. * Gets the root Animatable used to synchronize and normalize animations
  81940. */
  81941. readonly syncRoot: Nullable<Animatable>;
  81942. /**
  81943. * Gets the current frame of the first RuntimeAnimation
  81944. * Used to synchronize Animatables
  81945. */
  81946. readonly masterFrame: number;
  81947. /**
  81948. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81949. */
  81950. weight: number;
  81951. /**
  81952. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81953. */
  81954. speedRatio: number;
  81955. /**
  81956. * Creates a new Animatable
  81957. * @param scene defines the hosting scene
  81958. * @param target defines the target object
  81959. * @param fromFrame defines the starting frame number (default is 0)
  81960. * @param toFrame defines the ending frame number (default is 100)
  81961. * @param loopAnimation defines if the animation must loop (default is false)
  81962. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81963. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81964. * @param animations defines a group of animation to add to the new Animatable
  81965. * @param onAnimationLoop defines a callback to call when animation loops
  81966. */
  81967. constructor(scene: Scene,
  81968. /** defines the target object */
  81969. target: any,
  81970. /** defines the starting frame number (default is 0) */
  81971. fromFrame?: number,
  81972. /** defines the ending frame number (default is 100) */
  81973. toFrame?: number,
  81974. /** defines if the animation must loop (default is false) */
  81975. loopAnimation?: boolean, speedRatio?: number,
  81976. /** defines a callback to call when animation ends if it is not looping */
  81977. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81978. /** defines a callback to call when animation loops */
  81979. onAnimationLoop?: (() => void) | null | undefined);
  81980. /**
  81981. * Synchronize and normalize current Animatable with a source Animatable
  81982. * This is useful when using animation weights and when animations are not of the same length
  81983. * @param root defines the root Animatable to synchronize with
  81984. * @returns the current Animatable
  81985. */
  81986. syncWith(root: Animatable): Animatable;
  81987. /**
  81988. * Gets the list of runtime animations
  81989. * @returns an array of RuntimeAnimation
  81990. */
  81991. getAnimations(): RuntimeAnimation[];
  81992. /**
  81993. * Adds more animations to the current animatable
  81994. * @param target defines the target of the animations
  81995. * @param animations defines the new animations to add
  81996. */
  81997. appendAnimations(target: any, animations: Animation[]): void;
  81998. /**
  81999. * Gets the source animation for a specific property
  82000. * @param property defines the propertyu to look for
  82001. * @returns null or the source animation for the given property
  82002. */
  82003. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  82004. /**
  82005. * Gets the runtime animation for a specific property
  82006. * @param property defines the propertyu to look for
  82007. * @returns null or the runtime animation for the given property
  82008. */
  82009. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  82010. /**
  82011. * Resets the animatable to its original state
  82012. */
  82013. reset(): void;
  82014. /**
  82015. * Allows the animatable to blend with current running animations
  82016. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82017. * @param blendingSpeed defines the blending speed to use
  82018. */
  82019. enableBlending(blendingSpeed: number): void;
  82020. /**
  82021. * Disable animation blending
  82022. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82023. */
  82024. disableBlending(): void;
  82025. /**
  82026. * Jump directly to a given frame
  82027. * @param frame defines the frame to jump to
  82028. */
  82029. goToFrame(frame: number): void;
  82030. /**
  82031. * Pause the animation
  82032. */
  82033. pause(): void;
  82034. /**
  82035. * Restart the animation
  82036. */
  82037. restart(): void;
  82038. private _raiseOnAnimationEnd;
  82039. /**
  82040. * Stop and delete the current animation
  82041. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  82042. * @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)
  82043. */
  82044. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  82045. /**
  82046. * Wait asynchronously for the animation to end
  82047. * @returns a promise which will be fullfilled when the animation ends
  82048. */
  82049. waitAsync(): Promise<Animatable>;
  82050. /** @hidden */
  82051. _animate(delay: number): boolean;
  82052. }
  82053. interface Scene {
  82054. /** @hidden */
  82055. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  82056. /** @hidden */
  82057. _processLateAnimationBindingsForMatrices(holder: {
  82058. totalWeight: number;
  82059. animations: RuntimeAnimation[];
  82060. originalValue: Matrix;
  82061. }): any;
  82062. /** @hidden */
  82063. _processLateAnimationBindingsForQuaternions(holder: {
  82064. totalWeight: number;
  82065. animations: RuntimeAnimation[];
  82066. originalValue: Quaternion;
  82067. }, refQuaternion: Quaternion): Quaternion;
  82068. /** @hidden */
  82069. _processLateAnimationBindings(): void;
  82070. /**
  82071. * Will start the animation sequence of a given target
  82072. * @param target defines the target
  82073. * @param from defines from which frame should animation start
  82074. * @param to defines until which frame should animation run.
  82075. * @param weight defines the weight to apply to the animation (1.0 by default)
  82076. * @param loop defines if the animation loops
  82077. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82078. * @param onAnimationEnd defines the function to be executed when the animation ends
  82079. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82080. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82081. * @param onAnimationLoop defines the callback to call when an animation loops
  82082. * @returns the animatable object created for this animation
  82083. */
  82084. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82085. /**
  82086. * Will start the animation sequence of a given target
  82087. * @param target defines the target
  82088. * @param from defines from which frame should animation start
  82089. * @param to defines until which frame should animation run.
  82090. * @param loop defines if the animation loops
  82091. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82092. * @param onAnimationEnd defines the function to be executed when the animation ends
  82093. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82094. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82095. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  82096. * @param onAnimationLoop defines the callback to call when an animation loops
  82097. * @returns the animatable object created for this animation
  82098. */
  82099. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82100. /**
  82101. * Will start the animation sequence of a given target and its hierarchy
  82102. * @param target defines the target
  82103. * @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.
  82104. * @param from defines from which frame should animation start
  82105. * @param to defines until which frame should animation run.
  82106. * @param loop defines if the animation loops
  82107. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82108. * @param onAnimationEnd defines the function to be executed when the animation ends
  82109. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82110. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82111. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82112. * @param onAnimationLoop defines the callback to call when an animation loops
  82113. * @returns the list of created animatables
  82114. */
  82115. 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[];
  82116. /**
  82117. * Begin a new animation on a given node
  82118. * @param target defines the target where the animation will take place
  82119. * @param animations defines the list of animations to start
  82120. * @param from defines the initial value
  82121. * @param to defines the final value
  82122. * @param loop defines if you want animation to loop (off by default)
  82123. * @param speedRatio defines the speed ratio to apply to all animations
  82124. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82125. * @param onAnimationLoop defines the callback to call when an animation loops
  82126. * @returns the list of created animatables
  82127. */
  82128. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  82129. /**
  82130. * Begin a new animation on a given node and its hierarchy
  82131. * @param target defines the root node where the animation will take place
  82132. * @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.
  82133. * @param animations defines the list of animations to start
  82134. * @param from defines the initial value
  82135. * @param to defines the final value
  82136. * @param loop defines if you want animation to loop (off by default)
  82137. * @param speedRatio defines the speed ratio to apply to all animations
  82138. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82139. * @param onAnimationLoop defines the callback to call when an animation loops
  82140. * @returns the list of animatables created for all nodes
  82141. */
  82142. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  82143. /**
  82144. * Gets the animatable associated with a specific target
  82145. * @param target defines the target of the animatable
  82146. * @returns the required animatable if found
  82147. */
  82148. getAnimatableByTarget(target: any): Nullable<Animatable>;
  82149. /**
  82150. * Gets all animatables associated with a given target
  82151. * @param target defines the target to look animatables for
  82152. * @returns an array of Animatables
  82153. */
  82154. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  82155. /**
  82156. * Stops and removes all animations that have been applied to the scene
  82157. */
  82158. stopAllAnimations(): void;
  82159. /**
  82160. * Gets the current delta time used by animation engine
  82161. */
  82162. deltaTime: number;
  82163. }
  82164. interface Bone {
  82165. /**
  82166. * Copy an animation range from another bone
  82167. * @param source defines the source bone
  82168. * @param rangeName defines the range name to copy
  82169. * @param frameOffset defines the frame offset
  82170. * @param rescaleAsRequired defines if rescaling must be applied if required
  82171. * @param skelDimensionsRatio defines the scaling ratio
  82172. * @returns true if operation was successful
  82173. */
  82174. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  82175. }
  82176. }
  82177. declare module BABYLON {
  82178. /**
  82179. * Class used to override all child animations of a given target
  82180. */
  82181. export class AnimationPropertiesOverride {
  82182. /**
  82183. * Gets or sets a value indicating if animation blending must be used
  82184. */
  82185. enableBlending: boolean;
  82186. /**
  82187. * Gets or sets the blending speed to use when enableBlending is true
  82188. */
  82189. blendingSpeed: number;
  82190. /**
  82191. * Gets or sets the default loop mode to use
  82192. */
  82193. loopMode: number;
  82194. }
  82195. }
  82196. declare module BABYLON {
  82197. /**
  82198. * Class used to handle skinning animations
  82199. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82200. */
  82201. export class Skeleton implements IAnimatable {
  82202. /** defines the skeleton name */
  82203. name: string;
  82204. /** defines the skeleton Id */
  82205. id: string;
  82206. /**
  82207. * Defines the list of child bones
  82208. */
  82209. bones: Bone[];
  82210. /**
  82211. * Defines an estimate of the dimension of the skeleton at rest
  82212. */
  82213. dimensionsAtRest: Vector3;
  82214. /**
  82215. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  82216. */
  82217. needInitialSkinMatrix: boolean;
  82218. /**
  82219. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  82220. */
  82221. overrideMesh: Nullable<AbstractMesh>;
  82222. /**
  82223. * Gets the list of animations attached to this skeleton
  82224. */
  82225. animations: Array<Animation>;
  82226. private _scene;
  82227. private _isDirty;
  82228. private _transformMatrices;
  82229. private _transformMatrixTexture;
  82230. private _meshesWithPoseMatrix;
  82231. private _animatables;
  82232. private _identity;
  82233. private _synchronizedWithMesh;
  82234. private _ranges;
  82235. private _lastAbsoluteTransformsUpdateId;
  82236. private _canUseTextureForBones;
  82237. private _uniqueId;
  82238. /** @hidden */
  82239. _numBonesWithLinkedTransformNode: number;
  82240. /** @hidden */
  82241. _hasWaitingData: Nullable<boolean>;
  82242. /**
  82243. * Specifies if the skeleton should be serialized
  82244. */
  82245. doNotSerialize: boolean;
  82246. private _useTextureToStoreBoneMatrices;
  82247. /**
  82248. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  82249. * Please note that this option is not available if the hardware does not support it
  82250. */
  82251. useTextureToStoreBoneMatrices: boolean;
  82252. private _animationPropertiesOverride;
  82253. /**
  82254. * Gets or sets the animation properties override
  82255. */
  82256. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82257. /**
  82258. * List of inspectable custom properties (used by the Inspector)
  82259. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82260. */
  82261. inspectableCustomProperties: IInspectable[];
  82262. /**
  82263. * An observable triggered before computing the skeleton's matrices
  82264. */
  82265. onBeforeComputeObservable: Observable<Skeleton>;
  82266. /**
  82267. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  82268. */
  82269. readonly isUsingTextureForMatrices: boolean;
  82270. /**
  82271. * Gets the unique ID of this skeleton
  82272. */
  82273. readonly uniqueId: number;
  82274. /**
  82275. * Creates a new skeleton
  82276. * @param name defines the skeleton name
  82277. * @param id defines the skeleton Id
  82278. * @param scene defines the hosting scene
  82279. */
  82280. constructor(
  82281. /** defines the skeleton name */
  82282. name: string,
  82283. /** defines the skeleton Id */
  82284. id: string, scene: Scene);
  82285. /**
  82286. * Gets the current object class name.
  82287. * @return the class name
  82288. */
  82289. getClassName(): string;
  82290. /**
  82291. * Returns an array containing the root bones
  82292. * @returns an array containing the root bones
  82293. */
  82294. getChildren(): Array<Bone>;
  82295. /**
  82296. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  82297. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82298. * @returns a Float32Array containing matrices data
  82299. */
  82300. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  82301. /**
  82302. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  82303. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82304. * @returns a raw texture containing the data
  82305. */
  82306. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  82307. /**
  82308. * Gets the current hosting scene
  82309. * @returns a scene object
  82310. */
  82311. getScene(): Scene;
  82312. /**
  82313. * Gets a string representing the current skeleton data
  82314. * @param fullDetails defines a boolean indicating if we want a verbose version
  82315. * @returns a string representing the current skeleton data
  82316. */
  82317. toString(fullDetails?: boolean): string;
  82318. /**
  82319. * Get bone's index searching by name
  82320. * @param name defines bone's name to search for
  82321. * @return the indice of the bone. Returns -1 if not found
  82322. */
  82323. getBoneIndexByName(name: string): number;
  82324. /**
  82325. * Creater a new animation range
  82326. * @param name defines the name of the range
  82327. * @param from defines the start key
  82328. * @param to defines the end key
  82329. */
  82330. createAnimationRange(name: string, from: number, to: number): void;
  82331. /**
  82332. * Delete a specific animation range
  82333. * @param name defines the name of the range
  82334. * @param deleteFrames defines if frames must be removed as well
  82335. */
  82336. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82337. /**
  82338. * Gets a specific animation range
  82339. * @param name defines the name of the range to look for
  82340. * @returns the requested animation range or null if not found
  82341. */
  82342. getAnimationRange(name: string): Nullable<AnimationRange>;
  82343. /**
  82344. * Gets the list of all animation ranges defined on this skeleton
  82345. * @returns an array
  82346. */
  82347. getAnimationRanges(): Nullable<AnimationRange>[];
  82348. /**
  82349. * Copy animation range from a source skeleton.
  82350. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  82351. * @param source defines the source skeleton
  82352. * @param name defines the name of the range to copy
  82353. * @param rescaleAsRequired defines if rescaling must be applied if required
  82354. * @returns true if operation was successful
  82355. */
  82356. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  82357. /**
  82358. * Forces the skeleton to go to rest pose
  82359. */
  82360. returnToRest(): void;
  82361. private _getHighestAnimationFrame;
  82362. /**
  82363. * Begin a specific animation range
  82364. * @param name defines the name of the range to start
  82365. * @param loop defines if looping must be turned on (false by default)
  82366. * @param speedRatio defines the speed ratio to apply (1 by default)
  82367. * @param onAnimationEnd defines a callback which will be called when animation will end
  82368. * @returns a new animatable
  82369. */
  82370. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82371. /** @hidden */
  82372. _markAsDirty(): void;
  82373. /** @hidden */
  82374. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82375. /** @hidden */
  82376. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82377. private _computeTransformMatrices;
  82378. /**
  82379. * Build all resources required to render a skeleton
  82380. */
  82381. prepare(): void;
  82382. /**
  82383. * Gets the list of animatables currently running for this skeleton
  82384. * @returns an array of animatables
  82385. */
  82386. getAnimatables(): IAnimatable[];
  82387. /**
  82388. * Clone the current skeleton
  82389. * @param name defines the name of the new skeleton
  82390. * @param id defines the id of the new skeleton
  82391. * @returns the new skeleton
  82392. */
  82393. clone(name: string, id?: string): Skeleton;
  82394. /**
  82395. * Enable animation blending for this skeleton
  82396. * @param blendingSpeed defines the blending speed to apply
  82397. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82398. */
  82399. enableBlending(blendingSpeed?: number): void;
  82400. /**
  82401. * Releases all resources associated with the current skeleton
  82402. */
  82403. dispose(): void;
  82404. /**
  82405. * Serialize the skeleton in a JSON object
  82406. * @returns a JSON object
  82407. */
  82408. serialize(): any;
  82409. /**
  82410. * Creates a new skeleton from serialized data
  82411. * @param parsedSkeleton defines the serialized data
  82412. * @param scene defines the hosting scene
  82413. * @returns a new skeleton
  82414. */
  82415. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  82416. /**
  82417. * Compute all node absolute transforms
  82418. * @param forceUpdate defines if computation must be done even if cache is up to date
  82419. */
  82420. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  82421. /**
  82422. * Gets the root pose matrix
  82423. * @returns a matrix
  82424. */
  82425. getPoseMatrix(): Nullable<Matrix>;
  82426. /**
  82427. * Sorts bones per internal index
  82428. */
  82429. sortBones(): void;
  82430. private _sortBones;
  82431. }
  82432. }
  82433. declare module BABYLON {
  82434. /**
  82435. * Class used to store bone information
  82436. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82437. */
  82438. export class Bone extends Node {
  82439. /**
  82440. * defines the bone name
  82441. */
  82442. name: string;
  82443. private static _tmpVecs;
  82444. private static _tmpQuat;
  82445. private static _tmpMats;
  82446. /**
  82447. * Gets the list of child bones
  82448. */
  82449. children: Bone[];
  82450. /** Gets the animations associated with this bone */
  82451. animations: Animation[];
  82452. /**
  82453. * Gets or sets bone length
  82454. */
  82455. length: number;
  82456. /**
  82457. * @hidden Internal only
  82458. * Set this value to map this bone to a different index in the transform matrices
  82459. * Set this value to -1 to exclude the bone from the transform matrices
  82460. */
  82461. _index: Nullable<number>;
  82462. private _skeleton;
  82463. private _localMatrix;
  82464. private _restPose;
  82465. private _baseMatrix;
  82466. private _absoluteTransform;
  82467. private _invertedAbsoluteTransform;
  82468. private _parent;
  82469. private _scalingDeterminant;
  82470. private _worldTransform;
  82471. private _localScaling;
  82472. private _localRotation;
  82473. private _localPosition;
  82474. private _needToDecompose;
  82475. private _needToCompose;
  82476. /** @hidden */
  82477. _linkedTransformNode: Nullable<TransformNode>;
  82478. /** @hidden */
  82479. _waitingTransformNodeId: Nullable<string>;
  82480. /** @hidden */
  82481. /** @hidden */
  82482. _matrix: Matrix;
  82483. /**
  82484. * Create a new bone
  82485. * @param name defines the bone name
  82486. * @param skeleton defines the parent skeleton
  82487. * @param parentBone defines the parent (can be null if the bone is the root)
  82488. * @param localMatrix defines the local matrix
  82489. * @param restPose defines the rest pose matrix
  82490. * @param baseMatrix defines the base matrix
  82491. * @param index defines index of the bone in the hiearchy
  82492. */
  82493. constructor(
  82494. /**
  82495. * defines the bone name
  82496. */
  82497. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  82498. /**
  82499. * Gets the current object class name.
  82500. * @return the class name
  82501. */
  82502. getClassName(): string;
  82503. /**
  82504. * Gets the parent skeleton
  82505. * @returns a skeleton
  82506. */
  82507. getSkeleton(): Skeleton;
  82508. /**
  82509. * Gets parent bone
  82510. * @returns a bone or null if the bone is the root of the bone hierarchy
  82511. */
  82512. getParent(): Nullable<Bone>;
  82513. /**
  82514. * Returns an array containing the root bones
  82515. * @returns an array containing the root bones
  82516. */
  82517. getChildren(): Array<Bone>;
  82518. /**
  82519. * Gets the node index in matrix array generated for rendering
  82520. * @returns the node index
  82521. */
  82522. getIndex(): number;
  82523. /**
  82524. * Sets the parent bone
  82525. * @param parent defines the parent (can be null if the bone is the root)
  82526. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82527. */
  82528. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  82529. /**
  82530. * Gets the local matrix
  82531. * @returns a matrix
  82532. */
  82533. getLocalMatrix(): Matrix;
  82534. /**
  82535. * Gets the base matrix (initial matrix which remains unchanged)
  82536. * @returns a matrix
  82537. */
  82538. getBaseMatrix(): Matrix;
  82539. /**
  82540. * Gets the rest pose matrix
  82541. * @returns a matrix
  82542. */
  82543. getRestPose(): Matrix;
  82544. /**
  82545. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  82546. */
  82547. getWorldMatrix(): Matrix;
  82548. /**
  82549. * Sets the local matrix to rest pose matrix
  82550. */
  82551. returnToRest(): void;
  82552. /**
  82553. * Gets the inverse of the absolute transform matrix.
  82554. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  82555. * @returns a matrix
  82556. */
  82557. getInvertedAbsoluteTransform(): Matrix;
  82558. /**
  82559. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  82560. * @returns a matrix
  82561. */
  82562. getAbsoluteTransform(): Matrix;
  82563. /**
  82564. * Links with the given transform node.
  82565. * The local matrix of this bone is copied from the transform node every frame.
  82566. * @param transformNode defines the transform node to link to
  82567. */
  82568. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  82569. /**
  82570. * Gets the node used to drive the bone's transformation
  82571. * @returns a transform node or null
  82572. */
  82573. getTransformNode(): Nullable<TransformNode>;
  82574. /** Gets or sets current position (in local space) */
  82575. position: Vector3;
  82576. /** Gets or sets current rotation (in local space) */
  82577. rotation: Vector3;
  82578. /** Gets or sets current rotation quaternion (in local space) */
  82579. rotationQuaternion: Quaternion;
  82580. /** Gets or sets current scaling (in local space) */
  82581. scaling: Vector3;
  82582. /**
  82583. * Gets the animation properties override
  82584. */
  82585. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82586. private _decompose;
  82587. private _compose;
  82588. /**
  82589. * Update the base and local matrices
  82590. * @param matrix defines the new base or local matrix
  82591. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82592. * @param updateLocalMatrix defines if the local matrix should be updated
  82593. */
  82594. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  82595. /** @hidden */
  82596. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  82597. /**
  82598. * Flag the bone as dirty (Forcing it to update everything)
  82599. */
  82600. markAsDirty(): void;
  82601. /** @hidden */
  82602. _markAsDirtyAndCompose(): void;
  82603. private _markAsDirtyAndDecompose;
  82604. /**
  82605. * Translate the bone in local or world space
  82606. * @param vec The amount to translate the bone
  82607. * @param space The space that the translation is in
  82608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82609. */
  82610. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82611. /**
  82612. * Set the postion of the bone in local or world space
  82613. * @param position The position to set the bone
  82614. * @param space The space that the position is in
  82615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82616. */
  82617. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82618. /**
  82619. * Set the absolute position of the bone (world space)
  82620. * @param position The position to set the bone
  82621. * @param mesh The mesh that this bone is attached to
  82622. */
  82623. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  82624. /**
  82625. * Scale the bone on the x, y and z axes (in local space)
  82626. * @param x The amount to scale the bone on the x axis
  82627. * @param y The amount to scale the bone on the y axis
  82628. * @param z The amount to scale the bone on the z axis
  82629. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  82630. */
  82631. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  82632. /**
  82633. * Set the bone scaling in local space
  82634. * @param scale defines the scaling vector
  82635. */
  82636. setScale(scale: Vector3): void;
  82637. /**
  82638. * Gets the current scaling in local space
  82639. * @returns the current scaling vector
  82640. */
  82641. getScale(): Vector3;
  82642. /**
  82643. * Gets the current scaling in local space and stores it in a target vector
  82644. * @param result defines the target vector
  82645. */
  82646. getScaleToRef(result: Vector3): void;
  82647. /**
  82648. * Set the yaw, pitch, and roll of the bone in local or world space
  82649. * @param yaw The rotation of the bone on the y axis
  82650. * @param pitch The rotation of the bone on the x axis
  82651. * @param roll The rotation of the bone on the z axis
  82652. * @param space The space that the axes of rotation are in
  82653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82654. */
  82655. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  82656. /**
  82657. * Add a rotation to the bone on an axis in local or world space
  82658. * @param axis The axis to rotate the bone on
  82659. * @param amount The amount to rotate the bone
  82660. * @param space The space that the axis is in
  82661. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82662. */
  82663. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  82664. /**
  82665. * Set the rotation of the bone to a particular axis angle in local or world space
  82666. * @param axis The axis to rotate the bone on
  82667. * @param angle The angle that the bone should be rotated to
  82668. * @param space The space that the axis is in
  82669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82670. */
  82671. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  82672. /**
  82673. * Set the euler rotation of the bone in local of world space
  82674. * @param rotation The euler rotation that the bone should be set to
  82675. * @param space The space that the rotation is in
  82676. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82677. */
  82678. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82679. /**
  82680. * Set the quaternion rotation of the bone in local of world space
  82681. * @param quat The quaternion rotation that the bone should be set to
  82682. * @param space The space that the rotation is in
  82683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82684. */
  82685. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  82686. /**
  82687. * Set the rotation matrix of the bone in local of world space
  82688. * @param rotMat The rotation matrix that the bone should be set to
  82689. * @param space The space that the rotation is in
  82690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82691. */
  82692. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  82693. private _rotateWithMatrix;
  82694. private _getNegativeRotationToRef;
  82695. /**
  82696. * Get the position of the bone in local or world space
  82697. * @param space The space that the returned position is in
  82698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82699. * @returns The position of the bone
  82700. */
  82701. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82702. /**
  82703. * Copy the position of the bone to a vector3 in local or world space
  82704. * @param space The space that the returned position is in
  82705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82706. * @param result The vector3 to copy the position to
  82707. */
  82708. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  82709. /**
  82710. * Get the absolute position of the bone (world space)
  82711. * @param mesh The mesh that this bone is attached to
  82712. * @returns The absolute position of the bone
  82713. */
  82714. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  82715. /**
  82716. * Copy the absolute position of the bone (world space) to the result param
  82717. * @param mesh The mesh that this bone is attached to
  82718. * @param result The vector3 to copy the absolute position to
  82719. */
  82720. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82721. /**
  82722. * Compute the absolute transforms of this bone and its children
  82723. */
  82724. computeAbsoluteTransforms(): void;
  82725. /**
  82726. * Get the world direction from an axis that is in the local space of the bone
  82727. * @param localAxis The local direction that is used to compute the world direction
  82728. * @param mesh The mesh that this bone is attached to
  82729. * @returns The world direction
  82730. */
  82731. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82732. /**
  82733. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82734. * @param localAxis The local direction that is used to compute the world direction
  82735. * @param mesh The mesh that this bone is attached to
  82736. * @param result The vector3 that the world direction will be copied to
  82737. */
  82738. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82739. /**
  82740. * Get the euler rotation of the bone in local or world space
  82741. * @param space The space that the rotation should be in
  82742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82743. * @returns The euler rotation
  82744. */
  82745. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82746. /**
  82747. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82748. * @param space The space that the rotation should be in
  82749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82750. * @param result The vector3 that the rotation should be copied to
  82751. */
  82752. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82753. /**
  82754. * Get the quaternion rotation of the bone in either local or world space
  82755. * @param space The space that the rotation should be in
  82756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82757. * @returns The quaternion rotation
  82758. */
  82759. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82760. /**
  82761. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82762. * @param space The space that the rotation should be in
  82763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82764. * @param result The quaternion that the rotation should be copied to
  82765. */
  82766. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82767. /**
  82768. * Get the rotation matrix of the bone in local or world space
  82769. * @param space The space that the rotation should be in
  82770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82771. * @returns The rotation matrix
  82772. */
  82773. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82774. /**
  82775. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82776. * @param space The space that the rotation should be in
  82777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82778. * @param result The quaternion that the rotation should be copied to
  82779. */
  82780. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82781. /**
  82782. * Get the world position of a point that is in the local space of the bone
  82783. * @param position The local position
  82784. * @param mesh The mesh that this bone is attached to
  82785. * @returns The world position
  82786. */
  82787. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82788. /**
  82789. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82790. * @param position The local position
  82791. * @param mesh The mesh that this bone is attached to
  82792. * @param result The vector3 that the world position should be copied to
  82793. */
  82794. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82795. /**
  82796. * Get the local position of a point that is in world space
  82797. * @param position The world position
  82798. * @param mesh The mesh that this bone is attached to
  82799. * @returns The local position
  82800. */
  82801. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82802. /**
  82803. * Get the local position of a point that is in world space and copy it to the result param
  82804. * @param position The world position
  82805. * @param mesh The mesh that this bone is attached to
  82806. * @param result The vector3 that the local position should be copied to
  82807. */
  82808. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82809. }
  82810. }
  82811. declare module BABYLON {
  82812. /**
  82813. * 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.
  82814. * @see https://doc.babylonjs.com/how_to/transformnode
  82815. */
  82816. export class TransformNode extends Node {
  82817. /**
  82818. * Object will not rotate to face the camera
  82819. */
  82820. static BILLBOARDMODE_NONE: number;
  82821. /**
  82822. * Object will rotate to face the camera but only on the x axis
  82823. */
  82824. static BILLBOARDMODE_X: number;
  82825. /**
  82826. * Object will rotate to face the camera but only on the y axis
  82827. */
  82828. static BILLBOARDMODE_Y: number;
  82829. /**
  82830. * Object will rotate to face the camera but only on the z axis
  82831. */
  82832. static BILLBOARDMODE_Z: number;
  82833. /**
  82834. * Object will rotate to face the camera
  82835. */
  82836. static BILLBOARDMODE_ALL: number;
  82837. /**
  82838. * Object will rotate to face the camera's position instead of orientation
  82839. */
  82840. static BILLBOARDMODE_USE_POSITION: number;
  82841. private _forward;
  82842. private _forwardInverted;
  82843. private _up;
  82844. private _right;
  82845. private _rightInverted;
  82846. private _position;
  82847. private _rotation;
  82848. private _rotationQuaternion;
  82849. protected _scaling: Vector3;
  82850. protected _isDirty: boolean;
  82851. private _transformToBoneReferal;
  82852. private _isAbsoluteSynced;
  82853. private _billboardMode;
  82854. /**
  82855. * Gets or sets the billboard mode. Default is 0.
  82856. *
  82857. * | Value | Type | Description |
  82858. * | --- | --- | --- |
  82859. * | 0 | BILLBOARDMODE_NONE | |
  82860. * | 1 | BILLBOARDMODE_X | |
  82861. * | 2 | BILLBOARDMODE_Y | |
  82862. * | 4 | BILLBOARDMODE_Z | |
  82863. * | 7 | BILLBOARDMODE_ALL | |
  82864. *
  82865. */
  82866. billboardMode: number;
  82867. private _preserveParentRotationForBillboard;
  82868. /**
  82869. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82870. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82871. */
  82872. preserveParentRotationForBillboard: boolean;
  82873. /**
  82874. * 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
  82875. */
  82876. scalingDeterminant: number;
  82877. private _infiniteDistance;
  82878. /**
  82879. * Gets or sets the distance of the object to max, often used by skybox
  82880. */
  82881. infiniteDistance: boolean;
  82882. /**
  82883. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82884. * By default the system will update normals to compensate
  82885. */
  82886. ignoreNonUniformScaling: boolean;
  82887. /**
  82888. * 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
  82889. */
  82890. reIntegrateRotationIntoRotationQuaternion: boolean;
  82891. /** @hidden */
  82892. _poseMatrix: Nullable<Matrix>;
  82893. /** @hidden */
  82894. _localMatrix: Matrix;
  82895. private _usePivotMatrix;
  82896. private _absolutePosition;
  82897. private _absoluteScaling;
  82898. private _absoluteRotationQuaternion;
  82899. private _pivotMatrix;
  82900. private _pivotMatrixInverse;
  82901. protected _postMultiplyPivotMatrix: boolean;
  82902. protected _isWorldMatrixFrozen: boolean;
  82903. /** @hidden */
  82904. _indexInSceneTransformNodesArray: number;
  82905. /**
  82906. * An event triggered after the world matrix is updated
  82907. */
  82908. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82909. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82910. /**
  82911. * Gets a string identifying the name of the class
  82912. * @returns "TransformNode" string
  82913. */
  82914. getClassName(): string;
  82915. /**
  82916. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82917. */
  82918. position: Vector3;
  82919. /**
  82920. * 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)).
  82921. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82922. */
  82923. rotation: Vector3;
  82924. /**
  82925. * 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)).
  82926. */
  82927. scaling: Vector3;
  82928. /**
  82929. * 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).
  82930. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  82931. */
  82932. rotationQuaternion: Nullable<Quaternion>;
  82933. /**
  82934. * The forward direction of that transform in world space.
  82935. */
  82936. readonly forward: Vector3;
  82937. /**
  82938. * The up direction of that transform in world space.
  82939. */
  82940. readonly up: Vector3;
  82941. /**
  82942. * The right direction of that transform in world space.
  82943. */
  82944. readonly right: Vector3;
  82945. /**
  82946. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82947. * @param matrix the matrix to copy the pose from
  82948. * @returns this TransformNode.
  82949. */
  82950. updatePoseMatrix(matrix: Matrix): TransformNode;
  82951. /**
  82952. * Returns the mesh Pose matrix.
  82953. * @returns the pose matrix
  82954. */
  82955. getPoseMatrix(): Matrix;
  82956. /** @hidden */
  82957. _isSynchronized(): boolean;
  82958. /** @hidden */
  82959. _initCache(): void;
  82960. /**
  82961. * Flag the transform node as dirty (Forcing it to update everything)
  82962. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82963. * @returns this transform node
  82964. */
  82965. markAsDirty(property: string): TransformNode;
  82966. /**
  82967. * Returns the current mesh absolute position.
  82968. * Returns a Vector3.
  82969. */
  82970. readonly absolutePosition: Vector3;
  82971. /**
  82972. * Returns the current mesh absolute scaling.
  82973. * Returns a Vector3.
  82974. */
  82975. readonly absoluteScaling: Vector3;
  82976. /**
  82977. * Returns the current mesh absolute rotation.
  82978. * Returns a Quaternion.
  82979. */
  82980. readonly absoluteRotationQuaternion: Quaternion;
  82981. /**
  82982. * Sets a new matrix to apply before all other transformation
  82983. * @param matrix defines the transform matrix
  82984. * @returns the current TransformNode
  82985. */
  82986. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82987. /**
  82988. * Sets a new pivot matrix to the current node
  82989. * @param matrix defines the new pivot matrix to use
  82990. * @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
  82991. * @returns the current TransformNode
  82992. */
  82993. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82994. /**
  82995. * Returns the mesh pivot matrix.
  82996. * Default : Identity.
  82997. * @returns the matrix
  82998. */
  82999. getPivotMatrix(): Matrix;
  83000. /**
  83001. * Instantiate (when possible) or clone that node with its hierarchy
  83002. * @param newParent defines the new parent to use for the instance (or clone)
  83003. * @param options defines options to configure how copy is done
  83004. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  83005. * @returns an instance (or a clone) of the current node with its hiearchy
  83006. */
  83007. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  83008. doNotInstantiate: boolean;
  83009. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  83010. /**
  83011. * Prevents the World matrix to be computed any longer
  83012. * @param newWorldMatrix defines an optional matrix to use as world matrix
  83013. * @returns the TransformNode.
  83014. */
  83015. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  83016. /**
  83017. * Allows back the World matrix computation.
  83018. * @returns the TransformNode.
  83019. */
  83020. unfreezeWorldMatrix(): this;
  83021. /**
  83022. * True if the World matrix has been frozen.
  83023. */
  83024. readonly isWorldMatrixFrozen: boolean;
  83025. /**
  83026. * Retuns the mesh absolute position in the World.
  83027. * @returns a Vector3.
  83028. */
  83029. getAbsolutePosition(): Vector3;
  83030. /**
  83031. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  83032. * @param absolutePosition the absolute position to set
  83033. * @returns the TransformNode.
  83034. */
  83035. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  83036. /**
  83037. * Sets the mesh position in its local space.
  83038. * @param vector3 the position to set in localspace
  83039. * @returns the TransformNode.
  83040. */
  83041. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  83042. /**
  83043. * Returns the mesh position in the local space from the current World matrix values.
  83044. * @returns a new Vector3.
  83045. */
  83046. getPositionExpressedInLocalSpace(): Vector3;
  83047. /**
  83048. * Translates the mesh along the passed Vector3 in its local space.
  83049. * @param vector3 the distance to translate in localspace
  83050. * @returns the TransformNode.
  83051. */
  83052. locallyTranslate(vector3: Vector3): TransformNode;
  83053. private static _lookAtVectorCache;
  83054. /**
  83055. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  83056. * @param targetPoint the position (must be in same space as current mesh) to look at
  83057. * @param yawCor optional yaw (y-axis) correction in radians
  83058. * @param pitchCor optional pitch (x-axis) correction in radians
  83059. * @param rollCor optional roll (z-axis) correction in radians
  83060. * @param space the choosen space of the target
  83061. * @returns the TransformNode.
  83062. */
  83063. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  83064. /**
  83065. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83066. * This Vector3 is expressed in the World space.
  83067. * @param localAxis axis to rotate
  83068. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83069. */
  83070. getDirection(localAxis: Vector3): Vector3;
  83071. /**
  83072. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  83073. * localAxis is expressed in the mesh local space.
  83074. * result is computed in the Wordl space from the mesh World matrix.
  83075. * @param localAxis axis to rotate
  83076. * @param result the resulting transformnode
  83077. * @returns this TransformNode.
  83078. */
  83079. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  83080. /**
  83081. * Sets this transform node rotation to the given local axis.
  83082. * @param localAxis the axis in local space
  83083. * @param yawCor optional yaw (y-axis) correction in radians
  83084. * @param pitchCor optional pitch (x-axis) correction in radians
  83085. * @param rollCor optional roll (z-axis) correction in radians
  83086. * @returns this TransformNode
  83087. */
  83088. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  83089. /**
  83090. * Sets a new pivot point to the current node
  83091. * @param point defines the new pivot point to use
  83092. * @param space defines if the point is in world or local space (local by default)
  83093. * @returns the current TransformNode
  83094. */
  83095. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  83096. /**
  83097. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  83098. * @returns the pivot point
  83099. */
  83100. getPivotPoint(): Vector3;
  83101. /**
  83102. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  83103. * @param result the vector3 to store the result
  83104. * @returns this TransformNode.
  83105. */
  83106. getPivotPointToRef(result: Vector3): TransformNode;
  83107. /**
  83108. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  83109. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  83110. */
  83111. getAbsolutePivotPoint(): Vector3;
  83112. /**
  83113. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  83114. * @param result vector3 to store the result
  83115. * @returns this TransformNode.
  83116. */
  83117. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  83118. /**
  83119. * Defines the passed node as the parent of the current node.
  83120. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  83121. * @see https://doc.babylonjs.com/how_to/parenting
  83122. * @param node the node ot set as the parent
  83123. * @returns this TransformNode.
  83124. */
  83125. setParent(node: Nullable<Node>): TransformNode;
  83126. private _nonUniformScaling;
  83127. /**
  83128. * True if the scaling property of this object is non uniform eg. (1,2,1)
  83129. */
  83130. readonly nonUniformScaling: boolean;
  83131. /** @hidden */
  83132. _updateNonUniformScalingState(value: boolean): boolean;
  83133. /**
  83134. * Attach the current TransformNode to another TransformNode associated with a bone
  83135. * @param bone Bone affecting the TransformNode
  83136. * @param affectedTransformNode TransformNode associated with the bone
  83137. * @returns this object
  83138. */
  83139. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  83140. /**
  83141. * Detach the transform node if its associated with a bone
  83142. * @returns this object
  83143. */
  83144. detachFromBone(): TransformNode;
  83145. private static _rotationAxisCache;
  83146. /**
  83147. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  83148. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83149. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83150. * The passed axis is also normalized.
  83151. * @param axis the axis to rotate around
  83152. * @param amount the amount to rotate in radians
  83153. * @param space Space to rotate in (Default: local)
  83154. * @returns the TransformNode.
  83155. */
  83156. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  83157. /**
  83158. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  83159. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83160. * The passed axis is also normalized. .
  83161. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  83162. * @param point the point to rotate around
  83163. * @param axis the axis to rotate around
  83164. * @param amount the amount to rotate in radians
  83165. * @returns the TransformNode
  83166. */
  83167. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  83168. /**
  83169. * Translates the mesh along the axis vector for the passed distance in the given space.
  83170. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83171. * @param axis the axis to translate in
  83172. * @param distance the distance to translate
  83173. * @param space Space to rotate in (Default: local)
  83174. * @returns the TransformNode.
  83175. */
  83176. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  83177. /**
  83178. * Adds a rotation step to the mesh current rotation.
  83179. * x, y, z are Euler angles expressed in radians.
  83180. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  83181. * This means this rotation is made in the mesh local space only.
  83182. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  83183. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  83184. * ```javascript
  83185. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  83186. * ```
  83187. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  83188. * 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.
  83189. * @param x Rotation to add
  83190. * @param y Rotation to add
  83191. * @param z Rotation to add
  83192. * @returns the TransformNode.
  83193. */
  83194. addRotation(x: number, y: number, z: number): TransformNode;
  83195. /**
  83196. * @hidden
  83197. */
  83198. protected _getEffectiveParent(): Nullable<Node>;
  83199. /**
  83200. * Computes the world matrix of the node
  83201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83202. * @returns the world matrix
  83203. */
  83204. computeWorldMatrix(force?: boolean): Matrix;
  83205. protected _afterComputeWorldMatrix(): void;
  83206. /**
  83207. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  83208. * @param func callback function to add
  83209. *
  83210. * @returns the TransformNode.
  83211. */
  83212. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83213. /**
  83214. * Removes a registered callback function.
  83215. * @param func callback function to remove
  83216. * @returns the TransformNode.
  83217. */
  83218. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83219. /**
  83220. * Gets the position of the current mesh in camera space
  83221. * @param camera defines the camera to use
  83222. * @returns a position
  83223. */
  83224. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  83225. /**
  83226. * Returns the distance from the mesh to the active camera
  83227. * @param camera defines the camera to use
  83228. * @returns the distance
  83229. */
  83230. getDistanceToCamera(camera?: Nullable<Camera>): number;
  83231. /**
  83232. * Clone the current transform node
  83233. * @param name Name of the new clone
  83234. * @param newParent New parent for the clone
  83235. * @param doNotCloneChildren Do not clone children hierarchy
  83236. * @returns the new transform node
  83237. */
  83238. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  83239. /**
  83240. * Serializes the objects information.
  83241. * @param currentSerializationObject defines the object to serialize in
  83242. * @returns the serialized object
  83243. */
  83244. serialize(currentSerializationObject?: any): any;
  83245. /**
  83246. * Returns a new TransformNode object parsed from the source provided.
  83247. * @param parsedTransformNode is the source.
  83248. * @param scene the scne the object belongs to
  83249. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  83250. * @returns a new TransformNode object parsed from the source provided.
  83251. */
  83252. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  83253. /**
  83254. * Get all child-transformNodes of this node
  83255. * @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
  83256. * @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
  83257. * @returns an array of TransformNode
  83258. */
  83259. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  83260. /**
  83261. * Releases resources associated with this transform node.
  83262. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83263. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83264. */
  83265. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83266. /**
  83267. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83268. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83269. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83270. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  83271. * @returns the current mesh
  83272. */
  83273. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  83274. private _syncAbsoluteScalingAndRotation;
  83275. }
  83276. }
  83277. declare module BABYLON {
  83278. /**
  83279. * Defines the types of pose enabled controllers that are supported
  83280. */
  83281. export enum PoseEnabledControllerType {
  83282. /**
  83283. * HTC Vive
  83284. */
  83285. VIVE = 0,
  83286. /**
  83287. * Oculus Rift
  83288. */
  83289. OCULUS = 1,
  83290. /**
  83291. * Windows mixed reality
  83292. */
  83293. WINDOWS = 2,
  83294. /**
  83295. * Samsung gear VR
  83296. */
  83297. GEAR_VR = 3,
  83298. /**
  83299. * Google Daydream
  83300. */
  83301. DAYDREAM = 4,
  83302. /**
  83303. * Generic
  83304. */
  83305. GENERIC = 5
  83306. }
  83307. /**
  83308. * Defines the MutableGamepadButton interface for the state of a gamepad button
  83309. */
  83310. export interface MutableGamepadButton {
  83311. /**
  83312. * Value of the button/trigger
  83313. */
  83314. value: number;
  83315. /**
  83316. * If the button/trigger is currently touched
  83317. */
  83318. touched: boolean;
  83319. /**
  83320. * If the button/trigger is currently pressed
  83321. */
  83322. pressed: boolean;
  83323. }
  83324. /**
  83325. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  83326. * @hidden
  83327. */
  83328. export interface ExtendedGamepadButton extends GamepadButton {
  83329. /**
  83330. * If the button/trigger is currently pressed
  83331. */
  83332. readonly pressed: boolean;
  83333. /**
  83334. * If the button/trigger is currently touched
  83335. */
  83336. readonly touched: boolean;
  83337. /**
  83338. * Value of the button/trigger
  83339. */
  83340. readonly value: number;
  83341. }
  83342. /** @hidden */
  83343. export interface _GamePadFactory {
  83344. /**
  83345. * Returns wether or not the current gamepad can be created for this type of controller.
  83346. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83347. * @returns true if it can be created, otherwise false
  83348. */
  83349. canCreate(gamepadInfo: any): boolean;
  83350. /**
  83351. * Creates a new instance of the Gamepad.
  83352. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83353. * @returns the new gamepad instance
  83354. */
  83355. create(gamepadInfo: any): Gamepad;
  83356. }
  83357. /**
  83358. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83359. */
  83360. export class PoseEnabledControllerHelper {
  83361. /** @hidden */
  83362. static _ControllerFactories: _GamePadFactory[];
  83363. /** @hidden */
  83364. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  83365. /**
  83366. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83367. * @param vrGamepad the gamepad to initialized
  83368. * @returns a vr controller of the type the gamepad identified as
  83369. */
  83370. static InitiateController(vrGamepad: any): Gamepad;
  83371. }
  83372. /**
  83373. * Defines the PoseEnabledController object that contains state of a vr capable controller
  83374. */
  83375. export class PoseEnabledController extends Gamepad implements PoseControlled {
  83376. /**
  83377. * If the controller is used in a webXR session
  83378. */
  83379. isXR: boolean;
  83380. private _deviceRoomPosition;
  83381. private _deviceRoomRotationQuaternion;
  83382. /**
  83383. * The device position in babylon space
  83384. */
  83385. devicePosition: Vector3;
  83386. /**
  83387. * The device rotation in babylon space
  83388. */
  83389. deviceRotationQuaternion: Quaternion;
  83390. /**
  83391. * The scale factor of the device in babylon space
  83392. */
  83393. deviceScaleFactor: number;
  83394. /**
  83395. * (Likely devicePosition should be used instead) The device position in its room space
  83396. */
  83397. position: Vector3;
  83398. /**
  83399. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  83400. */
  83401. rotationQuaternion: Quaternion;
  83402. /**
  83403. * The type of controller (Eg. Windows mixed reality)
  83404. */
  83405. controllerType: PoseEnabledControllerType;
  83406. protected _calculatedPosition: Vector3;
  83407. private _calculatedRotation;
  83408. /**
  83409. * The raw pose from the device
  83410. */
  83411. rawPose: DevicePose;
  83412. private _trackPosition;
  83413. private _maxRotationDistFromHeadset;
  83414. private _draggedRoomRotation;
  83415. /**
  83416. * @hidden
  83417. */
  83418. _disableTrackPosition(fixedPosition: Vector3): void;
  83419. /**
  83420. * Internal, the mesh attached to the controller
  83421. * @hidden
  83422. */
  83423. _mesh: Nullable<AbstractMesh>;
  83424. private _poseControlledCamera;
  83425. private _leftHandSystemQuaternion;
  83426. /**
  83427. * Internal, matrix used to convert room space to babylon space
  83428. * @hidden
  83429. */
  83430. _deviceToWorld: Matrix;
  83431. /**
  83432. * Node to be used when casting a ray from the controller
  83433. * @hidden
  83434. */
  83435. _pointingPoseNode: Nullable<TransformNode>;
  83436. /**
  83437. * Name of the child mesh that can be used to cast a ray from the controller
  83438. */
  83439. static readonly POINTING_POSE: string;
  83440. /**
  83441. * Creates a new PoseEnabledController from a gamepad
  83442. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  83443. */
  83444. constructor(browserGamepad: any);
  83445. private _workingMatrix;
  83446. /**
  83447. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  83448. */
  83449. update(): void;
  83450. /**
  83451. * Updates only the pose device and mesh without doing any button event checking
  83452. */
  83453. protected _updatePoseAndMesh(): void;
  83454. /**
  83455. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  83456. * @param poseData raw pose fromthe device
  83457. */
  83458. updateFromDevice(poseData: DevicePose): void;
  83459. /**
  83460. * @hidden
  83461. */
  83462. _meshAttachedObservable: Observable<AbstractMesh>;
  83463. /**
  83464. * Attaches a mesh to the controller
  83465. * @param mesh the mesh to be attached
  83466. */
  83467. attachToMesh(mesh: AbstractMesh): void;
  83468. /**
  83469. * Attaches the controllers mesh to a camera
  83470. * @param camera the camera the mesh should be attached to
  83471. */
  83472. attachToPoseControlledCamera(camera: TargetCamera): void;
  83473. /**
  83474. * Disposes of the controller
  83475. */
  83476. dispose(): void;
  83477. /**
  83478. * The mesh that is attached to the controller
  83479. */
  83480. readonly mesh: Nullable<AbstractMesh>;
  83481. /**
  83482. * Gets the ray of the controller in the direction the controller is pointing
  83483. * @param length the length the resulting ray should be
  83484. * @returns a ray in the direction the controller is pointing
  83485. */
  83486. getForwardRay(length?: number): Ray;
  83487. }
  83488. }
  83489. declare module BABYLON {
  83490. /**
  83491. * Defines the WebVRController object that represents controllers tracked in 3D space
  83492. */
  83493. export abstract class WebVRController extends PoseEnabledController {
  83494. /**
  83495. * Internal, the default controller model for the controller
  83496. */
  83497. protected _defaultModel: Nullable<AbstractMesh>;
  83498. /**
  83499. * Fired when the trigger state has changed
  83500. */
  83501. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  83502. /**
  83503. * Fired when the main button state has changed
  83504. */
  83505. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83506. /**
  83507. * Fired when the secondary button state has changed
  83508. */
  83509. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83510. /**
  83511. * Fired when the pad state has changed
  83512. */
  83513. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  83514. /**
  83515. * Fired when controllers stick values have changed
  83516. */
  83517. onPadValuesChangedObservable: Observable<StickValues>;
  83518. /**
  83519. * Array of button availible on the controller
  83520. */
  83521. protected _buttons: Array<MutableGamepadButton>;
  83522. private _onButtonStateChange;
  83523. /**
  83524. * Fired when a controller button's state has changed
  83525. * @param callback the callback containing the button that was modified
  83526. */
  83527. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  83528. /**
  83529. * X and Y axis corresponding to the controllers joystick
  83530. */
  83531. pad: StickValues;
  83532. /**
  83533. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  83534. */
  83535. hand: string;
  83536. /**
  83537. * The default controller model for the controller
  83538. */
  83539. readonly defaultModel: Nullable<AbstractMesh>;
  83540. /**
  83541. * Creates a new WebVRController from a gamepad
  83542. * @param vrGamepad the gamepad that the WebVRController should be created from
  83543. */
  83544. constructor(vrGamepad: any);
  83545. /**
  83546. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  83547. */
  83548. update(): void;
  83549. /**
  83550. * Function to be called when a button is modified
  83551. */
  83552. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  83553. /**
  83554. * Loads a mesh and attaches it to the controller
  83555. * @param scene the scene the mesh should be added to
  83556. * @param meshLoaded callback for when the mesh has been loaded
  83557. */
  83558. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  83559. private _setButtonValue;
  83560. private _changes;
  83561. private _checkChanges;
  83562. /**
  83563. * Disposes of th webVRCOntroller
  83564. */
  83565. dispose(): void;
  83566. }
  83567. }
  83568. declare module BABYLON {
  83569. /**
  83570. * The HemisphericLight simulates the ambient environment light,
  83571. * so the passed direction is the light reflection direction, not the incoming direction.
  83572. */
  83573. export class HemisphericLight extends Light {
  83574. /**
  83575. * The groundColor is the light in the opposite direction to the one specified during creation.
  83576. * 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.
  83577. */
  83578. groundColor: Color3;
  83579. /**
  83580. * The light reflection direction, not the incoming direction.
  83581. */
  83582. direction: Vector3;
  83583. /**
  83584. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  83585. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  83586. * The HemisphericLight can't cast shadows.
  83587. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83588. * @param name The friendly name of the light
  83589. * @param direction The direction of the light reflection
  83590. * @param scene The scene the light belongs to
  83591. */
  83592. constructor(name: string, direction: Vector3, scene: Scene);
  83593. protected _buildUniformLayout(): void;
  83594. /**
  83595. * Returns the string "HemisphericLight".
  83596. * @return The class name
  83597. */
  83598. getClassName(): string;
  83599. /**
  83600. * Sets the HemisphericLight direction towards the passed target (Vector3).
  83601. * Returns the updated direction.
  83602. * @param target The target the direction should point to
  83603. * @return The computed direction
  83604. */
  83605. setDirectionToTarget(target: Vector3): Vector3;
  83606. /**
  83607. * Returns the shadow generator associated to the light.
  83608. * @returns Always null for hemispheric lights because it does not support shadows.
  83609. */
  83610. getShadowGenerator(): Nullable<IShadowGenerator>;
  83611. /**
  83612. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  83613. * @param effect The effect to update
  83614. * @param lightIndex The index of the light in the effect to update
  83615. * @returns The hemispheric light
  83616. */
  83617. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  83618. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  83619. /**
  83620. * Computes the world matrix of the node
  83621. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83622. * @param useWasUpdatedFlag defines a reserved property
  83623. * @returns the world matrix
  83624. */
  83625. computeWorldMatrix(): Matrix;
  83626. /**
  83627. * Returns the integer 3.
  83628. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83629. */
  83630. getTypeID(): number;
  83631. /**
  83632. * Prepares the list of defines specific to the light type.
  83633. * @param defines the list of defines
  83634. * @param lightIndex defines the index of the light for the effect
  83635. */
  83636. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83637. }
  83638. }
  83639. declare module BABYLON {
  83640. /** @hidden */
  83641. export var vrMultiviewToSingleviewPixelShader: {
  83642. name: string;
  83643. shader: string;
  83644. };
  83645. }
  83646. declare module BABYLON {
  83647. /**
  83648. * Renders to multiple views with a single draw call
  83649. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  83650. */
  83651. export class MultiviewRenderTarget extends RenderTargetTexture {
  83652. /**
  83653. * Creates a multiview render target
  83654. * @param scene scene used with the render target
  83655. * @param size the size of the render target (used for each view)
  83656. */
  83657. constructor(scene: Scene, size?: number | {
  83658. width: number;
  83659. height: number;
  83660. } | {
  83661. ratio: number;
  83662. });
  83663. /**
  83664. * @hidden
  83665. * @param faceIndex the face index, if its a cube texture
  83666. */
  83667. _bindFrameBuffer(faceIndex?: number): void;
  83668. /**
  83669. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83670. * @returns the view count
  83671. */
  83672. getViewCount(): number;
  83673. }
  83674. }
  83675. declare module BABYLON {
  83676. /**
  83677. * Represents a camera frustum
  83678. */
  83679. export class Frustum {
  83680. /**
  83681. * Gets the planes representing the frustum
  83682. * @param transform matrix to be applied to the returned planes
  83683. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  83684. */
  83685. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  83686. /**
  83687. * Gets the near frustum plane transformed by the transform matrix
  83688. * @param transform transformation matrix to be applied to the resulting frustum plane
  83689. * @param frustumPlane the resuling frustum plane
  83690. */
  83691. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83692. /**
  83693. * Gets the far frustum plane transformed by the transform matrix
  83694. * @param transform transformation matrix to be applied to the resulting frustum plane
  83695. * @param frustumPlane the resuling frustum plane
  83696. */
  83697. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83698. /**
  83699. * Gets the left frustum plane transformed by the transform matrix
  83700. * @param transform transformation matrix to be applied to the resulting frustum plane
  83701. * @param frustumPlane the resuling frustum plane
  83702. */
  83703. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83704. /**
  83705. * Gets the right frustum plane transformed by the transform matrix
  83706. * @param transform transformation matrix to be applied to the resulting frustum plane
  83707. * @param frustumPlane the resuling frustum plane
  83708. */
  83709. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83710. /**
  83711. * Gets the top frustum plane transformed by the transform matrix
  83712. * @param transform transformation matrix to be applied to the resulting frustum plane
  83713. * @param frustumPlane the resuling frustum plane
  83714. */
  83715. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83716. /**
  83717. * Gets the bottom frustum plane transformed by the transform matrix
  83718. * @param transform transformation matrix to be applied to the resulting frustum plane
  83719. * @param frustumPlane the resuling frustum plane
  83720. */
  83721. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83722. /**
  83723. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83724. * @param transform transformation matrix to be applied to the resulting frustum planes
  83725. * @param frustumPlanes the resuling frustum planes
  83726. */
  83727. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83728. }
  83729. }
  83730. declare module BABYLON {
  83731. interface Engine {
  83732. /**
  83733. * Creates a new multiview render target
  83734. * @param width defines the width of the texture
  83735. * @param height defines the height of the texture
  83736. * @returns the created multiview texture
  83737. */
  83738. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83739. /**
  83740. * Binds a multiview framebuffer to be drawn to
  83741. * @param multiviewTexture texture to bind
  83742. */
  83743. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83744. }
  83745. interface Camera {
  83746. /**
  83747. * @hidden
  83748. * 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)
  83749. */
  83750. _useMultiviewToSingleView: boolean;
  83751. /**
  83752. * @hidden
  83753. * 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)
  83754. */
  83755. _multiviewTexture: Nullable<RenderTargetTexture>;
  83756. /**
  83757. * @hidden
  83758. * ensures the multiview texture of the camera exists and has the specified width/height
  83759. * @param width height to set on the multiview texture
  83760. * @param height width to set on the multiview texture
  83761. */
  83762. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83763. }
  83764. interface Scene {
  83765. /** @hidden */
  83766. _transformMatrixR: Matrix;
  83767. /** @hidden */
  83768. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83769. /** @hidden */
  83770. _createMultiviewUbo(): void;
  83771. /** @hidden */
  83772. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83773. /** @hidden */
  83774. _renderMultiviewToSingleView(camera: Camera): void;
  83775. }
  83776. }
  83777. declare module BABYLON {
  83778. /**
  83779. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83780. * This will not be used for webXR as it supports displaying texture arrays directly
  83781. */
  83782. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83783. /**
  83784. * Initializes a VRMultiviewToSingleview
  83785. * @param name name of the post process
  83786. * @param camera camera to be applied to
  83787. * @param scaleFactor scaling factor to the size of the output texture
  83788. */
  83789. constructor(name: string, camera: Camera, scaleFactor: number);
  83790. }
  83791. }
  83792. declare module BABYLON {
  83793. /**
  83794. * Interface used to define additional presentation attributes
  83795. */
  83796. export interface IVRPresentationAttributes {
  83797. /**
  83798. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83799. */
  83800. highRefreshRate: boolean;
  83801. /**
  83802. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83803. */
  83804. foveationLevel: number;
  83805. }
  83806. interface Engine {
  83807. /** @hidden */
  83808. _vrDisplay: any;
  83809. /** @hidden */
  83810. _vrSupported: boolean;
  83811. /** @hidden */
  83812. _oldSize: Size;
  83813. /** @hidden */
  83814. _oldHardwareScaleFactor: number;
  83815. /** @hidden */
  83816. _vrExclusivePointerMode: boolean;
  83817. /** @hidden */
  83818. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83819. /** @hidden */
  83820. _onVRDisplayPointerRestricted: () => void;
  83821. /** @hidden */
  83822. _onVRDisplayPointerUnrestricted: () => void;
  83823. /** @hidden */
  83824. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83825. /** @hidden */
  83826. _onVrDisplayDisconnect: Nullable<() => void>;
  83827. /** @hidden */
  83828. _onVrDisplayPresentChange: Nullable<() => void>;
  83829. /**
  83830. * Observable signaled when VR display mode changes
  83831. */
  83832. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83833. /**
  83834. * Observable signaled when VR request present is complete
  83835. */
  83836. onVRRequestPresentComplete: Observable<boolean>;
  83837. /**
  83838. * Observable signaled when VR request present starts
  83839. */
  83840. onVRRequestPresentStart: Observable<Engine>;
  83841. /**
  83842. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83843. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83844. */
  83845. isInVRExclusivePointerMode: boolean;
  83846. /**
  83847. * Gets a boolean indicating if a webVR device was detected
  83848. * @returns true if a webVR device was detected
  83849. */
  83850. isVRDevicePresent(): boolean;
  83851. /**
  83852. * Gets the current webVR device
  83853. * @returns the current webVR device (or null)
  83854. */
  83855. getVRDevice(): any;
  83856. /**
  83857. * Initializes a webVR display and starts listening to display change events
  83858. * The onVRDisplayChangedObservable will be notified upon these changes
  83859. * @returns A promise containing a VRDisplay and if vr is supported
  83860. */
  83861. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83862. /** @hidden */
  83863. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83864. /**
  83865. * Gets or sets the presentation attributes used to configure VR rendering
  83866. */
  83867. vrPresentationAttributes?: IVRPresentationAttributes;
  83868. /**
  83869. * Call this function to switch to webVR mode
  83870. * Will do nothing if webVR is not supported or if there is no webVR device
  83871. * @param options the webvr options provided to the camera. mainly used for multiview
  83872. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83873. */
  83874. enableVR(options: WebVROptions): void;
  83875. /** @hidden */
  83876. _onVRFullScreenTriggered(): void;
  83877. }
  83878. }
  83879. declare module BABYLON {
  83880. /**
  83881. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83882. * IMPORTANT!! The data is right-hand data.
  83883. * @export
  83884. * @interface DevicePose
  83885. */
  83886. export interface DevicePose {
  83887. /**
  83888. * The position of the device, values in array are [x,y,z].
  83889. */
  83890. readonly position: Nullable<Float32Array>;
  83891. /**
  83892. * The linearVelocity of the device, values in array are [x,y,z].
  83893. */
  83894. readonly linearVelocity: Nullable<Float32Array>;
  83895. /**
  83896. * The linearAcceleration of the device, values in array are [x,y,z].
  83897. */
  83898. readonly linearAcceleration: Nullable<Float32Array>;
  83899. /**
  83900. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83901. */
  83902. readonly orientation: Nullable<Float32Array>;
  83903. /**
  83904. * The angularVelocity of the device, values in array are [x,y,z].
  83905. */
  83906. readonly angularVelocity: Nullable<Float32Array>;
  83907. /**
  83908. * The angularAcceleration of the device, values in array are [x,y,z].
  83909. */
  83910. readonly angularAcceleration: Nullable<Float32Array>;
  83911. }
  83912. /**
  83913. * Interface representing a pose controlled object in Babylon.
  83914. * A pose controlled object has both regular pose values as well as pose values
  83915. * from an external device such as a VR head mounted display
  83916. */
  83917. export interface PoseControlled {
  83918. /**
  83919. * The position of the object in babylon space.
  83920. */
  83921. position: Vector3;
  83922. /**
  83923. * The rotation quaternion of the object in babylon space.
  83924. */
  83925. rotationQuaternion: Quaternion;
  83926. /**
  83927. * The position of the device in babylon space.
  83928. */
  83929. devicePosition?: Vector3;
  83930. /**
  83931. * The rotation quaternion of the device in babylon space.
  83932. */
  83933. deviceRotationQuaternion: Quaternion;
  83934. /**
  83935. * The raw pose coming from the device.
  83936. */
  83937. rawPose: Nullable<DevicePose>;
  83938. /**
  83939. * The scale of the device to be used when translating from device space to babylon space.
  83940. */
  83941. deviceScaleFactor: number;
  83942. /**
  83943. * Updates the poseControlled values based on the input device pose.
  83944. * @param poseData the pose data to update the object with
  83945. */
  83946. updateFromDevice(poseData: DevicePose): void;
  83947. }
  83948. /**
  83949. * Set of options to customize the webVRCamera
  83950. */
  83951. export interface WebVROptions {
  83952. /**
  83953. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83954. */
  83955. trackPosition?: boolean;
  83956. /**
  83957. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83958. */
  83959. positionScale?: number;
  83960. /**
  83961. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83962. */
  83963. displayName?: string;
  83964. /**
  83965. * Should the native controller meshes be initialized. (default: true)
  83966. */
  83967. controllerMeshes?: boolean;
  83968. /**
  83969. * Creating a default HemiLight only on controllers. (default: true)
  83970. */
  83971. defaultLightingOnControllers?: boolean;
  83972. /**
  83973. * If you don't want to use the default VR button of the helper. (default: false)
  83974. */
  83975. useCustomVRButton?: boolean;
  83976. /**
  83977. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83978. */
  83979. customVRButton?: HTMLButtonElement;
  83980. /**
  83981. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83982. */
  83983. rayLength?: number;
  83984. /**
  83985. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83986. */
  83987. defaultHeight?: number;
  83988. /**
  83989. * If multiview should be used if availible (default: false)
  83990. */
  83991. useMultiview?: boolean;
  83992. }
  83993. /**
  83994. * This represents a WebVR camera.
  83995. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83996. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83997. */
  83998. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83999. private webVROptions;
  84000. /**
  84001. * @hidden
  84002. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  84003. */
  84004. _vrDevice: any;
  84005. /**
  84006. * The rawPose of the vrDevice.
  84007. */
  84008. rawPose: Nullable<DevicePose>;
  84009. private _onVREnabled;
  84010. private _specsVersion;
  84011. private _attached;
  84012. private _frameData;
  84013. protected _descendants: Array<Node>;
  84014. private _deviceRoomPosition;
  84015. /** @hidden */
  84016. _deviceRoomRotationQuaternion: Quaternion;
  84017. private _standingMatrix;
  84018. /**
  84019. * Represents device position in babylon space.
  84020. */
  84021. devicePosition: Vector3;
  84022. /**
  84023. * Represents device rotation in babylon space.
  84024. */
  84025. deviceRotationQuaternion: Quaternion;
  84026. /**
  84027. * The scale of the device to be used when translating from device space to babylon space.
  84028. */
  84029. deviceScaleFactor: number;
  84030. private _deviceToWorld;
  84031. private _worldToDevice;
  84032. /**
  84033. * References to the webVR controllers for the vrDevice.
  84034. */
  84035. controllers: Array<WebVRController>;
  84036. /**
  84037. * Emits an event when a controller is attached.
  84038. */
  84039. onControllersAttachedObservable: Observable<WebVRController[]>;
  84040. /**
  84041. * Emits an event when a controller's mesh has been loaded;
  84042. */
  84043. onControllerMeshLoadedObservable: Observable<WebVRController>;
  84044. /**
  84045. * Emits an event when the HMD's pose has been updated.
  84046. */
  84047. onPoseUpdatedFromDeviceObservable: Observable<any>;
  84048. private _poseSet;
  84049. /**
  84050. * If the rig cameras be used as parent instead of this camera.
  84051. */
  84052. rigParenting: boolean;
  84053. private _lightOnControllers;
  84054. private _defaultHeight?;
  84055. /**
  84056. * Instantiates a WebVRFreeCamera.
  84057. * @param name The name of the WebVRFreeCamera
  84058. * @param position The starting anchor position for the camera
  84059. * @param scene The scene the camera belongs to
  84060. * @param webVROptions a set of customizable options for the webVRCamera
  84061. */
  84062. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  84063. /**
  84064. * Gets the device distance from the ground in meters.
  84065. * @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.
  84066. */
  84067. deviceDistanceToRoomGround(): number;
  84068. /**
  84069. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84070. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  84071. */
  84072. useStandingMatrix(callback?: (bool: boolean) => void): void;
  84073. /**
  84074. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84075. * @returns A promise with a boolean set to if the standing matrix is supported.
  84076. */
  84077. useStandingMatrixAsync(): Promise<boolean>;
  84078. /**
  84079. * Disposes the camera
  84080. */
  84081. dispose(): void;
  84082. /**
  84083. * Gets a vrController by name.
  84084. * @param name The name of the controller to retreive
  84085. * @returns the controller matching the name specified or null if not found
  84086. */
  84087. getControllerByName(name: string): Nullable<WebVRController>;
  84088. private _leftController;
  84089. /**
  84090. * The controller corresponding to the users left hand.
  84091. */
  84092. readonly leftController: Nullable<WebVRController>;
  84093. private _rightController;
  84094. /**
  84095. * The controller corresponding to the users right hand.
  84096. */
  84097. readonly rightController: Nullable<WebVRController>;
  84098. /**
  84099. * Casts a ray forward from the vrCamera's gaze.
  84100. * @param length Length of the ray (default: 100)
  84101. * @returns the ray corresponding to the gaze
  84102. */
  84103. getForwardRay(length?: number): Ray;
  84104. /**
  84105. * @hidden
  84106. * Updates the camera based on device's frame data
  84107. */
  84108. _checkInputs(): void;
  84109. /**
  84110. * Updates the poseControlled values based on the input device pose.
  84111. * @param poseData Pose coming from the device
  84112. */
  84113. updateFromDevice(poseData: DevicePose): void;
  84114. private _htmlElementAttached;
  84115. private _detachIfAttached;
  84116. /**
  84117. * WebVR's attach control will start broadcasting frames to the device.
  84118. * Note that in certain browsers (chrome for example) this function must be called
  84119. * within a user-interaction callback. Example:
  84120. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  84121. *
  84122. * @param element html element to attach the vrDevice to
  84123. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  84124. */
  84125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84126. /**
  84127. * Detaches the camera from the html element and disables VR
  84128. *
  84129. * @param element html element to detach from
  84130. */
  84131. detachControl(element: HTMLElement): void;
  84132. /**
  84133. * @returns the name of this class
  84134. */
  84135. getClassName(): string;
  84136. /**
  84137. * Calls resetPose on the vrDisplay
  84138. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  84139. */
  84140. resetToCurrentRotation(): void;
  84141. /**
  84142. * @hidden
  84143. * Updates the rig cameras (left and right eye)
  84144. */
  84145. _updateRigCameras(): void;
  84146. private _workingVector;
  84147. private _oneVector;
  84148. private _workingMatrix;
  84149. private updateCacheCalled;
  84150. private _correctPositionIfNotTrackPosition;
  84151. /**
  84152. * @hidden
  84153. * Updates the cached values of the camera
  84154. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  84155. */
  84156. _updateCache(ignoreParentClass?: boolean): void;
  84157. /**
  84158. * @hidden
  84159. * Get current device position in babylon world
  84160. */
  84161. _computeDevicePosition(): void;
  84162. /**
  84163. * Updates the current device position and rotation in the babylon world
  84164. */
  84165. update(): void;
  84166. /**
  84167. * @hidden
  84168. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  84169. * @returns an identity matrix
  84170. */
  84171. _getViewMatrix(): Matrix;
  84172. private _tmpMatrix;
  84173. /**
  84174. * This function is called by the two RIG cameras.
  84175. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  84176. * @hidden
  84177. */
  84178. _getWebVRViewMatrix(): Matrix;
  84179. /** @hidden */
  84180. _getWebVRProjectionMatrix(): Matrix;
  84181. private _onGamepadConnectedObserver;
  84182. private _onGamepadDisconnectedObserver;
  84183. private _updateCacheWhenTrackingDisabledObserver;
  84184. /**
  84185. * Initializes the controllers and their meshes
  84186. */
  84187. initControllers(): void;
  84188. }
  84189. }
  84190. declare module BABYLON {
  84191. /**
  84192. * Size options for a post process
  84193. */
  84194. export type PostProcessOptions = {
  84195. width: number;
  84196. height: number;
  84197. };
  84198. /**
  84199. * PostProcess can be used to apply a shader to a texture after it has been rendered
  84200. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84201. */
  84202. export class PostProcess {
  84203. /** Name of the PostProcess. */
  84204. name: string;
  84205. /**
  84206. * Gets or sets the unique id of the post process
  84207. */
  84208. uniqueId: number;
  84209. /**
  84210. * Width of the texture to apply the post process on
  84211. */
  84212. width: number;
  84213. /**
  84214. * Height of the texture to apply the post process on
  84215. */
  84216. height: number;
  84217. /**
  84218. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  84219. * @hidden
  84220. */
  84221. _outputTexture: Nullable<InternalTexture>;
  84222. /**
  84223. * Sampling mode used by the shader
  84224. * See https://doc.babylonjs.com/classes/3.1/texture
  84225. */
  84226. renderTargetSamplingMode: number;
  84227. /**
  84228. * Clear color to use when screen clearing
  84229. */
  84230. clearColor: Color4;
  84231. /**
  84232. * If the buffer needs to be cleared before applying the post process. (default: true)
  84233. * Should be set to false if shader will overwrite all previous pixels.
  84234. */
  84235. autoClear: boolean;
  84236. /**
  84237. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  84238. */
  84239. alphaMode: number;
  84240. /**
  84241. * Sets the setAlphaBlendConstants of the babylon engine
  84242. */
  84243. alphaConstants: Color4;
  84244. /**
  84245. * Animations to be used for the post processing
  84246. */
  84247. animations: Animation[];
  84248. /**
  84249. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  84250. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  84251. */
  84252. enablePixelPerfectMode: boolean;
  84253. /**
  84254. * Force the postprocess to be applied without taking in account viewport
  84255. */
  84256. forceFullscreenViewport: boolean;
  84257. /**
  84258. * List of inspectable custom properties (used by the Inspector)
  84259. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84260. */
  84261. inspectableCustomProperties: IInspectable[];
  84262. /**
  84263. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  84264. *
  84265. * | Value | Type | Description |
  84266. * | ----- | ----------------------------------- | ----------- |
  84267. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  84268. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  84269. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  84270. *
  84271. */
  84272. scaleMode: number;
  84273. /**
  84274. * Force textures to be a power of two (default: false)
  84275. */
  84276. alwaysForcePOT: boolean;
  84277. private _samples;
  84278. /**
  84279. * Number of sample textures (default: 1)
  84280. */
  84281. samples: number;
  84282. /**
  84283. * Modify the scale of the post process to be the same as the viewport (default: false)
  84284. */
  84285. adaptScaleToCurrentViewport: boolean;
  84286. private _camera;
  84287. private _scene;
  84288. private _engine;
  84289. private _options;
  84290. private _reusable;
  84291. private _textureType;
  84292. /**
  84293. * Smart array of input and output textures for the post process.
  84294. * @hidden
  84295. */
  84296. _textures: SmartArray<InternalTexture>;
  84297. /**
  84298. * The index in _textures that corresponds to the output texture.
  84299. * @hidden
  84300. */
  84301. _currentRenderTextureInd: number;
  84302. private _effect;
  84303. private _samplers;
  84304. private _fragmentUrl;
  84305. private _vertexUrl;
  84306. private _parameters;
  84307. private _scaleRatio;
  84308. protected _indexParameters: any;
  84309. private _shareOutputWithPostProcess;
  84310. private _texelSize;
  84311. private _forcedOutputTexture;
  84312. /**
  84313. * Returns the fragment url or shader name used in the post process.
  84314. * @returns the fragment url or name in the shader store.
  84315. */
  84316. getEffectName(): string;
  84317. /**
  84318. * An event triggered when the postprocess is activated.
  84319. */
  84320. onActivateObservable: Observable<Camera>;
  84321. private _onActivateObserver;
  84322. /**
  84323. * A function that is added to the onActivateObservable
  84324. */
  84325. onActivate: Nullable<(camera: Camera) => void>;
  84326. /**
  84327. * An event triggered when the postprocess changes its size.
  84328. */
  84329. onSizeChangedObservable: Observable<PostProcess>;
  84330. private _onSizeChangedObserver;
  84331. /**
  84332. * A function that is added to the onSizeChangedObservable
  84333. */
  84334. onSizeChanged: (postProcess: PostProcess) => void;
  84335. /**
  84336. * An event triggered when the postprocess applies its effect.
  84337. */
  84338. onApplyObservable: Observable<Effect>;
  84339. private _onApplyObserver;
  84340. /**
  84341. * A function that is added to the onApplyObservable
  84342. */
  84343. onApply: (effect: Effect) => void;
  84344. /**
  84345. * An event triggered before rendering the postprocess
  84346. */
  84347. onBeforeRenderObservable: Observable<Effect>;
  84348. private _onBeforeRenderObserver;
  84349. /**
  84350. * A function that is added to the onBeforeRenderObservable
  84351. */
  84352. onBeforeRender: (effect: Effect) => void;
  84353. /**
  84354. * An event triggered after rendering the postprocess
  84355. */
  84356. onAfterRenderObservable: Observable<Effect>;
  84357. private _onAfterRenderObserver;
  84358. /**
  84359. * A function that is added to the onAfterRenderObservable
  84360. */
  84361. onAfterRender: (efect: Effect) => void;
  84362. /**
  84363. * 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
  84364. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  84365. */
  84366. inputTexture: InternalTexture;
  84367. /**
  84368. * Gets the camera which post process is applied to.
  84369. * @returns The camera the post process is applied to.
  84370. */
  84371. getCamera(): Camera;
  84372. /**
  84373. * Gets the texel size of the postprocess.
  84374. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  84375. */
  84376. readonly texelSize: Vector2;
  84377. /**
  84378. * Creates a new instance PostProcess
  84379. * @param name The name of the PostProcess.
  84380. * @param fragmentUrl The url of the fragment shader to be used.
  84381. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  84382. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  84383. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84384. * @param camera The camera to apply the render pass to.
  84385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84386. * @param engine The engine which the post process will be applied. (default: current engine)
  84387. * @param reusable If the post process can be reused on the same frame. (default: false)
  84388. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  84389. * @param textureType Type of textures used when performing the post process. (default: 0)
  84390. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  84391. * @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
  84392. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  84393. */
  84394. constructor(
  84395. /** Name of the PostProcess. */
  84396. 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);
  84397. /**
  84398. * Gets a string idenfifying the name of the class
  84399. * @returns "PostProcess" string
  84400. */
  84401. getClassName(): string;
  84402. /**
  84403. * Gets the engine which this post process belongs to.
  84404. * @returns The engine the post process was enabled with.
  84405. */
  84406. getEngine(): Engine;
  84407. /**
  84408. * The effect that is created when initializing the post process.
  84409. * @returns The created effect corresponding the the postprocess.
  84410. */
  84411. getEffect(): Effect;
  84412. /**
  84413. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  84414. * @param postProcess The post process to share the output with.
  84415. * @returns This post process.
  84416. */
  84417. shareOutputWith(postProcess: PostProcess): PostProcess;
  84418. /**
  84419. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  84420. * This should be called if the post process that shares output with this post process is disabled/disposed.
  84421. */
  84422. useOwnOutput(): void;
  84423. /**
  84424. * Updates the effect with the current post process compile time values and recompiles the shader.
  84425. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84426. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84427. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84428. * @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
  84429. * @param onCompiled Called when the shader has been compiled.
  84430. * @param onError Called if there is an error when compiling a shader.
  84431. */
  84432. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84433. /**
  84434. * The post process is reusable if it can be used multiple times within one frame.
  84435. * @returns If the post process is reusable
  84436. */
  84437. isReusable(): boolean;
  84438. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  84439. markTextureDirty(): void;
  84440. /**
  84441. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  84442. * 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.
  84443. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  84444. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  84445. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  84446. * @returns The target texture that was bound to be written to.
  84447. */
  84448. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  84449. /**
  84450. * If the post process is supported.
  84451. */
  84452. readonly isSupported: boolean;
  84453. /**
  84454. * The aspect ratio of the output texture.
  84455. */
  84456. readonly aspectRatio: number;
  84457. /**
  84458. * Get a value indicating if the post-process is ready to be used
  84459. * @returns true if the post-process is ready (shader is compiled)
  84460. */
  84461. isReady(): boolean;
  84462. /**
  84463. * Binds all textures and uniforms to the shader, this will be run on every pass.
  84464. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  84465. */
  84466. apply(): Nullable<Effect>;
  84467. private _disposeTextures;
  84468. /**
  84469. * Disposes the post process.
  84470. * @param camera The camera to dispose the post process on.
  84471. */
  84472. dispose(camera?: Camera): void;
  84473. }
  84474. }
  84475. declare module BABYLON {
  84476. /** @hidden */
  84477. export var kernelBlurVaryingDeclaration: {
  84478. name: string;
  84479. shader: string;
  84480. };
  84481. }
  84482. declare module BABYLON {
  84483. /** @hidden */
  84484. export var kernelBlurFragment: {
  84485. name: string;
  84486. shader: string;
  84487. };
  84488. }
  84489. declare module BABYLON {
  84490. /** @hidden */
  84491. export var kernelBlurFragment2: {
  84492. name: string;
  84493. shader: string;
  84494. };
  84495. }
  84496. declare module BABYLON {
  84497. /** @hidden */
  84498. export var kernelBlurPixelShader: {
  84499. name: string;
  84500. shader: string;
  84501. };
  84502. }
  84503. declare module BABYLON {
  84504. /** @hidden */
  84505. export var kernelBlurVertex: {
  84506. name: string;
  84507. shader: string;
  84508. };
  84509. }
  84510. declare module BABYLON {
  84511. /** @hidden */
  84512. export var kernelBlurVertexShader: {
  84513. name: string;
  84514. shader: string;
  84515. };
  84516. }
  84517. declare module BABYLON {
  84518. /**
  84519. * The Blur Post Process which blurs an image based on a kernel and direction.
  84520. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  84521. */
  84522. export class BlurPostProcess extends PostProcess {
  84523. /** The direction in which to blur the image. */
  84524. direction: Vector2;
  84525. private blockCompilation;
  84526. protected _kernel: number;
  84527. protected _idealKernel: number;
  84528. protected _packedFloat: boolean;
  84529. private _staticDefines;
  84530. /**
  84531. * Sets the length in pixels of the blur sample region
  84532. */
  84533. /**
  84534. * Gets the length in pixels of the blur sample region
  84535. */
  84536. kernel: number;
  84537. /**
  84538. * Sets wether or not the blur needs to unpack/repack floats
  84539. */
  84540. /**
  84541. * Gets wether or not the blur is unpacking/repacking floats
  84542. */
  84543. packedFloat: boolean;
  84544. /**
  84545. * Creates a new instance BlurPostProcess
  84546. * @param name The name of the effect.
  84547. * @param direction The direction in which to blur the image.
  84548. * @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.
  84549. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84550. * @param camera The camera to apply the render pass to.
  84551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84552. * @param engine The engine which the post process will be applied. (default: current engine)
  84553. * @param reusable If the post process can be reused on the same frame. (default: false)
  84554. * @param textureType Type of textures used when performing the post process. (default: 0)
  84555. * @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)
  84556. */
  84557. constructor(name: string,
  84558. /** The direction in which to blur the image. */
  84559. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  84560. /**
  84561. * Updates the effect with the current post process compile time values and recompiles the shader.
  84562. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84563. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84564. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84565. * @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
  84566. * @param onCompiled Called when the shader has been compiled.
  84567. * @param onError Called if there is an error when compiling a shader.
  84568. */
  84569. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84570. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84571. /**
  84572. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  84573. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  84574. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  84575. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  84576. * The gaps between physical kernels are compensated for in the weighting of the samples
  84577. * @param idealKernel Ideal blur kernel.
  84578. * @return Nearest best kernel.
  84579. */
  84580. protected _nearestBestKernel(idealKernel: number): number;
  84581. /**
  84582. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  84583. * @param x The point on the Gaussian distribution to sample.
  84584. * @return the value of the Gaussian function at x.
  84585. */
  84586. protected _gaussianWeight(x: number): number;
  84587. /**
  84588. * Generates a string that can be used as a floating point number in GLSL.
  84589. * @param x Value to print.
  84590. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  84591. * @return GLSL float string.
  84592. */
  84593. protected _glslFloat(x: number, decimalFigures?: number): string;
  84594. }
  84595. }
  84596. declare module BABYLON {
  84597. /**
  84598. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84599. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84600. * You can then easily use it as a reflectionTexture on a flat surface.
  84601. * In case the surface is not a plane, please consider relying on reflection probes.
  84602. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84603. */
  84604. export class MirrorTexture extends RenderTargetTexture {
  84605. private scene;
  84606. /**
  84607. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  84608. * 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.
  84609. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84610. */
  84611. mirrorPlane: Plane;
  84612. /**
  84613. * Define the blur ratio used to blur the reflection if needed.
  84614. */
  84615. blurRatio: number;
  84616. /**
  84617. * Define the adaptive blur kernel used to blur the reflection if needed.
  84618. * This will autocompute the closest best match for the `blurKernel`
  84619. */
  84620. adaptiveBlurKernel: number;
  84621. /**
  84622. * Define the blur kernel used to blur the reflection if needed.
  84623. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84624. */
  84625. blurKernel: number;
  84626. /**
  84627. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  84628. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84629. */
  84630. blurKernelX: number;
  84631. /**
  84632. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  84633. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84634. */
  84635. blurKernelY: number;
  84636. private _autoComputeBlurKernel;
  84637. protected _onRatioRescale(): void;
  84638. private _updateGammaSpace;
  84639. private _imageProcessingConfigChangeObserver;
  84640. private _transformMatrix;
  84641. private _mirrorMatrix;
  84642. private _savedViewMatrix;
  84643. private _blurX;
  84644. private _blurY;
  84645. private _adaptiveBlurKernel;
  84646. private _blurKernelX;
  84647. private _blurKernelY;
  84648. private _blurRatio;
  84649. /**
  84650. * Instantiates a Mirror Texture.
  84651. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84652. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84653. * You can then easily use it as a reflectionTexture on a flat surface.
  84654. * In case the surface is not a plane, please consider relying on reflection probes.
  84655. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84656. * @param name
  84657. * @param size
  84658. * @param scene
  84659. * @param generateMipMaps
  84660. * @param type
  84661. * @param samplingMode
  84662. * @param generateDepthBuffer
  84663. */
  84664. constructor(name: string, size: number | {
  84665. width: number;
  84666. height: number;
  84667. } | {
  84668. ratio: number;
  84669. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  84670. private _preparePostProcesses;
  84671. /**
  84672. * Clone the mirror texture.
  84673. * @returns the cloned texture
  84674. */
  84675. clone(): MirrorTexture;
  84676. /**
  84677. * Serialize the texture to a JSON representation you could use in Parse later on
  84678. * @returns the serialized JSON representation
  84679. */
  84680. serialize(): any;
  84681. /**
  84682. * Dispose the texture and release its associated resources.
  84683. */
  84684. dispose(): void;
  84685. }
  84686. }
  84687. declare module BABYLON {
  84688. /**
  84689. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84690. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84691. */
  84692. export class Texture extends BaseTexture {
  84693. /**
  84694. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  84695. */
  84696. static SerializeBuffers: boolean;
  84697. /** @hidden */
  84698. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  84699. /** @hidden */
  84700. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  84701. /** @hidden */
  84702. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  84703. /** nearest is mag = nearest and min = nearest and mip = linear */
  84704. static readonly NEAREST_SAMPLINGMODE: number;
  84705. /** nearest is mag = nearest and min = nearest and mip = linear */
  84706. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  84707. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84708. static readonly BILINEAR_SAMPLINGMODE: number;
  84709. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84710. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  84711. /** Trilinear is mag = linear and min = linear and mip = linear */
  84712. static readonly TRILINEAR_SAMPLINGMODE: number;
  84713. /** Trilinear is mag = linear and min = linear and mip = linear */
  84714. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  84715. /** mag = nearest and min = nearest and mip = nearest */
  84716. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84717. /** mag = nearest and min = linear and mip = nearest */
  84718. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84719. /** mag = nearest and min = linear and mip = linear */
  84720. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84721. /** mag = nearest and min = linear and mip = none */
  84722. static readonly NEAREST_LINEAR: number;
  84723. /** mag = nearest and min = nearest and mip = none */
  84724. static readonly NEAREST_NEAREST: number;
  84725. /** mag = linear and min = nearest and mip = nearest */
  84726. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84727. /** mag = linear and min = nearest and mip = linear */
  84728. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84729. /** mag = linear and min = linear and mip = none */
  84730. static readonly LINEAR_LINEAR: number;
  84731. /** mag = linear and min = nearest and mip = none */
  84732. static readonly LINEAR_NEAREST: number;
  84733. /** Explicit coordinates mode */
  84734. static readonly EXPLICIT_MODE: number;
  84735. /** Spherical coordinates mode */
  84736. static readonly SPHERICAL_MODE: number;
  84737. /** Planar coordinates mode */
  84738. static readonly PLANAR_MODE: number;
  84739. /** Cubic coordinates mode */
  84740. static readonly CUBIC_MODE: number;
  84741. /** Projection coordinates mode */
  84742. static readonly PROJECTION_MODE: number;
  84743. /** Inverse Cubic coordinates mode */
  84744. static readonly SKYBOX_MODE: number;
  84745. /** Inverse Cubic coordinates mode */
  84746. static readonly INVCUBIC_MODE: number;
  84747. /** Equirectangular coordinates mode */
  84748. static readonly EQUIRECTANGULAR_MODE: number;
  84749. /** Equirectangular Fixed coordinates mode */
  84750. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84751. /** Equirectangular Fixed Mirrored coordinates mode */
  84752. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84753. /** Texture is not repeating outside of 0..1 UVs */
  84754. static readonly CLAMP_ADDRESSMODE: number;
  84755. /** Texture is repeating outside of 0..1 UVs */
  84756. static readonly WRAP_ADDRESSMODE: number;
  84757. /** Texture is repeating and mirrored */
  84758. static readonly MIRROR_ADDRESSMODE: number;
  84759. /**
  84760. * 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
  84761. */
  84762. static UseSerializedUrlIfAny: boolean;
  84763. /**
  84764. * Define the url of the texture.
  84765. */
  84766. url: Nullable<string>;
  84767. /**
  84768. * Define an offset on the texture to offset the u coordinates of the UVs
  84769. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84770. */
  84771. uOffset: number;
  84772. /**
  84773. * Define an offset on the texture to offset the v coordinates of the UVs
  84774. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84775. */
  84776. vOffset: number;
  84777. /**
  84778. * Define an offset on the texture to scale the u coordinates of the UVs
  84779. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84780. */
  84781. uScale: number;
  84782. /**
  84783. * Define an offset on the texture to scale the v coordinates of the UVs
  84784. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84785. */
  84786. vScale: number;
  84787. /**
  84788. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84789. * @see http://doc.babylonjs.com/how_to/more_materials
  84790. */
  84791. uAng: number;
  84792. /**
  84793. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84794. * @see http://doc.babylonjs.com/how_to/more_materials
  84795. */
  84796. vAng: number;
  84797. /**
  84798. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84799. * @see http://doc.babylonjs.com/how_to/more_materials
  84800. */
  84801. wAng: number;
  84802. /**
  84803. * Defines the center of rotation (U)
  84804. */
  84805. uRotationCenter: number;
  84806. /**
  84807. * Defines the center of rotation (V)
  84808. */
  84809. vRotationCenter: number;
  84810. /**
  84811. * Defines the center of rotation (W)
  84812. */
  84813. wRotationCenter: number;
  84814. /**
  84815. * Are mip maps generated for this texture or not.
  84816. */
  84817. readonly noMipmap: boolean;
  84818. /**
  84819. * List of inspectable custom properties (used by the Inspector)
  84820. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84821. */
  84822. inspectableCustomProperties: Nullable<IInspectable[]>;
  84823. private _noMipmap;
  84824. /** @hidden */
  84825. _invertY: boolean;
  84826. private _rowGenerationMatrix;
  84827. private _cachedTextureMatrix;
  84828. private _projectionModeMatrix;
  84829. private _t0;
  84830. private _t1;
  84831. private _t2;
  84832. private _cachedUOffset;
  84833. private _cachedVOffset;
  84834. private _cachedUScale;
  84835. private _cachedVScale;
  84836. private _cachedUAng;
  84837. private _cachedVAng;
  84838. private _cachedWAng;
  84839. private _cachedProjectionMatrixId;
  84840. private _cachedCoordinatesMode;
  84841. /** @hidden */
  84842. protected _initialSamplingMode: number;
  84843. /** @hidden */
  84844. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84845. private _deleteBuffer;
  84846. protected _format: Nullable<number>;
  84847. private _delayedOnLoad;
  84848. private _delayedOnError;
  84849. private _mimeType?;
  84850. /**
  84851. * Observable triggered once the texture has been loaded.
  84852. */
  84853. onLoadObservable: Observable<Texture>;
  84854. protected _isBlocking: boolean;
  84855. /**
  84856. * Is the texture preventing material to render while loading.
  84857. * If false, a default texture will be used instead of the loading one during the preparation step.
  84858. */
  84859. isBlocking: boolean;
  84860. /**
  84861. * Get the current sampling mode associated with the texture.
  84862. */
  84863. readonly samplingMode: number;
  84864. /**
  84865. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84866. */
  84867. readonly invertY: boolean;
  84868. /**
  84869. * Instantiates a new texture.
  84870. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84871. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84872. * @param url defines the url of the picture to load as a texture
  84873. * @param scene defines the scene or engine the texture will belong to
  84874. * @param noMipmap defines if the texture will require mip maps or not
  84875. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84876. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84877. * @param onLoad defines a callback triggered when the texture has been loaded
  84878. * @param onError defines a callback triggered when an error occurred during the loading session
  84879. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84880. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84881. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84882. * @param mimeType defines an optional mime type information
  84883. */
  84884. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  84885. /**
  84886. * Update the url (and optional buffer) of this texture if url was null during construction.
  84887. * @param url the url of the texture
  84888. * @param buffer the buffer of the texture (defaults to null)
  84889. * @param onLoad callback called when the texture is loaded (defaults to null)
  84890. */
  84891. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84892. /**
  84893. * Finish the loading sequence of a texture flagged as delayed load.
  84894. * @hidden
  84895. */
  84896. delayLoad(): void;
  84897. private _prepareRowForTextureGeneration;
  84898. /**
  84899. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84900. * @returns the transform matrix of the texture.
  84901. */
  84902. getTextureMatrix(uBase?: number): Matrix;
  84903. /**
  84904. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84905. * @returns The reflection texture transform
  84906. */
  84907. getReflectionTextureMatrix(): Matrix;
  84908. /**
  84909. * Clones the texture.
  84910. * @returns the cloned texture
  84911. */
  84912. clone(): Texture;
  84913. /**
  84914. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84915. * @returns The JSON representation of the texture
  84916. */
  84917. serialize(): any;
  84918. /**
  84919. * Get the current class name of the texture useful for serialization or dynamic coding.
  84920. * @returns "Texture"
  84921. */
  84922. getClassName(): string;
  84923. /**
  84924. * Dispose the texture and release its associated resources.
  84925. */
  84926. dispose(): void;
  84927. /**
  84928. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  84929. * @param parsedTexture Define the JSON representation of the texture
  84930. * @param scene Define the scene the parsed texture should be instantiated in
  84931. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  84932. * @returns The parsed texture if successful
  84933. */
  84934. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84935. /**
  84936. * Creates a texture from its base 64 representation.
  84937. * @param data Define the base64 payload without the data: prefix
  84938. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84939. * @param scene Define the scene the texture should belong to
  84940. * @param noMipmap Forces the texture to not create mip map information if true
  84941. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84942. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84943. * @param onLoad define a callback triggered when the texture has been loaded
  84944. * @param onError define a callback triggered when an error occurred during the loading session
  84945. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84946. * @returns the created texture
  84947. */
  84948. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84949. /**
  84950. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84951. * @param data Define the base64 payload without the data: prefix
  84952. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84953. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84954. * @param scene Define the scene the texture should belong to
  84955. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84956. * @param noMipmap Forces the texture to not create mip map information if true
  84957. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84958. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84959. * @param onLoad define a callback triggered when the texture has been loaded
  84960. * @param onError define a callback triggered when an error occurred during the loading session
  84961. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84962. * @returns the created texture
  84963. */
  84964. 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;
  84965. }
  84966. }
  84967. declare module BABYLON {
  84968. /**
  84969. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84970. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84971. */
  84972. export class PostProcessManager {
  84973. private _scene;
  84974. private _indexBuffer;
  84975. private _vertexBuffers;
  84976. /**
  84977. * Creates a new instance PostProcess
  84978. * @param scene The scene that the post process is associated with.
  84979. */
  84980. constructor(scene: Scene);
  84981. private _prepareBuffers;
  84982. private _buildIndexBuffer;
  84983. /**
  84984. * Rebuilds the vertex buffers of the manager.
  84985. * @hidden
  84986. */
  84987. _rebuild(): void;
  84988. /**
  84989. * Prepares a frame to be run through a post process.
  84990. * @param sourceTexture The input texture to the post procesess. (default: null)
  84991. * @param postProcesses An array of post processes to be run. (default: null)
  84992. * @returns True if the post processes were able to be run.
  84993. * @hidden
  84994. */
  84995. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84996. /**
  84997. * Manually render a set of post processes to a texture.
  84998. * @param postProcesses An array of post processes to be run.
  84999. * @param targetTexture The target texture to render to.
  85000. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  85001. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  85002. * @param lodLevel defines which lod of the texture to render to
  85003. */
  85004. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  85005. /**
  85006. * Finalize the result of the output of the postprocesses.
  85007. * @param doNotPresent If true the result will not be displayed to the screen.
  85008. * @param targetTexture The target texture to render to.
  85009. * @param faceIndex The index of the face to bind the target texture to.
  85010. * @param postProcesses The array of post processes to render.
  85011. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  85012. * @hidden
  85013. */
  85014. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  85015. /**
  85016. * Disposes of the post process manager.
  85017. */
  85018. dispose(): void;
  85019. }
  85020. }
  85021. declare module BABYLON {
  85022. /** Interface used by value gradients (color, factor, ...) */
  85023. export interface IValueGradient {
  85024. /**
  85025. * Gets or sets the gradient value (between 0 and 1)
  85026. */
  85027. gradient: number;
  85028. }
  85029. /** Class used to store color4 gradient */
  85030. export class ColorGradient implements IValueGradient {
  85031. /**
  85032. * Gets or sets the gradient value (between 0 and 1)
  85033. */
  85034. gradient: number;
  85035. /**
  85036. * Gets or sets first associated color
  85037. */
  85038. color1: Color4;
  85039. /**
  85040. * Gets or sets second associated color
  85041. */
  85042. color2?: Color4;
  85043. /**
  85044. * Will get a color picked randomly between color1 and color2.
  85045. * If color2 is undefined then color1 will be used
  85046. * @param result defines the target Color4 to store the result in
  85047. */
  85048. getColorToRef(result: Color4): void;
  85049. }
  85050. /** Class used to store color 3 gradient */
  85051. export class Color3Gradient implements IValueGradient {
  85052. /**
  85053. * Gets or sets the gradient value (between 0 and 1)
  85054. */
  85055. gradient: number;
  85056. /**
  85057. * Gets or sets the associated color
  85058. */
  85059. color: Color3;
  85060. }
  85061. /** Class used to store factor gradient */
  85062. export class FactorGradient implements IValueGradient {
  85063. /**
  85064. * Gets or sets the gradient value (between 0 and 1)
  85065. */
  85066. gradient: number;
  85067. /**
  85068. * Gets or sets first associated factor
  85069. */
  85070. factor1: number;
  85071. /**
  85072. * Gets or sets second associated factor
  85073. */
  85074. factor2?: number;
  85075. /**
  85076. * Will get a number picked randomly between factor1 and factor2.
  85077. * If factor2 is undefined then factor1 will be used
  85078. * @returns the picked number
  85079. */
  85080. getFactor(): number;
  85081. }
  85082. /**
  85083. * Helper used to simplify some generic gradient tasks
  85084. */
  85085. export class GradientHelper {
  85086. /**
  85087. * Gets the current gradient from an array of IValueGradient
  85088. * @param ratio defines the current ratio to get
  85089. * @param gradients defines the array of IValueGradient
  85090. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  85091. */
  85092. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  85093. }
  85094. }
  85095. declare module BABYLON {
  85096. interface ThinEngine {
  85097. /**
  85098. * Creates a dynamic texture
  85099. * @param width defines the width of the texture
  85100. * @param height defines the height of the texture
  85101. * @param generateMipMaps defines if the engine should generate the mip levels
  85102. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85103. * @returns the dynamic texture inside an InternalTexture
  85104. */
  85105. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85106. /**
  85107. * Update the content of a dynamic texture
  85108. * @param texture defines the texture to update
  85109. * @param canvas defines the canvas containing the source
  85110. * @param invertY defines if data must be stored with Y axis inverted
  85111. * @param premulAlpha defines if alpha is stored as premultiplied
  85112. * @param format defines the format of the data
  85113. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85114. */
  85115. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85116. }
  85117. }
  85118. declare module BABYLON {
  85119. /**
  85120. * Helper class used to generate a canvas to manipulate images
  85121. */
  85122. export class CanvasGenerator {
  85123. /**
  85124. * Create a new canvas (or offscreen canvas depending on the context)
  85125. * @param width defines the expected width
  85126. * @param height defines the expected height
  85127. * @return a new canvas or offscreen canvas
  85128. */
  85129. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  85130. }
  85131. }
  85132. declare module BABYLON {
  85133. /**
  85134. * A class extending Texture allowing drawing on a texture
  85135. * @see http://doc.babylonjs.com/how_to/dynamictexture
  85136. */
  85137. export class DynamicTexture extends Texture {
  85138. private _generateMipMaps;
  85139. private _canvas;
  85140. private _context;
  85141. private _engine;
  85142. /**
  85143. * Creates a DynamicTexture
  85144. * @param name defines the name of the texture
  85145. * @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
  85146. * @param scene defines the scene where you want the texture
  85147. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  85148. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  85149. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  85150. */
  85151. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  85152. /**
  85153. * Get the current class name of the texture useful for serialization or dynamic coding.
  85154. * @returns "DynamicTexture"
  85155. */
  85156. getClassName(): string;
  85157. /**
  85158. * Gets the current state of canRescale
  85159. */
  85160. readonly canRescale: boolean;
  85161. private _recreate;
  85162. /**
  85163. * Scales the texture
  85164. * @param ratio the scale factor to apply to both width and height
  85165. */
  85166. scale(ratio: number): void;
  85167. /**
  85168. * Resizes the texture
  85169. * @param width the new width
  85170. * @param height the new height
  85171. */
  85172. scaleTo(width: number, height: number): void;
  85173. /**
  85174. * Gets the context of the canvas used by the texture
  85175. * @returns the canvas context of the dynamic texture
  85176. */
  85177. getContext(): CanvasRenderingContext2D;
  85178. /**
  85179. * Clears the texture
  85180. */
  85181. clear(): void;
  85182. /**
  85183. * Updates the texture
  85184. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85185. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  85186. */
  85187. update(invertY?: boolean, premulAlpha?: boolean): void;
  85188. /**
  85189. * Draws text onto the texture
  85190. * @param text defines the text to be drawn
  85191. * @param x defines the placement of the text from the left
  85192. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  85193. * @param font defines the font to be used with font-style, font-size, font-name
  85194. * @param color defines the color used for the text
  85195. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  85196. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85197. * @param update defines whether texture is immediately update (default is true)
  85198. */
  85199. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  85200. /**
  85201. * Clones the texture
  85202. * @returns the clone of the texture.
  85203. */
  85204. clone(): DynamicTexture;
  85205. /**
  85206. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  85207. * @returns a serialized dynamic texture object
  85208. */
  85209. serialize(): any;
  85210. /** @hidden */
  85211. _rebuild(): void;
  85212. }
  85213. }
  85214. declare module BABYLON {
  85215. interface AbstractScene {
  85216. /**
  85217. * The list of procedural textures added to the scene
  85218. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85219. */
  85220. proceduralTextures: Array<ProceduralTexture>;
  85221. }
  85222. /**
  85223. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85224. * in a given scene.
  85225. */
  85226. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85227. /**
  85228. * The component name helpfull to identify the component in the list of scene components.
  85229. */
  85230. readonly name: string;
  85231. /**
  85232. * The scene the component belongs to.
  85233. */
  85234. scene: Scene;
  85235. /**
  85236. * Creates a new instance of the component for the given scene
  85237. * @param scene Defines the scene to register the component in
  85238. */
  85239. constructor(scene: Scene);
  85240. /**
  85241. * Registers the component in a given scene
  85242. */
  85243. register(): void;
  85244. /**
  85245. * Rebuilds the elements related to this component in case of
  85246. * context lost for instance.
  85247. */
  85248. rebuild(): void;
  85249. /**
  85250. * Disposes the component and the associated ressources.
  85251. */
  85252. dispose(): void;
  85253. private _beforeClear;
  85254. }
  85255. }
  85256. declare module BABYLON {
  85257. interface ThinEngine {
  85258. /**
  85259. * Creates a new render target cube texture
  85260. * @param size defines the size of the texture
  85261. * @param options defines the options used to create the texture
  85262. * @returns a new render target cube texture stored in an InternalTexture
  85263. */
  85264. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85265. }
  85266. }
  85267. declare module BABYLON {
  85268. /** @hidden */
  85269. export var proceduralVertexShader: {
  85270. name: string;
  85271. shader: string;
  85272. };
  85273. }
  85274. declare module BABYLON {
  85275. /**
  85276. * 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.
  85277. * This is the base class of any Procedural texture and contains most of the shareable code.
  85278. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85279. */
  85280. export class ProceduralTexture extends Texture {
  85281. isCube: boolean;
  85282. /**
  85283. * Define if the texture is enabled or not (disabled texture will not render)
  85284. */
  85285. isEnabled: boolean;
  85286. /**
  85287. * Define if the texture must be cleared before rendering (default is true)
  85288. */
  85289. autoClear: boolean;
  85290. /**
  85291. * Callback called when the texture is generated
  85292. */
  85293. onGenerated: () => void;
  85294. /**
  85295. * Event raised when the texture is generated
  85296. */
  85297. onGeneratedObservable: Observable<ProceduralTexture>;
  85298. /** @hidden */
  85299. _generateMipMaps: boolean;
  85300. /** @hidden **/
  85301. _effect: Effect;
  85302. /** @hidden */
  85303. _textures: {
  85304. [key: string]: Texture;
  85305. };
  85306. private _size;
  85307. private _currentRefreshId;
  85308. private _refreshRate;
  85309. private _vertexBuffers;
  85310. private _indexBuffer;
  85311. private _uniforms;
  85312. private _samplers;
  85313. private _fragment;
  85314. private _floats;
  85315. private _ints;
  85316. private _floatsArrays;
  85317. private _colors3;
  85318. private _colors4;
  85319. private _vectors2;
  85320. private _vectors3;
  85321. private _matrices;
  85322. private _fallbackTexture;
  85323. private _fallbackTextureUsed;
  85324. private _engine;
  85325. private _cachedDefines;
  85326. private _contentUpdateId;
  85327. private _contentData;
  85328. /**
  85329. * Instantiates a new procedural texture.
  85330. * 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.
  85331. * This is the base class of any Procedural texture and contains most of the shareable code.
  85332. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85333. * @param name Define the name of the texture
  85334. * @param size Define the size of the texture to create
  85335. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85336. * @param scene Define the scene the texture belongs to
  85337. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85338. * @param generateMipMaps Define if the texture should creates mip maps or not
  85339. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85340. */
  85341. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85342. /**
  85343. * The effect that is created when initializing the post process.
  85344. * @returns The created effect corresponding the the postprocess.
  85345. */
  85346. getEffect(): Effect;
  85347. /**
  85348. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85349. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85350. */
  85351. getContent(): Nullable<ArrayBufferView>;
  85352. private _createIndexBuffer;
  85353. /** @hidden */
  85354. _rebuild(): void;
  85355. /**
  85356. * Resets the texture in order to recreate its associated resources.
  85357. * This can be called in case of context loss
  85358. */
  85359. reset(): void;
  85360. protected _getDefines(): string;
  85361. /**
  85362. * Is the texture ready to be used ? (rendered at least once)
  85363. * @returns true if ready, otherwise, false.
  85364. */
  85365. isReady(): boolean;
  85366. /**
  85367. * Resets the refresh counter of the texture and start bak from scratch.
  85368. * Could be useful to regenerate the texture if it is setup to render only once.
  85369. */
  85370. resetRefreshCounter(): void;
  85371. /**
  85372. * Set the fragment shader to use in order to render the texture.
  85373. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85374. */
  85375. setFragment(fragment: any): void;
  85376. /**
  85377. * Define the refresh rate of the texture or the rendering frequency.
  85378. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85379. */
  85380. refreshRate: number;
  85381. /** @hidden */
  85382. _shouldRender(): boolean;
  85383. /**
  85384. * Get the size the texture is rendering at.
  85385. * @returns the size (texture is always squared)
  85386. */
  85387. getRenderSize(): number;
  85388. /**
  85389. * Resize the texture to new value.
  85390. * @param size Define the new size the texture should have
  85391. * @param generateMipMaps Define whether the new texture should create mip maps
  85392. */
  85393. resize(size: number, generateMipMaps: boolean): void;
  85394. private _checkUniform;
  85395. /**
  85396. * Set a texture in the shader program used to render.
  85397. * @param name Define the name of the uniform samplers as defined in the shader
  85398. * @param texture Define the texture to bind to this sampler
  85399. * @return the texture itself allowing "fluent" like uniform updates
  85400. */
  85401. setTexture(name: string, texture: Texture): ProceduralTexture;
  85402. /**
  85403. * Set a float in the shader.
  85404. * @param name Define the name of the uniform as defined in the shader
  85405. * @param value Define the value to give to the uniform
  85406. * @return the texture itself allowing "fluent" like uniform updates
  85407. */
  85408. setFloat(name: string, value: number): ProceduralTexture;
  85409. /**
  85410. * Set a int in the shader.
  85411. * @param name Define the name of the uniform as defined in the shader
  85412. * @param value Define the value to give to the uniform
  85413. * @return the texture itself allowing "fluent" like uniform updates
  85414. */
  85415. setInt(name: string, value: number): ProceduralTexture;
  85416. /**
  85417. * Set an array of floats in the shader.
  85418. * @param name Define the name of the uniform as defined in the shader
  85419. * @param value Define the value to give to the uniform
  85420. * @return the texture itself allowing "fluent" like uniform updates
  85421. */
  85422. setFloats(name: string, value: number[]): ProceduralTexture;
  85423. /**
  85424. * Set a vec3 in the shader from a Color3.
  85425. * @param name Define the name of the uniform as defined in the shader
  85426. * @param value Define the value to give to the uniform
  85427. * @return the texture itself allowing "fluent" like uniform updates
  85428. */
  85429. setColor3(name: string, value: Color3): ProceduralTexture;
  85430. /**
  85431. * Set a vec4 in the shader from a Color4.
  85432. * @param name Define the name of the uniform as defined in the shader
  85433. * @param value Define the value to give to the uniform
  85434. * @return the texture itself allowing "fluent" like uniform updates
  85435. */
  85436. setColor4(name: string, value: Color4): ProceduralTexture;
  85437. /**
  85438. * Set a vec2 in the shader from a Vector2.
  85439. * @param name Define the name of the uniform as defined in the shader
  85440. * @param value Define the value to give to the uniform
  85441. * @return the texture itself allowing "fluent" like uniform updates
  85442. */
  85443. setVector2(name: string, value: Vector2): ProceduralTexture;
  85444. /**
  85445. * Set a vec3 in the shader from a Vector3.
  85446. * @param name Define the name of the uniform as defined in the shader
  85447. * @param value Define the value to give to the uniform
  85448. * @return the texture itself allowing "fluent" like uniform updates
  85449. */
  85450. setVector3(name: string, value: Vector3): ProceduralTexture;
  85451. /**
  85452. * Set a mat4 in the shader from a MAtrix.
  85453. * @param name Define the name of the uniform as defined in the shader
  85454. * @param value Define the value to give to the uniform
  85455. * @return the texture itself allowing "fluent" like uniform updates
  85456. */
  85457. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85458. /**
  85459. * Render the texture to its associated render target.
  85460. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85461. */
  85462. render(useCameraPostProcess?: boolean): void;
  85463. /**
  85464. * Clone the texture.
  85465. * @returns the cloned texture
  85466. */
  85467. clone(): ProceduralTexture;
  85468. /**
  85469. * Dispose the texture and release its asoociated resources.
  85470. */
  85471. dispose(): void;
  85472. }
  85473. }
  85474. declare module BABYLON {
  85475. /**
  85476. * This represents the base class for particle system in Babylon.
  85477. * 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.
  85478. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85479. * @example https://doc.babylonjs.com/babylon101/particles
  85480. */
  85481. export class BaseParticleSystem {
  85482. /**
  85483. * Source color is added to the destination color without alpha affecting the result
  85484. */
  85485. static BLENDMODE_ONEONE: number;
  85486. /**
  85487. * Blend current color and particle color using particle’s alpha
  85488. */
  85489. static BLENDMODE_STANDARD: number;
  85490. /**
  85491. * Add current color and particle color multiplied by particle’s alpha
  85492. */
  85493. static BLENDMODE_ADD: number;
  85494. /**
  85495. * Multiply current color with particle color
  85496. */
  85497. static BLENDMODE_MULTIPLY: number;
  85498. /**
  85499. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85500. */
  85501. static BLENDMODE_MULTIPLYADD: number;
  85502. /**
  85503. * List of animations used by the particle system.
  85504. */
  85505. animations: Animation[];
  85506. /**
  85507. * The id of the Particle system.
  85508. */
  85509. id: string;
  85510. /**
  85511. * The friendly name of the Particle system.
  85512. */
  85513. name: string;
  85514. /**
  85515. * The rendering group used by the Particle system to chose when to render.
  85516. */
  85517. renderingGroupId: number;
  85518. /**
  85519. * The emitter represents the Mesh or position we are attaching the particle system to.
  85520. */
  85521. emitter: Nullable<AbstractMesh | Vector3>;
  85522. /**
  85523. * The maximum number of particles to emit per frame
  85524. */
  85525. emitRate: number;
  85526. /**
  85527. * If you want to launch only a few particles at once, that can be done, as well.
  85528. */
  85529. manualEmitCount: number;
  85530. /**
  85531. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85532. */
  85533. updateSpeed: number;
  85534. /**
  85535. * The amount of time the particle system is running (depends of the overall update speed).
  85536. */
  85537. targetStopDuration: number;
  85538. /**
  85539. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85540. */
  85541. disposeOnStop: boolean;
  85542. /**
  85543. * Minimum power of emitting particles.
  85544. */
  85545. minEmitPower: number;
  85546. /**
  85547. * Maximum power of emitting particles.
  85548. */
  85549. maxEmitPower: number;
  85550. /**
  85551. * Minimum life time of emitting particles.
  85552. */
  85553. minLifeTime: number;
  85554. /**
  85555. * Maximum life time of emitting particles.
  85556. */
  85557. maxLifeTime: number;
  85558. /**
  85559. * Minimum Size of emitting particles.
  85560. */
  85561. minSize: number;
  85562. /**
  85563. * Maximum Size of emitting particles.
  85564. */
  85565. maxSize: number;
  85566. /**
  85567. * Minimum scale of emitting particles on X axis.
  85568. */
  85569. minScaleX: number;
  85570. /**
  85571. * Maximum scale of emitting particles on X axis.
  85572. */
  85573. maxScaleX: number;
  85574. /**
  85575. * Minimum scale of emitting particles on Y axis.
  85576. */
  85577. minScaleY: number;
  85578. /**
  85579. * Maximum scale of emitting particles on Y axis.
  85580. */
  85581. maxScaleY: number;
  85582. /**
  85583. * Gets or sets the minimal initial rotation in radians.
  85584. */
  85585. minInitialRotation: number;
  85586. /**
  85587. * Gets or sets the maximal initial rotation in radians.
  85588. */
  85589. maxInitialRotation: number;
  85590. /**
  85591. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85592. */
  85593. minAngularSpeed: number;
  85594. /**
  85595. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85596. */
  85597. maxAngularSpeed: number;
  85598. /**
  85599. * The texture used to render each particle. (this can be a spritesheet)
  85600. */
  85601. particleTexture: Nullable<Texture>;
  85602. /**
  85603. * The layer mask we are rendering the particles through.
  85604. */
  85605. layerMask: number;
  85606. /**
  85607. * This can help using your own shader to render the particle system.
  85608. * The according effect will be created
  85609. */
  85610. customShader: any;
  85611. /**
  85612. * By default particle system starts as soon as they are created. This prevents the
  85613. * automatic start to happen and let you decide when to start emitting particles.
  85614. */
  85615. preventAutoStart: boolean;
  85616. private _noiseTexture;
  85617. /**
  85618. * Gets or sets a texture used to add random noise to particle positions
  85619. */
  85620. noiseTexture: Nullable<ProceduralTexture>;
  85621. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85622. noiseStrength: Vector3;
  85623. /**
  85624. * Callback triggered when the particle animation is ending.
  85625. */
  85626. onAnimationEnd: Nullable<() => void>;
  85627. /**
  85628. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85629. */
  85630. blendMode: number;
  85631. /**
  85632. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85633. * to override the particles.
  85634. */
  85635. forceDepthWrite: boolean;
  85636. /** 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 */
  85637. preWarmCycles: number;
  85638. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85639. preWarmStepOffset: number;
  85640. /**
  85641. * 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)
  85642. */
  85643. spriteCellChangeSpeed: number;
  85644. /**
  85645. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85646. */
  85647. startSpriteCellID: number;
  85648. /**
  85649. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85650. */
  85651. endSpriteCellID: number;
  85652. /**
  85653. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85654. */
  85655. spriteCellWidth: number;
  85656. /**
  85657. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85658. */
  85659. spriteCellHeight: number;
  85660. /**
  85661. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85662. */
  85663. spriteRandomStartCell: boolean;
  85664. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85665. translationPivot: Vector2;
  85666. /** @hidden */
  85667. protected _isAnimationSheetEnabled: boolean;
  85668. /**
  85669. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85670. */
  85671. beginAnimationOnStart: boolean;
  85672. /**
  85673. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85674. */
  85675. beginAnimationFrom: number;
  85676. /**
  85677. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85678. */
  85679. beginAnimationTo: number;
  85680. /**
  85681. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85682. */
  85683. beginAnimationLoop: boolean;
  85684. /**
  85685. * Gets or sets a world offset applied to all particles
  85686. */
  85687. worldOffset: Vector3;
  85688. /**
  85689. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85690. */
  85691. isAnimationSheetEnabled: boolean;
  85692. /**
  85693. * Get hosting scene
  85694. * @returns the scene
  85695. */
  85696. getScene(): Scene;
  85697. /**
  85698. * You can use gravity if you want to give an orientation to your particles.
  85699. */
  85700. gravity: Vector3;
  85701. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85702. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85703. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85704. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85705. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85706. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85707. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85708. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85709. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85710. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85711. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85712. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85713. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85714. /**
  85715. * Defines the delay in milliseconds before starting the system (0 by default)
  85716. */
  85717. startDelay: number;
  85718. /**
  85719. * Gets the current list of drag gradients.
  85720. * You must use addDragGradient and removeDragGradient to udpate this list
  85721. * @returns the list of drag gradients
  85722. */
  85723. getDragGradients(): Nullable<Array<FactorGradient>>;
  85724. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85725. limitVelocityDamping: number;
  85726. /**
  85727. * Gets the current list of limit velocity gradients.
  85728. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85729. * @returns the list of limit velocity gradients
  85730. */
  85731. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85732. /**
  85733. * Gets the current list of color gradients.
  85734. * You must use addColorGradient and removeColorGradient to udpate this list
  85735. * @returns the list of color gradients
  85736. */
  85737. getColorGradients(): Nullable<Array<ColorGradient>>;
  85738. /**
  85739. * Gets the current list of size gradients.
  85740. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85741. * @returns the list of size gradients
  85742. */
  85743. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85744. /**
  85745. * Gets the current list of color remap gradients.
  85746. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85747. * @returns the list of color remap gradients
  85748. */
  85749. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85750. /**
  85751. * Gets the current list of alpha remap gradients.
  85752. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85753. * @returns the list of alpha remap gradients
  85754. */
  85755. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85756. /**
  85757. * Gets the current list of life time gradients.
  85758. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85759. * @returns the list of life time gradients
  85760. */
  85761. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85762. /**
  85763. * Gets the current list of angular speed gradients.
  85764. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85765. * @returns the list of angular speed gradients
  85766. */
  85767. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85768. /**
  85769. * Gets the current list of velocity gradients.
  85770. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85771. * @returns the list of velocity gradients
  85772. */
  85773. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85774. /**
  85775. * Gets the current list of start size gradients.
  85776. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85777. * @returns the list of start size gradients
  85778. */
  85779. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85780. /**
  85781. * Gets the current list of emit rate gradients.
  85782. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85783. * @returns the list of emit rate gradients
  85784. */
  85785. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85786. /**
  85787. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85788. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85789. */
  85790. direction1: Vector3;
  85791. /**
  85792. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85793. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85794. */
  85795. direction2: Vector3;
  85796. /**
  85797. * 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.
  85798. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85799. */
  85800. minEmitBox: Vector3;
  85801. /**
  85802. * 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.
  85803. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85804. */
  85805. maxEmitBox: Vector3;
  85806. /**
  85807. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85808. */
  85809. color1: Color4;
  85810. /**
  85811. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85812. */
  85813. color2: Color4;
  85814. /**
  85815. * Color the particle will have at the end of its lifetime
  85816. */
  85817. colorDead: Color4;
  85818. /**
  85819. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85820. */
  85821. textureMask: Color4;
  85822. /**
  85823. * The particle emitter type defines the emitter used by the particle system.
  85824. * It can be for example box, sphere, or cone...
  85825. */
  85826. particleEmitterType: IParticleEmitterType;
  85827. /** @hidden */
  85828. _isSubEmitter: boolean;
  85829. /**
  85830. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85831. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85832. */
  85833. billboardMode: number;
  85834. protected _isBillboardBased: boolean;
  85835. /**
  85836. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85837. */
  85838. isBillboardBased: boolean;
  85839. /**
  85840. * The scene the particle system belongs to.
  85841. */
  85842. protected _scene: Scene;
  85843. /**
  85844. * Local cache of defines for image processing.
  85845. */
  85846. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85847. /**
  85848. * Default configuration related to image processing available in the standard Material.
  85849. */
  85850. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85851. /**
  85852. * Gets the image processing configuration used either in this material.
  85853. */
  85854. /**
  85855. * Sets the Default image processing configuration used either in the this material.
  85856. *
  85857. * If sets to null, the scene one is in use.
  85858. */
  85859. imageProcessingConfiguration: ImageProcessingConfiguration;
  85860. /**
  85861. * Attaches a new image processing configuration to the Standard Material.
  85862. * @param configuration
  85863. */
  85864. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85865. /** @hidden */
  85866. protected _reset(): void;
  85867. /** @hidden */
  85868. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85869. /**
  85870. * Instantiates a particle system.
  85871. * 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.
  85872. * @param name The name of the particle system
  85873. */
  85874. constructor(name: string);
  85875. /**
  85876. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85879. * @returns the emitter
  85880. */
  85881. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85882. /**
  85883. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85884. * @param radius The radius of the hemisphere to emit from
  85885. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85886. * @returns the emitter
  85887. */
  85888. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85889. /**
  85890. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85891. * @param radius The radius of the sphere to emit from
  85892. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85893. * @returns the emitter
  85894. */
  85895. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85896. /**
  85897. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85898. * @param radius The radius of the sphere to emit from
  85899. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85900. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85901. * @returns the emitter
  85902. */
  85903. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85904. /**
  85905. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85906. * @param radius The radius of the emission cylinder
  85907. * @param height The height of the emission cylinder
  85908. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85909. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85910. * @returns the emitter
  85911. */
  85912. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85913. /**
  85914. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85915. * @param radius The radius of the cylinder to emit from
  85916. * @param height The height of the emission cylinder
  85917. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85918. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85919. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85920. * @returns the emitter
  85921. */
  85922. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85923. /**
  85924. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85925. * @param radius The radius of the cone to emit from
  85926. * @param angle The base angle of the cone
  85927. * @returns the emitter
  85928. */
  85929. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85930. /**
  85931. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85932. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85933. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85934. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85935. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85936. * @returns the emitter
  85937. */
  85938. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85939. }
  85940. }
  85941. declare module BABYLON {
  85942. /**
  85943. * Type of sub emitter
  85944. */
  85945. export enum SubEmitterType {
  85946. /**
  85947. * Attached to the particle over it's lifetime
  85948. */
  85949. ATTACHED = 0,
  85950. /**
  85951. * Created when the particle dies
  85952. */
  85953. END = 1
  85954. }
  85955. /**
  85956. * Sub emitter class used to emit particles from an existing particle
  85957. */
  85958. export class SubEmitter {
  85959. /**
  85960. * the particle system to be used by the sub emitter
  85961. */
  85962. particleSystem: ParticleSystem;
  85963. /**
  85964. * Type of the submitter (Default: END)
  85965. */
  85966. type: SubEmitterType;
  85967. /**
  85968. * 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)
  85969. * Note: This only is supported when using an emitter of type Mesh
  85970. */
  85971. inheritDirection: boolean;
  85972. /**
  85973. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85974. */
  85975. inheritedVelocityAmount: number;
  85976. /**
  85977. * Creates a sub emitter
  85978. * @param particleSystem the particle system to be used by the sub emitter
  85979. */
  85980. constructor(
  85981. /**
  85982. * the particle system to be used by the sub emitter
  85983. */
  85984. particleSystem: ParticleSystem);
  85985. /**
  85986. * Clones the sub emitter
  85987. * @returns the cloned sub emitter
  85988. */
  85989. clone(): SubEmitter;
  85990. /**
  85991. * Serialize current object to a JSON object
  85992. * @returns the serialized object
  85993. */
  85994. serialize(): any;
  85995. /** @hidden */
  85996. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85997. /**
  85998. * Creates a new SubEmitter from a serialized JSON version
  85999. * @param serializationObject defines the JSON object to read from
  86000. * @param scene defines the hosting scene
  86001. * @param rootUrl defines the rootUrl for data loading
  86002. * @returns a new SubEmitter
  86003. */
  86004. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  86005. /** Release associated resources */
  86006. dispose(): void;
  86007. }
  86008. }
  86009. declare module BABYLON {
  86010. /** @hidden */
  86011. export var clipPlaneFragmentDeclaration: {
  86012. name: string;
  86013. shader: string;
  86014. };
  86015. }
  86016. declare module BABYLON {
  86017. /** @hidden */
  86018. export var imageProcessingDeclaration: {
  86019. name: string;
  86020. shader: string;
  86021. };
  86022. }
  86023. declare module BABYLON {
  86024. /** @hidden */
  86025. export var imageProcessingFunctions: {
  86026. name: string;
  86027. shader: string;
  86028. };
  86029. }
  86030. declare module BABYLON {
  86031. /** @hidden */
  86032. export var clipPlaneFragment: {
  86033. name: string;
  86034. shader: string;
  86035. };
  86036. }
  86037. declare module BABYLON {
  86038. /** @hidden */
  86039. export var particlesPixelShader: {
  86040. name: string;
  86041. shader: string;
  86042. };
  86043. }
  86044. declare module BABYLON {
  86045. /** @hidden */
  86046. export var clipPlaneVertexDeclaration: {
  86047. name: string;
  86048. shader: string;
  86049. };
  86050. }
  86051. declare module BABYLON {
  86052. /** @hidden */
  86053. export var clipPlaneVertex: {
  86054. name: string;
  86055. shader: string;
  86056. };
  86057. }
  86058. declare module BABYLON {
  86059. /** @hidden */
  86060. export var particlesVertexShader: {
  86061. name: string;
  86062. shader: string;
  86063. };
  86064. }
  86065. declare module BABYLON {
  86066. /**
  86067. * This represents a particle system in Babylon.
  86068. * 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.
  86069. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86070. * @example https://doc.babylonjs.com/babylon101/particles
  86071. */
  86072. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  86073. /**
  86074. * Billboard mode will only apply to Y axis
  86075. */
  86076. static readonly BILLBOARDMODE_Y: number;
  86077. /**
  86078. * Billboard mode will apply to all axes
  86079. */
  86080. static readonly BILLBOARDMODE_ALL: number;
  86081. /**
  86082. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86083. */
  86084. static readonly BILLBOARDMODE_STRETCHED: number;
  86085. /**
  86086. * This function can be defined to provide custom update for active particles.
  86087. * This function will be called instead of regular update (age, position, color, etc.).
  86088. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  86089. */
  86090. updateFunction: (particles: Particle[]) => void;
  86091. private _emitterWorldMatrix;
  86092. /**
  86093. * This function can be defined to specify initial direction for every new particle.
  86094. * It by default use the emitterType defined function
  86095. */
  86096. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  86097. /**
  86098. * This function can be defined to specify initial position for every new particle.
  86099. * It by default use the emitterType defined function
  86100. */
  86101. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  86102. /**
  86103. * @hidden
  86104. */
  86105. _inheritedVelocityOffset: Vector3;
  86106. /**
  86107. * An event triggered when the system is disposed
  86108. */
  86109. onDisposeObservable: Observable<ParticleSystem>;
  86110. private _onDisposeObserver;
  86111. /**
  86112. * Sets a callback that will be triggered when the system is disposed
  86113. */
  86114. onDispose: () => void;
  86115. private _particles;
  86116. private _epsilon;
  86117. private _capacity;
  86118. private _stockParticles;
  86119. private _newPartsExcess;
  86120. private _vertexData;
  86121. private _vertexBuffer;
  86122. private _vertexBuffers;
  86123. private _spriteBuffer;
  86124. private _indexBuffer;
  86125. private _effect;
  86126. private _customEffect;
  86127. private _cachedDefines;
  86128. private _scaledColorStep;
  86129. private _colorDiff;
  86130. private _scaledDirection;
  86131. private _scaledGravity;
  86132. private _currentRenderId;
  86133. private _alive;
  86134. private _useInstancing;
  86135. private _started;
  86136. private _stopped;
  86137. private _actualFrame;
  86138. private _scaledUpdateSpeed;
  86139. private _vertexBufferSize;
  86140. /** @hidden */
  86141. _currentEmitRateGradient: Nullable<FactorGradient>;
  86142. /** @hidden */
  86143. _currentEmitRate1: number;
  86144. /** @hidden */
  86145. _currentEmitRate2: number;
  86146. /** @hidden */
  86147. _currentStartSizeGradient: Nullable<FactorGradient>;
  86148. /** @hidden */
  86149. _currentStartSize1: number;
  86150. /** @hidden */
  86151. _currentStartSize2: number;
  86152. private readonly _rawTextureWidth;
  86153. private _rampGradientsTexture;
  86154. private _useRampGradients;
  86155. /** Gets or sets a boolean indicating that ramp gradients must be used
  86156. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86157. */
  86158. useRampGradients: boolean;
  86159. /**
  86160. * 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.
  86161. * 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: [])
  86162. */
  86163. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  86164. private _subEmitters;
  86165. /**
  86166. * @hidden
  86167. * If the particle systems emitter should be disposed when the particle system is disposed
  86168. */
  86169. _disposeEmitterOnDispose: boolean;
  86170. /**
  86171. * The current active Sub-systems, this property is used by the root particle system only.
  86172. */
  86173. activeSubSystems: Array<ParticleSystem>;
  86174. private _rootParticleSystem;
  86175. /**
  86176. * Gets the current list of active particles
  86177. */
  86178. readonly particles: Particle[];
  86179. /**
  86180. * Returns the string "ParticleSystem"
  86181. * @returns a string containing the class name
  86182. */
  86183. getClassName(): string;
  86184. /**
  86185. * Instantiates a particle system.
  86186. * 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.
  86187. * @param name The name of the particle system
  86188. * @param capacity The max number of particles alive at the same time
  86189. * @param scene The scene the particle system belongs to
  86190. * @param customEffect a custom effect used to change the way particles are rendered by default
  86191. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86192. * @param epsilon Offset used to render the particles
  86193. */
  86194. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86195. private _addFactorGradient;
  86196. private _removeFactorGradient;
  86197. /**
  86198. * Adds a new life time gradient
  86199. * @param gradient defines the gradient to use (between 0 and 1)
  86200. * @param factor defines the life time factor to affect to the specified gradient
  86201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86202. * @returns the current particle system
  86203. */
  86204. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86205. /**
  86206. * Remove a specific life time gradient
  86207. * @param gradient defines the gradient to remove
  86208. * @returns the current particle system
  86209. */
  86210. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86211. /**
  86212. * Adds a new size gradient
  86213. * @param gradient defines the gradient to use (between 0 and 1)
  86214. * @param factor defines the size factor to affect to the specified gradient
  86215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86216. * @returns the current particle system
  86217. */
  86218. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86219. /**
  86220. * Remove a specific size gradient
  86221. * @param gradient defines the gradient to remove
  86222. * @returns the current particle system
  86223. */
  86224. removeSizeGradient(gradient: number): IParticleSystem;
  86225. /**
  86226. * Adds a new color remap gradient
  86227. * @param gradient defines the gradient to use (between 0 and 1)
  86228. * @param min defines the color remap minimal range
  86229. * @param max defines the color remap maximal range
  86230. * @returns the current particle system
  86231. */
  86232. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86233. /**
  86234. * Remove a specific color remap gradient
  86235. * @param gradient defines the gradient to remove
  86236. * @returns the current particle system
  86237. */
  86238. removeColorRemapGradient(gradient: number): IParticleSystem;
  86239. /**
  86240. * Adds a new alpha remap gradient
  86241. * @param gradient defines the gradient to use (between 0 and 1)
  86242. * @param min defines the alpha remap minimal range
  86243. * @param max defines the alpha remap maximal range
  86244. * @returns the current particle system
  86245. */
  86246. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86247. /**
  86248. * Remove a specific alpha remap gradient
  86249. * @param gradient defines the gradient to remove
  86250. * @returns the current particle system
  86251. */
  86252. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86253. /**
  86254. * Adds a new angular speed gradient
  86255. * @param gradient defines the gradient to use (between 0 and 1)
  86256. * @param factor defines the angular speed to affect to the specified gradient
  86257. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86258. * @returns the current particle system
  86259. */
  86260. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86261. /**
  86262. * Remove a specific angular speed gradient
  86263. * @param gradient defines the gradient to remove
  86264. * @returns the current particle system
  86265. */
  86266. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86267. /**
  86268. * Adds a new velocity gradient
  86269. * @param gradient defines the gradient to use (between 0 and 1)
  86270. * @param factor defines the velocity to affect to the specified gradient
  86271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86272. * @returns the current particle system
  86273. */
  86274. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86275. /**
  86276. * Remove a specific velocity gradient
  86277. * @param gradient defines the gradient to remove
  86278. * @returns the current particle system
  86279. */
  86280. removeVelocityGradient(gradient: number): IParticleSystem;
  86281. /**
  86282. * Adds a new limit velocity gradient
  86283. * @param gradient defines the gradient to use (between 0 and 1)
  86284. * @param factor defines the limit velocity value to affect to the specified gradient
  86285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86286. * @returns the current particle system
  86287. */
  86288. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86289. /**
  86290. * Remove a specific limit velocity gradient
  86291. * @param gradient defines the gradient to remove
  86292. * @returns the current particle system
  86293. */
  86294. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86295. /**
  86296. * Adds a new drag gradient
  86297. * @param gradient defines the gradient to use (between 0 and 1)
  86298. * @param factor defines the drag value to affect to the specified gradient
  86299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86300. * @returns the current particle system
  86301. */
  86302. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86303. /**
  86304. * Remove a specific drag gradient
  86305. * @param gradient defines the gradient to remove
  86306. * @returns the current particle system
  86307. */
  86308. removeDragGradient(gradient: number): IParticleSystem;
  86309. /**
  86310. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86311. * @param gradient defines the gradient to use (between 0 and 1)
  86312. * @param factor defines the emit rate value to affect to the specified gradient
  86313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86314. * @returns the current particle system
  86315. */
  86316. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86317. /**
  86318. * Remove a specific emit rate gradient
  86319. * @param gradient defines the gradient to remove
  86320. * @returns the current particle system
  86321. */
  86322. removeEmitRateGradient(gradient: number): IParticleSystem;
  86323. /**
  86324. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86325. * @param gradient defines the gradient to use (between 0 and 1)
  86326. * @param factor defines the start size value to affect to the specified gradient
  86327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86328. * @returns the current particle system
  86329. */
  86330. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86331. /**
  86332. * Remove a specific start size gradient
  86333. * @param gradient defines the gradient to remove
  86334. * @returns the current particle system
  86335. */
  86336. removeStartSizeGradient(gradient: number): IParticleSystem;
  86337. private _createRampGradientTexture;
  86338. /**
  86339. * Gets the current list of ramp gradients.
  86340. * You must use addRampGradient and removeRampGradient to udpate this list
  86341. * @returns the list of ramp gradients
  86342. */
  86343. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86344. /**
  86345. * Adds a new ramp gradient used to remap particle colors
  86346. * @param gradient defines the gradient to use (between 0 and 1)
  86347. * @param color defines the color to affect to the specified gradient
  86348. * @returns the current particle system
  86349. */
  86350. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86351. /**
  86352. * Remove a specific ramp gradient
  86353. * @param gradient defines the gradient to remove
  86354. * @returns the current particle system
  86355. */
  86356. removeRampGradient(gradient: number): ParticleSystem;
  86357. /**
  86358. * Adds a new color gradient
  86359. * @param gradient defines the gradient to use (between 0 and 1)
  86360. * @param color1 defines the color to affect to the specified gradient
  86361. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86362. * @returns this particle system
  86363. */
  86364. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86365. /**
  86366. * Remove a specific color gradient
  86367. * @param gradient defines the gradient to remove
  86368. * @returns this particle system
  86369. */
  86370. removeColorGradient(gradient: number): IParticleSystem;
  86371. private _fetchR;
  86372. protected _reset(): void;
  86373. private _resetEffect;
  86374. private _createVertexBuffers;
  86375. private _createIndexBuffer;
  86376. /**
  86377. * Gets the maximum number of particles active at the same time.
  86378. * @returns The max number of active particles.
  86379. */
  86380. getCapacity(): number;
  86381. /**
  86382. * Gets whether there are still active particles in the system.
  86383. * @returns True if it is alive, otherwise false.
  86384. */
  86385. isAlive(): boolean;
  86386. /**
  86387. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86388. * @returns True if it has been started, otherwise false.
  86389. */
  86390. isStarted(): boolean;
  86391. private _prepareSubEmitterInternalArray;
  86392. /**
  86393. * Starts the particle system and begins to emit
  86394. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86395. */
  86396. start(delay?: number): void;
  86397. /**
  86398. * Stops the particle system.
  86399. * @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.
  86400. */
  86401. stop(stopSubEmitters?: boolean): void;
  86402. /**
  86403. * Remove all active particles
  86404. */
  86405. reset(): void;
  86406. /**
  86407. * @hidden (for internal use only)
  86408. */
  86409. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86410. /**
  86411. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86412. * Its lifetime will start back at 0.
  86413. */
  86414. recycleParticle: (particle: Particle) => void;
  86415. private _stopSubEmitters;
  86416. private _createParticle;
  86417. private _removeFromRoot;
  86418. private _emitFromParticle;
  86419. private _update;
  86420. /** @hidden */
  86421. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86422. /** @hidden */
  86423. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86424. /** @hidden */
  86425. private _getEffect;
  86426. /**
  86427. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86428. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86429. */
  86430. animate(preWarmOnly?: boolean): void;
  86431. private _appendParticleVertices;
  86432. /**
  86433. * Rebuilds the particle system.
  86434. */
  86435. rebuild(): void;
  86436. /**
  86437. * Is this system ready to be used/rendered
  86438. * @return true if the system is ready
  86439. */
  86440. isReady(): boolean;
  86441. private _render;
  86442. /**
  86443. * Renders the particle system in its current state.
  86444. * @returns the current number of particles
  86445. */
  86446. render(): number;
  86447. /**
  86448. * Disposes the particle system and free the associated resources
  86449. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86450. */
  86451. dispose(disposeTexture?: boolean): void;
  86452. /**
  86453. * Clones the particle system.
  86454. * @param name The name of the cloned object
  86455. * @param newEmitter The new emitter to use
  86456. * @returns the cloned particle system
  86457. */
  86458. clone(name: string, newEmitter: any): ParticleSystem;
  86459. /**
  86460. * Serializes the particle system to a JSON object.
  86461. * @returns the JSON object
  86462. */
  86463. serialize(): any;
  86464. /** @hidden */
  86465. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86466. /** @hidden */
  86467. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86468. /**
  86469. * Parses a JSON object to create a particle system.
  86470. * @param parsedParticleSystem The JSON object to parse
  86471. * @param scene The scene to create the particle system in
  86472. * @param rootUrl The root url to use to load external dependencies like texture
  86473. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86474. * @returns the Parsed particle system
  86475. */
  86476. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86477. }
  86478. }
  86479. declare module BABYLON {
  86480. /**
  86481. * A particle represents one of the element emitted by a particle system.
  86482. * This is mainly define by its coordinates, direction, velocity and age.
  86483. */
  86484. export class Particle {
  86485. /**
  86486. * The particle system the particle belongs to.
  86487. */
  86488. particleSystem: ParticleSystem;
  86489. private static _Count;
  86490. /**
  86491. * Unique ID of the particle
  86492. */
  86493. id: number;
  86494. /**
  86495. * The world position of the particle in the scene.
  86496. */
  86497. position: Vector3;
  86498. /**
  86499. * The world direction of the particle in the scene.
  86500. */
  86501. direction: Vector3;
  86502. /**
  86503. * The color of the particle.
  86504. */
  86505. color: Color4;
  86506. /**
  86507. * The color change of the particle per step.
  86508. */
  86509. colorStep: Color4;
  86510. /**
  86511. * Defines how long will the life of the particle be.
  86512. */
  86513. lifeTime: number;
  86514. /**
  86515. * The current age of the particle.
  86516. */
  86517. age: number;
  86518. /**
  86519. * The current size of the particle.
  86520. */
  86521. size: number;
  86522. /**
  86523. * The current scale of the particle.
  86524. */
  86525. scale: Vector2;
  86526. /**
  86527. * The current angle of the particle.
  86528. */
  86529. angle: number;
  86530. /**
  86531. * Defines how fast is the angle changing.
  86532. */
  86533. angularSpeed: number;
  86534. /**
  86535. * Defines the cell index used by the particle to be rendered from a sprite.
  86536. */
  86537. cellIndex: number;
  86538. /**
  86539. * The information required to support color remapping
  86540. */
  86541. remapData: Vector4;
  86542. /** @hidden */
  86543. _randomCellOffset?: number;
  86544. /** @hidden */
  86545. _initialDirection: Nullable<Vector3>;
  86546. /** @hidden */
  86547. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86548. /** @hidden */
  86549. _initialStartSpriteCellID: number;
  86550. /** @hidden */
  86551. _initialEndSpriteCellID: number;
  86552. /** @hidden */
  86553. _currentColorGradient: Nullable<ColorGradient>;
  86554. /** @hidden */
  86555. _currentColor1: Color4;
  86556. /** @hidden */
  86557. _currentColor2: Color4;
  86558. /** @hidden */
  86559. _currentSizeGradient: Nullable<FactorGradient>;
  86560. /** @hidden */
  86561. _currentSize1: number;
  86562. /** @hidden */
  86563. _currentSize2: number;
  86564. /** @hidden */
  86565. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86566. /** @hidden */
  86567. _currentAngularSpeed1: number;
  86568. /** @hidden */
  86569. _currentAngularSpeed2: number;
  86570. /** @hidden */
  86571. _currentVelocityGradient: Nullable<FactorGradient>;
  86572. /** @hidden */
  86573. _currentVelocity1: number;
  86574. /** @hidden */
  86575. _currentVelocity2: number;
  86576. /** @hidden */
  86577. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86578. /** @hidden */
  86579. _currentLimitVelocity1: number;
  86580. /** @hidden */
  86581. _currentLimitVelocity2: number;
  86582. /** @hidden */
  86583. _currentDragGradient: Nullable<FactorGradient>;
  86584. /** @hidden */
  86585. _currentDrag1: number;
  86586. /** @hidden */
  86587. _currentDrag2: number;
  86588. /** @hidden */
  86589. _randomNoiseCoordinates1: Vector3;
  86590. /** @hidden */
  86591. _randomNoiseCoordinates2: Vector3;
  86592. /**
  86593. * Creates a new instance Particle
  86594. * @param particleSystem the particle system the particle belongs to
  86595. */
  86596. constructor(
  86597. /**
  86598. * The particle system the particle belongs to.
  86599. */
  86600. particleSystem: ParticleSystem);
  86601. private updateCellInfoFromSystem;
  86602. /**
  86603. * Defines how the sprite cell index is updated for the particle
  86604. */
  86605. updateCellIndex(): void;
  86606. /** @hidden */
  86607. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86608. /** @hidden */
  86609. _inheritParticleInfoToSubEmitters(): void;
  86610. /** @hidden */
  86611. _reset(): void;
  86612. /**
  86613. * Copy the properties of particle to another one.
  86614. * @param other the particle to copy the information to.
  86615. */
  86616. copyTo(other: Particle): void;
  86617. }
  86618. }
  86619. declare module BABYLON {
  86620. /**
  86621. * Particle emitter represents a volume emitting particles.
  86622. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86623. */
  86624. export interface IParticleEmitterType {
  86625. /**
  86626. * Called by the particle System when the direction is computed for the created particle.
  86627. * @param worldMatrix is the world matrix of the particle system
  86628. * @param directionToUpdate is the direction vector to update with the result
  86629. * @param particle is the particle we are computed the direction for
  86630. */
  86631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86632. /**
  86633. * Called by the particle System when the position is computed for the created particle.
  86634. * @param worldMatrix is the world matrix of the particle system
  86635. * @param positionToUpdate is the position vector to update with the result
  86636. * @param particle is the particle we are computed the position for
  86637. */
  86638. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86639. /**
  86640. * Clones the current emitter and returns a copy of it
  86641. * @returns the new emitter
  86642. */
  86643. clone(): IParticleEmitterType;
  86644. /**
  86645. * Called by the GPUParticleSystem to setup the update shader
  86646. * @param effect defines the update shader
  86647. */
  86648. applyToShader(effect: Effect): void;
  86649. /**
  86650. * Returns a string to use to update the GPU particles update shader
  86651. * @returns the effect defines string
  86652. */
  86653. getEffectDefines(): string;
  86654. /**
  86655. * Returns a string representing the class name
  86656. * @returns a string containing the class name
  86657. */
  86658. getClassName(): string;
  86659. /**
  86660. * Serializes the particle system to a JSON object.
  86661. * @returns the JSON object
  86662. */
  86663. serialize(): any;
  86664. /**
  86665. * Parse properties from a JSON object
  86666. * @param serializationObject defines the JSON object
  86667. */
  86668. parse(serializationObject: any): void;
  86669. }
  86670. }
  86671. declare module BABYLON {
  86672. /**
  86673. * Particle emitter emitting particles from the inside of a box.
  86674. * It emits the particles randomly between 2 given directions.
  86675. */
  86676. export class BoxParticleEmitter implements IParticleEmitterType {
  86677. /**
  86678. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86679. */
  86680. direction1: Vector3;
  86681. /**
  86682. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86683. */
  86684. direction2: Vector3;
  86685. /**
  86686. * 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.
  86687. */
  86688. minEmitBox: Vector3;
  86689. /**
  86690. * 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.
  86691. */
  86692. maxEmitBox: Vector3;
  86693. /**
  86694. * Creates a new instance BoxParticleEmitter
  86695. */
  86696. constructor();
  86697. /**
  86698. * Called by the particle System when the direction is computed for the created particle.
  86699. * @param worldMatrix is the world matrix of the particle system
  86700. * @param directionToUpdate is the direction vector to update with the result
  86701. * @param particle is the particle we are computed the direction for
  86702. */
  86703. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86704. /**
  86705. * Called by the particle System when the position is computed for the created particle.
  86706. * @param worldMatrix is the world matrix of the particle system
  86707. * @param positionToUpdate is the position vector to update with the result
  86708. * @param particle is the particle we are computed the position for
  86709. */
  86710. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86711. /**
  86712. * Clones the current emitter and returns a copy of it
  86713. * @returns the new emitter
  86714. */
  86715. clone(): BoxParticleEmitter;
  86716. /**
  86717. * Called by the GPUParticleSystem to setup the update shader
  86718. * @param effect defines the update shader
  86719. */
  86720. applyToShader(effect: Effect): void;
  86721. /**
  86722. * Returns a string to use to update the GPU particles update shader
  86723. * @returns a string containng the defines string
  86724. */
  86725. getEffectDefines(): string;
  86726. /**
  86727. * Returns the string "BoxParticleEmitter"
  86728. * @returns a string containing the class name
  86729. */
  86730. getClassName(): string;
  86731. /**
  86732. * Serializes the particle system to a JSON object.
  86733. * @returns the JSON object
  86734. */
  86735. serialize(): any;
  86736. /**
  86737. * Parse properties from a JSON object
  86738. * @param serializationObject defines the JSON object
  86739. */
  86740. parse(serializationObject: any): void;
  86741. }
  86742. }
  86743. declare module BABYLON {
  86744. /**
  86745. * Particle emitter emitting particles from the inside of a cone.
  86746. * It emits the particles alongside the cone volume from the base to the particle.
  86747. * The emission direction might be randomized.
  86748. */
  86749. export class ConeParticleEmitter implements IParticleEmitterType {
  86750. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86751. directionRandomizer: number;
  86752. private _radius;
  86753. private _angle;
  86754. private _height;
  86755. /**
  86756. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86757. */
  86758. radiusRange: number;
  86759. /**
  86760. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86761. */
  86762. heightRange: number;
  86763. /**
  86764. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86765. */
  86766. emitFromSpawnPointOnly: boolean;
  86767. /**
  86768. * Gets or sets the radius of the emission cone
  86769. */
  86770. radius: number;
  86771. /**
  86772. * Gets or sets the angle of the emission cone
  86773. */
  86774. angle: number;
  86775. private _buildHeight;
  86776. /**
  86777. * Creates a new instance ConeParticleEmitter
  86778. * @param radius the radius of the emission cone (1 by default)
  86779. * @param angle the cone base angle (PI by default)
  86780. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86781. */
  86782. constructor(radius?: number, angle?: number,
  86783. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86784. directionRandomizer?: number);
  86785. /**
  86786. * Called by the particle System when the direction is computed for the created particle.
  86787. * @param worldMatrix is the world matrix of the particle system
  86788. * @param directionToUpdate is the direction vector to update with the result
  86789. * @param particle is the particle we are computed the direction for
  86790. */
  86791. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86792. /**
  86793. * Called by the particle System when the position is computed for the created particle.
  86794. * @param worldMatrix is the world matrix of the particle system
  86795. * @param positionToUpdate is the position vector to update with the result
  86796. * @param particle is the particle we are computed the position for
  86797. */
  86798. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86799. /**
  86800. * Clones the current emitter and returns a copy of it
  86801. * @returns the new emitter
  86802. */
  86803. clone(): ConeParticleEmitter;
  86804. /**
  86805. * Called by the GPUParticleSystem to setup the update shader
  86806. * @param effect defines the update shader
  86807. */
  86808. applyToShader(effect: Effect): void;
  86809. /**
  86810. * Returns a string to use to update the GPU particles update shader
  86811. * @returns a string containng the defines string
  86812. */
  86813. getEffectDefines(): string;
  86814. /**
  86815. * Returns the string "ConeParticleEmitter"
  86816. * @returns a string containing the class name
  86817. */
  86818. getClassName(): string;
  86819. /**
  86820. * Serializes the particle system to a JSON object.
  86821. * @returns the JSON object
  86822. */
  86823. serialize(): any;
  86824. /**
  86825. * Parse properties from a JSON object
  86826. * @param serializationObject defines the JSON object
  86827. */
  86828. parse(serializationObject: any): void;
  86829. }
  86830. }
  86831. declare module BABYLON {
  86832. /**
  86833. * Particle emitter emitting particles from the inside of a cylinder.
  86834. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86835. */
  86836. export class CylinderParticleEmitter implements IParticleEmitterType {
  86837. /**
  86838. * The radius of the emission cylinder.
  86839. */
  86840. radius: number;
  86841. /**
  86842. * The height of the emission cylinder.
  86843. */
  86844. height: number;
  86845. /**
  86846. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86847. */
  86848. radiusRange: number;
  86849. /**
  86850. * How much to randomize the particle direction [0-1].
  86851. */
  86852. directionRandomizer: number;
  86853. /**
  86854. * Creates a new instance CylinderParticleEmitter
  86855. * @param radius the radius of the emission cylinder (1 by default)
  86856. * @param height the height of the emission cylinder (1 by default)
  86857. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86858. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86859. */
  86860. constructor(
  86861. /**
  86862. * The radius of the emission cylinder.
  86863. */
  86864. radius?: number,
  86865. /**
  86866. * The height of the emission cylinder.
  86867. */
  86868. height?: number,
  86869. /**
  86870. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86871. */
  86872. radiusRange?: number,
  86873. /**
  86874. * How much to randomize the particle direction [0-1].
  86875. */
  86876. directionRandomizer?: number);
  86877. /**
  86878. * Called by the particle System when the direction is computed for the created particle.
  86879. * @param worldMatrix is the world matrix of the particle system
  86880. * @param directionToUpdate is the direction vector to update with the result
  86881. * @param particle is the particle we are computed the direction for
  86882. */
  86883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86884. /**
  86885. * Called by the particle System when the position is computed for the created particle.
  86886. * @param worldMatrix is the world matrix of the particle system
  86887. * @param positionToUpdate is the position vector to update with the result
  86888. * @param particle is the particle we are computed the position for
  86889. */
  86890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86891. /**
  86892. * Clones the current emitter and returns a copy of it
  86893. * @returns the new emitter
  86894. */
  86895. clone(): CylinderParticleEmitter;
  86896. /**
  86897. * Called by the GPUParticleSystem to setup the update shader
  86898. * @param effect defines the update shader
  86899. */
  86900. applyToShader(effect: Effect): void;
  86901. /**
  86902. * Returns a string to use to update the GPU particles update shader
  86903. * @returns a string containng the defines string
  86904. */
  86905. getEffectDefines(): string;
  86906. /**
  86907. * Returns the string "CylinderParticleEmitter"
  86908. * @returns a string containing the class name
  86909. */
  86910. getClassName(): string;
  86911. /**
  86912. * Serializes the particle system to a JSON object.
  86913. * @returns the JSON object
  86914. */
  86915. serialize(): any;
  86916. /**
  86917. * Parse properties from a JSON object
  86918. * @param serializationObject defines the JSON object
  86919. */
  86920. parse(serializationObject: any): void;
  86921. }
  86922. /**
  86923. * Particle emitter emitting particles from the inside of a cylinder.
  86924. * It emits the particles randomly between two vectors.
  86925. */
  86926. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86927. /**
  86928. * The min limit of the emission direction.
  86929. */
  86930. direction1: Vector3;
  86931. /**
  86932. * The max limit of the emission direction.
  86933. */
  86934. direction2: Vector3;
  86935. /**
  86936. * Creates a new instance CylinderDirectedParticleEmitter
  86937. * @param radius the radius of the emission cylinder (1 by default)
  86938. * @param height the height of the emission cylinder (1 by default)
  86939. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86940. * @param direction1 the min limit of the emission direction (up vector by default)
  86941. * @param direction2 the max limit of the emission direction (up vector by default)
  86942. */
  86943. constructor(radius?: number, height?: number, radiusRange?: number,
  86944. /**
  86945. * The min limit of the emission direction.
  86946. */
  86947. direction1?: Vector3,
  86948. /**
  86949. * The max limit of the emission direction.
  86950. */
  86951. direction2?: Vector3);
  86952. /**
  86953. * Called by the particle System when the direction is computed for the created particle.
  86954. * @param worldMatrix is the world matrix of the particle system
  86955. * @param directionToUpdate is the direction vector to update with the result
  86956. * @param particle is the particle we are computed the direction for
  86957. */
  86958. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86959. /**
  86960. * Clones the current emitter and returns a copy of it
  86961. * @returns the new emitter
  86962. */
  86963. clone(): CylinderDirectedParticleEmitter;
  86964. /**
  86965. * Called by the GPUParticleSystem to setup the update shader
  86966. * @param effect defines the update shader
  86967. */
  86968. applyToShader(effect: Effect): void;
  86969. /**
  86970. * Returns a string to use to update the GPU particles update shader
  86971. * @returns a string containng the defines string
  86972. */
  86973. getEffectDefines(): string;
  86974. /**
  86975. * Returns the string "CylinderDirectedParticleEmitter"
  86976. * @returns a string containing the class name
  86977. */
  86978. getClassName(): string;
  86979. /**
  86980. * Serializes the particle system to a JSON object.
  86981. * @returns the JSON object
  86982. */
  86983. serialize(): any;
  86984. /**
  86985. * Parse properties from a JSON object
  86986. * @param serializationObject defines the JSON object
  86987. */
  86988. parse(serializationObject: any): void;
  86989. }
  86990. }
  86991. declare module BABYLON {
  86992. /**
  86993. * Particle emitter emitting particles from the inside of a hemisphere.
  86994. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86995. */
  86996. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86997. /**
  86998. * The radius of the emission hemisphere.
  86999. */
  87000. radius: number;
  87001. /**
  87002. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87003. */
  87004. radiusRange: number;
  87005. /**
  87006. * How much to randomize the particle direction [0-1].
  87007. */
  87008. directionRandomizer: number;
  87009. /**
  87010. * Creates a new instance HemisphericParticleEmitter
  87011. * @param radius the radius of the emission hemisphere (1 by default)
  87012. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87013. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87014. */
  87015. constructor(
  87016. /**
  87017. * The radius of the emission hemisphere.
  87018. */
  87019. radius?: number,
  87020. /**
  87021. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87022. */
  87023. radiusRange?: number,
  87024. /**
  87025. * How much to randomize the particle direction [0-1].
  87026. */
  87027. directionRandomizer?: number);
  87028. /**
  87029. * Called by the particle System when the direction is computed for the created particle.
  87030. * @param worldMatrix is the world matrix of the particle system
  87031. * @param directionToUpdate is the direction vector to update with the result
  87032. * @param particle is the particle we are computed the direction for
  87033. */
  87034. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87035. /**
  87036. * Called by the particle System when the position is computed for the created particle.
  87037. * @param worldMatrix is the world matrix of the particle system
  87038. * @param positionToUpdate is the position vector to update with the result
  87039. * @param particle is the particle we are computed the position for
  87040. */
  87041. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87042. /**
  87043. * Clones the current emitter and returns a copy of it
  87044. * @returns the new emitter
  87045. */
  87046. clone(): HemisphericParticleEmitter;
  87047. /**
  87048. * Called by the GPUParticleSystem to setup the update shader
  87049. * @param effect defines the update shader
  87050. */
  87051. applyToShader(effect: Effect): void;
  87052. /**
  87053. * Returns a string to use to update the GPU particles update shader
  87054. * @returns a string containng the defines string
  87055. */
  87056. getEffectDefines(): string;
  87057. /**
  87058. * Returns the string "HemisphericParticleEmitter"
  87059. * @returns a string containing the class name
  87060. */
  87061. getClassName(): string;
  87062. /**
  87063. * Serializes the particle system to a JSON object.
  87064. * @returns the JSON object
  87065. */
  87066. serialize(): any;
  87067. /**
  87068. * Parse properties from a JSON object
  87069. * @param serializationObject defines the JSON object
  87070. */
  87071. parse(serializationObject: any): void;
  87072. }
  87073. }
  87074. declare module BABYLON {
  87075. /**
  87076. * Particle emitter emitting particles from a point.
  87077. * It emits the particles randomly between 2 given directions.
  87078. */
  87079. export class PointParticleEmitter implements IParticleEmitterType {
  87080. /**
  87081. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87082. */
  87083. direction1: Vector3;
  87084. /**
  87085. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87086. */
  87087. direction2: Vector3;
  87088. /**
  87089. * Creates a new instance PointParticleEmitter
  87090. */
  87091. constructor();
  87092. /**
  87093. * Called by the particle System when the direction is computed for the created particle.
  87094. * @param worldMatrix is the world matrix of the particle system
  87095. * @param directionToUpdate is the direction vector to update with the result
  87096. * @param particle is the particle we are computed the direction for
  87097. */
  87098. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87099. /**
  87100. * Called by the particle System when the position is computed for the created particle.
  87101. * @param worldMatrix is the world matrix of the particle system
  87102. * @param positionToUpdate is the position vector to update with the result
  87103. * @param particle is the particle we are computed the position for
  87104. */
  87105. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87106. /**
  87107. * Clones the current emitter and returns a copy of it
  87108. * @returns the new emitter
  87109. */
  87110. clone(): PointParticleEmitter;
  87111. /**
  87112. * Called by the GPUParticleSystem to setup the update shader
  87113. * @param effect defines the update shader
  87114. */
  87115. applyToShader(effect: Effect): void;
  87116. /**
  87117. * Returns a string to use to update the GPU particles update shader
  87118. * @returns a string containng the defines string
  87119. */
  87120. getEffectDefines(): string;
  87121. /**
  87122. * Returns the string "PointParticleEmitter"
  87123. * @returns a string containing the class name
  87124. */
  87125. getClassName(): string;
  87126. /**
  87127. * Serializes the particle system to a JSON object.
  87128. * @returns the JSON object
  87129. */
  87130. serialize(): any;
  87131. /**
  87132. * Parse properties from a JSON object
  87133. * @param serializationObject defines the JSON object
  87134. */
  87135. parse(serializationObject: any): void;
  87136. }
  87137. }
  87138. declare module BABYLON {
  87139. /**
  87140. * Particle emitter emitting particles from the inside of a sphere.
  87141. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87142. */
  87143. export class SphereParticleEmitter implements IParticleEmitterType {
  87144. /**
  87145. * The radius of the emission sphere.
  87146. */
  87147. radius: number;
  87148. /**
  87149. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87150. */
  87151. radiusRange: number;
  87152. /**
  87153. * How much to randomize the particle direction [0-1].
  87154. */
  87155. directionRandomizer: number;
  87156. /**
  87157. * Creates a new instance SphereParticleEmitter
  87158. * @param radius the radius of the emission sphere (1 by default)
  87159. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87160. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87161. */
  87162. constructor(
  87163. /**
  87164. * The radius of the emission sphere.
  87165. */
  87166. radius?: number,
  87167. /**
  87168. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87169. */
  87170. radiusRange?: number,
  87171. /**
  87172. * How much to randomize the particle direction [0-1].
  87173. */
  87174. directionRandomizer?: number);
  87175. /**
  87176. * Called by the particle System when the direction is computed for the created particle.
  87177. * @param worldMatrix is the world matrix of the particle system
  87178. * @param directionToUpdate is the direction vector to update with the result
  87179. * @param particle is the particle we are computed the direction for
  87180. */
  87181. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87182. /**
  87183. * Called by the particle System when the position is computed for the created particle.
  87184. * @param worldMatrix is the world matrix of the particle system
  87185. * @param positionToUpdate is the position vector to update with the result
  87186. * @param particle is the particle we are computed the position for
  87187. */
  87188. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87189. /**
  87190. * Clones the current emitter and returns a copy of it
  87191. * @returns the new emitter
  87192. */
  87193. clone(): SphereParticleEmitter;
  87194. /**
  87195. * Called by the GPUParticleSystem to setup the update shader
  87196. * @param effect defines the update shader
  87197. */
  87198. applyToShader(effect: Effect): void;
  87199. /**
  87200. * Returns a string to use to update the GPU particles update shader
  87201. * @returns a string containng the defines string
  87202. */
  87203. getEffectDefines(): string;
  87204. /**
  87205. * Returns the string "SphereParticleEmitter"
  87206. * @returns a string containing the class name
  87207. */
  87208. getClassName(): string;
  87209. /**
  87210. * Serializes the particle system to a JSON object.
  87211. * @returns the JSON object
  87212. */
  87213. serialize(): any;
  87214. /**
  87215. * Parse properties from a JSON object
  87216. * @param serializationObject defines the JSON object
  87217. */
  87218. parse(serializationObject: any): void;
  87219. }
  87220. /**
  87221. * Particle emitter emitting particles from the inside of a sphere.
  87222. * It emits the particles randomly between two vectors.
  87223. */
  87224. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87225. /**
  87226. * The min limit of the emission direction.
  87227. */
  87228. direction1: Vector3;
  87229. /**
  87230. * The max limit of the emission direction.
  87231. */
  87232. direction2: Vector3;
  87233. /**
  87234. * Creates a new instance SphereDirectedParticleEmitter
  87235. * @param radius the radius of the emission sphere (1 by default)
  87236. * @param direction1 the min limit of the emission direction (up vector by default)
  87237. * @param direction2 the max limit of the emission direction (up vector by default)
  87238. */
  87239. constructor(radius?: number,
  87240. /**
  87241. * The min limit of the emission direction.
  87242. */
  87243. direction1?: Vector3,
  87244. /**
  87245. * The max limit of the emission direction.
  87246. */
  87247. direction2?: Vector3);
  87248. /**
  87249. * Called by the particle System when the direction is computed for the created particle.
  87250. * @param worldMatrix is the world matrix of the particle system
  87251. * @param directionToUpdate is the direction vector to update with the result
  87252. * @param particle is the particle we are computed the direction for
  87253. */
  87254. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87255. /**
  87256. * Clones the current emitter and returns a copy of it
  87257. * @returns the new emitter
  87258. */
  87259. clone(): SphereDirectedParticleEmitter;
  87260. /**
  87261. * Called by the GPUParticleSystem to setup the update shader
  87262. * @param effect defines the update shader
  87263. */
  87264. applyToShader(effect: Effect): void;
  87265. /**
  87266. * Returns a string to use to update the GPU particles update shader
  87267. * @returns a string containng the defines string
  87268. */
  87269. getEffectDefines(): string;
  87270. /**
  87271. * Returns the string "SphereDirectedParticleEmitter"
  87272. * @returns a string containing the class name
  87273. */
  87274. getClassName(): string;
  87275. /**
  87276. * Serializes the particle system to a JSON object.
  87277. * @returns the JSON object
  87278. */
  87279. serialize(): any;
  87280. /**
  87281. * Parse properties from a JSON object
  87282. * @param serializationObject defines the JSON object
  87283. */
  87284. parse(serializationObject: any): void;
  87285. }
  87286. }
  87287. declare module BABYLON {
  87288. /**
  87289. * Interface representing a particle system in Babylon.js.
  87290. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87291. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87292. */
  87293. export interface IParticleSystem {
  87294. /**
  87295. * List of animations used by the particle system.
  87296. */
  87297. animations: Animation[];
  87298. /**
  87299. * The id of the Particle system.
  87300. */
  87301. id: string;
  87302. /**
  87303. * The name of the Particle system.
  87304. */
  87305. name: string;
  87306. /**
  87307. * The emitter represents the Mesh or position we are attaching the particle system to.
  87308. */
  87309. emitter: Nullable<AbstractMesh | Vector3>;
  87310. /**
  87311. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87312. */
  87313. isBillboardBased: boolean;
  87314. /**
  87315. * The rendering group used by the Particle system to chose when to render.
  87316. */
  87317. renderingGroupId: number;
  87318. /**
  87319. * The layer mask we are rendering the particles through.
  87320. */
  87321. layerMask: number;
  87322. /**
  87323. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87324. */
  87325. updateSpeed: number;
  87326. /**
  87327. * The amount of time the particle system is running (depends of the overall update speed).
  87328. */
  87329. targetStopDuration: number;
  87330. /**
  87331. * The texture used to render each particle. (this can be a spritesheet)
  87332. */
  87333. particleTexture: Nullable<Texture>;
  87334. /**
  87335. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87336. */
  87337. blendMode: number;
  87338. /**
  87339. * Minimum life time of emitting particles.
  87340. */
  87341. minLifeTime: number;
  87342. /**
  87343. * Maximum life time of emitting particles.
  87344. */
  87345. maxLifeTime: number;
  87346. /**
  87347. * Minimum Size of emitting particles.
  87348. */
  87349. minSize: number;
  87350. /**
  87351. * Maximum Size of emitting particles.
  87352. */
  87353. maxSize: number;
  87354. /**
  87355. * Minimum scale of emitting particles on X axis.
  87356. */
  87357. minScaleX: number;
  87358. /**
  87359. * Maximum scale of emitting particles on X axis.
  87360. */
  87361. maxScaleX: number;
  87362. /**
  87363. * Minimum scale of emitting particles on Y axis.
  87364. */
  87365. minScaleY: number;
  87366. /**
  87367. * Maximum scale of emitting particles on Y axis.
  87368. */
  87369. maxScaleY: number;
  87370. /**
  87371. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87372. */
  87373. color1: Color4;
  87374. /**
  87375. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87376. */
  87377. color2: Color4;
  87378. /**
  87379. * Color the particle will have at the end of its lifetime.
  87380. */
  87381. colorDead: Color4;
  87382. /**
  87383. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87384. */
  87385. emitRate: number;
  87386. /**
  87387. * You can use gravity if you want to give an orientation to your particles.
  87388. */
  87389. gravity: Vector3;
  87390. /**
  87391. * Minimum power of emitting particles.
  87392. */
  87393. minEmitPower: number;
  87394. /**
  87395. * Maximum power of emitting particles.
  87396. */
  87397. maxEmitPower: number;
  87398. /**
  87399. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87400. */
  87401. minAngularSpeed: number;
  87402. /**
  87403. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87404. */
  87405. maxAngularSpeed: number;
  87406. /**
  87407. * Gets or sets the minimal initial rotation in radians.
  87408. */
  87409. minInitialRotation: number;
  87410. /**
  87411. * Gets or sets the maximal initial rotation in radians.
  87412. */
  87413. maxInitialRotation: number;
  87414. /**
  87415. * The particle emitter type defines the emitter used by the particle system.
  87416. * It can be for example box, sphere, or cone...
  87417. */
  87418. particleEmitterType: Nullable<IParticleEmitterType>;
  87419. /**
  87420. * Defines the delay in milliseconds before starting the system (0 by default)
  87421. */
  87422. startDelay: number;
  87423. /**
  87424. * 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
  87425. */
  87426. preWarmCycles: number;
  87427. /**
  87428. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87429. */
  87430. preWarmStepOffset: number;
  87431. /**
  87432. * 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)
  87433. */
  87434. spriteCellChangeSpeed: number;
  87435. /**
  87436. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87437. */
  87438. startSpriteCellID: number;
  87439. /**
  87440. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87441. */
  87442. endSpriteCellID: number;
  87443. /**
  87444. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87445. */
  87446. spriteCellWidth: number;
  87447. /**
  87448. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87449. */
  87450. spriteCellHeight: number;
  87451. /**
  87452. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87453. */
  87454. spriteRandomStartCell: boolean;
  87455. /**
  87456. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87457. */
  87458. isAnimationSheetEnabled: boolean;
  87459. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87460. translationPivot: Vector2;
  87461. /**
  87462. * Gets or sets a texture used to add random noise to particle positions
  87463. */
  87464. noiseTexture: Nullable<BaseTexture>;
  87465. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87466. noiseStrength: Vector3;
  87467. /**
  87468. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87469. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87470. */
  87471. billboardMode: number;
  87472. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87473. limitVelocityDamping: number;
  87474. /**
  87475. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87476. */
  87477. beginAnimationOnStart: boolean;
  87478. /**
  87479. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87480. */
  87481. beginAnimationFrom: number;
  87482. /**
  87483. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87484. */
  87485. beginAnimationTo: number;
  87486. /**
  87487. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87488. */
  87489. beginAnimationLoop: boolean;
  87490. /**
  87491. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87492. */
  87493. disposeOnStop: boolean;
  87494. /**
  87495. * Gets the maximum number of particles active at the same time.
  87496. * @returns The max number of active particles.
  87497. */
  87498. getCapacity(): number;
  87499. /**
  87500. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87501. * @returns True if it has been started, otherwise false.
  87502. */
  87503. isStarted(): boolean;
  87504. /**
  87505. * Animates the particle system for this frame.
  87506. */
  87507. animate(): void;
  87508. /**
  87509. * Renders the particle system in its current state.
  87510. * @returns the current number of particles
  87511. */
  87512. render(): number;
  87513. /**
  87514. * Dispose the particle system and frees its associated resources.
  87515. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87516. */
  87517. dispose(disposeTexture?: boolean): void;
  87518. /**
  87519. * Clones the particle system.
  87520. * @param name The name of the cloned object
  87521. * @param newEmitter The new emitter to use
  87522. * @returns the cloned particle system
  87523. */
  87524. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87525. /**
  87526. * Serializes the particle system to a JSON object.
  87527. * @returns the JSON object
  87528. */
  87529. serialize(): any;
  87530. /**
  87531. * Rebuild the particle system
  87532. */
  87533. rebuild(): void;
  87534. /**
  87535. * Starts the particle system and begins to emit
  87536. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87537. */
  87538. start(delay?: number): void;
  87539. /**
  87540. * Stops the particle system.
  87541. */
  87542. stop(): void;
  87543. /**
  87544. * Remove all active particles
  87545. */
  87546. reset(): void;
  87547. /**
  87548. * Is this system ready to be used/rendered
  87549. * @return true if the system is ready
  87550. */
  87551. isReady(): boolean;
  87552. /**
  87553. * Adds a new color gradient
  87554. * @param gradient defines the gradient to use (between 0 and 1)
  87555. * @param color1 defines the color to affect to the specified gradient
  87556. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87557. * @returns the current particle system
  87558. */
  87559. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87560. /**
  87561. * Remove a specific color gradient
  87562. * @param gradient defines the gradient to remove
  87563. * @returns the current particle system
  87564. */
  87565. removeColorGradient(gradient: number): IParticleSystem;
  87566. /**
  87567. * Adds a new size gradient
  87568. * @param gradient defines the gradient to use (between 0 and 1)
  87569. * @param factor defines the size factor to affect to the specified gradient
  87570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87571. * @returns the current particle system
  87572. */
  87573. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87574. /**
  87575. * Remove a specific size gradient
  87576. * @param gradient defines the gradient to remove
  87577. * @returns the current particle system
  87578. */
  87579. removeSizeGradient(gradient: number): IParticleSystem;
  87580. /**
  87581. * Gets the current list of color gradients.
  87582. * You must use addColorGradient and removeColorGradient to udpate this list
  87583. * @returns the list of color gradients
  87584. */
  87585. getColorGradients(): Nullable<Array<ColorGradient>>;
  87586. /**
  87587. * Gets the current list of size gradients.
  87588. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87589. * @returns the list of size gradients
  87590. */
  87591. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87592. /**
  87593. * Gets the current list of angular speed gradients.
  87594. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87595. * @returns the list of angular speed gradients
  87596. */
  87597. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87598. /**
  87599. * Adds a new angular speed gradient
  87600. * @param gradient defines the gradient to use (between 0 and 1)
  87601. * @param factor defines the angular speed to affect to the specified gradient
  87602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87603. * @returns the current particle system
  87604. */
  87605. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87606. /**
  87607. * Remove a specific angular speed gradient
  87608. * @param gradient defines the gradient to remove
  87609. * @returns the current particle system
  87610. */
  87611. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87612. /**
  87613. * Gets the current list of velocity gradients.
  87614. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87615. * @returns the list of velocity gradients
  87616. */
  87617. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87618. /**
  87619. * Adds a new velocity gradient
  87620. * @param gradient defines the gradient to use (between 0 and 1)
  87621. * @param factor defines the velocity to affect to the specified gradient
  87622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87623. * @returns the current particle system
  87624. */
  87625. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87626. /**
  87627. * Remove a specific velocity gradient
  87628. * @param gradient defines the gradient to remove
  87629. * @returns the current particle system
  87630. */
  87631. removeVelocityGradient(gradient: number): IParticleSystem;
  87632. /**
  87633. * Gets the current list of limit velocity gradients.
  87634. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87635. * @returns the list of limit velocity gradients
  87636. */
  87637. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87638. /**
  87639. * Adds a new limit velocity gradient
  87640. * @param gradient defines the gradient to use (between 0 and 1)
  87641. * @param factor defines the limit velocity to affect to the specified gradient
  87642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87643. * @returns the current particle system
  87644. */
  87645. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87646. /**
  87647. * Remove a specific limit velocity gradient
  87648. * @param gradient defines the gradient to remove
  87649. * @returns the current particle system
  87650. */
  87651. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87652. /**
  87653. * Adds a new drag gradient
  87654. * @param gradient defines the gradient to use (between 0 and 1)
  87655. * @param factor defines the drag to affect to the specified gradient
  87656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87657. * @returns the current particle system
  87658. */
  87659. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87660. /**
  87661. * Remove a specific drag gradient
  87662. * @param gradient defines the gradient to remove
  87663. * @returns the current particle system
  87664. */
  87665. removeDragGradient(gradient: number): IParticleSystem;
  87666. /**
  87667. * Gets the current list of drag gradients.
  87668. * You must use addDragGradient and removeDragGradient to udpate this list
  87669. * @returns the list of drag gradients
  87670. */
  87671. getDragGradients(): Nullable<Array<FactorGradient>>;
  87672. /**
  87673. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87674. * @param gradient defines the gradient to use (between 0 and 1)
  87675. * @param factor defines the emit rate to affect to the specified gradient
  87676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87677. * @returns the current particle system
  87678. */
  87679. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87680. /**
  87681. * Remove a specific emit rate gradient
  87682. * @param gradient defines the gradient to remove
  87683. * @returns the current particle system
  87684. */
  87685. removeEmitRateGradient(gradient: number): IParticleSystem;
  87686. /**
  87687. * Gets the current list of emit rate gradients.
  87688. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87689. * @returns the list of emit rate gradients
  87690. */
  87691. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87692. /**
  87693. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87694. * @param gradient defines the gradient to use (between 0 and 1)
  87695. * @param factor defines the start size to affect to the specified gradient
  87696. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87697. * @returns the current particle system
  87698. */
  87699. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87700. /**
  87701. * Remove a specific start size gradient
  87702. * @param gradient defines the gradient to remove
  87703. * @returns the current particle system
  87704. */
  87705. removeStartSizeGradient(gradient: number): IParticleSystem;
  87706. /**
  87707. * Gets the current list of start size gradients.
  87708. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87709. * @returns the list of start size gradients
  87710. */
  87711. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87712. /**
  87713. * Adds a new life time gradient
  87714. * @param gradient defines the gradient to use (between 0 and 1)
  87715. * @param factor defines the life time factor to affect to the specified gradient
  87716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87717. * @returns the current particle system
  87718. */
  87719. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87720. /**
  87721. * Remove a specific life time gradient
  87722. * @param gradient defines the gradient to remove
  87723. * @returns the current particle system
  87724. */
  87725. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87726. /**
  87727. * Gets the current list of life time gradients.
  87728. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87729. * @returns the list of life time gradients
  87730. */
  87731. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87732. /**
  87733. * Gets the current list of color gradients.
  87734. * You must use addColorGradient and removeColorGradient to udpate this list
  87735. * @returns the list of color gradients
  87736. */
  87737. getColorGradients(): Nullable<Array<ColorGradient>>;
  87738. /**
  87739. * Adds a new ramp gradient used to remap particle colors
  87740. * @param gradient defines the gradient to use (between 0 and 1)
  87741. * @param color defines the color to affect to the specified gradient
  87742. * @returns the current particle system
  87743. */
  87744. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87745. /**
  87746. * Gets the current list of ramp gradients.
  87747. * You must use addRampGradient and removeRampGradient to udpate this list
  87748. * @returns the list of ramp gradients
  87749. */
  87750. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87751. /** Gets or sets a boolean indicating that ramp gradients must be used
  87752. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87753. */
  87754. useRampGradients: boolean;
  87755. /**
  87756. * Adds a new color remap gradient
  87757. * @param gradient defines the gradient to use (between 0 and 1)
  87758. * @param min defines the color remap minimal range
  87759. * @param max defines the color remap maximal range
  87760. * @returns the current particle system
  87761. */
  87762. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87763. /**
  87764. * Gets the current list of color remap gradients.
  87765. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87766. * @returns the list of color remap gradients
  87767. */
  87768. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87769. /**
  87770. * Adds a new alpha remap gradient
  87771. * @param gradient defines the gradient to use (between 0 and 1)
  87772. * @param min defines the alpha remap minimal range
  87773. * @param max defines the alpha remap maximal range
  87774. * @returns the current particle system
  87775. */
  87776. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87777. /**
  87778. * Gets the current list of alpha remap gradients.
  87779. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87780. * @returns the list of alpha remap gradients
  87781. */
  87782. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87783. /**
  87784. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87785. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87786. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87787. * @returns the emitter
  87788. */
  87789. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87790. /**
  87791. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87792. * @param radius The radius of the hemisphere to emit from
  87793. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87794. * @returns the emitter
  87795. */
  87796. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87797. /**
  87798. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87799. * @param radius The radius of the sphere to emit from
  87800. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87801. * @returns the emitter
  87802. */
  87803. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87804. /**
  87805. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87806. * @param radius The radius of the sphere to emit from
  87807. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87808. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87809. * @returns the emitter
  87810. */
  87811. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87812. /**
  87813. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87814. * @param radius The radius of the emission cylinder
  87815. * @param height The height of the emission cylinder
  87816. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87817. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87818. * @returns the emitter
  87819. */
  87820. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87821. /**
  87822. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87823. * @param radius The radius of the cylinder to emit from
  87824. * @param height The height of the emission cylinder
  87825. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87826. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87827. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87828. * @returns the emitter
  87829. */
  87830. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87831. /**
  87832. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87833. * @param radius The radius of the cone to emit from
  87834. * @param angle The base angle of the cone
  87835. * @returns the emitter
  87836. */
  87837. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87838. /**
  87839. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87842. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87843. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87844. * @returns the emitter
  87845. */
  87846. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87847. /**
  87848. * Get hosting scene
  87849. * @returns the scene
  87850. */
  87851. getScene(): Scene;
  87852. }
  87853. }
  87854. declare module BABYLON {
  87855. /**
  87856. * Creates an instance based on a source mesh.
  87857. */
  87858. export class InstancedMesh extends AbstractMesh {
  87859. private _sourceMesh;
  87860. private _currentLOD;
  87861. /** @hidden */
  87862. _indexInSourceMeshInstanceArray: number;
  87863. constructor(name: string, source: Mesh);
  87864. /**
  87865. * Returns the string "InstancedMesh".
  87866. */
  87867. getClassName(): string;
  87868. /** Gets the list of lights affecting that mesh */
  87869. readonly lightSources: Light[];
  87870. _resyncLightSources(): void;
  87871. _resyncLightSource(light: Light): void;
  87872. _removeLightSource(light: Light, dispose: boolean): void;
  87873. /**
  87874. * If the source mesh receives shadows
  87875. */
  87876. readonly receiveShadows: boolean;
  87877. /**
  87878. * The material of the source mesh
  87879. */
  87880. readonly material: Nullable<Material>;
  87881. /**
  87882. * Visibility of the source mesh
  87883. */
  87884. readonly visibility: number;
  87885. /**
  87886. * Skeleton of the source mesh
  87887. */
  87888. readonly skeleton: Nullable<Skeleton>;
  87889. /**
  87890. * Rendering ground id of the source mesh
  87891. */
  87892. renderingGroupId: number;
  87893. /**
  87894. * Returns the total number of vertices (integer).
  87895. */
  87896. getTotalVertices(): number;
  87897. /**
  87898. * Returns a positive integer : the total number of indices in this mesh geometry.
  87899. * @returns the numner of indices or zero if the mesh has no geometry.
  87900. */
  87901. getTotalIndices(): number;
  87902. /**
  87903. * The source mesh of the instance
  87904. */
  87905. readonly sourceMesh: Mesh;
  87906. /**
  87907. * Is this node ready to be used/rendered
  87908. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87909. * @return {boolean} is it ready
  87910. */
  87911. isReady(completeCheck?: boolean): boolean;
  87912. /**
  87913. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87914. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87915. * @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.
  87916. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87917. */
  87918. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87919. /**
  87920. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87921. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87922. * The `data` are either a numeric array either a Float32Array.
  87923. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87924. * 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).
  87925. * Note that a new underlying VertexBuffer object is created each call.
  87926. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87927. *
  87928. * Possible `kind` values :
  87929. * - VertexBuffer.PositionKind
  87930. * - VertexBuffer.UVKind
  87931. * - VertexBuffer.UV2Kind
  87932. * - VertexBuffer.UV3Kind
  87933. * - VertexBuffer.UV4Kind
  87934. * - VertexBuffer.UV5Kind
  87935. * - VertexBuffer.UV6Kind
  87936. * - VertexBuffer.ColorKind
  87937. * - VertexBuffer.MatricesIndicesKind
  87938. * - VertexBuffer.MatricesIndicesExtraKind
  87939. * - VertexBuffer.MatricesWeightsKind
  87940. * - VertexBuffer.MatricesWeightsExtraKind
  87941. *
  87942. * Returns the Mesh.
  87943. */
  87944. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87945. /**
  87946. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87947. * If the mesh has no geometry, it is simply returned as it is.
  87948. * The `data` are either a numeric array either a Float32Array.
  87949. * No new underlying VertexBuffer object is created.
  87950. * 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.
  87951. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87952. *
  87953. * Possible `kind` values :
  87954. * - VertexBuffer.PositionKind
  87955. * - VertexBuffer.UVKind
  87956. * - VertexBuffer.UV2Kind
  87957. * - VertexBuffer.UV3Kind
  87958. * - VertexBuffer.UV4Kind
  87959. * - VertexBuffer.UV5Kind
  87960. * - VertexBuffer.UV6Kind
  87961. * - VertexBuffer.ColorKind
  87962. * - VertexBuffer.MatricesIndicesKind
  87963. * - VertexBuffer.MatricesIndicesExtraKind
  87964. * - VertexBuffer.MatricesWeightsKind
  87965. * - VertexBuffer.MatricesWeightsExtraKind
  87966. *
  87967. * Returns the Mesh.
  87968. */
  87969. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87970. /**
  87971. * Sets the mesh indices.
  87972. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87973. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87974. * This method creates a new index buffer each call.
  87975. * Returns the Mesh.
  87976. */
  87977. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87978. /**
  87979. * Boolean : True if the mesh owns the requested kind of data.
  87980. */
  87981. isVerticesDataPresent(kind: string): boolean;
  87982. /**
  87983. * Returns an array of indices (IndicesArray).
  87984. */
  87985. getIndices(): Nullable<IndicesArray>;
  87986. readonly _positions: Nullable<Vector3[]>;
  87987. /**
  87988. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87989. * This means the mesh underlying bounding box and sphere are recomputed.
  87990. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87991. * @returns the current mesh
  87992. */
  87993. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87994. /** @hidden */
  87995. _preActivate(): InstancedMesh;
  87996. /** @hidden */
  87997. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87998. /** @hidden */
  87999. _postActivate(): void;
  88000. getWorldMatrix(): Matrix;
  88001. readonly isAnInstance: boolean;
  88002. /**
  88003. * Returns the current associated LOD AbstractMesh.
  88004. */
  88005. getLOD(camera: Camera): AbstractMesh;
  88006. /** @hidden */
  88007. _syncSubMeshes(): InstancedMesh;
  88008. /** @hidden */
  88009. _generatePointsArray(): boolean;
  88010. /**
  88011. * Creates a new InstancedMesh from the current mesh.
  88012. * - name (string) : the cloned mesh name
  88013. * - newParent (optional Node) : the optional Node to parent the clone to.
  88014. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88015. *
  88016. * Returns the clone.
  88017. */
  88018. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88019. /**
  88020. * Disposes the InstancedMesh.
  88021. * Returns nothing.
  88022. */
  88023. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88024. }
  88025. interface Mesh {
  88026. /**
  88027. * Register a custom buffer that will be instanced
  88028. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88029. * @param kind defines the buffer kind
  88030. * @param stride defines the stride in floats
  88031. */
  88032. registerInstancedBuffer(kind: string, stride: number): void;
  88033. /** @hidden */
  88034. _userInstancedBuffersStorage: {
  88035. data: {
  88036. [key: string]: Float32Array;
  88037. };
  88038. sizes: {
  88039. [key: string]: number;
  88040. };
  88041. vertexBuffers: {
  88042. [key: string]: Nullable<VertexBuffer>;
  88043. };
  88044. strides: {
  88045. [key: string]: number;
  88046. };
  88047. };
  88048. }
  88049. interface AbstractMesh {
  88050. /**
  88051. * Object used to store instanced buffers defined by user
  88052. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88053. */
  88054. instancedBuffers: {
  88055. [key: string]: any;
  88056. };
  88057. }
  88058. }
  88059. declare module BABYLON {
  88060. /**
  88061. * Defines the options associated with the creation of a shader material.
  88062. */
  88063. export interface IShaderMaterialOptions {
  88064. /**
  88065. * Does the material work in alpha blend mode
  88066. */
  88067. needAlphaBlending: boolean;
  88068. /**
  88069. * Does the material work in alpha test mode
  88070. */
  88071. needAlphaTesting: boolean;
  88072. /**
  88073. * The list of attribute names used in the shader
  88074. */
  88075. attributes: string[];
  88076. /**
  88077. * The list of unifrom names used in the shader
  88078. */
  88079. uniforms: string[];
  88080. /**
  88081. * The list of UBO names used in the shader
  88082. */
  88083. uniformBuffers: string[];
  88084. /**
  88085. * The list of sampler names used in the shader
  88086. */
  88087. samplers: string[];
  88088. /**
  88089. * The list of defines used in the shader
  88090. */
  88091. defines: string[];
  88092. }
  88093. /**
  88094. * 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.
  88095. *
  88096. * This returned material effects how the mesh will look based on the code in the shaders.
  88097. *
  88098. * @see http://doc.babylonjs.com/how_to/shader_material
  88099. */
  88100. export class ShaderMaterial extends Material {
  88101. private _shaderPath;
  88102. private _options;
  88103. private _textures;
  88104. private _textureArrays;
  88105. private _floats;
  88106. private _ints;
  88107. private _floatsArrays;
  88108. private _colors3;
  88109. private _colors3Arrays;
  88110. private _colors4;
  88111. private _colors4Arrays;
  88112. private _vectors2;
  88113. private _vectors3;
  88114. private _vectors4;
  88115. private _matrices;
  88116. private _matrixArrays;
  88117. private _matrices3x3;
  88118. private _matrices2x2;
  88119. private _vectors2Arrays;
  88120. private _vectors3Arrays;
  88121. private _vectors4Arrays;
  88122. private _cachedWorldViewMatrix;
  88123. private _cachedWorldViewProjectionMatrix;
  88124. private _renderId;
  88125. private _multiview;
  88126. /**
  88127. * Instantiate a new shader material.
  88128. * 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.
  88129. * This returned material effects how the mesh will look based on the code in the shaders.
  88130. * @see http://doc.babylonjs.com/how_to/shader_material
  88131. * @param name Define the name of the material in the scene
  88132. * @param scene Define the scene the material belongs to
  88133. * @param shaderPath Defines the route to the shader code in one of three ways:
  88134. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88135. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88136. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88137. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88138. * @param options Define the options used to create the shader
  88139. */
  88140. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88141. /**
  88142. * Gets the shader path used to define the shader code
  88143. * It can be modified to trigger a new compilation
  88144. */
  88145. /**
  88146. * Sets the shader path used to define the shader code
  88147. * It can be modified to trigger a new compilation
  88148. */
  88149. shaderPath: any;
  88150. /**
  88151. * Gets the options used to compile the shader.
  88152. * They can be modified to trigger a new compilation
  88153. */
  88154. readonly options: IShaderMaterialOptions;
  88155. /**
  88156. * Gets the current class name of the material e.g. "ShaderMaterial"
  88157. * Mainly use in serialization.
  88158. * @returns the class name
  88159. */
  88160. getClassName(): string;
  88161. /**
  88162. * Specifies if the material will require alpha blending
  88163. * @returns a boolean specifying if alpha blending is needed
  88164. */
  88165. needAlphaBlending(): boolean;
  88166. /**
  88167. * Specifies if this material should be rendered in alpha test mode
  88168. * @returns a boolean specifying if an alpha test is needed.
  88169. */
  88170. needAlphaTesting(): boolean;
  88171. private _checkUniform;
  88172. /**
  88173. * Set a texture in the shader.
  88174. * @param name Define the name of the uniform samplers as defined in the shader
  88175. * @param texture Define the texture to bind to this sampler
  88176. * @return the material itself allowing "fluent" like uniform updates
  88177. */
  88178. setTexture(name: string, texture: Texture): ShaderMaterial;
  88179. /**
  88180. * Set a texture array in the shader.
  88181. * @param name Define the name of the uniform sampler array as defined in the shader
  88182. * @param textures Define the list of textures to bind to this sampler
  88183. * @return the material itself allowing "fluent" like uniform updates
  88184. */
  88185. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88186. /**
  88187. * Set a float in the shader.
  88188. * @param name Define the name of the uniform as defined in the shader
  88189. * @param value Define the value to give to the uniform
  88190. * @return the material itself allowing "fluent" like uniform updates
  88191. */
  88192. setFloat(name: string, value: number): ShaderMaterial;
  88193. /**
  88194. * Set a int in the shader.
  88195. * @param name Define the name of the uniform as defined in the shader
  88196. * @param value Define the value to give to the uniform
  88197. * @return the material itself allowing "fluent" like uniform updates
  88198. */
  88199. setInt(name: string, value: number): ShaderMaterial;
  88200. /**
  88201. * Set an array of floats in the shader.
  88202. * @param name Define the name of the uniform as defined in the shader
  88203. * @param value Define the value to give to the uniform
  88204. * @return the material itself allowing "fluent" like uniform updates
  88205. */
  88206. setFloats(name: string, value: number[]): ShaderMaterial;
  88207. /**
  88208. * Set a vec3 in the shader from a Color3.
  88209. * @param name Define the name of the uniform as defined in the shader
  88210. * @param value Define the value to give to the uniform
  88211. * @return the material itself allowing "fluent" like uniform updates
  88212. */
  88213. setColor3(name: string, value: Color3): ShaderMaterial;
  88214. /**
  88215. * Set a vec3 array in the shader from a Color3 array.
  88216. * @param name Define the name of the uniform as defined in the shader
  88217. * @param value Define the value to give to the uniform
  88218. * @return the material itself allowing "fluent" like uniform updates
  88219. */
  88220. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88221. /**
  88222. * Set a vec4 in the shader from a Color4.
  88223. * @param name Define the name of the uniform as defined in the shader
  88224. * @param value Define the value to give to the uniform
  88225. * @return the material itself allowing "fluent" like uniform updates
  88226. */
  88227. setColor4(name: string, value: Color4): ShaderMaterial;
  88228. /**
  88229. * Set a vec4 array in the shader from a Color4 array.
  88230. * @param name Define the name of the uniform as defined in the shader
  88231. * @param value Define the value to give to the uniform
  88232. * @return the material itself allowing "fluent" like uniform updates
  88233. */
  88234. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88235. /**
  88236. * Set a vec2 in the shader from a Vector2.
  88237. * @param name Define the name of the uniform as defined in the shader
  88238. * @param value Define the value to give to the uniform
  88239. * @return the material itself allowing "fluent" like uniform updates
  88240. */
  88241. setVector2(name: string, value: Vector2): ShaderMaterial;
  88242. /**
  88243. * Set a vec3 in the shader from a Vector3.
  88244. * @param name Define the name of the uniform as defined in the shader
  88245. * @param value Define the value to give to the uniform
  88246. * @return the material itself allowing "fluent" like uniform updates
  88247. */
  88248. setVector3(name: string, value: Vector3): ShaderMaterial;
  88249. /**
  88250. * Set a vec4 in the shader from a Vector4.
  88251. * @param name Define the name of the uniform as defined in the shader
  88252. * @param value Define the value to give to the uniform
  88253. * @return the material itself allowing "fluent" like uniform updates
  88254. */
  88255. setVector4(name: string, value: Vector4): ShaderMaterial;
  88256. /**
  88257. * Set a mat4 in the shader from a Matrix.
  88258. * @param name Define the name of the uniform as defined in the shader
  88259. * @param value Define the value to give to the uniform
  88260. * @return the material itself allowing "fluent" like uniform updates
  88261. */
  88262. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88263. /**
  88264. * Set a float32Array in the shader from a matrix array.
  88265. * @param name Define the name of the uniform as defined in the shader
  88266. * @param value Define the value to give to the uniform
  88267. * @return the material itself allowing "fluent" like uniform updates
  88268. */
  88269. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88270. /**
  88271. * Set a mat3 in the shader from a Float32Array.
  88272. * @param name Define the name of the uniform as defined in the shader
  88273. * @param value Define the value to give to the uniform
  88274. * @return the material itself allowing "fluent" like uniform updates
  88275. */
  88276. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88277. /**
  88278. * Set a mat2 in the shader from a Float32Array.
  88279. * @param name Define the name of the uniform as defined in the shader
  88280. * @param value Define the value to give to the uniform
  88281. * @return the material itself allowing "fluent" like uniform updates
  88282. */
  88283. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88284. /**
  88285. * Set a vec2 array in the shader from a number array.
  88286. * @param name Define the name of the uniform as defined in the shader
  88287. * @param value Define the value to give to the uniform
  88288. * @return the material itself allowing "fluent" like uniform updates
  88289. */
  88290. setArray2(name: string, value: number[]): ShaderMaterial;
  88291. /**
  88292. * Set a vec3 array in the shader from a number array.
  88293. * @param name Define the name of the uniform as defined in the shader
  88294. * @param value Define the value to give to the uniform
  88295. * @return the material itself allowing "fluent" like uniform updates
  88296. */
  88297. setArray3(name: string, value: number[]): ShaderMaterial;
  88298. /**
  88299. * Set a vec4 array in the shader from a number array.
  88300. * @param name Define the name of the uniform as defined in the shader
  88301. * @param value Define the value to give to the uniform
  88302. * @return the material itself allowing "fluent" like uniform updates
  88303. */
  88304. setArray4(name: string, value: number[]): ShaderMaterial;
  88305. private _checkCache;
  88306. /**
  88307. * Specifies that the submesh is ready to be used
  88308. * @param mesh defines the mesh to check
  88309. * @param subMesh defines which submesh to check
  88310. * @param useInstances specifies that instances should be used
  88311. * @returns a boolean indicating that the submesh is ready or not
  88312. */
  88313. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88314. /**
  88315. * Checks if the material is ready to render the requested mesh
  88316. * @param mesh Define the mesh to render
  88317. * @param useInstances Define whether or not the material is used with instances
  88318. * @returns true if ready, otherwise false
  88319. */
  88320. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88321. /**
  88322. * Binds the world matrix to the material
  88323. * @param world defines the world transformation matrix
  88324. */
  88325. bindOnlyWorldMatrix(world: Matrix): void;
  88326. /**
  88327. * Binds the material to the mesh
  88328. * @param world defines the world transformation matrix
  88329. * @param mesh defines the mesh to bind the material to
  88330. */
  88331. bind(world: Matrix, mesh?: Mesh): void;
  88332. /**
  88333. * Gets the active textures from the material
  88334. * @returns an array of textures
  88335. */
  88336. getActiveTextures(): BaseTexture[];
  88337. /**
  88338. * Specifies if the material uses a texture
  88339. * @param texture defines the texture to check against the material
  88340. * @returns a boolean specifying if the material uses the texture
  88341. */
  88342. hasTexture(texture: BaseTexture): boolean;
  88343. /**
  88344. * Makes a duplicate of the material, and gives it a new name
  88345. * @param name defines the new name for the duplicated material
  88346. * @returns the cloned material
  88347. */
  88348. clone(name: string): ShaderMaterial;
  88349. /**
  88350. * Disposes the material
  88351. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88352. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88353. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88354. */
  88355. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88356. /**
  88357. * Serializes this material in a JSON representation
  88358. * @returns the serialized material object
  88359. */
  88360. serialize(): any;
  88361. /**
  88362. * Creates a shader material from parsed shader material data
  88363. * @param source defines the JSON represnetation of the material
  88364. * @param scene defines the hosting scene
  88365. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88366. * @returns a new material
  88367. */
  88368. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88369. }
  88370. }
  88371. declare module BABYLON {
  88372. /** @hidden */
  88373. export var colorPixelShader: {
  88374. name: string;
  88375. shader: string;
  88376. };
  88377. }
  88378. declare module BABYLON {
  88379. /** @hidden */
  88380. export var colorVertexShader: {
  88381. name: string;
  88382. shader: string;
  88383. };
  88384. }
  88385. declare module BABYLON {
  88386. /**
  88387. * Line mesh
  88388. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88389. */
  88390. export class LinesMesh extends Mesh {
  88391. /**
  88392. * If vertex color should be applied to the mesh
  88393. */
  88394. readonly useVertexColor?: boolean | undefined;
  88395. /**
  88396. * If vertex alpha should be applied to the mesh
  88397. */
  88398. readonly useVertexAlpha?: boolean | undefined;
  88399. /**
  88400. * Color of the line (Default: White)
  88401. */
  88402. color: Color3;
  88403. /**
  88404. * Alpha of the line (Default: 1)
  88405. */
  88406. alpha: number;
  88407. /**
  88408. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88409. * This margin is expressed in world space coordinates, so its value may vary.
  88410. * Default value is 0.1
  88411. */
  88412. intersectionThreshold: number;
  88413. private _colorShader;
  88414. private color4;
  88415. /**
  88416. * Creates a new LinesMesh
  88417. * @param name defines the name
  88418. * @param scene defines the hosting scene
  88419. * @param parent defines the parent mesh if any
  88420. * @param source defines the optional source LinesMesh used to clone data from
  88421. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88422. * When false, achieved by calling a clone(), also passing False.
  88423. * This will make creation of children, recursive.
  88424. * @param useVertexColor defines if this LinesMesh supports vertex color
  88425. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88426. */
  88427. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88428. /**
  88429. * If vertex color should be applied to the mesh
  88430. */
  88431. useVertexColor?: boolean | undefined,
  88432. /**
  88433. * If vertex alpha should be applied to the mesh
  88434. */
  88435. useVertexAlpha?: boolean | undefined);
  88436. private _addClipPlaneDefine;
  88437. private _removeClipPlaneDefine;
  88438. isReady(): boolean;
  88439. /**
  88440. * Returns the string "LineMesh"
  88441. */
  88442. getClassName(): string;
  88443. /**
  88444. * @hidden
  88445. */
  88446. /**
  88447. * @hidden
  88448. */
  88449. material: Material;
  88450. /**
  88451. * @hidden
  88452. */
  88453. readonly checkCollisions: boolean;
  88454. /** @hidden */
  88455. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88456. /** @hidden */
  88457. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88458. /**
  88459. * Disposes of the line mesh
  88460. * @param doNotRecurse If children should be disposed
  88461. */
  88462. dispose(doNotRecurse?: boolean): void;
  88463. /**
  88464. * Returns a new LineMesh object cloned from the current one.
  88465. */
  88466. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88467. /**
  88468. * Creates a new InstancedLinesMesh object from the mesh model.
  88469. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88470. * @param name defines the name of the new instance
  88471. * @returns a new InstancedLinesMesh
  88472. */
  88473. createInstance(name: string): InstancedLinesMesh;
  88474. }
  88475. /**
  88476. * Creates an instance based on a source LinesMesh
  88477. */
  88478. export class InstancedLinesMesh extends InstancedMesh {
  88479. /**
  88480. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88481. * This margin is expressed in world space coordinates, so its value may vary.
  88482. * Initilized with the intersectionThreshold value of the source LinesMesh
  88483. */
  88484. intersectionThreshold: number;
  88485. constructor(name: string, source: LinesMesh);
  88486. /**
  88487. * Returns the string "InstancedLinesMesh".
  88488. */
  88489. getClassName(): string;
  88490. }
  88491. }
  88492. declare module BABYLON {
  88493. /** @hidden */
  88494. export var linePixelShader: {
  88495. name: string;
  88496. shader: string;
  88497. };
  88498. }
  88499. declare module BABYLON {
  88500. /** @hidden */
  88501. export var lineVertexShader: {
  88502. name: string;
  88503. shader: string;
  88504. };
  88505. }
  88506. declare module BABYLON {
  88507. interface AbstractMesh {
  88508. /**
  88509. * Gets the edgesRenderer associated with the mesh
  88510. */
  88511. edgesRenderer: Nullable<EdgesRenderer>;
  88512. }
  88513. interface LinesMesh {
  88514. /**
  88515. * Enables the edge rendering mode on the mesh.
  88516. * This mode makes the mesh edges visible
  88517. * @param epsilon defines the maximal distance between two angles to detect a face
  88518. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88519. * @returns the currentAbstractMesh
  88520. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88521. */
  88522. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88523. }
  88524. interface InstancedLinesMesh {
  88525. /**
  88526. * Enables the edge rendering mode on the mesh.
  88527. * This mode makes the mesh edges visible
  88528. * @param epsilon defines the maximal distance between two angles to detect a face
  88529. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88530. * @returns the current InstancedLinesMesh
  88531. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88532. */
  88533. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88534. }
  88535. /**
  88536. * Defines the minimum contract an Edges renderer should follow.
  88537. */
  88538. export interface IEdgesRenderer extends IDisposable {
  88539. /**
  88540. * Gets or sets a boolean indicating if the edgesRenderer is active
  88541. */
  88542. isEnabled: boolean;
  88543. /**
  88544. * Renders the edges of the attached mesh,
  88545. */
  88546. render(): void;
  88547. /**
  88548. * Checks wether or not the edges renderer is ready to render.
  88549. * @return true if ready, otherwise false.
  88550. */
  88551. isReady(): boolean;
  88552. }
  88553. /**
  88554. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88555. */
  88556. export class EdgesRenderer implements IEdgesRenderer {
  88557. /**
  88558. * Define the size of the edges with an orthographic camera
  88559. */
  88560. edgesWidthScalerForOrthographic: number;
  88561. /**
  88562. * Define the size of the edges with a perspective camera
  88563. */
  88564. edgesWidthScalerForPerspective: number;
  88565. protected _source: AbstractMesh;
  88566. protected _linesPositions: number[];
  88567. protected _linesNormals: number[];
  88568. protected _linesIndices: number[];
  88569. protected _epsilon: number;
  88570. protected _indicesCount: number;
  88571. protected _lineShader: ShaderMaterial;
  88572. protected _ib: DataBuffer;
  88573. protected _buffers: {
  88574. [key: string]: Nullable<VertexBuffer>;
  88575. };
  88576. protected _checkVerticesInsteadOfIndices: boolean;
  88577. private _meshRebuildObserver;
  88578. private _meshDisposeObserver;
  88579. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88580. isEnabled: boolean;
  88581. /**
  88582. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88583. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88584. * @param source Mesh used to create edges
  88585. * @param epsilon sum of angles in adjacency to check for edge
  88586. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88587. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88588. */
  88589. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88590. protected _prepareRessources(): void;
  88591. /** @hidden */
  88592. _rebuild(): void;
  88593. /**
  88594. * Releases the required resources for the edges renderer
  88595. */
  88596. dispose(): void;
  88597. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88598. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88599. /**
  88600. * Checks if the pair of p0 and p1 is en edge
  88601. * @param faceIndex
  88602. * @param edge
  88603. * @param faceNormals
  88604. * @param p0
  88605. * @param p1
  88606. * @private
  88607. */
  88608. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88609. /**
  88610. * push line into the position, normal and index buffer
  88611. * @protected
  88612. */
  88613. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88614. /**
  88615. * Generates lines edges from adjacencjes
  88616. * @private
  88617. */
  88618. _generateEdgesLines(): void;
  88619. /**
  88620. * Checks wether or not the edges renderer is ready to render.
  88621. * @return true if ready, otherwise false.
  88622. */
  88623. isReady(): boolean;
  88624. /**
  88625. * Renders the edges of the attached mesh,
  88626. */
  88627. render(): void;
  88628. }
  88629. /**
  88630. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  88631. */
  88632. export class LineEdgesRenderer extends EdgesRenderer {
  88633. /**
  88634. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  88635. * @param source LineMesh used to generate edges
  88636. * @param epsilon not important (specified angle for edge detection)
  88637. * @param checkVerticesInsteadOfIndices not important for LineMesh
  88638. */
  88639. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  88640. /**
  88641. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  88642. */
  88643. _generateEdgesLines(): void;
  88644. }
  88645. }
  88646. declare module BABYLON {
  88647. /**
  88648. * This represents the object necessary to create a rendering group.
  88649. * This is exclusively used and created by the rendering manager.
  88650. * To modify the behavior, you use the available helpers in your scene or meshes.
  88651. * @hidden
  88652. */
  88653. export class RenderingGroup {
  88654. index: number;
  88655. private static _zeroVector;
  88656. private _scene;
  88657. private _opaqueSubMeshes;
  88658. private _transparentSubMeshes;
  88659. private _alphaTestSubMeshes;
  88660. private _depthOnlySubMeshes;
  88661. private _particleSystems;
  88662. private _spriteManagers;
  88663. private _opaqueSortCompareFn;
  88664. private _alphaTestSortCompareFn;
  88665. private _transparentSortCompareFn;
  88666. private _renderOpaque;
  88667. private _renderAlphaTest;
  88668. private _renderTransparent;
  88669. /** @hidden */
  88670. _edgesRenderers: SmartArray<IEdgesRenderer>;
  88671. onBeforeTransparentRendering: () => void;
  88672. /**
  88673. * Set the opaque sort comparison function.
  88674. * If null the sub meshes will be render in the order they were created
  88675. */
  88676. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88677. /**
  88678. * Set the alpha test sort comparison function.
  88679. * If null the sub meshes will be render in the order they were created
  88680. */
  88681. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88682. /**
  88683. * Set the transparent sort comparison function.
  88684. * If null the sub meshes will be render in the order they were created
  88685. */
  88686. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88687. /**
  88688. * Creates a new rendering group.
  88689. * @param index The rendering group index
  88690. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  88691. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  88692. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  88693. */
  88694. 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>);
  88695. /**
  88696. * Render all the sub meshes contained in the group.
  88697. * @param customRenderFunction Used to override the default render behaviour of the group.
  88698. * @returns true if rendered some submeshes.
  88699. */
  88700. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  88701. /**
  88702. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  88703. * @param subMeshes The submeshes to render
  88704. */
  88705. private renderOpaqueSorted;
  88706. /**
  88707. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  88708. * @param subMeshes The submeshes to render
  88709. */
  88710. private renderAlphaTestSorted;
  88711. /**
  88712. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  88713. * @param subMeshes The submeshes to render
  88714. */
  88715. private renderTransparentSorted;
  88716. /**
  88717. * Renders the submeshes in a specified order.
  88718. * @param subMeshes The submeshes to sort before render
  88719. * @param sortCompareFn The comparison function use to sort
  88720. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88721. * @param transparent Specifies to activate blending if true
  88722. */
  88723. private static renderSorted;
  88724. /**
  88725. * Renders the submeshes in the order they were dispatched (no sort applied).
  88726. * @param subMeshes The submeshes to render
  88727. */
  88728. private static renderUnsorted;
  88729. /**
  88730. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88731. * are rendered back to front if in the same alpha index.
  88732. *
  88733. * @param a The first submesh
  88734. * @param b The second submesh
  88735. * @returns The result of the comparison
  88736. */
  88737. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88738. /**
  88739. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88740. * are rendered back to front.
  88741. *
  88742. * @param a The first submesh
  88743. * @param b The second submesh
  88744. * @returns The result of the comparison
  88745. */
  88746. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88747. /**
  88748. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88749. * are rendered front to back (prevent overdraw).
  88750. *
  88751. * @param a The first submesh
  88752. * @param b The second submesh
  88753. * @returns The result of the comparison
  88754. */
  88755. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88756. /**
  88757. * Resets the different lists of submeshes to prepare a new frame.
  88758. */
  88759. prepare(): void;
  88760. dispose(): void;
  88761. /**
  88762. * Inserts the submesh in its correct queue depending on its material.
  88763. * @param subMesh The submesh to dispatch
  88764. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88765. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88766. */
  88767. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88768. dispatchSprites(spriteManager: ISpriteManager): void;
  88769. dispatchParticles(particleSystem: IParticleSystem): void;
  88770. private _renderParticles;
  88771. private _renderSprites;
  88772. }
  88773. }
  88774. declare module BABYLON {
  88775. /**
  88776. * Interface describing the different options available in the rendering manager
  88777. * regarding Auto Clear between groups.
  88778. */
  88779. export interface IRenderingManagerAutoClearSetup {
  88780. /**
  88781. * Defines whether or not autoclear is enable.
  88782. */
  88783. autoClear: boolean;
  88784. /**
  88785. * Defines whether or not to autoclear the depth buffer.
  88786. */
  88787. depth: boolean;
  88788. /**
  88789. * Defines whether or not to autoclear the stencil buffer.
  88790. */
  88791. stencil: boolean;
  88792. }
  88793. /**
  88794. * This class is used by the onRenderingGroupObservable
  88795. */
  88796. export class RenderingGroupInfo {
  88797. /**
  88798. * The Scene that being rendered
  88799. */
  88800. scene: Scene;
  88801. /**
  88802. * The camera currently used for the rendering pass
  88803. */
  88804. camera: Nullable<Camera>;
  88805. /**
  88806. * The ID of the renderingGroup being processed
  88807. */
  88808. renderingGroupId: number;
  88809. }
  88810. /**
  88811. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88812. * It is enable to manage the different groups as well as the different necessary sort functions.
  88813. * This should not be used directly aside of the few static configurations
  88814. */
  88815. export class RenderingManager {
  88816. /**
  88817. * The max id used for rendering groups (not included)
  88818. */
  88819. static MAX_RENDERINGGROUPS: number;
  88820. /**
  88821. * The min id used for rendering groups (included)
  88822. */
  88823. static MIN_RENDERINGGROUPS: number;
  88824. /**
  88825. * Used to globally prevent autoclearing scenes.
  88826. */
  88827. static AUTOCLEAR: boolean;
  88828. /**
  88829. * @hidden
  88830. */
  88831. _useSceneAutoClearSetup: boolean;
  88832. private _scene;
  88833. private _renderingGroups;
  88834. private _depthStencilBufferAlreadyCleaned;
  88835. private _autoClearDepthStencil;
  88836. private _customOpaqueSortCompareFn;
  88837. private _customAlphaTestSortCompareFn;
  88838. private _customTransparentSortCompareFn;
  88839. private _renderingGroupInfo;
  88840. /**
  88841. * Instantiates a new rendering group for a particular scene
  88842. * @param scene Defines the scene the groups belongs to
  88843. */
  88844. constructor(scene: Scene);
  88845. private _clearDepthStencilBuffer;
  88846. /**
  88847. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88848. * @hidden
  88849. */
  88850. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88851. /**
  88852. * Resets the different information of the group to prepare a new frame
  88853. * @hidden
  88854. */
  88855. reset(): void;
  88856. /**
  88857. * Dispose and release the group and its associated resources.
  88858. * @hidden
  88859. */
  88860. dispose(): void;
  88861. /**
  88862. * Clear the info related to rendering groups preventing retention points during dispose.
  88863. */
  88864. freeRenderingGroups(): void;
  88865. private _prepareRenderingGroup;
  88866. /**
  88867. * Add a sprite manager to the rendering manager in order to render it this frame.
  88868. * @param spriteManager Define the sprite manager to render
  88869. */
  88870. dispatchSprites(spriteManager: ISpriteManager): void;
  88871. /**
  88872. * Add a particle system to the rendering manager in order to render it this frame.
  88873. * @param particleSystem Define the particle system to render
  88874. */
  88875. dispatchParticles(particleSystem: IParticleSystem): void;
  88876. /**
  88877. * Add a submesh to the manager in order to render it this frame
  88878. * @param subMesh The submesh to dispatch
  88879. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88880. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88881. */
  88882. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88883. /**
  88884. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88885. * This allowed control for front to back rendering or reversly depending of the special needs.
  88886. *
  88887. * @param renderingGroupId The rendering group id corresponding to its index
  88888. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88889. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88890. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88891. */
  88892. 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;
  88893. /**
  88894. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88895. *
  88896. * @param renderingGroupId The rendering group id corresponding to its index
  88897. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88898. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88899. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88900. */
  88901. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88902. /**
  88903. * Gets the current auto clear configuration for one rendering group of the rendering
  88904. * manager.
  88905. * @param index the rendering group index to get the information for
  88906. * @returns The auto clear setup for the requested rendering group
  88907. */
  88908. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88909. }
  88910. }
  88911. declare module BABYLON {
  88912. /**
  88913. * This Helps creating a texture that will be created from a camera in your scene.
  88914. * It is basically a dynamic texture that could be used to create special effects for instance.
  88915. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88916. */
  88917. export class RenderTargetTexture extends Texture {
  88918. isCube: boolean;
  88919. /**
  88920. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88921. */
  88922. static readonly REFRESHRATE_RENDER_ONCE: number;
  88923. /**
  88924. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88925. */
  88926. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88927. /**
  88928. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  88929. * the central point of your effect and can save a lot of performances.
  88930. */
  88931. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  88932. /**
  88933. * Use this predicate to dynamically define the list of mesh you want to render.
  88934. * If set, the renderList property will be overwritten.
  88935. */
  88936. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88937. private _renderList;
  88938. /**
  88939. * Use this list to define the list of mesh you want to render.
  88940. */
  88941. renderList: Nullable<Array<AbstractMesh>>;
  88942. private _hookArray;
  88943. /**
  88944. * Define if particles should be rendered in your texture.
  88945. */
  88946. renderParticles: boolean;
  88947. /**
  88948. * Define if sprites should be rendered in your texture.
  88949. */
  88950. renderSprites: boolean;
  88951. /**
  88952. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88953. */
  88954. coordinatesMode: number;
  88955. /**
  88956. * Define the camera used to render the texture.
  88957. */
  88958. activeCamera: Nullable<Camera>;
  88959. /**
  88960. * Override the render function of the texture with your own one.
  88961. */
  88962. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88963. /**
  88964. * Define if camera post processes should be use while rendering the texture.
  88965. */
  88966. useCameraPostProcesses: boolean;
  88967. /**
  88968. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88969. */
  88970. ignoreCameraViewport: boolean;
  88971. private _postProcessManager;
  88972. private _postProcesses;
  88973. private _resizeObserver;
  88974. /**
  88975. * An event triggered when the texture is unbind.
  88976. */
  88977. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88978. /**
  88979. * An event triggered when the texture is unbind.
  88980. */
  88981. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88982. private _onAfterUnbindObserver;
  88983. /**
  88984. * Set a after unbind callback in the texture.
  88985. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88986. */
  88987. onAfterUnbind: () => void;
  88988. /**
  88989. * An event triggered before rendering the texture
  88990. */
  88991. onBeforeRenderObservable: Observable<number>;
  88992. private _onBeforeRenderObserver;
  88993. /**
  88994. * Set a before render callback in the texture.
  88995. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88996. */
  88997. onBeforeRender: (faceIndex: number) => void;
  88998. /**
  88999. * An event triggered after rendering the texture
  89000. */
  89001. onAfterRenderObservable: Observable<number>;
  89002. private _onAfterRenderObserver;
  89003. /**
  89004. * Set a after render callback in the texture.
  89005. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  89006. */
  89007. onAfterRender: (faceIndex: number) => void;
  89008. /**
  89009. * An event triggered after the texture clear
  89010. */
  89011. onClearObservable: Observable<Engine>;
  89012. private _onClearObserver;
  89013. /**
  89014. * Set a clear callback in the texture.
  89015. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  89016. */
  89017. onClear: (Engine: Engine) => void;
  89018. /**
  89019. * An event triggered when the texture is resized.
  89020. */
  89021. onResizeObservable: Observable<RenderTargetTexture>;
  89022. /**
  89023. * Define the clear color of the Render Target if it should be different from the scene.
  89024. */
  89025. clearColor: Color4;
  89026. protected _size: number | {
  89027. width: number;
  89028. height: number;
  89029. };
  89030. protected _initialSizeParameter: number | {
  89031. width: number;
  89032. height: number;
  89033. } | {
  89034. ratio: number;
  89035. };
  89036. protected _sizeRatio: Nullable<number>;
  89037. /** @hidden */
  89038. _generateMipMaps: boolean;
  89039. protected _renderingManager: RenderingManager;
  89040. /** @hidden */
  89041. _waitingRenderList: string[];
  89042. protected _doNotChangeAspectRatio: boolean;
  89043. protected _currentRefreshId: number;
  89044. protected _refreshRate: number;
  89045. protected _textureMatrix: Matrix;
  89046. protected _samples: number;
  89047. protected _renderTargetOptions: RenderTargetCreationOptions;
  89048. /**
  89049. * Gets render target creation options that were used.
  89050. */
  89051. readonly renderTargetOptions: RenderTargetCreationOptions;
  89052. protected _engine: Engine;
  89053. protected _onRatioRescale(): void;
  89054. /**
  89055. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  89056. * It must define where the camera used to render the texture is set
  89057. */
  89058. boundingBoxPosition: Vector3;
  89059. private _boundingBoxSize;
  89060. /**
  89061. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  89062. * When defined, the cubemap will switch to local mode
  89063. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89064. * @example https://www.babylonjs-playground.com/#RNASML
  89065. */
  89066. boundingBoxSize: Vector3;
  89067. /**
  89068. * In case the RTT has been created with a depth texture, get the associated
  89069. * depth texture.
  89070. * Otherwise, return null.
  89071. */
  89072. depthStencilTexture: Nullable<InternalTexture>;
  89073. /**
  89074. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  89075. * or used a shadow, depth texture...
  89076. * @param name The friendly name of the texture
  89077. * @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)
  89078. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  89079. * @param generateMipMaps True if mip maps need to be generated after render.
  89080. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  89081. * @param type The type of the buffer in the RTT (int, half float, float...)
  89082. * @param isCube True if a cube texture needs to be created
  89083. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  89084. * @param generateDepthBuffer True to generate a depth buffer
  89085. * @param generateStencilBuffer True to generate a stencil buffer
  89086. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  89087. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  89088. * @param delayAllocation if the texture allocation should be delayed (default: false)
  89089. */
  89090. constructor(name: string, size: number | {
  89091. width: number;
  89092. height: number;
  89093. } | {
  89094. ratio: number;
  89095. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  89096. /**
  89097. * Creates a depth stencil texture.
  89098. * This is only available in WebGL 2 or with the depth texture extension available.
  89099. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  89100. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  89101. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  89102. */
  89103. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  89104. private _processSizeParameter;
  89105. /**
  89106. * Define the number of samples to use in case of MSAA.
  89107. * It defaults to one meaning no MSAA has been enabled.
  89108. */
  89109. samples: number;
  89110. /**
  89111. * Resets the refresh counter of the texture and start bak from scratch.
  89112. * Could be useful to regenerate the texture if it is setup to render only once.
  89113. */
  89114. resetRefreshCounter(): void;
  89115. /**
  89116. * Define the refresh rate of the texture or the rendering frequency.
  89117. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89118. */
  89119. refreshRate: number;
  89120. /**
  89121. * Adds a post process to the render target rendering passes.
  89122. * @param postProcess define the post process to add
  89123. */
  89124. addPostProcess(postProcess: PostProcess): void;
  89125. /**
  89126. * Clear all the post processes attached to the render target
  89127. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  89128. */
  89129. clearPostProcesses(dispose?: boolean): void;
  89130. /**
  89131. * Remove one of the post process from the list of attached post processes to the texture
  89132. * @param postProcess define the post process to remove from the list
  89133. */
  89134. removePostProcess(postProcess: PostProcess): void;
  89135. /** @hidden */
  89136. _shouldRender(): boolean;
  89137. /**
  89138. * Gets the actual render size of the texture.
  89139. * @returns the width of the render size
  89140. */
  89141. getRenderSize(): number;
  89142. /**
  89143. * Gets the actual render width of the texture.
  89144. * @returns the width of the render size
  89145. */
  89146. getRenderWidth(): number;
  89147. /**
  89148. * Gets the actual render height of the texture.
  89149. * @returns the height of the render size
  89150. */
  89151. getRenderHeight(): number;
  89152. /**
  89153. * Get if the texture can be rescaled or not.
  89154. */
  89155. readonly canRescale: boolean;
  89156. /**
  89157. * Resize the texture using a ratio.
  89158. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  89159. */
  89160. scale(ratio: number): void;
  89161. /**
  89162. * Get the texture reflection matrix used to rotate/transform the reflection.
  89163. * @returns the reflection matrix
  89164. */
  89165. getReflectionTextureMatrix(): Matrix;
  89166. /**
  89167. * Resize the texture to a new desired size.
  89168. * Be carrefull as it will recreate all the data in the new texture.
  89169. * @param size Define the new size. It can be:
  89170. * - a number for squared texture,
  89171. * - an object containing { width: number, height: number }
  89172. * - or an object containing a ratio { ratio: number }
  89173. */
  89174. resize(size: number | {
  89175. width: number;
  89176. height: number;
  89177. } | {
  89178. ratio: number;
  89179. }): void;
  89180. /**
  89181. * Renders all the objects from the render list into the texture.
  89182. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  89183. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  89184. */
  89185. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  89186. private _bestReflectionRenderTargetDimension;
  89187. /**
  89188. * @hidden
  89189. * @param faceIndex face index to bind to if this is a cubetexture
  89190. */
  89191. _bindFrameBuffer(faceIndex?: number): void;
  89192. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  89193. private renderToTarget;
  89194. /**
  89195. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89196. * This allowed control for front to back rendering or reversly depending of the special needs.
  89197. *
  89198. * @param renderingGroupId The rendering group id corresponding to its index
  89199. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89200. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89201. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89202. */
  89203. 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;
  89204. /**
  89205. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89206. *
  89207. * @param renderingGroupId The rendering group id corresponding to its index
  89208. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89209. */
  89210. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  89211. /**
  89212. * Clones the texture.
  89213. * @returns the cloned texture
  89214. */
  89215. clone(): RenderTargetTexture;
  89216. /**
  89217. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89218. * @returns The JSON representation of the texture
  89219. */
  89220. serialize(): any;
  89221. /**
  89222. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  89223. */
  89224. disposeFramebufferObjects(): void;
  89225. /**
  89226. * Dispose the texture and release its associated resources.
  89227. */
  89228. dispose(): void;
  89229. /** @hidden */
  89230. _rebuild(): void;
  89231. /**
  89232. * Clear the info related to rendering groups preventing retention point in material dispose.
  89233. */
  89234. freeRenderingGroups(): void;
  89235. /**
  89236. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  89237. * @returns the view count
  89238. */
  89239. getViewCount(): number;
  89240. }
  89241. }
  89242. declare module BABYLON {
  89243. /**
  89244. * Options for compiling materials.
  89245. */
  89246. export interface IMaterialCompilationOptions {
  89247. /**
  89248. * Defines whether clip planes are enabled.
  89249. */
  89250. clipPlane: boolean;
  89251. /**
  89252. * Defines whether instances are enabled.
  89253. */
  89254. useInstances: boolean;
  89255. }
  89256. /**
  89257. * Base class for the main features of a material in Babylon.js
  89258. */
  89259. export class Material implements IAnimatable {
  89260. /**
  89261. * Returns the triangle fill mode
  89262. */
  89263. static readonly TriangleFillMode: number;
  89264. /**
  89265. * Returns the wireframe mode
  89266. */
  89267. static readonly WireFrameFillMode: number;
  89268. /**
  89269. * Returns the point fill mode
  89270. */
  89271. static readonly PointFillMode: number;
  89272. /**
  89273. * Returns the point list draw mode
  89274. */
  89275. static readonly PointListDrawMode: number;
  89276. /**
  89277. * Returns the line list draw mode
  89278. */
  89279. static readonly LineListDrawMode: number;
  89280. /**
  89281. * Returns the line loop draw mode
  89282. */
  89283. static readonly LineLoopDrawMode: number;
  89284. /**
  89285. * Returns the line strip draw mode
  89286. */
  89287. static readonly LineStripDrawMode: number;
  89288. /**
  89289. * Returns the triangle strip draw mode
  89290. */
  89291. static readonly TriangleStripDrawMode: number;
  89292. /**
  89293. * Returns the triangle fan draw mode
  89294. */
  89295. static readonly TriangleFanDrawMode: number;
  89296. /**
  89297. * Stores the clock-wise side orientation
  89298. */
  89299. static readonly ClockWiseSideOrientation: number;
  89300. /**
  89301. * Stores the counter clock-wise side orientation
  89302. */
  89303. static readonly CounterClockWiseSideOrientation: number;
  89304. /**
  89305. * The dirty texture flag value
  89306. */
  89307. static readonly TextureDirtyFlag: number;
  89308. /**
  89309. * The dirty light flag value
  89310. */
  89311. static readonly LightDirtyFlag: number;
  89312. /**
  89313. * The dirty fresnel flag value
  89314. */
  89315. static readonly FresnelDirtyFlag: number;
  89316. /**
  89317. * The dirty attribute flag value
  89318. */
  89319. static readonly AttributesDirtyFlag: number;
  89320. /**
  89321. * The dirty misc flag value
  89322. */
  89323. static readonly MiscDirtyFlag: number;
  89324. /**
  89325. * The all dirty flag value
  89326. */
  89327. static readonly AllDirtyFlag: number;
  89328. /**
  89329. * The ID of the material
  89330. */
  89331. id: string;
  89332. /**
  89333. * Gets or sets the unique id of the material
  89334. */
  89335. uniqueId: number;
  89336. /**
  89337. * The name of the material
  89338. */
  89339. name: string;
  89340. /**
  89341. * Gets or sets user defined metadata
  89342. */
  89343. metadata: any;
  89344. /**
  89345. * For internal use only. Please do not use.
  89346. */
  89347. reservedDataStore: any;
  89348. /**
  89349. * Specifies if the ready state should be checked on each call
  89350. */
  89351. checkReadyOnEveryCall: boolean;
  89352. /**
  89353. * Specifies if the ready state should be checked once
  89354. */
  89355. checkReadyOnlyOnce: boolean;
  89356. /**
  89357. * The state of the material
  89358. */
  89359. state: string;
  89360. /**
  89361. * The alpha value of the material
  89362. */
  89363. protected _alpha: number;
  89364. /**
  89365. * List of inspectable custom properties (used by the Inspector)
  89366. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89367. */
  89368. inspectableCustomProperties: IInspectable[];
  89369. /**
  89370. * Sets the alpha value of the material
  89371. */
  89372. /**
  89373. * Gets the alpha value of the material
  89374. */
  89375. alpha: number;
  89376. /**
  89377. * Specifies if back face culling is enabled
  89378. */
  89379. protected _backFaceCulling: boolean;
  89380. /**
  89381. * Sets the back-face culling state
  89382. */
  89383. /**
  89384. * Gets the back-face culling state
  89385. */
  89386. backFaceCulling: boolean;
  89387. /**
  89388. * Stores the value for side orientation
  89389. */
  89390. sideOrientation: number;
  89391. /**
  89392. * Callback triggered when the material is compiled
  89393. */
  89394. onCompiled: Nullable<(effect: Effect) => void>;
  89395. /**
  89396. * Callback triggered when an error occurs
  89397. */
  89398. onError: Nullable<(effect: Effect, errors: string) => void>;
  89399. /**
  89400. * Callback triggered to get the render target textures
  89401. */
  89402. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  89403. /**
  89404. * Gets a boolean indicating that current material needs to register RTT
  89405. */
  89406. readonly hasRenderTargetTextures: boolean;
  89407. /**
  89408. * Specifies if the material should be serialized
  89409. */
  89410. doNotSerialize: boolean;
  89411. /**
  89412. * @hidden
  89413. */
  89414. _storeEffectOnSubMeshes: boolean;
  89415. /**
  89416. * Stores the animations for the material
  89417. */
  89418. animations: Nullable<Array<Animation>>;
  89419. /**
  89420. * An event triggered when the material is disposed
  89421. */
  89422. onDisposeObservable: Observable<Material>;
  89423. /**
  89424. * An observer which watches for dispose events
  89425. */
  89426. private _onDisposeObserver;
  89427. private _onUnBindObservable;
  89428. /**
  89429. * Called during a dispose event
  89430. */
  89431. onDispose: () => void;
  89432. private _onBindObservable;
  89433. /**
  89434. * An event triggered when the material is bound
  89435. */
  89436. readonly onBindObservable: Observable<AbstractMesh>;
  89437. /**
  89438. * An observer which watches for bind events
  89439. */
  89440. private _onBindObserver;
  89441. /**
  89442. * Called during a bind event
  89443. */
  89444. onBind: (Mesh: AbstractMesh) => void;
  89445. /**
  89446. * An event triggered when the material is unbound
  89447. */
  89448. readonly onUnBindObservable: Observable<Material>;
  89449. /**
  89450. * Stores the value of the alpha mode
  89451. */
  89452. private _alphaMode;
  89453. /**
  89454. * Sets the value of the alpha mode.
  89455. *
  89456. * | Value | Type | Description |
  89457. * | --- | --- | --- |
  89458. * | 0 | ALPHA_DISABLE | |
  89459. * | 1 | ALPHA_ADD | |
  89460. * | 2 | ALPHA_COMBINE | |
  89461. * | 3 | ALPHA_SUBTRACT | |
  89462. * | 4 | ALPHA_MULTIPLY | |
  89463. * | 5 | ALPHA_MAXIMIZED | |
  89464. * | 6 | ALPHA_ONEONE | |
  89465. * | 7 | ALPHA_PREMULTIPLIED | |
  89466. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  89467. * | 9 | ALPHA_INTERPOLATE | |
  89468. * | 10 | ALPHA_SCREENMODE | |
  89469. *
  89470. */
  89471. /**
  89472. * Gets the value of the alpha mode
  89473. */
  89474. alphaMode: number;
  89475. /**
  89476. * Stores the state of the need depth pre-pass value
  89477. */
  89478. private _needDepthPrePass;
  89479. /**
  89480. * Sets the need depth pre-pass value
  89481. */
  89482. /**
  89483. * Gets the depth pre-pass value
  89484. */
  89485. needDepthPrePass: boolean;
  89486. /**
  89487. * Specifies if depth writing should be disabled
  89488. */
  89489. disableDepthWrite: boolean;
  89490. /**
  89491. * Specifies if depth writing should be forced
  89492. */
  89493. forceDepthWrite: boolean;
  89494. /**
  89495. * Specifies the depth function that should be used. 0 means the default engine function
  89496. */
  89497. depthFunction: number;
  89498. /**
  89499. * Specifies if there should be a separate pass for culling
  89500. */
  89501. separateCullingPass: boolean;
  89502. /**
  89503. * Stores the state specifing if fog should be enabled
  89504. */
  89505. private _fogEnabled;
  89506. /**
  89507. * Sets the state for enabling fog
  89508. */
  89509. /**
  89510. * Gets the value of the fog enabled state
  89511. */
  89512. fogEnabled: boolean;
  89513. /**
  89514. * Stores the size of points
  89515. */
  89516. pointSize: number;
  89517. /**
  89518. * Stores the z offset value
  89519. */
  89520. zOffset: number;
  89521. /**
  89522. * Gets a value specifying if wireframe mode is enabled
  89523. */
  89524. /**
  89525. * Sets the state of wireframe mode
  89526. */
  89527. wireframe: boolean;
  89528. /**
  89529. * Gets the value specifying if point clouds are enabled
  89530. */
  89531. /**
  89532. * Sets the state of point cloud mode
  89533. */
  89534. pointsCloud: boolean;
  89535. /**
  89536. * Gets the material fill mode
  89537. */
  89538. /**
  89539. * Sets the material fill mode
  89540. */
  89541. fillMode: number;
  89542. /**
  89543. * @hidden
  89544. * Stores the effects for the material
  89545. */
  89546. _effect: Nullable<Effect>;
  89547. /**
  89548. * @hidden
  89549. * Specifies if the material was previously ready
  89550. */
  89551. _wasPreviouslyReady: boolean;
  89552. /**
  89553. * Specifies if uniform buffers should be used
  89554. */
  89555. private _useUBO;
  89556. /**
  89557. * Stores a reference to the scene
  89558. */
  89559. private _scene;
  89560. /**
  89561. * Stores the fill mode state
  89562. */
  89563. private _fillMode;
  89564. /**
  89565. * Specifies if the depth write state should be cached
  89566. */
  89567. private _cachedDepthWriteState;
  89568. /**
  89569. * Specifies if the depth function state should be cached
  89570. */
  89571. private _cachedDepthFunctionState;
  89572. /**
  89573. * Stores the uniform buffer
  89574. */
  89575. protected _uniformBuffer: UniformBuffer;
  89576. /** @hidden */
  89577. _indexInSceneMaterialArray: number;
  89578. /** @hidden */
  89579. meshMap: Nullable<{
  89580. [id: string]: AbstractMesh | undefined;
  89581. }>;
  89582. /**
  89583. * Creates a material instance
  89584. * @param name defines the name of the material
  89585. * @param scene defines the scene to reference
  89586. * @param doNotAdd specifies if the material should be added to the scene
  89587. */
  89588. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  89589. /**
  89590. * Returns a string representation of the current material
  89591. * @param fullDetails defines a boolean indicating which levels of logging is desired
  89592. * @returns a string with material information
  89593. */
  89594. toString(fullDetails?: boolean): string;
  89595. /**
  89596. * Gets the class name of the material
  89597. * @returns a string with the class name of the material
  89598. */
  89599. getClassName(): string;
  89600. /**
  89601. * Specifies if updates for the material been locked
  89602. */
  89603. readonly isFrozen: boolean;
  89604. /**
  89605. * Locks updates for the material
  89606. */
  89607. freeze(): void;
  89608. /**
  89609. * Unlocks updates for the material
  89610. */
  89611. unfreeze(): void;
  89612. /**
  89613. * Specifies if the material is ready to be used
  89614. * @param mesh defines the mesh to check
  89615. * @param useInstances specifies if instances should be used
  89616. * @returns a boolean indicating if the material is ready to be used
  89617. */
  89618. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89619. /**
  89620. * Specifies that the submesh is ready to be used
  89621. * @param mesh defines the mesh to check
  89622. * @param subMesh defines which submesh to check
  89623. * @param useInstances specifies that instances should be used
  89624. * @returns a boolean indicating that the submesh is ready or not
  89625. */
  89626. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89627. /**
  89628. * Returns the material effect
  89629. * @returns the effect associated with the material
  89630. */
  89631. getEffect(): Nullable<Effect>;
  89632. /**
  89633. * Returns the current scene
  89634. * @returns a Scene
  89635. */
  89636. getScene(): Scene;
  89637. /**
  89638. * Specifies if the material will require alpha blending
  89639. * @returns a boolean specifying if alpha blending is needed
  89640. */
  89641. needAlphaBlending(): boolean;
  89642. /**
  89643. * Specifies if the mesh will require alpha blending
  89644. * @param mesh defines the mesh to check
  89645. * @returns a boolean specifying if alpha blending is needed for the mesh
  89646. */
  89647. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  89648. /**
  89649. * Specifies if this material should be rendered in alpha test mode
  89650. * @returns a boolean specifying if an alpha test is needed.
  89651. */
  89652. needAlphaTesting(): boolean;
  89653. /**
  89654. * Gets the texture used for the alpha test
  89655. * @returns the texture to use for alpha testing
  89656. */
  89657. getAlphaTestTexture(): Nullable<BaseTexture>;
  89658. /**
  89659. * Marks the material to indicate that it needs to be re-calculated
  89660. */
  89661. markDirty(): void;
  89662. /** @hidden */
  89663. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  89664. /**
  89665. * Binds the material to the mesh
  89666. * @param world defines the world transformation matrix
  89667. * @param mesh defines the mesh to bind the material to
  89668. */
  89669. bind(world: Matrix, mesh?: Mesh): void;
  89670. /**
  89671. * Binds the submesh to the material
  89672. * @param world defines the world transformation matrix
  89673. * @param mesh defines the mesh containing the submesh
  89674. * @param subMesh defines the submesh to bind the material to
  89675. */
  89676. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  89677. /**
  89678. * Binds the world matrix to the material
  89679. * @param world defines the world transformation matrix
  89680. */
  89681. bindOnlyWorldMatrix(world: Matrix): void;
  89682. /**
  89683. * Binds the scene's uniform buffer to the effect.
  89684. * @param effect defines the effect to bind to the scene uniform buffer
  89685. * @param sceneUbo defines the uniform buffer storing scene data
  89686. */
  89687. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  89688. /**
  89689. * Binds the view matrix to the effect
  89690. * @param effect defines the effect to bind the view matrix to
  89691. */
  89692. bindView(effect: Effect): void;
  89693. /**
  89694. * Binds the view projection matrix to the effect
  89695. * @param effect defines the effect to bind the view projection matrix to
  89696. */
  89697. bindViewProjection(effect: Effect): void;
  89698. /**
  89699. * Specifies if material alpha testing should be turned on for the mesh
  89700. * @param mesh defines the mesh to check
  89701. */
  89702. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  89703. /**
  89704. * Processes to execute after binding the material to a mesh
  89705. * @param mesh defines the rendered mesh
  89706. */
  89707. protected _afterBind(mesh?: Mesh): void;
  89708. /**
  89709. * Unbinds the material from the mesh
  89710. */
  89711. unbind(): void;
  89712. /**
  89713. * Gets the active textures from the material
  89714. * @returns an array of textures
  89715. */
  89716. getActiveTextures(): BaseTexture[];
  89717. /**
  89718. * Specifies if the material uses a texture
  89719. * @param texture defines the texture to check against the material
  89720. * @returns a boolean specifying if the material uses the texture
  89721. */
  89722. hasTexture(texture: BaseTexture): boolean;
  89723. /**
  89724. * Makes a duplicate of the material, and gives it a new name
  89725. * @param name defines the new name for the duplicated material
  89726. * @returns the cloned material
  89727. */
  89728. clone(name: string): Nullable<Material>;
  89729. /**
  89730. * Gets the meshes bound to the material
  89731. * @returns an array of meshes bound to the material
  89732. */
  89733. getBindedMeshes(): AbstractMesh[];
  89734. /**
  89735. * Force shader compilation
  89736. * @param mesh defines the mesh associated with this material
  89737. * @param onCompiled defines a function to execute once the material is compiled
  89738. * @param options defines the options to configure the compilation
  89739. * @param onError defines a function to execute if the material fails compiling
  89740. */
  89741. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89742. /**
  89743. * Force shader compilation
  89744. * @param mesh defines the mesh that will use this material
  89745. * @param options defines additional options for compiling the shaders
  89746. * @returns a promise that resolves when the compilation completes
  89747. */
  89748. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89749. private static readonly _AllDirtyCallBack;
  89750. private static readonly _ImageProcessingDirtyCallBack;
  89751. private static readonly _TextureDirtyCallBack;
  89752. private static readonly _FresnelDirtyCallBack;
  89753. private static readonly _MiscDirtyCallBack;
  89754. private static readonly _LightsDirtyCallBack;
  89755. private static readonly _AttributeDirtyCallBack;
  89756. private static _FresnelAndMiscDirtyCallBack;
  89757. private static _TextureAndMiscDirtyCallBack;
  89758. private static readonly _DirtyCallbackArray;
  89759. private static readonly _RunDirtyCallBacks;
  89760. /**
  89761. * Marks a define in the material to indicate that it needs to be re-computed
  89762. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89763. */
  89764. markAsDirty(flag: number): void;
  89765. /**
  89766. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89767. * @param func defines a function which checks material defines against the submeshes
  89768. */
  89769. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89770. /**
  89771. * Indicates that we need to re-calculated for all submeshes
  89772. */
  89773. protected _markAllSubMeshesAsAllDirty(): void;
  89774. /**
  89775. * Indicates that image processing needs to be re-calculated for all submeshes
  89776. */
  89777. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89778. /**
  89779. * Indicates that textures need to be re-calculated for all submeshes
  89780. */
  89781. protected _markAllSubMeshesAsTexturesDirty(): void;
  89782. /**
  89783. * Indicates that fresnel needs to be re-calculated for all submeshes
  89784. */
  89785. protected _markAllSubMeshesAsFresnelDirty(): void;
  89786. /**
  89787. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89788. */
  89789. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89790. /**
  89791. * Indicates that lights need to be re-calculated for all submeshes
  89792. */
  89793. protected _markAllSubMeshesAsLightsDirty(): void;
  89794. /**
  89795. * Indicates that attributes need to be re-calculated for all submeshes
  89796. */
  89797. protected _markAllSubMeshesAsAttributesDirty(): void;
  89798. /**
  89799. * Indicates that misc needs to be re-calculated for all submeshes
  89800. */
  89801. protected _markAllSubMeshesAsMiscDirty(): void;
  89802. /**
  89803. * Indicates that textures and misc need to be re-calculated for all submeshes
  89804. */
  89805. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89806. /**
  89807. * Disposes the material
  89808. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89809. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89810. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89811. */
  89812. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89813. /** @hidden */
  89814. private releaseVertexArrayObject;
  89815. /**
  89816. * Serializes this material
  89817. * @returns the serialized material object
  89818. */
  89819. serialize(): any;
  89820. /**
  89821. * Creates a material from parsed material data
  89822. * @param parsedMaterial defines parsed material data
  89823. * @param scene defines the hosting scene
  89824. * @param rootUrl defines the root URL to use to load textures
  89825. * @returns a new material
  89826. */
  89827. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89828. }
  89829. }
  89830. declare module BABYLON {
  89831. /**
  89832. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89833. * separate meshes. This can be use to improve performances.
  89834. * @see http://doc.babylonjs.com/how_to/multi_materials
  89835. */
  89836. export class MultiMaterial extends Material {
  89837. private _subMaterials;
  89838. /**
  89839. * Gets or Sets the list of Materials used within the multi material.
  89840. * They need to be ordered according to the submeshes order in the associated mesh
  89841. */
  89842. subMaterials: Nullable<Material>[];
  89843. /**
  89844. * Function used to align with Node.getChildren()
  89845. * @returns the list of Materials used within the multi material
  89846. */
  89847. getChildren(): Nullable<Material>[];
  89848. /**
  89849. * Instantiates a new Multi Material
  89850. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89851. * separate meshes. This can be use to improve performances.
  89852. * @see http://doc.babylonjs.com/how_to/multi_materials
  89853. * @param name Define the name in the scene
  89854. * @param scene Define the scene the material belongs to
  89855. */
  89856. constructor(name: string, scene: Scene);
  89857. private _hookArray;
  89858. /**
  89859. * Get one of the submaterial by its index in the submaterials array
  89860. * @param index The index to look the sub material at
  89861. * @returns The Material if the index has been defined
  89862. */
  89863. getSubMaterial(index: number): Nullable<Material>;
  89864. /**
  89865. * Get the list of active textures for the whole sub materials list.
  89866. * @returns All the textures that will be used during the rendering
  89867. */
  89868. getActiveTextures(): BaseTexture[];
  89869. /**
  89870. * Gets the current class name of the material e.g. "MultiMaterial"
  89871. * Mainly use in serialization.
  89872. * @returns the class name
  89873. */
  89874. getClassName(): string;
  89875. /**
  89876. * Checks if the material is ready to render the requested sub mesh
  89877. * @param mesh Define the mesh the submesh belongs to
  89878. * @param subMesh Define the sub mesh to look readyness for
  89879. * @param useInstances Define whether or not the material is used with instances
  89880. * @returns true if ready, otherwise false
  89881. */
  89882. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89883. /**
  89884. * Clones the current material and its related sub materials
  89885. * @param name Define the name of the newly cloned material
  89886. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89887. * @returns the cloned material
  89888. */
  89889. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89890. /**
  89891. * Serializes the materials into a JSON representation.
  89892. * @returns the JSON representation
  89893. */
  89894. serialize(): any;
  89895. /**
  89896. * Dispose the material and release its associated resources
  89897. * @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)
  89898. * @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)
  89899. * @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)
  89900. */
  89901. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89902. /**
  89903. * Creates a MultiMaterial from parsed MultiMaterial data.
  89904. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89905. * @param scene defines the hosting scene
  89906. * @returns a new MultiMaterial
  89907. */
  89908. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89909. }
  89910. }
  89911. declare module BABYLON {
  89912. /**
  89913. * Base class for submeshes
  89914. */
  89915. export class BaseSubMesh {
  89916. /** @hidden */
  89917. _materialDefines: Nullable<MaterialDefines>;
  89918. /** @hidden */
  89919. _materialEffect: Nullable<Effect>;
  89920. /**
  89921. * Gets material defines used by the effect associated to the sub mesh
  89922. */
  89923. /**
  89924. * Sets material defines used by the effect associated to the sub mesh
  89925. */
  89926. materialDefines: Nullable<MaterialDefines>;
  89927. /**
  89928. * Gets associated effect
  89929. */
  89930. readonly effect: Nullable<Effect>;
  89931. /**
  89932. * Sets associated effect (effect used to render this submesh)
  89933. * @param effect defines the effect to associate with
  89934. * @param defines defines the set of defines used to compile this effect
  89935. */
  89936. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  89937. }
  89938. /**
  89939. * Defines a subdivision inside a mesh
  89940. */
  89941. export class SubMesh extends BaseSubMesh implements ICullable {
  89942. /** the material index to use */
  89943. materialIndex: number;
  89944. /** vertex index start */
  89945. verticesStart: number;
  89946. /** vertices count */
  89947. verticesCount: number;
  89948. /** index start */
  89949. indexStart: number;
  89950. /** indices count */
  89951. indexCount: number;
  89952. /** @hidden */
  89953. _linesIndexCount: number;
  89954. private _mesh;
  89955. private _renderingMesh;
  89956. private _boundingInfo;
  89957. private _linesIndexBuffer;
  89958. /** @hidden */
  89959. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89960. /** @hidden */
  89961. _trianglePlanes: Plane[];
  89962. /** @hidden */
  89963. _lastColliderTransformMatrix: Nullable<Matrix>;
  89964. /** @hidden */
  89965. _renderId: number;
  89966. /** @hidden */
  89967. _alphaIndex: number;
  89968. /** @hidden */
  89969. _distanceToCamera: number;
  89970. /** @hidden */
  89971. _id: number;
  89972. private _currentMaterial;
  89973. /**
  89974. * Add a new submesh to a mesh
  89975. * @param materialIndex defines the material index to use
  89976. * @param verticesStart defines vertex index start
  89977. * @param verticesCount defines vertices count
  89978. * @param indexStart defines index start
  89979. * @param indexCount defines indices count
  89980. * @param mesh defines the parent mesh
  89981. * @param renderingMesh defines an optional rendering mesh
  89982. * @param createBoundingBox defines if bounding box should be created for this submesh
  89983. * @returns the new submesh
  89984. */
  89985. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89986. /**
  89987. * Creates a new submesh
  89988. * @param materialIndex defines the material index to use
  89989. * @param verticesStart defines vertex index start
  89990. * @param verticesCount defines vertices count
  89991. * @param indexStart defines index start
  89992. * @param indexCount defines indices count
  89993. * @param mesh defines the parent mesh
  89994. * @param renderingMesh defines an optional rendering mesh
  89995. * @param createBoundingBox defines if bounding box should be created for this submesh
  89996. */
  89997. constructor(
  89998. /** the material index to use */
  89999. materialIndex: number,
  90000. /** vertex index start */
  90001. verticesStart: number,
  90002. /** vertices count */
  90003. verticesCount: number,
  90004. /** index start */
  90005. indexStart: number,
  90006. /** indices count */
  90007. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  90008. /**
  90009. * Returns true if this submesh covers the entire parent mesh
  90010. * @ignorenaming
  90011. */
  90012. readonly IsGlobal: boolean;
  90013. /**
  90014. * Returns the submesh BoudingInfo object
  90015. * @returns current bounding info (or mesh's one if the submesh is global)
  90016. */
  90017. getBoundingInfo(): BoundingInfo;
  90018. /**
  90019. * Sets the submesh BoundingInfo
  90020. * @param boundingInfo defines the new bounding info to use
  90021. * @returns the SubMesh
  90022. */
  90023. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  90024. /**
  90025. * Returns the mesh of the current submesh
  90026. * @return the parent mesh
  90027. */
  90028. getMesh(): AbstractMesh;
  90029. /**
  90030. * Returns the rendering mesh of the submesh
  90031. * @returns the rendering mesh (could be different from parent mesh)
  90032. */
  90033. getRenderingMesh(): Mesh;
  90034. /**
  90035. * Returns the submesh material
  90036. * @returns null or the current material
  90037. */
  90038. getMaterial(): Nullable<Material>;
  90039. /**
  90040. * Sets a new updated BoundingInfo object to the submesh
  90041. * @param data defines an optional position array to use to determine the bounding info
  90042. * @returns the SubMesh
  90043. */
  90044. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  90045. /** @hidden */
  90046. _checkCollision(collider: Collider): boolean;
  90047. /**
  90048. * Updates the submesh BoundingInfo
  90049. * @param world defines the world matrix to use to update the bounding info
  90050. * @returns the submesh
  90051. */
  90052. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  90053. /**
  90054. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  90055. * @param frustumPlanes defines the frustum planes
  90056. * @returns true if the submesh is intersecting with the frustum
  90057. */
  90058. isInFrustum(frustumPlanes: Plane[]): boolean;
  90059. /**
  90060. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  90061. * @param frustumPlanes defines the frustum planes
  90062. * @returns true if the submesh is inside the frustum
  90063. */
  90064. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90065. /**
  90066. * Renders the submesh
  90067. * @param enableAlphaMode defines if alpha needs to be used
  90068. * @returns the submesh
  90069. */
  90070. render(enableAlphaMode: boolean): SubMesh;
  90071. /**
  90072. * @hidden
  90073. */
  90074. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  90075. /**
  90076. * Checks if the submesh intersects with a ray
  90077. * @param ray defines the ray to test
  90078. * @returns true is the passed ray intersects the submesh bounding box
  90079. */
  90080. canIntersects(ray: Ray): boolean;
  90081. /**
  90082. * Intersects current submesh with a ray
  90083. * @param ray defines the ray to test
  90084. * @param positions defines mesh's positions array
  90085. * @param indices defines mesh's indices array
  90086. * @param fastCheck defines if only bounding info should be used
  90087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90088. * @returns intersection info or null if no intersection
  90089. */
  90090. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  90091. /** @hidden */
  90092. private _intersectLines;
  90093. /** @hidden */
  90094. private _intersectUnIndexedLines;
  90095. /** @hidden */
  90096. private _intersectTriangles;
  90097. /** @hidden */
  90098. private _intersectUnIndexedTriangles;
  90099. /** @hidden */
  90100. _rebuild(): void;
  90101. /**
  90102. * Creates a new submesh from the passed mesh
  90103. * @param newMesh defines the new hosting mesh
  90104. * @param newRenderingMesh defines an optional rendering mesh
  90105. * @returns the new submesh
  90106. */
  90107. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  90108. /**
  90109. * Release associated resources
  90110. */
  90111. dispose(): void;
  90112. /**
  90113. * Gets the class name
  90114. * @returns the string "SubMesh".
  90115. */
  90116. getClassName(): string;
  90117. /**
  90118. * Creates a new submesh from indices data
  90119. * @param materialIndex the index of the main mesh material
  90120. * @param startIndex the index where to start the copy in the mesh indices array
  90121. * @param indexCount the number of indices to copy then from the startIndex
  90122. * @param mesh the main mesh to create the submesh from
  90123. * @param renderingMesh the optional rendering mesh
  90124. * @returns a new submesh
  90125. */
  90126. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  90127. }
  90128. }
  90129. declare module BABYLON {
  90130. /**
  90131. * Class used to represent data loading progression
  90132. */
  90133. export class SceneLoaderFlags {
  90134. private static _ForceFullSceneLoadingForIncremental;
  90135. private static _ShowLoadingScreen;
  90136. private static _CleanBoneMatrixWeights;
  90137. private static _loggingLevel;
  90138. /**
  90139. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  90140. */
  90141. static ForceFullSceneLoadingForIncremental: boolean;
  90142. /**
  90143. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  90144. */
  90145. static ShowLoadingScreen: boolean;
  90146. /**
  90147. * Defines the current logging level (while loading the scene)
  90148. * @ignorenaming
  90149. */
  90150. static loggingLevel: number;
  90151. /**
  90152. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  90153. */
  90154. static CleanBoneMatrixWeights: boolean;
  90155. }
  90156. }
  90157. declare module BABYLON {
  90158. /**
  90159. * Class used to store geometry data (vertex buffers + index buffer)
  90160. */
  90161. export class Geometry implements IGetSetVerticesData {
  90162. /**
  90163. * Gets or sets the ID of the geometry
  90164. */
  90165. id: string;
  90166. /**
  90167. * Gets or sets the unique ID of the geometry
  90168. */
  90169. uniqueId: number;
  90170. /**
  90171. * Gets the delay loading state of the geometry (none by default which means not delayed)
  90172. */
  90173. delayLoadState: number;
  90174. /**
  90175. * Gets the file containing the data to load when running in delay load state
  90176. */
  90177. delayLoadingFile: Nullable<string>;
  90178. /**
  90179. * Callback called when the geometry is updated
  90180. */
  90181. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  90182. private _scene;
  90183. private _engine;
  90184. private _meshes;
  90185. private _totalVertices;
  90186. /** @hidden */
  90187. _indices: IndicesArray;
  90188. /** @hidden */
  90189. _vertexBuffers: {
  90190. [key: string]: VertexBuffer;
  90191. };
  90192. private _isDisposed;
  90193. private _extend;
  90194. private _boundingBias;
  90195. /** @hidden */
  90196. _delayInfo: Array<string>;
  90197. private _indexBuffer;
  90198. private _indexBufferIsUpdatable;
  90199. /** @hidden */
  90200. _boundingInfo: Nullable<BoundingInfo>;
  90201. /** @hidden */
  90202. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  90203. /** @hidden */
  90204. _softwareSkinningFrameId: number;
  90205. private _vertexArrayObjects;
  90206. private _updatable;
  90207. /** @hidden */
  90208. _positions: Nullable<Vector3[]>;
  90209. /**
  90210. * 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
  90211. */
  90212. /**
  90213. * 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
  90214. */
  90215. boundingBias: Vector2;
  90216. /**
  90217. * Static function used to attach a new empty geometry to a mesh
  90218. * @param mesh defines the mesh to attach the geometry to
  90219. * @returns the new Geometry
  90220. */
  90221. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  90222. /**
  90223. * Creates a new geometry
  90224. * @param id defines the unique ID
  90225. * @param scene defines the hosting scene
  90226. * @param vertexData defines the VertexData used to get geometry data
  90227. * @param updatable defines if geometry must be updatable (false by default)
  90228. * @param mesh defines the mesh that will be associated with the geometry
  90229. */
  90230. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  90231. /**
  90232. * Gets the current extend of the geometry
  90233. */
  90234. readonly extend: {
  90235. minimum: Vector3;
  90236. maximum: Vector3;
  90237. };
  90238. /**
  90239. * Gets the hosting scene
  90240. * @returns the hosting Scene
  90241. */
  90242. getScene(): Scene;
  90243. /**
  90244. * Gets the hosting engine
  90245. * @returns the hosting Engine
  90246. */
  90247. getEngine(): Engine;
  90248. /**
  90249. * Defines if the geometry is ready to use
  90250. * @returns true if the geometry is ready to be used
  90251. */
  90252. isReady(): boolean;
  90253. /**
  90254. * Gets a value indicating that the geometry should not be serialized
  90255. */
  90256. readonly doNotSerialize: boolean;
  90257. /** @hidden */
  90258. _rebuild(): void;
  90259. /**
  90260. * Affects all geometry data in one call
  90261. * @param vertexData defines the geometry data
  90262. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  90263. */
  90264. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  90265. /**
  90266. * Set specific vertex data
  90267. * @param kind defines the data kind (Position, normal, etc...)
  90268. * @param data defines the vertex data to use
  90269. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90270. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90271. */
  90272. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  90273. /**
  90274. * Removes a specific vertex data
  90275. * @param kind defines the data kind (Position, normal, etc...)
  90276. */
  90277. removeVerticesData(kind: string): void;
  90278. /**
  90279. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  90280. * @param buffer defines the vertex buffer to use
  90281. * @param totalVertices defines the total number of vertices for position kind (could be null)
  90282. */
  90283. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  90284. /**
  90285. * Update a specific vertex buffer
  90286. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  90287. * It will do nothing if the buffer is not updatable
  90288. * @param kind defines the data kind (Position, normal, etc...)
  90289. * @param data defines the data to use
  90290. * @param offset defines the offset in the target buffer where to store the data
  90291. * @param useBytes set to true if the offset is in bytes
  90292. */
  90293. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  90294. /**
  90295. * Update a specific vertex buffer
  90296. * This function will create a new buffer if the current one is not updatable
  90297. * @param kind defines the data kind (Position, normal, etc...)
  90298. * @param data defines the data to use
  90299. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  90300. */
  90301. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  90302. private _updateBoundingInfo;
  90303. /** @hidden */
  90304. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  90305. /**
  90306. * Gets total number of vertices
  90307. * @returns the total number of vertices
  90308. */
  90309. getTotalVertices(): number;
  90310. /**
  90311. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90312. * @param kind defines the data kind (Position, normal, etc...)
  90313. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90314. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90315. * @returns a float array containing vertex data
  90316. */
  90317. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90318. /**
  90319. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  90320. * @param kind defines the data kind (Position, normal, etc...)
  90321. * @returns true if the vertex buffer with the specified kind is updatable
  90322. */
  90323. isVertexBufferUpdatable(kind: string): boolean;
  90324. /**
  90325. * Gets a specific vertex buffer
  90326. * @param kind defines the data kind (Position, normal, etc...)
  90327. * @returns a VertexBuffer
  90328. */
  90329. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90330. /**
  90331. * Returns all vertex buffers
  90332. * @return an object holding all vertex buffers indexed by kind
  90333. */
  90334. getVertexBuffers(): Nullable<{
  90335. [key: string]: VertexBuffer;
  90336. }>;
  90337. /**
  90338. * Gets a boolean indicating if specific vertex buffer is present
  90339. * @param kind defines the data kind (Position, normal, etc...)
  90340. * @returns true if data is present
  90341. */
  90342. isVerticesDataPresent(kind: string): boolean;
  90343. /**
  90344. * Gets a list of all attached data kinds (Position, normal, etc...)
  90345. * @returns a list of string containing all kinds
  90346. */
  90347. getVerticesDataKinds(): string[];
  90348. /**
  90349. * Update index buffer
  90350. * @param indices defines the indices to store in the index buffer
  90351. * @param offset defines the offset in the target buffer where to store the data
  90352. * @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)
  90353. */
  90354. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  90355. /**
  90356. * Creates a new index buffer
  90357. * @param indices defines the indices to store in the index buffer
  90358. * @param totalVertices defines the total number of vertices (could be null)
  90359. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90360. */
  90361. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  90362. /**
  90363. * Return the total number of indices
  90364. * @returns the total number of indices
  90365. */
  90366. getTotalIndices(): number;
  90367. /**
  90368. * Gets the index buffer array
  90369. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90370. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90371. * @returns the index buffer array
  90372. */
  90373. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90374. /**
  90375. * Gets the index buffer
  90376. * @return the index buffer
  90377. */
  90378. getIndexBuffer(): Nullable<DataBuffer>;
  90379. /** @hidden */
  90380. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  90381. /**
  90382. * Release the associated resources for a specific mesh
  90383. * @param mesh defines the source mesh
  90384. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  90385. */
  90386. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  90387. /**
  90388. * Apply current geometry to a given mesh
  90389. * @param mesh defines the mesh to apply geometry to
  90390. */
  90391. applyToMesh(mesh: Mesh): void;
  90392. private _updateExtend;
  90393. private _applyToMesh;
  90394. private notifyUpdate;
  90395. /**
  90396. * Load the geometry if it was flagged as delay loaded
  90397. * @param scene defines the hosting scene
  90398. * @param onLoaded defines a callback called when the geometry is loaded
  90399. */
  90400. load(scene: Scene, onLoaded?: () => void): void;
  90401. private _queueLoad;
  90402. /**
  90403. * Invert the geometry to move from a right handed system to a left handed one.
  90404. */
  90405. toLeftHanded(): void;
  90406. /** @hidden */
  90407. _resetPointsArrayCache(): void;
  90408. /** @hidden */
  90409. _generatePointsArray(): boolean;
  90410. /**
  90411. * Gets a value indicating if the geometry is disposed
  90412. * @returns true if the geometry was disposed
  90413. */
  90414. isDisposed(): boolean;
  90415. private _disposeVertexArrayObjects;
  90416. /**
  90417. * Free all associated resources
  90418. */
  90419. dispose(): void;
  90420. /**
  90421. * Clone the current geometry into a new geometry
  90422. * @param id defines the unique ID of the new geometry
  90423. * @returns a new geometry object
  90424. */
  90425. copy(id: string): Geometry;
  90426. /**
  90427. * Serialize the current geometry info (and not the vertices data) into a JSON object
  90428. * @return a JSON representation of the current geometry data (without the vertices data)
  90429. */
  90430. serialize(): any;
  90431. private toNumberArray;
  90432. /**
  90433. * Serialize all vertices data into a JSON oject
  90434. * @returns a JSON representation of the current geometry data
  90435. */
  90436. serializeVerticeData(): any;
  90437. /**
  90438. * Extracts a clone of a mesh geometry
  90439. * @param mesh defines the source mesh
  90440. * @param id defines the unique ID of the new geometry object
  90441. * @returns the new geometry object
  90442. */
  90443. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  90444. /**
  90445. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  90446. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90447. * Be aware Math.random() could cause collisions, but:
  90448. * "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"
  90449. * @returns a string containing a new GUID
  90450. */
  90451. static RandomId(): string;
  90452. /** @hidden */
  90453. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  90454. private static _CleanMatricesWeights;
  90455. /**
  90456. * Create a new geometry from persisted data (Using .babylon file format)
  90457. * @param parsedVertexData defines the persisted data
  90458. * @param scene defines the hosting scene
  90459. * @param rootUrl defines the root url to use to load assets (like delayed data)
  90460. * @returns the new geometry object
  90461. */
  90462. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  90463. }
  90464. }
  90465. declare module BABYLON {
  90466. /**
  90467. * Define an interface for all classes that will get and set the data on vertices
  90468. */
  90469. export interface IGetSetVerticesData {
  90470. /**
  90471. * Gets a boolean indicating if specific vertex data is present
  90472. * @param kind defines the vertex data kind to use
  90473. * @returns true is data kind is present
  90474. */
  90475. isVerticesDataPresent(kind: string): boolean;
  90476. /**
  90477. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90478. * @param kind defines the data kind (Position, normal, etc...)
  90479. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90481. * @returns a float array containing vertex data
  90482. */
  90483. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90484. /**
  90485. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90486. * @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.
  90487. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90488. * @returns the indices array or an empty array if the mesh has no geometry
  90489. */
  90490. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90491. /**
  90492. * Set specific vertex data
  90493. * @param kind defines the data kind (Position, normal, etc...)
  90494. * @param data defines the vertex data to use
  90495. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90496. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90497. */
  90498. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  90499. /**
  90500. * Update a specific associated vertex buffer
  90501. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90502. * - VertexBuffer.PositionKind
  90503. * - VertexBuffer.UVKind
  90504. * - VertexBuffer.UV2Kind
  90505. * - VertexBuffer.UV3Kind
  90506. * - VertexBuffer.UV4Kind
  90507. * - VertexBuffer.UV5Kind
  90508. * - VertexBuffer.UV6Kind
  90509. * - VertexBuffer.ColorKind
  90510. * - VertexBuffer.MatricesIndicesKind
  90511. * - VertexBuffer.MatricesIndicesExtraKind
  90512. * - VertexBuffer.MatricesWeightsKind
  90513. * - VertexBuffer.MatricesWeightsExtraKind
  90514. * @param data defines the data source
  90515. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90516. * @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)
  90517. */
  90518. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  90519. /**
  90520. * Creates a new index buffer
  90521. * @param indices defines the indices to store in the index buffer
  90522. * @param totalVertices defines the total number of vertices (could be null)
  90523. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90524. */
  90525. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  90526. }
  90527. /**
  90528. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90529. */
  90530. export class VertexData {
  90531. /**
  90532. * Mesh side orientation : usually the external or front surface
  90533. */
  90534. static readonly FRONTSIDE: number;
  90535. /**
  90536. * Mesh side orientation : usually the internal or back surface
  90537. */
  90538. static readonly BACKSIDE: number;
  90539. /**
  90540. * Mesh side orientation : both internal and external or front and back surfaces
  90541. */
  90542. static readonly DOUBLESIDE: number;
  90543. /**
  90544. * Mesh side orientation : by default, `FRONTSIDE`
  90545. */
  90546. static readonly DEFAULTSIDE: number;
  90547. /**
  90548. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  90549. */
  90550. positions: Nullable<FloatArray>;
  90551. /**
  90552. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  90553. */
  90554. normals: Nullable<FloatArray>;
  90555. /**
  90556. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  90557. */
  90558. tangents: Nullable<FloatArray>;
  90559. /**
  90560. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90561. */
  90562. uvs: Nullable<FloatArray>;
  90563. /**
  90564. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90565. */
  90566. uvs2: Nullable<FloatArray>;
  90567. /**
  90568. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90569. */
  90570. uvs3: Nullable<FloatArray>;
  90571. /**
  90572. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90573. */
  90574. uvs4: Nullable<FloatArray>;
  90575. /**
  90576. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90577. */
  90578. uvs5: Nullable<FloatArray>;
  90579. /**
  90580. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90581. */
  90582. uvs6: Nullable<FloatArray>;
  90583. /**
  90584. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  90585. */
  90586. colors: Nullable<FloatArray>;
  90587. /**
  90588. * 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).
  90589. */
  90590. matricesIndices: Nullable<FloatArray>;
  90591. /**
  90592. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  90593. */
  90594. matricesWeights: Nullable<FloatArray>;
  90595. /**
  90596. * An array extending the number of possible indices
  90597. */
  90598. matricesIndicesExtra: Nullable<FloatArray>;
  90599. /**
  90600. * An array extending the number of possible weights when the number of indices is extended
  90601. */
  90602. matricesWeightsExtra: Nullable<FloatArray>;
  90603. /**
  90604. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  90605. */
  90606. indices: Nullable<IndicesArray>;
  90607. /**
  90608. * Uses the passed data array to set the set the values for the specified kind of data
  90609. * @param data a linear array of floating numbers
  90610. * @param kind the type of data that is being set, eg positions, colors etc
  90611. */
  90612. set(data: FloatArray, kind: string): void;
  90613. /**
  90614. * Associates the vertexData to the passed Mesh.
  90615. * Sets it as updatable or not (default `false`)
  90616. * @param mesh the mesh the vertexData is applied to
  90617. * @param updatable when used and having the value true allows new data to update the vertexData
  90618. * @returns the VertexData
  90619. */
  90620. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  90621. /**
  90622. * Associates the vertexData to the passed Geometry.
  90623. * Sets it as updatable or not (default `false`)
  90624. * @param geometry the geometry the vertexData is applied to
  90625. * @param updatable when used and having the value true allows new data to update the vertexData
  90626. * @returns VertexData
  90627. */
  90628. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  90629. /**
  90630. * Updates the associated mesh
  90631. * @param mesh the mesh to be updated
  90632. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90633. * @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
  90634. * @returns VertexData
  90635. */
  90636. updateMesh(mesh: Mesh): VertexData;
  90637. /**
  90638. * Updates the associated geometry
  90639. * @param geometry the geometry to be updated
  90640. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90641. * @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
  90642. * @returns VertexData.
  90643. */
  90644. updateGeometry(geometry: Geometry): VertexData;
  90645. private _applyTo;
  90646. private _update;
  90647. /**
  90648. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90649. * @param matrix the transforming matrix
  90650. * @returns the VertexData
  90651. */
  90652. transform(matrix: Matrix): VertexData;
  90653. /**
  90654. * Merges the passed VertexData into the current one
  90655. * @param other the VertexData to be merged into the current one
  90656. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90657. * @returns the modified VertexData
  90658. */
  90659. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  90660. private _mergeElement;
  90661. private _validate;
  90662. /**
  90663. * Serializes the VertexData
  90664. * @returns a serialized object
  90665. */
  90666. serialize(): any;
  90667. /**
  90668. * Extracts the vertexData from a mesh
  90669. * @param mesh the mesh from which to extract the VertexData
  90670. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90671. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90672. * @returns the object VertexData associated to the passed mesh
  90673. */
  90674. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90675. /**
  90676. * Extracts the vertexData from the geometry
  90677. * @param geometry the geometry from which to extract the VertexData
  90678. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90679. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90680. * @returns the object VertexData associated to the passed mesh
  90681. */
  90682. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90683. private static _ExtractFrom;
  90684. /**
  90685. * Creates the VertexData for a Ribbon
  90686. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90687. * * pathArray array of paths, each of which an array of successive Vector3
  90688. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90689. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90690. * * 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
  90691. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90692. * * 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)
  90693. * * 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)
  90694. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90695. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90696. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90697. * @returns the VertexData of the ribbon
  90698. */
  90699. static CreateRibbon(options: {
  90700. pathArray: Vector3[][];
  90701. closeArray?: boolean;
  90702. closePath?: boolean;
  90703. offset?: number;
  90704. sideOrientation?: number;
  90705. frontUVs?: Vector4;
  90706. backUVs?: Vector4;
  90707. invertUV?: boolean;
  90708. uvs?: Vector2[];
  90709. colors?: Color4[];
  90710. }): VertexData;
  90711. /**
  90712. * Creates the VertexData for a box
  90713. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90714. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90715. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90716. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90717. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90718. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90719. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90720. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90721. * * 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)
  90722. * * 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)
  90723. * @returns the VertexData of the box
  90724. */
  90725. static CreateBox(options: {
  90726. size?: number;
  90727. width?: number;
  90728. height?: number;
  90729. depth?: number;
  90730. faceUV?: Vector4[];
  90731. faceColors?: Color4[];
  90732. sideOrientation?: number;
  90733. frontUVs?: Vector4;
  90734. backUVs?: Vector4;
  90735. }): VertexData;
  90736. /**
  90737. * Creates the VertexData for a tiled box
  90738. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90739. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90740. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90741. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90742. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90743. * @returns the VertexData of the box
  90744. */
  90745. static CreateTiledBox(options: {
  90746. pattern?: number;
  90747. width?: number;
  90748. height?: number;
  90749. depth?: number;
  90750. tileSize?: number;
  90751. tileWidth?: number;
  90752. tileHeight?: number;
  90753. alignHorizontal?: number;
  90754. alignVertical?: number;
  90755. faceUV?: Vector4[];
  90756. faceColors?: Color4[];
  90757. sideOrientation?: number;
  90758. }): VertexData;
  90759. /**
  90760. * Creates the VertexData for a tiled plane
  90761. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90762. * * pattern a limited pattern arrangement depending on the number
  90763. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90764. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90765. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90767. * * 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)
  90768. * * 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)
  90769. * @returns the VertexData of the tiled plane
  90770. */
  90771. static CreateTiledPlane(options: {
  90772. pattern?: number;
  90773. tileSize?: number;
  90774. tileWidth?: number;
  90775. tileHeight?: number;
  90776. size?: number;
  90777. width?: number;
  90778. height?: number;
  90779. alignHorizontal?: number;
  90780. alignVertical?: number;
  90781. sideOrientation?: number;
  90782. frontUVs?: Vector4;
  90783. backUVs?: Vector4;
  90784. }): VertexData;
  90785. /**
  90786. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90787. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90788. * * segments sets the number of horizontal strips optional, default 32
  90789. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90790. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90791. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90792. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90793. * * 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
  90794. * * 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
  90795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90796. * * 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)
  90797. * * 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)
  90798. * @returns the VertexData of the ellipsoid
  90799. */
  90800. static CreateSphere(options: {
  90801. segments?: number;
  90802. diameter?: number;
  90803. diameterX?: number;
  90804. diameterY?: number;
  90805. diameterZ?: number;
  90806. arc?: number;
  90807. slice?: number;
  90808. sideOrientation?: number;
  90809. frontUVs?: Vector4;
  90810. backUVs?: Vector4;
  90811. }): VertexData;
  90812. /**
  90813. * Creates the VertexData for a cylinder, cone or prism
  90814. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90815. * * height sets the height (y direction) of the cylinder, optional, default 2
  90816. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90817. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90818. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90819. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90820. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90821. * * 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
  90822. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90823. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90824. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90825. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90827. * * 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)
  90828. * * 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)
  90829. * @returns the VertexData of the cylinder, cone or prism
  90830. */
  90831. static CreateCylinder(options: {
  90832. height?: number;
  90833. diameterTop?: number;
  90834. diameterBottom?: number;
  90835. diameter?: number;
  90836. tessellation?: number;
  90837. subdivisions?: number;
  90838. arc?: number;
  90839. faceColors?: Color4[];
  90840. faceUV?: Vector4[];
  90841. hasRings?: boolean;
  90842. enclose?: boolean;
  90843. sideOrientation?: number;
  90844. frontUVs?: Vector4;
  90845. backUVs?: Vector4;
  90846. }): VertexData;
  90847. /**
  90848. * Creates the VertexData for a torus
  90849. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90850. * * diameter the diameter of the torus, optional default 1
  90851. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90852. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90854. * * 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)
  90855. * * 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)
  90856. * @returns the VertexData of the torus
  90857. */
  90858. static CreateTorus(options: {
  90859. diameter?: number;
  90860. thickness?: number;
  90861. tessellation?: number;
  90862. sideOrientation?: number;
  90863. frontUVs?: Vector4;
  90864. backUVs?: Vector4;
  90865. }): VertexData;
  90866. /**
  90867. * Creates the VertexData of the LineSystem
  90868. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90869. * - lines an array of lines, each line being an array of successive Vector3
  90870. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90871. * @returns the VertexData of the LineSystem
  90872. */
  90873. static CreateLineSystem(options: {
  90874. lines: Vector3[][];
  90875. colors?: Nullable<Color4[][]>;
  90876. }): VertexData;
  90877. /**
  90878. * Create the VertexData for a DashedLines
  90879. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90880. * - points an array successive Vector3
  90881. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90882. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90883. * - dashNb the intended total number of dashes, optional, default 200
  90884. * @returns the VertexData for the DashedLines
  90885. */
  90886. static CreateDashedLines(options: {
  90887. points: Vector3[];
  90888. dashSize?: number;
  90889. gapSize?: number;
  90890. dashNb?: number;
  90891. }): VertexData;
  90892. /**
  90893. * Creates the VertexData for a Ground
  90894. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90895. * - width the width (x direction) of the ground, optional, default 1
  90896. * - height the height (z direction) of the ground, optional, default 1
  90897. * - subdivisions the number of subdivisions per side, optional, default 1
  90898. * @returns the VertexData of the Ground
  90899. */
  90900. static CreateGround(options: {
  90901. width?: number;
  90902. height?: number;
  90903. subdivisions?: number;
  90904. subdivisionsX?: number;
  90905. subdivisionsY?: number;
  90906. }): VertexData;
  90907. /**
  90908. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90909. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90910. * * xmin the ground minimum X coordinate, optional, default -1
  90911. * * zmin the ground minimum Z coordinate, optional, default -1
  90912. * * xmax the ground maximum X coordinate, optional, default 1
  90913. * * zmax the ground maximum Z coordinate, optional, default 1
  90914. * * 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}
  90915. * * 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}
  90916. * @returns the VertexData of the TiledGround
  90917. */
  90918. static CreateTiledGround(options: {
  90919. xmin: number;
  90920. zmin: number;
  90921. xmax: number;
  90922. zmax: number;
  90923. subdivisions?: {
  90924. w: number;
  90925. h: number;
  90926. };
  90927. precision?: {
  90928. w: number;
  90929. h: number;
  90930. };
  90931. }): VertexData;
  90932. /**
  90933. * Creates the VertexData of the Ground designed from a heightmap
  90934. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90935. * * width the width (x direction) of the ground
  90936. * * height the height (z direction) of the ground
  90937. * * subdivisions the number of subdivisions per side
  90938. * * minHeight the minimum altitude on the ground, optional, default 0
  90939. * * maxHeight the maximum altitude on the ground, optional default 1
  90940. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90941. * * buffer the array holding the image color data
  90942. * * bufferWidth the width of image
  90943. * * bufferHeight the height of image
  90944. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90945. * @returns the VertexData of the Ground designed from a heightmap
  90946. */
  90947. static CreateGroundFromHeightMap(options: {
  90948. width: number;
  90949. height: number;
  90950. subdivisions: number;
  90951. minHeight: number;
  90952. maxHeight: number;
  90953. colorFilter: Color3;
  90954. buffer: Uint8Array;
  90955. bufferWidth: number;
  90956. bufferHeight: number;
  90957. alphaFilter: number;
  90958. }): VertexData;
  90959. /**
  90960. * Creates the VertexData for a Plane
  90961. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90962. * * size sets the width and height of the plane to the value of size, optional default 1
  90963. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90964. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90966. * * 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)
  90967. * * 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)
  90968. * @returns the VertexData of the box
  90969. */
  90970. static CreatePlane(options: {
  90971. size?: number;
  90972. width?: number;
  90973. height?: number;
  90974. sideOrientation?: number;
  90975. frontUVs?: Vector4;
  90976. backUVs?: Vector4;
  90977. }): VertexData;
  90978. /**
  90979. * Creates the VertexData of the Disc or regular Polygon
  90980. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90981. * * radius the radius of the disc, optional default 0.5
  90982. * * tessellation the number of polygon sides, optional, default 64
  90983. * * 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
  90984. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90985. * * 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)
  90986. * * 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)
  90987. * @returns the VertexData of the box
  90988. */
  90989. static CreateDisc(options: {
  90990. radius?: number;
  90991. tessellation?: number;
  90992. arc?: number;
  90993. sideOrientation?: number;
  90994. frontUVs?: Vector4;
  90995. backUVs?: Vector4;
  90996. }): VertexData;
  90997. /**
  90998. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90999. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91000. * @param polygon a mesh built from polygonTriangulation.build()
  91001. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91002. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91003. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91004. * @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)
  91005. * @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)
  91006. * @returns the VertexData of the Polygon
  91007. */
  91008. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  91009. /**
  91010. * Creates the VertexData of the IcoSphere
  91011. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91012. * * radius the radius of the IcoSphere, optional default 1
  91013. * * radiusX allows stretching in the x direction, optional, default radius
  91014. * * radiusY allows stretching in the y direction, optional, default radius
  91015. * * radiusZ allows stretching in the z direction, optional, default radius
  91016. * * flat when true creates a flat shaded mesh, optional, default true
  91017. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91018. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91019. * * 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)
  91020. * * 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)
  91021. * @returns the VertexData of the IcoSphere
  91022. */
  91023. static CreateIcoSphere(options: {
  91024. radius?: number;
  91025. radiusX?: number;
  91026. radiusY?: number;
  91027. radiusZ?: number;
  91028. flat?: boolean;
  91029. subdivisions?: number;
  91030. sideOrientation?: number;
  91031. frontUVs?: Vector4;
  91032. backUVs?: Vector4;
  91033. }): VertexData;
  91034. /**
  91035. * Creates the VertexData for a Polyhedron
  91036. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91037. * * type provided types are:
  91038. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91039. * * 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)
  91040. * * size the size of the IcoSphere, optional default 1
  91041. * * sizeX allows stretching in the x direction, optional, default size
  91042. * * sizeY allows stretching in the y direction, optional, default size
  91043. * * sizeZ allows stretching in the z direction, optional, default size
  91044. * * 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
  91045. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91046. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91047. * * flat when true creates a flat shaded mesh, optional, default true
  91048. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91049. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91050. * * 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)
  91051. * * 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)
  91052. * @returns the VertexData of the Polyhedron
  91053. */
  91054. static CreatePolyhedron(options: {
  91055. type?: number;
  91056. size?: number;
  91057. sizeX?: number;
  91058. sizeY?: number;
  91059. sizeZ?: number;
  91060. custom?: any;
  91061. faceUV?: Vector4[];
  91062. faceColors?: Color4[];
  91063. flat?: boolean;
  91064. sideOrientation?: number;
  91065. frontUVs?: Vector4;
  91066. backUVs?: Vector4;
  91067. }): VertexData;
  91068. /**
  91069. * Creates the VertexData for a TorusKnot
  91070. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91071. * * radius the radius of the torus knot, optional, default 2
  91072. * * tube the thickness of the tube, optional, default 0.5
  91073. * * radialSegments the number of sides on each tube segments, optional, default 32
  91074. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91075. * * p the number of windings around the z axis, optional, default 2
  91076. * * q the number of windings around the x axis, optional, default 3
  91077. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91078. * * 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)
  91079. * * 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)
  91080. * @returns the VertexData of the Torus Knot
  91081. */
  91082. static CreateTorusKnot(options: {
  91083. radius?: number;
  91084. tube?: number;
  91085. radialSegments?: number;
  91086. tubularSegments?: number;
  91087. p?: number;
  91088. q?: number;
  91089. sideOrientation?: number;
  91090. frontUVs?: Vector4;
  91091. backUVs?: Vector4;
  91092. }): VertexData;
  91093. /**
  91094. * Compute normals for given positions and indices
  91095. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91096. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91097. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91098. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91099. * * facetNormals : optional array of facet normals (vector3)
  91100. * * facetPositions : optional array of facet positions (vector3)
  91101. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91102. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91103. * * bInfo : optional bounding info, required for facetPartitioning computation
  91104. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91105. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91106. * * useRightHandedSystem: optional boolean to for right handed system computation
  91107. * * depthSort : optional boolean to enable the facet depth sort computation
  91108. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91109. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91110. */
  91111. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  91112. facetNormals?: any;
  91113. facetPositions?: any;
  91114. facetPartitioning?: any;
  91115. ratio?: number;
  91116. bInfo?: any;
  91117. bbSize?: Vector3;
  91118. subDiv?: any;
  91119. useRightHandedSystem?: boolean;
  91120. depthSort?: boolean;
  91121. distanceTo?: Vector3;
  91122. depthSortedFacets?: any;
  91123. }): void;
  91124. /** @hidden */
  91125. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  91126. /**
  91127. * Applies VertexData created from the imported parameters to the geometry
  91128. * @param parsedVertexData the parsed data from an imported file
  91129. * @param geometry the geometry to apply the VertexData to
  91130. */
  91131. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  91132. }
  91133. }
  91134. declare module BABYLON {
  91135. /**
  91136. * Defines a target to use with MorphTargetManager
  91137. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91138. */
  91139. export class MorphTarget implements IAnimatable {
  91140. /** defines the name of the target */
  91141. name: string;
  91142. /**
  91143. * Gets or sets the list of animations
  91144. */
  91145. animations: Animation[];
  91146. private _scene;
  91147. private _positions;
  91148. private _normals;
  91149. private _tangents;
  91150. private _uvs;
  91151. private _influence;
  91152. private _uniqueId;
  91153. /**
  91154. * Observable raised when the influence changes
  91155. */
  91156. onInfluenceChanged: Observable<boolean>;
  91157. /** @hidden */
  91158. _onDataLayoutChanged: Observable<void>;
  91159. /**
  91160. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  91161. */
  91162. influence: number;
  91163. /**
  91164. * Gets or sets the id of the morph Target
  91165. */
  91166. id: string;
  91167. private _animationPropertiesOverride;
  91168. /**
  91169. * Gets or sets the animation properties override
  91170. */
  91171. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91172. /**
  91173. * Creates a new MorphTarget
  91174. * @param name defines the name of the target
  91175. * @param influence defines the influence to use
  91176. * @param scene defines the scene the morphtarget belongs to
  91177. */
  91178. constructor(
  91179. /** defines the name of the target */
  91180. name: string, influence?: number, scene?: Nullable<Scene>);
  91181. /**
  91182. * Gets the unique ID of this manager
  91183. */
  91184. readonly uniqueId: number;
  91185. /**
  91186. * Gets a boolean defining if the target contains position data
  91187. */
  91188. readonly hasPositions: boolean;
  91189. /**
  91190. * Gets a boolean defining if the target contains normal data
  91191. */
  91192. readonly hasNormals: boolean;
  91193. /**
  91194. * Gets a boolean defining if the target contains tangent data
  91195. */
  91196. readonly hasTangents: boolean;
  91197. /**
  91198. * Gets a boolean defining if the target contains texture coordinates data
  91199. */
  91200. readonly hasUVs: boolean;
  91201. /**
  91202. * Affects position data to this target
  91203. * @param data defines the position data to use
  91204. */
  91205. setPositions(data: Nullable<FloatArray>): void;
  91206. /**
  91207. * Gets the position data stored in this target
  91208. * @returns a FloatArray containing the position data (or null if not present)
  91209. */
  91210. getPositions(): Nullable<FloatArray>;
  91211. /**
  91212. * Affects normal data to this target
  91213. * @param data defines the normal data to use
  91214. */
  91215. setNormals(data: Nullable<FloatArray>): void;
  91216. /**
  91217. * Gets the normal data stored in this target
  91218. * @returns a FloatArray containing the normal data (or null if not present)
  91219. */
  91220. getNormals(): Nullable<FloatArray>;
  91221. /**
  91222. * Affects tangent data to this target
  91223. * @param data defines the tangent data to use
  91224. */
  91225. setTangents(data: Nullable<FloatArray>): void;
  91226. /**
  91227. * Gets the tangent data stored in this target
  91228. * @returns a FloatArray containing the tangent data (or null if not present)
  91229. */
  91230. getTangents(): Nullable<FloatArray>;
  91231. /**
  91232. * Affects texture coordinates data to this target
  91233. * @param data defines the texture coordinates data to use
  91234. */
  91235. setUVs(data: Nullable<FloatArray>): void;
  91236. /**
  91237. * Gets the texture coordinates data stored in this target
  91238. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  91239. */
  91240. getUVs(): Nullable<FloatArray>;
  91241. /**
  91242. * Clone the current target
  91243. * @returns a new MorphTarget
  91244. */
  91245. clone(): MorphTarget;
  91246. /**
  91247. * Serializes the current target into a Serialization object
  91248. * @returns the serialized object
  91249. */
  91250. serialize(): any;
  91251. /**
  91252. * Returns the string "MorphTarget"
  91253. * @returns "MorphTarget"
  91254. */
  91255. getClassName(): string;
  91256. /**
  91257. * Creates a new target from serialized data
  91258. * @param serializationObject defines the serialized data to use
  91259. * @returns a new MorphTarget
  91260. */
  91261. static Parse(serializationObject: any): MorphTarget;
  91262. /**
  91263. * Creates a MorphTarget from mesh data
  91264. * @param mesh defines the source mesh
  91265. * @param name defines the name to use for the new target
  91266. * @param influence defines the influence to attach to the target
  91267. * @returns a new MorphTarget
  91268. */
  91269. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  91270. }
  91271. }
  91272. declare module BABYLON {
  91273. /**
  91274. * This class is used to deform meshes using morphing between different targets
  91275. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91276. */
  91277. export class MorphTargetManager {
  91278. private _targets;
  91279. private _targetInfluenceChangedObservers;
  91280. private _targetDataLayoutChangedObservers;
  91281. private _activeTargets;
  91282. private _scene;
  91283. private _influences;
  91284. private _supportsNormals;
  91285. private _supportsTangents;
  91286. private _supportsUVs;
  91287. private _vertexCount;
  91288. private _uniqueId;
  91289. private _tempInfluences;
  91290. /**
  91291. * Gets or sets a boolean indicating if normals must be morphed
  91292. */
  91293. enableNormalMorphing: boolean;
  91294. /**
  91295. * Gets or sets a boolean indicating if tangents must be morphed
  91296. */
  91297. enableTangentMorphing: boolean;
  91298. /**
  91299. * Gets or sets a boolean indicating if UV must be morphed
  91300. */
  91301. enableUVMorphing: boolean;
  91302. /**
  91303. * Creates a new MorphTargetManager
  91304. * @param scene defines the current scene
  91305. */
  91306. constructor(scene?: Nullable<Scene>);
  91307. /**
  91308. * Gets the unique ID of this manager
  91309. */
  91310. readonly uniqueId: number;
  91311. /**
  91312. * Gets the number of vertices handled by this manager
  91313. */
  91314. readonly vertexCount: number;
  91315. /**
  91316. * Gets a boolean indicating if this manager supports morphing of normals
  91317. */
  91318. readonly supportsNormals: boolean;
  91319. /**
  91320. * Gets a boolean indicating if this manager supports morphing of tangents
  91321. */
  91322. readonly supportsTangents: boolean;
  91323. /**
  91324. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  91325. */
  91326. readonly supportsUVs: boolean;
  91327. /**
  91328. * Gets the number of targets stored in this manager
  91329. */
  91330. readonly numTargets: number;
  91331. /**
  91332. * Gets the number of influencers (ie. the number of targets with influences > 0)
  91333. */
  91334. readonly numInfluencers: number;
  91335. /**
  91336. * Gets the list of influences (one per target)
  91337. */
  91338. readonly influences: Float32Array;
  91339. /**
  91340. * Gets the active target at specified index. An active target is a target with an influence > 0
  91341. * @param index defines the index to check
  91342. * @returns the requested target
  91343. */
  91344. getActiveTarget(index: number): MorphTarget;
  91345. /**
  91346. * Gets the target at specified index
  91347. * @param index defines the index to check
  91348. * @returns the requested target
  91349. */
  91350. getTarget(index: number): MorphTarget;
  91351. /**
  91352. * Add a new target to this manager
  91353. * @param target defines the target to add
  91354. */
  91355. addTarget(target: MorphTarget): void;
  91356. /**
  91357. * Removes a target from the manager
  91358. * @param target defines the target to remove
  91359. */
  91360. removeTarget(target: MorphTarget): void;
  91361. /**
  91362. * Clone the current manager
  91363. * @returns a new MorphTargetManager
  91364. */
  91365. clone(): MorphTargetManager;
  91366. /**
  91367. * Serializes the current manager into a Serialization object
  91368. * @returns the serialized object
  91369. */
  91370. serialize(): any;
  91371. private _syncActiveTargets;
  91372. /**
  91373. * Syncrhonize the targets with all the meshes using this morph target manager
  91374. */
  91375. synchronize(): void;
  91376. /**
  91377. * Creates a new MorphTargetManager from serialized data
  91378. * @param serializationObject defines the serialized data
  91379. * @param scene defines the hosting scene
  91380. * @returns the new MorphTargetManager
  91381. */
  91382. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  91383. }
  91384. }
  91385. declare module BABYLON {
  91386. /**
  91387. * Class used to represent a specific level of detail of a mesh
  91388. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91389. */
  91390. export class MeshLODLevel {
  91391. /** Defines the distance where this level should start being displayed */
  91392. distance: number;
  91393. /** Defines the mesh to use to render this level */
  91394. mesh: Nullable<Mesh>;
  91395. /**
  91396. * Creates a new LOD level
  91397. * @param distance defines the distance where this level should star being displayed
  91398. * @param mesh defines the mesh to use to render this level
  91399. */
  91400. constructor(
  91401. /** Defines the distance where this level should start being displayed */
  91402. distance: number,
  91403. /** Defines the mesh to use to render this level */
  91404. mesh: Nullable<Mesh>);
  91405. }
  91406. }
  91407. declare module BABYLON {
  91408. /**
  91409. * Mesh representing the gorund
  91410. */
  91411. export class GroundMesh extends Mesh {
  91412. /** If octree should be generated */
  91413. generateOctree: boolean;
  91414. private _heightQuads;
  91415. /** @hidden */
  91416. _subdivisionsX: number;
  91417. /** @hidden */
  91418. _subdivisionsY: number;
  91419. /** @hidden */
  91420. _width: number;
  91421. /** @hidden */
  91422. _height: number;
  91423. /** @hidden */
  91424. _minX: number;
  91425. /** @hidden */
  91426. _maxX: number;
  91427. /** @hidden */
  91428. _minZ: number;
  91429. /** @hidden */
  91430. _maxZ: number;
  91431. constructor(name: string, scene: Scene);
  91432. /**
  91433. * "GroundMesh"
  91434. * @returns "GroundMesh"
  91435. */
  91436. getClassName(): string;
  91437. /**
  91438. * The minimum of x and y subdivisions
  91439. */
  91440. readonly subdivisions: number;
  91441. /**
  91442. * X subdivisions
  91443. */
  91444. readonly subdivisionsX: number;
  91445. /**
  91446. * Y subdivisions
  91447. */
  91448. readonly subdivisionsY: number;
  91449. /**
  91450. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  91451. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  91452. * @param chunksCount the number of subdivisions for x and y
  91453. * @param octreeBlocksSize (Default: 32)
  91454. */
  91455. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  91456. /**
  91457. * Returns a height (y) value in the Worl system :
  91458. * the ground altitude at the coordinates (x, z) expressed in the World system.
  91459. * @param x x coordinate
  91460. * @param z z coordinate
  91461. * @returns the ground y position if (x, z) are outside the ground surface.
  91462. */
  91463. getHeightAtCoordinates(x: number, z: number): number;
  91464. /**
  91465. * Returns a normalized vector (Vector3) orthogonal to the ground
  91466. * at the ground coordinates (x, z) expressed in the World system.
  91467. * @param x x coordinate
  91468. * @param z z coordinate
  91469. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  91470. */
  91471. getNormalAtCoordinates(x: number, z: number): Vector3;
  91472. /**
  91473. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  91474. * at the ground coordinates (x, z) expressed in the World system.
  91475. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  91476. * @param x x coordinate
  91477. * @param z z coordinate
  91478. * @param ref vector to store the result
  91479. * @returns the GroundMesh.
  91480. */
  91481. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  91482. /**
  91483. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  91484. * if the ground has been updated.
  91485. * This can be used in the render loop.
  91486. * @returns the GroundMesh.
  91487. */
  91488. updateCoordinateHeights(): GroundMesh;
  91489. private _getFacetAt;
  91490. private _initHeightQuads;
  91491. private _computeHeightQuads;
  91492. /**
  91493. * Serializes this ground mesh
  91494. * @param serializationObject object to write serialization to
  91495. */
  91496. serialize(serializationObject: any): void;
  91497. /**
  91498. * Parses a serialized ground mesh
  91499. * @param parsedMesh the serialized mesh
  91500. * @param scene the scene to create the ground mesh in
  91501. * @returns the created ground mesh
  91502. */
  91503. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  91504. }
  91505. }
  91506. declare module BABYLON {
  91507. /**
  91508. * Interface for Physics-Joint data
  91509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91510. */
  91511. export interface PhysicsJointData {
  91512. /**
  91513. * The main pivot of the joint
  91514. */
  91515. mainPivot?: Vector3;
  91516. /**
  91517. * The connected pivot of the joint
  91518. */
  91519. connectedPivot?: Vector3;
  91520. /**
  91521. * The main axis of the joint
  91522. */
  91523. mainAxis?: Vector3;
  91524. /**
  91525. * The connected axis of the joint
  91526. */
  91527. connectedAxis?: Vector3;
  91528. /**
  91529. * The collision of the joint
  91530. */
  91531. collision?: boolean;
  91532. /**
  91533. * Native Oimo/Cannon/Energy data
  91534. */
  91535. nativeParams?: any;
  91536. }
  91537. /**
  91538. * This is a holder class for the physics joint created by the physics plugin
  91539. * It holds a set of functions to control the underlying joint
  91540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91541. */
  91542. export class PhysicsJoint {
  91543. /**
  91544. * The type of the physics joint
  91545. */
  91546. type: number;
  91547. /**
  91548. * The data for the physics joint
  91549. */
  91550. jointData: PhysicsJointData;
  91551. private _physicsJoint;
  91552. protected _physicsPlugin: IPhysicsEnginePlugin;
  91553. /**
  91554. * Initializes the physics joint
  91555. * @param type The type of the physics joint
  91556. * @param jointData The data for the physics joint
  91557. */
  91558. constructor(
  91559. /**
  91560. * The type of the physics joint
  91561. */
  91562. type: number,
  91563. /**
  91564. * The data for the physics joint
  91565. */
  91566. jointData: PhysicsJointData);
  91567. /**
  91568. * Gets the physics joint
  91569. */
  91570. /**
  91571. * Sets the physics joint
  91572. */
  91573. physicsJoint: any;
  91574. /**
  91575. * Sets the physics plugin
  91576. */
  91577. physicsPlugin: IPhysicsEnginePlugin;
  91578. /**
  91579. * Execute a function that is physics-plugin specific.
  91580. * @param {Function} func the function that will be executed.
  91581. * It accepts two parameters: the physics world and the physics joint
  91582. */
  91583. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  91584. /**
  91585. * Distance-Joint type
  91586. */
  91587. static DistanceJoint: number;
  91588. /**
  91589. * Hinge-Joint type
  91590. */
  91591. static HingeJoint: number;
  91592. /**
  91593. * Ball-and-Socket joint type
  91594. */
  91595. static BallAndSocketJoint: number;
  91596. /**
  91597. * Wheel-Joint type
  91598. */
  91599. static WheelJoint: number;
  91600. /**
  91601. * Slider-Joint type
  91602. */
  91603. static SliderJoint: number;
  91604. /**
  91605. * Prismatic-Joint type
  91606. */
  91607. static PrismaticJoint: number;
  91608. /**
  91609. * Universal-Joint type
  91610. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  91611. */
  91612. static UniversalJoint: number;
  91613. /**
  91614. * Hinge-Joint 2 type
  91615. */
  91616. static Hinge2Joint: number;
  91617. /**
  91618. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  91619. */
  91620. static PointToPointJoint: number;
  91621. /**
  91622. * Spring-Joint type
  91623. */
  91624. static SpringJoint: number;
  91625. /**
  91626. * Lock-Joint type
  91627. */
  91628. static LockJoint: number;
  91629. }
  91630. /**
  91631. * A class representing a physics distance joint
  91632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91633. */
  91634. export class DistanceJoint extends PhysicsJoint {
  91635. /**
  91636. *
  91637. * @param jointData The data for the Distance-Joint
  91638. */
  91639. constructor(jointData: DistanceJointData);
  91640. /**
  91641. * Update the predefined distance.
  91642. * @param maxDistance The maximum preferred distance
  91643. * @param minDistance The minimum preferred distance
  91644. */
  91645. updateDistance(maxDistance: number, minDistance?: number): void;
  91646. }
  91647. /**
  91648. * Represents a Motor-Enabled Joint
  91649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91650. */
  91651. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  91652. /**
  91653. * Initializes the Motor-Enabled Joint
  91654. * @param type The type of the joint
  91655. * @param jointData The physica joint data for the joint
  91656. */
  91657. constructor(type: number, jointData: PhysicsJointData);
  91658. /**
  91659. * Set the motor values.
  91660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91661. * @param force the force to apply
  91662. * @param maxForce max force for this motor.
  91663. */
  91664. setMotor(force?: number, maxForce?: number): void;
  91665. /**
  91666. * Set the motor's limits.
  91667. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91668. * @param upperLimit The upper limit of the motor
  91669. * @param lowerLimit The lower limit of the motor
  91670. */
  91671. setLimit(upperLimit: number, lowerLimit?: number): void;
  91672. }
  91673. /**
  91674. * This class represents a single physics Hinge-Joint
  91675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91676. */
  91677. export class HingeJoint extends MotorEnabledJoint {
  91678. /**
  91679. * Initializes the Hinge-Joint
  91680. * @param jointData The joint data for the Hinge-Joint
  91681. */
  91682. constructor(jointData: PhysicsJointData);
  91683. /**
  91684. * Set the motor values.
  91685. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91686. * @param {number} force the force to apply
  91687. * @param {number} maxForce max force for this motor.
  91688. */
  91689. setMotor(force?: number, maxForce?: number): void;
  91690. /**
  91691. * Set the motor's limits.
  91692. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91693. * @param upperLimit The upper limit of the motor
  91694. * @param lowerLimit The lower limit of the motor
  91695. */
  91696. setLimit(upperLimit: number, lowerLimit?: number): void;
  91697. }
  91698. /**
  91699. * This class represents a dual hinge physics joint (same as wheel joint)
  91700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91701. */
  91702. export class Hinge2Joint extends MotorEnabledJoint {
  91703. /**
  91704. * Initializes the Hinge2-Joint
  91705. * @param jointData The joint data for the Hinge2-Joint
  91706. */
  91707. constructor(jointData: PhysicsJointData);
  91708. /**
  91709. * Set the motor values.
  91710. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91711. * @param {number} targetSpeed the speed the motor is to reach
  91712. * @param {number} maxForce max force for this motor.
  91713. * @param {motorIndex} the motor's index, 0 or 1.
  91714. */
  91715. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  91716. /**
  91717. * Set the motor limits.
  91718. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91719. * @param {number} upperLimit the upper limit
  91720. * @param {number} lowerLimit lower limit
  91721. * @param {motorIndex} the motor's index, 0 or 1.
  91722. */
  91723. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91724. }
  91725. /**
  91726. * Interface for a motor enabled joint
  91727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91728. */
  91729. export interface IMotorEnabledJoint {
  91730. /**
  91731. * Physics joint
  91732. */
  91733. physicsJoint: any;
  91734. /**
  91735. * Sets the motor of the motor-enabled joint
  91736. * @param force The force of the motor
  91737. * @param maxForce The maximum force of the motor
  91738. * @param motorIndex The index of the motor
  91739. */
  91740. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91741. /**
  91742. * Sets the limit of the motor
  91743. * @param upperLimit The upper limit of the motor
  91744. * @param lowerLimit The lower limit of the motor
  91745. * @param motorIndex The index of the motor
  91746. */
  91747. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91748. }
  91749. /**
  91750. * Joint data for a Distance-Joint
  91751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91752. */
  91753. export interface DistanceJointData extends PhysicsJointData {
  91754. /**
  91755. * Max distance the 2 joint objects can be apart
  91756. */
  91757. maxDistance: number;
  91758. }
  91759. /**
  91760. * Joint data from a spring joint
  91761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91762. */
  91763. export interface SpringJointData extends PhysicsJointData {
  91764. /**
  91765. * Length of the spring
  91766. */
  91767. length: number;
  91768. /**
  91769. * Stiffness of the spring
  91770. */
  91771. stiffness: number;
  91772. /**
  91773. * Damping of the spring
  91774. */
  91775. damping: number;
  91776. /** this callback will be called when applying the force to the impostors. */
  91777. forceApplicationCallback: () => void;
  91778. }
  91779. }
  91780. declare module BABYLON {
  91781. /**
  91782. * Holds the data for the raycast result
  91783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91784. */
  91785. export class PhysicsRaycastResult {
  91786. private _hasHit;
  91787. private _hitDistance;
  91788. private _hitNormalWorld;
  91789. private _hitPointWorld;
  91790. private _rayFromWorld;
  91791. private _rayToWorld;
  91792. /**
  91793. * Gets if there was a hit
  91794. */
  91795. readonly hasHit: boolean;
  91796. /**
  91797. * Gets the distance from the hit
  91798. */
  91799. readonly hitDistance: number;
  91800. /**
  91801. * Gets the hit normal/direction in the world
  91802. */
  91803. readonly hitNormalWorld: Vector3;
  91804. /**
  91805. * Gets the hit point in the world
  91806. */
  91807. readonly hitPointWorld: Vector3;
  91808. /**
  91809. * Gets the ray "start point" of the ray in the world
  91810. */
  91811. readonly rayFromWorld: Vector3;
  91812. /**
  91813. * Gets the ray "end point" of the ray in the world
  91814. */
  91815. readonly rayToWorld: Vector3;
  91816. /**
  91817. * Sets the hit data (normal & point in world space)
  91818. * @param hitNormalWorld defines the normal in world space
  91819. * @param hitPointWorld defines the point in world space
  91820. */
  91821. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91822. /**
  91823. * Sets the distance from the start point to the hit point
  91824. * @param distance
  91825. */
  91826. setHitDistance(distance: number): void;
  91827. /**
  91828. * Calculates the distance manually
  91829. */
  91830. calculateHitDistance(): void;
  91831. /**
  91832. * Resets all the values to default
  91833. * @param from The from point on world space
  91834. * @param to The to point on world space
  91835. */
  91836. reset(from?: Vector3, to?: Vector3): void;
  91837. }
  91838. /**
  91839. * Interface for the size containing width and height
  91840. */
  91841. interface IXYZ {
  91842. /**
  91843. * X
  91844. */
  91845. x: number;
  91846. /**
  91847. * Y
  91848. */
  91849. y: number;
  91850. /**
  91851. * Z
  91852. */
  91853. z: number;
  91854. }
  91855. }
  91856. declare module BABYLON {
  91857. /**
  91858. * Interface used to describe a physics joint
  91859. */
  91860. export interface PhysicsImpostorJoint {
  91861. /** Defines the main impostor to which the joint is linked */
  91862. mainImpostor: PhysicsImpostor;
  91863. /** Defines the impostor that is connected to the main impostor using this joint */
  91864. connectedImpostor: PhysicsImpostor;
  91865. /** Defines the joint itself */
  91866. joint: PhysicsJoint;
  91867. }
  91868. /** @hidden */
  91869. export interface IPhysicsEnginePlugin {
  91870. world: any;
  91871. name: string;
  91872. setGravity(gravity: Vector3): void;
  91873. setTimeStep(timeStep: number): void;
  91874. getTimeStep(): number;
  91875. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91876. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91877. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91878. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91879. removePhysicsBody(impostor: PhysicsImpostor): void;
  91880. generateJoint(joint: PhysicsImpostorJoint): void;
  91881. removeJoint(joint: PhysicsImpostorJoint): void;
  91882. isSupported(): boolean;
  91883. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91884. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91885. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91887. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91888. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91889. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91890. getBodyMass(impostor: PhysicsImpostor): number;
  91891. getBodyFriction(impostor: PhysicsImpostor): number;
  91892. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91893. getBodyRestitution(impostor: PhysicsImpostor): number;
  91894. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91895. getBodyPressure?(impostor: PhysicsImpostor): number;
  91896. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91897. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91898. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91899. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91900. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91901. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91902. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91903. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91904. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91905. sleepBody(impostor: PhysicsImpostor): void;
  91906. wakeUpBody(impostor: PhysicsImpostor): void;
  91907. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91908. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91909. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91910. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91911. getRadius(impostor: PhysicsImpostor): number;
  91912. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91913. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91914. dispose(): void;
  91915. }
  91916. /**
  91917. * Interface used to define a physics engine
  91918. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91919. */
  91920. export interface IPhysicsEngine {
  91921. /**
  91922. * Gets the gravity vector used by the simulation
  91923. */
  91924. gravity: Vector3;
  91925. /**
  91926. * Sets the gravity vector used by the simulation
  91927. * @param gravity defines the gravity vector to use
  91928. */
  91929. setGravity(gravity: Vector3): void;
  91930. /**
  91931. * Set the time step of the physics engine.
  91932. * Default is 1/60.
  91933. * To slow it down, enter 1/600 for example.
  91934. * To speed it up, 1/30
  91935. * @param newTimeStep the new timestep to apply to this world.
  91936. */
  91937. setTimeStep(newTimeStep: number): void;
  91938. /**
  91939. * Get the time step of the physics engine.
  91940. * @returns the current time step
  91941. */
  91942. getTimeStep(): number;
  91943. /**
  91944. * Set the sub time step of the physics engine.
  91945. * Default is 0 meaning there is no sub steps
  91946. * To increase physics resolution precision, set a small value (like 1 ms)
  91947. * @param subTimeStep defines the new sub timestep used for physics resolution.
  91948. */
  91949. setSubTimeStep(subTimeStep: number): void;
  91950. /**
  91951. * Get the sub time step of the physics engine.
  91952. * @returns the current sub time step
  91953. */
  91954. getSubTimeStep(): number;
  91955. /**
  91956. * Release all resources
  91957. */
  91958. dispose(): void;
  91959. /**
  91960. * Gets the name of the current physics plugin
  91961. * @returns the name of the plugin
  91962. */
  91963. getPhysicsPluginName(): string;
  91964. /**
  91965. * Adding a new impostor for the impostor tracking.
  91966. * This will be done by the impostor itself.
  91967. * @param impostor the impostor to add
  91968. */
  91969. addImpostor(impostor: PhysicsImpostor): void;
  91970. /**
  91971. * Remove an impostor from the engine.
  91972. * This impostor and its mesh will not longer be updated by the physics engine.
  91973. * @param impostor the impostor to remove
  91974. */
  91975. removeImpostor(impostor: PhysicsImpostor): void;
  91976. /**
  91977. * Add a joint to the physics engine
  91978. * @param mainImpostor defines the main impostor to which the joint is added.
  91979. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91980. * @param joint defines the joint that will connect both impostors.
  91981. */
  91982. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91983. /**
  91984. * Removes a joint from the simulation
  91985. * @param mainImpostor defines the impostor used with the joint
  91986. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91987. * @param joint defines the joint to remove
  91988. */
  91989. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91990. /**
  91991. * Gets the current plugin used to run the simulation
  91992. * @returns current plugin
  91993. */
  91994. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91995. /**
  91996. * Gets the list of physic impostors
  91997. * @returns an array of PhysicsImpostor
  91998. */
  91999. getImpostors(): Array<PhysicsImpostor>;
  92000. /**
  92001. * Gets the impostor for a physics enabled object
  92002. * @param object defines the object impersonated by the impostor
  92003. * @returns the PhysicsImpostor or null if not found
  92004. */
  92005. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92006. /**
  92007. * Gets the impostor for a physics body object
  92008. * @param body defines physics body used by the impostor
  92009. * @returns the PhysicsImpostor or null if not found
  92010. */
  92011. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  92012. /**
  92013. * Does a raycast in the physics world
  92014. * @param from when should the ray start?
  92015. * @param to when should the ray end?
  92016. * @returns PhysicsRaycastResult
  92017. */
  92018. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92019. /**
  92020. * Called by the scene. No need to call it.
  92021. * @param delta defines the timespam between frames
  92022. */
  92023. _step(delta: number): void;
  92024. }
  92025. }
  92026. declare module BABYLON {
  92027. /**
  92028. * The interface for the physics imposter parameters
  92029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92030. */
  92031. export interface PhysicsImpostorParameters {
  92032. /**
  92033. * The mass of the physics imposter
  92034. */
  92035. mass: number;
  92036. /**
  92037. * The friction of the physics imposter
  92038. */
  92039. friction?: number;
  92040. /**
  92041. * The coefficient of restitution of the physics imposter
  92042. */
  92043. restitution?: number;
  92044. /**
  92045. * The native options of the physics imposter
  92046. */
  92047. nativeOptions?: any;
  92048. /**
  92049. * Specifies if the parent should be ignored
  92050. */
  92051. ignoreParent?: boolean;
  92052. /**
  92053. * Specifies if bi-directional transformations should be disabled
  92054. */
  92055. disableBidirectionalTransformation?: boolean;
  92056. /**
  92057. * The pressure inside the physics imposter, soft object only
  92058. */
  92059. pressure?: number;
  92060. /**
  92061. * The stiffness the physics imposter, soft object only
  92062. */
  92063. stiffness?: number;
  92064. /**
  92065. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  92066. */
  92067. velocityIterations?: number;
  92068. /**
  92069. * The number of iterations used in maintaining consistent vertex positions, soft object only
  92070. */
  92071. positionIterations?: number;
  92072. /**
  92073. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  92074. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  92075. * Add to fix multiple points
  92076. */
  92077. fixedPoints?: number;
  92078. /**
  92079. * The collision margin around a soft object
  92080. */
  92081. margin?: number;
  92082. /**
  92083. * The collision margin around a soft object
  92084. */
  92085. damping?: number;
  92086. /**
  92087. * The path for a rope based on an extrusion
  92088. */
  92089. path?: any;
  92090. /**
  92091. * The shape of an extrusion used for a rope based on an extrusion
  92092. */
  92093. shape?: any;
  92094. }
  92095. /**
  92096. * Interface for a physics-enabled object
  92097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92098. */
  92099. export interface IPhysicsEnabledObject {
  92100. /**
  92101. * The position of the physics-enabled object
  92102. */
  92103. position: Vector3;
  92104. /**
  92105. * The rotation of the physics-enabled object
  92106. */
  92107. rotationQuaternion: Nullable<Quaternion>;
  92108. /**
  92109. * The scale of the physics-enabled object
  92110. */
  92111. scaling: Vector3;
  92112. /**
  92113. * The rotation of the physics-enabled object
  92114. */
  92115. rotation?: Vector3;
  92116. /**
  92117. * The parent of the physics-enabled object
  92118. */
  92119. parent?: any;
  92120. /**
  92121. * The bounding info of the physics-enabled object
  92122. * @returns The bounding info of the physics-enabled object
  92123. */
  92124. getBoundingInfo(): BoundingInfo;
  92125. /**
  92126. * Computes the world matrix
  92127. * @param force Specifies if the world matrix should be computed by force
  92128. * @returns A world matrix
  92129. */
  92130. computeWorldMatrix(force: boolean): Matrix;
  92131. /**
  92132. * Gets the world matrix
  92133. * @returns A world matrix
  92134. */
  92135. getWorldMatrix?(): Matrix;
  92136. /**
  92137. * Gets the child meshes
  92138. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  92139. * @returns An array of abstract meshes
  92140. */
  92141. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  92142. /**
  92143. * Gets the vertex data
  92144. * @param kind The type of vertex data
  92145. * @returns A nullable array of numbers, or a float32 array
  92146. */
  92147. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  92148. /**
  92149. * Gets the indices from the mesh
  92150. * @returns A nullable array of index arrays
  92151. */
  92152. getIndices?(): Nullable<IndicesArray>;
  92153. /**
  92154. * Gets the scene from the mesh
  92155. * @returns the indices array or null
  92156. */
  92157. getScene?(): Scene;
  92158. /**
  92159. * Gets the absolute position from the mesh
  92160. * @returns the absolute position
  92161. */
  92162. getAbsolutePosition(): Vector3;
  92163. /**
  92164. * Gets the absolute pivot point from the mesh
  92165. * @returns the absolute pivot point
  92166. */
  92167. getAbsolutePivotPoint(): Vector3;
  92168. /**
  92169. * Rotates the mesh
  92170. * @param axis The axis of rotation
  92171. * @param amount The amount of rotation
  92172. * @param space The space of the rotation
  92173. * @returns The rotation transform node
  92174. */
  92175. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92176. /**
  92177. * Translates the mesh
  92178. * @param axis The axis of translation
  92179. * @param distance The distance of translation
  92180. * @param space The space of the translation
  92181. * @returns The transform node
  92182. */
  92183. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92184. /**
  92185. * Sets the absolute position of the mesh
  92186. * @param absolutePosition The absolute position of the mesh
  92187. * @returns The transform node
  92188. */
  92189. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92190. /**
  92191. * Gets the class name of the mesh
  92192. * @returns The class name
  92193. */
  92194. getClassName(): string;
  92195. }
  92196. /**
  92197. * Represents a physics imposter
  92198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92199. */
  92200. export class PhysicsImpostor {
  92201. /**
  92202. * The physics-enabled object used as the physics imposter
  92203. */
  92204. object: IPhysicsEnabledObject;
  92205. /**
  92206. * The type of the physics imposter
  92207. */
  92208. type: number;
  92209. private _options;
  92210. private _scene?;
  92211. /**
  92212. * The default object size of the imposter
  92213. */
  92214. static DEFAULT_OBJECT_SIZE: Vector3;
  92215. /**
  92216. * The identity quaternion of the imposter
  92217. */
  92218. static IDENTITY_QUATERNION: Quaternion;
  92219. /** @hidden */
  92220. _pluginData: any;
  92221. private _physicsEngine;
  92222. private _physicsBody;
  92223. private _bodyUpdateRequired;
  92224. private _onBeforePhysicsStepCallbacks;
  92225. private _onAfterPhysicsStepCallbacks;
  92226. /** @hidden */
  92227. _onPhysicsCollideCallbacks: Array<{
  92228. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  92229. otherImpostors: Array<PhysicsImpostor>;
  92230. }>;
  92231. private _deltaPosition;
  92232. private _deltaRotation;
  92233. private _deltaRotationConjugated;
  92234. /** @hidden */
  92235. _isFromLine: boolean;
  92236. private _parent;
  92237. private _isDisposed;
  92238. private static _tmpVecs;
  92239. private static _tmpQuat;
  92240. /**
  92241. * Specifies if the physics imposter is disposed
  92242. */
  92243. readonly isDisposed: boolean;
  92244. /**
  92245. * Gets the mass of the physics imposter
  92246. */
  92247. mass: number;
  92248. /**
  92249. * Gets the coefficient of friction
  92250. */
  92251. /**
  92252. * Sets the coefficient of friction
  92253. */
  92254. friction: number;
  92255. /**
  92256. * Gets the coefficient of restitution
  92257. */
  92258. /**
  92259. * Sets the coefficient of restitution
  92260. */
  92261. restitution: number;
  92262. /**
  92263. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  92264. */
  92265. /**
  92266. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  92267. */
  92268. pressure: number;
  92269. /**
  92270. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92271. */
  92272. /**
  92273. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92274. */
  92275. stiffness: number;
  92276. /**
  92277. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92278. */
  92279. /**
  92280. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92281. */
  92282. velocityIterations: number;
  92283. /**
  92284. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92285. */
  92286. /**
  92287. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92288. */
  92289. positionIterations: number;
  92290. /**
  92291. * The unique id of the physics imposter
  92292. * set by the physics engine when adding this impostor to the array
  92293. */
  92294. uniqueId: number;
  92295. /**
  92296. * @hidden
  92297. */
  92298. soft: boolean;
  92299. /**
  92300. * @hidden
  92301. */
  92302. segments: number;
  92303. private _joints;
  92304. /**
  92305. * Initializes the physics imposter
  92306. * @param object The physics-enabled object used as the physics imposter
  92307. * @param type The type of the physics imposter
  92308. * @param _options The options for the physics imposter
  92309. * @param _scene The Babylon scene
  92310. */
  92311. constructor(
  92312. /**
  92313. * The physics-enabled object used as the physics imposter
  92314. */
  92315. object: IPhysicsEnabledObject,
  92316. /**
  92317. * The type of the physics imposter
  92318. */
  92319. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  92320. /**
  92321. * This function will completly initialize this impostor.
  92322. * It will create a new body - but only if this mesh has no parent.
  92323. * If it has, this impostor will not be used other than to define the impostor
  92324. * of the child mesh.
  92325. * @hidden
  92326. */
  92327. _init(): void;
  92328. private _getPhysicsParent;
  92329. /**
  92330. * Should a new body be generated.
  92331. * @returns boolean specifying if body initialization is required
  92332. */
  92333. isBodyInitRequired(): boolean;
  92334. /**
  92335. * Sets the updated scaling
  92336. * @param updated Specifies if the scaling is updated
  92337. */
  92338. setScalingUpdated(): void;
  92339. /**
  92340. * Force a regeneration of this or the parent's impostor's body.
  92341. * Use under cautious - This will remove all joints already implemented.
  92342. */
  92343. forceUpdate(): void;
  92344. /**
  92345. * Gets the body that holds this impostor. Either its own, or its parent.
  92346. */
  92347. /**
  92348. * Set the physics body. Used mainly by the physics engine/plugin
  92349. */
  92350. physicsBody: any;
  92351. /**
  92352. * Get the parent of the physics imposter
  92353. * @returns Physics imposter or null
  92354. */
  92355. /**
  92356. * Sets the parent of the physics imposter
  92357. */
  92358. parent: Nullable<PhysicsImpostor>;
  92359. /**
  92360. * Resets the update flags
  92361. */
  92362. resetUpdateFlags(): void;
  92363. /**
  92364. * Gets the object extend size
  92365. * @returns the object extend size
  92366. */
  92367. getObjectExtendSize(): Vector3;
  92368. /**
  92369. * Gets the object center
  92370. * @returns The object center
  92371. */
  92372. getObjectCenter(): Vector3;
  92373. /**
  92374. * Get a specific parametes from the options parameter
  92375. * @param paramName The object parameter name
  92376. * @returns The object parameter
  92377. */
  92378. getParam(paramName: string): any;
  92379. /**
  92380. * Sets a specific parameter in the options given to the physics plugin
  92381. * @param paramName The parameter name
  92382. * @param value The value of the parameter
  92383. */
  92384. setParam(paramName: string, value: number): void;
  92385. /**
  92386. * Specifically change the body's mass option. Won't recreate the physics body object
  92387. * @param mass The mass of the physics imposter
  92388. */
  92389. setMass(mass: number): void;
  92390. /**
  92391. * Gets the linear velocity
  92392. * @returns linear velocity or null
  92393. */
  92394. getLinearVelocity(): Nullable<Vector3>;
  92395. /**
  92396. * Sets the linear velocity
  92397. * @param velocity linear velocity or null
  92398. */
  92399. setLinearVelocity(velocity: Nullable<Vector3>): void;
  92400. /**
  92401. * Gets the angular velocity
  92402. * @returns angular velocity or null
  92403. */
  92404. getAngularVelocity(): Nullable<Vector3>;
  92405. /**
  92406. * Sets the angular velocity
  92407. * @param velocity The velocity or null
  92408. */
  92409. setAngularVelocity(velocity: Nullable<Vector3>): void;
  92410. /**
  92411. * Execute a function with the physics plugin native code
  92412. * Provide a function the will have two variables - the world object and the physics body object
  92413. * @param func The function to execute with the physics plugin native code
  92414. */
  92415. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  92416. /**
  92417. * Register a function that will be executed before the physics world is stepping forward
  92418. * @param func The function to execute before the physics world is stepped forward
  92419. */
  92420. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92421. /**
  92422. * Unregister a function that will be executed before the physics world is stepping forward
  92423. * @param func The function to execute before the physics world is stepped forward
  92424. */
  92425. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92426. /**
  92427. * Register a function that will be executed after the physics step
  92428. * @param func The function to execute after physics step
  92429. */
  92430. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92431. /**
  92432. * Unregisters a function that will be executed after the physics step
  92433. * @param func The function to execute after physics step
  92434. */
  92435. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92436. /**
  92437. * register a function that will be executed when this impostor collides against a different body
  92438. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  92439. * @param func Callback that is executed on collision
  92440. */
  92441. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  92442. /**
  92443. * Unregisters the physics imposter on contact
  92444. * @param collideAgainst The physics object to collide against
  92445. * @param func Callback to execute on collision
  92446. */
  92447. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  92448. private _tmpQuat;
  92449. private _tmpQuat2;
  92450. /**
  92451. * Get the parent rotation
  92452. * @returns The parent rotation
  92453. */
  92454. getParentsRotation(): Quaternion;
  92455. /**
  92456. * this function is executed by the physics engine.
  92457. */
  92458. beforeStep: () => void;
  92459. /**
  92460. * this function is executed by the physics engine
  92461. */
  92462. afterStep: () => void;
  92463. /**
  92464. * Legacy collision detection event support
  92465. */
  92466. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  92467. /**
  92468. * event and body object due to cannon's event-based architecture.
  92469. */
  92470. onCollide: (e: {
  92471. body: any;
  92472. }) => void;
  92473. /**
  92474. * Apply a force
  92475. * @param force The force to apply
  92476. * @param contactPoint The contact point for the force
  92477. * @returns The physics imposter
  92478. */
  92479. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92480. /**
  92481. * Apply an impulse
  92482. * @param force The impulse force
  92483. * @param contactPoint The contact point for the impulse force
  92484. * @returns The physics imposter
  92485. */
  92486. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92487. /**
  92488. * A help function to create a joint
  92489. * @param otherImpostor A physics imposter used to create a joint
  92490. * @param jointType The type of joint
  92491. * @param jointData The data for the joint
  92492. * @returns The physics imposter
  92493. */
  92494. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  92495. /**
  92496. * Add a joint to this impostor with a different impostor
  92497. * @param otherImpostor A physics imposter used to add a joint
  92498. * @param joint The joint to add
  92499. * @returns The physics imposter
  92500. */
  92501. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  92502. /**
  92503. * Add an anchor to a cloth impostor
  92504. * @param otherImpostor rigid impostor to anchor to
  92505. * @param width ratio across width from 0 to 1
  92506. * @param height ratio up height from 0 to 1
  92507. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  92508. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  92509. * @returns impostor the soft imposter
  92510. */
  92511. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92512. /**
  92513. * Add a hook to a rope impostor
  92514. * @param otherImpostor rigid impostor to anchor to
  92515. * @param length ratio across rope from 0 to 1
  92516. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  92517. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  92518. * @returns impostor the rope imposter
  92519. */
  92520. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92521. /**
  92522. * Will keep this body still, in a sleep mode.
  92523. * @returns the physics imposter
  92524. */
  92525. sleep(): PhysicsImpostor;
  92526. /**
  92527. * Wake the body up.
  92528. * @returns The physics imposter
  92529. */
  92530. wakeUp(): PhysicsImpostor;
  92531. /**
  92532. * Clones the physics imposter
  92533. * @param newObject The physics imposter clones to this physics-enabled object
  92534. * @returns A nullable physics imposter
  92535. */
  92536. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92537. /**
  92538. * Disposes the physics imposter
  92539. */
  92540. dispose(): void;
  92541. /**
  92542. * Sets the delta position
  92543. * @param position The delta position amount
  92544. */
  92545. setDeltaPosition(position: Vector3): void;
  92546. /**
  92547. * Sets the delta rotation
  92548. * @param rotation The delta rotation amount
  92549. */
  92550. setDeltaRotation(rotation: Quaternion): void;
  92551. /**
  92552. * Gets the box size of the physics imposter and stores the result in the input parameter
  92553. * @param result Stores the box size
  92554. * @returns The physics imposter
  92555. */
  92556. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  92557. /**
  92558. * Gets the radius of the physics imposter
  92559. * @returns Radius of the physics imposter
  92560. */
  92561. getRadius(): number;
  92562. /**
  92563. * Sync a bone with this impostor
  92564. * @param bone The bone to sync to the impostor.
  92565. * @param boneMesh The mesh that the bone is influencing.
  92566. * @param jointPivot The pivot of the joint / bone in local space.
  92567. * @param distToJoint Optional distance from the impostor to the joint.
  92568. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92569. */
  92570. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  92571. /**
  92572. * Sync impostor to a bone
  92573. * @param bone The bone that the impostor will be synced to.
  92574. * @param boneMesh The mesh that the bone is influencing.
  92575. * @param jointPivot The pivot of the joint / bone in local space.
  92576. * @param distToJoint Optional distance from the impostor to the joint.
  92577. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92578. * @param boneAxis Optional vector3 axis the bone is aligned with
  92579. */
  92580. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  92581. /**
  92582. * No-Imposter type
  92583. */
  92584. static NoImpostor: number;
  92585. /**
  92586. * Sphere-Imposter type
  92587. */
  92588. static SphereImpostor: number;
  92589. /**
  92590. * Box-Imposter type
  92591. */
  92592. static BoxImpostor: number;
  92593. /**
  92594. * Plane-Imposter type
  92595. */
  92596. static PlaneImpostor: number;
  92597. /**
  92598. * Mesh-imposter type
  92599. */
  92600. static MeshImpostor: number;
  92601. /**
  92602. * Capsule-Impostor type (Ammo.js plugin only)
  92603. */
  92604. static CapsuleImpostor: number;
  92605. /**
  92606. * Cylinder-Imposter type
  92607. */
  92608. static CylinderImpostor: number;
  92609. /**
  92610. * Particle-Imposter type
  92611. */
  92612. static ParticleImpostor: number;
  92613. /**
  92614. * Heightmap-Imposter type
  92615. */
  92616. static HeightmapImpostor: number;
  92617. /**
  92618. * ConvexHull-Impostor type (Ammo.js plugin only)
  92619. */
  92620. static ConvexHullImpostor: number;
  92621. /**
  92622. * Custom-Imposter type (Ammo.js plugin only)
  92623. */
  92624. static CustomImpostor: number;
  92625. /**
  92626. * Rope-Imposter type
  92627. */
  92628. static RopeImpostor: number;
  92629. /**
  92630. * Cloth-Imposter type
  92631. */
  92632. static ClothImpostor: number;
  92633. /**
  92634. * Softbody-Imposter type
  92635. */
  92636. static SoftbodyImpostor: number;
  92637. }
  92638. }
  92639. declare module BABYLON {
  92640. /**
  92641. * @hidden
  92642. **/
  92643. export class _CreationDataStorage {
  92644. closePath?: boolean;
  92645. closeArray?: boolean;
  92646. idx: number[];
  92647. dashSize: number;
  92648. gapSize: number;
  92649. path3D: Path3D;
  92650. pathArray: Vector3[][];
  92651. arc: number;
  92652. radius: number;
  92653. cap: number;
  92654. tessellation: number;
  92655. }
  92656. /**
  92657. * @hidden
  92658. **/
  92659. class _InstanceDataStorage {
  92660. visibleInstances: any;
  92661. batchCache: _InstancesBatch;
  92662. instancesBufferSize: number;
  92663. instancesBuffer: Nullable<Buffer>;
  92664. instancesData: Float32Array;
  92665. overridenInstanceCount: number;
  92666. isFrozen: boolean;
  92667. previousBatch: Nullable<_InstancesBatch>;
  92668. hardwareInstancedRendering: boolean;
  92669. sideOrientation: number;
  92670. manualUpdate: boolean;
  92671. }
  92672. /**
  92673. * @hidden
  92674. **/
  92675. export class _InstancesBatch {
  92676. mustReturn: boolean;
  92677. visibleInstances: Nullable<InstancedMesh[]>[];
  92678. renderSelf: boolean[];
  92679. hardwareInstancedRendering: boolean[];
  92680. }
  92681. /**
  92682. * Class used to represent renderable models
  92683. */
  92684. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  92685. /**
  92686. * Mesh side orientation : usually the external or front surface
  92687. */
  92688. static readonly FRONTSIDE: number;
  92689. /**
  92690. * Mesh side orientation : usually the internal or back surface
  92691. */
  92692. static readonly BACKSIDE: number;
  92693. /**
  92694. * Mesh side orientation : both internal and external or front and back surfaces
  92695. */
  92696. static readonly DOUBLESIDE: number;
  92697. /**
  92698. * Mesh side orientation : by default, `FRONTSIDE`
  92699. */
  92700. static readonly DEFAULTSIDE: number;
  92701. /**
  92702. * Mesh cap setting : no cap
  92703. */
  92704. static readonly NO_CAP: number;
  92705. /**
  92706. * Mesh cap setting : one cap at the beginning of the mesh
  92707. */
  92708. static readonly CAP_START: number;
  92709. /**
  92710. * Mesh cap setting : one cap at the end of the mesh
  92711. */
  92712. static readonly CAP_END: number;
  92713. /**
  92714. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92715. */
  92716. static readonly CAP_ALL: number;
  92717. /**
  92718. * Mesh pattern setting : no flip or rotate
  92719. */
  92720. static readonly NO_FLIP: number;
  92721. /**
  92722. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  92723. */
  92724. static readonly FLIP_TILE: number;
  92725. /**
  92726. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  92727. */
  92728. static readonly ROTATE_TILE: number;
  92729. /**
  92730. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  92731. */
  92732. static readonly FLIP_ROW: number;
  92733. /**
  92734. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  92735. */
  92736. static readonly ROTATE_ROW: number;
  92737. /**
  92738. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  92739. */
  92740. static readonly FLIP_N_ROTATE_TILE: number;
  92741. /**
  92742. * Mesh pattern setting : rotate pattern and rotate
  92743. */
  92744. static readonly FLIP_N_ROTATE_ROW: number;
  92745. /**
  92746. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92747. */
  92748. static readonly CENTER: number;
  92749. /**
  92750. * Mesh tile positioning : part tiles on left
  92751. */
  92752. static readonly LEFT: number;
  92753. /**
  92754. * Mesh tile positioning : part tiles on right
  92755. */
  92756. static readonly RIGHT: number;
  92757. /**
  92758. * Mesh tile positioning : part tiles on top
  92759. */
  92760. static readonly TOP: number;
  92761. /**
  92762. * Mesh tile positioning : part tiles on bottom
  92763. */
  92764. static readonly BOTTOM: number;
  92765. /**
  92766. * Gets the default side orientation.
  92767. * @param orientation the orientation to value to attempt to get
  92768. * @returns the default orientation
  92769. * @hidden
  92770. */
  92771. static _GetDefaultSideOrientation(orientation?: number): number;
  92772. private _internalMeshDataInfo;
  92773. /**
  92774. * An event triggered before rendering the mesh
  92775. */
  92776. readonly onBeforeRenderObservable: Observable<Mesh>;
  92777. /**
  92778. * An event triggered before binding the mesh
  92779. */
  92780. readonly onBeforeBindObservable: Observable<Mesh>;
  92781. /**
  92782. * An event triggered after rendering the mesh
  92783. */
  92784. readonly onAfterRenderObservable: Observable<Mesh>;
  92785. /**
  92786. * An event triggered before drawing the mesh
  92787. */
  92788. readonly onBeforeDrawObservable: Observable<Mesh>;
  92789. private _onBeforeDrawObserver;
  92790. /**
  92791. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92792. */
  92793. onBeforeDraw: () => void;
  92794. readonly hasInstances: boolean;
  92795. /**
  92796. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92797. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92798. */
  92799. delayLoadState: number;
  92800. /**
  92801. * Gets the list of instances created from this mesh
  92802. * it is not supposed to be modified manually.
  92803. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92804. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92805. */
  92806. instances: InstancedMesh[];
  92807. /**
  92808. * Gets the file containing delay loading data for this mesh
  92809. */
  92810. delayLoadingFile: string;
  92811. /** @hidden */
  92812. _binaryInfo: any;
  92813. /**
  92814. * User defined function used to change how LOD level selection is done
  92815. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92816. */
  92817. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92818. /**
  92819. * Gets or sets the morph target manager
  92820. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92821. */
  92822. morphTargetManager: Nullable<MorphTargetManager>;
  92823. /** @hidden */
  92824. _creationDataStorage: Nullable<_CreationDataStorage>;
  92825. /** @hidden */
  92826. _geometry: Nullable<Geometry>;
  92827. /** @hidden */
  92828. _delayInfo: Array<string>;
  92829. /** @hidden */
  92830. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92831. /** @hidden */
  92832. _instanceDataStorage: _InstanceDataStorage;
  92833. private _effectiveMaterial;
  92834. /** @hidden */
  92835. _shouldGenerateFlatShading: boolean;
  92836. /** @hidden */
  92837. _originalBuilderSideOrientation: number;
  92838. /**
  92839. * Use this property to change the original side orientation defined at construction time
  92840. */
  92841. overrideMaterialSideOrientation: Nullable<number>;
  92842. /**
  92843. * Gets the source mesh (the one used to clone this one from)
  92844. */
  92845. readonly source: Nullable<Mesh>;
  92846. /**
  92847. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92848. */
  92849. isUnIndexed: boolean;
  92850. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92851. readonly worldMatrixInstancedBuffer: Float32Array;
  92852. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92853. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92854. /**
  92855. * @constructor
  92856. * @param name The value used by scene.getMeshByName() to do a lookup.
  92857. * @param scene The scene to add this mesh to.
  92858. * @param parent The parent of this mesh, if it has one
  92859. * @param source An optional Mesh from which geometry is shared, cloned.
  92860. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92861. * When false, achieved by calling a clone(), also passing False.
  92862. * This will make creation of children, recursive.
  92863. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92864. */
  92865. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92866. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92867. doNotInstantiate: boolean;
  92868. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92869. /**
  92870. * Gets the class name
  92871. * @returns the string "Mesh".
  92872. */
  92873. getClassName(): string;
  92874. /** @hidden */
  92875. readonly _isMesh: boolean;
  92876. /**
  92877. * Returns a description of this mesh
  92878. * @param fullDetails define if full details about this mesh must be used
  92879. * @returns a descriptive string representing this mesh
  92880. */
  92881. toString(fullDetails?: boolean): string;
  92882. /** @hidden */
  92883. _unBindEffect(): void;
  92884. /**
  92885. * Gets a boolean indicating if this mesh has LOD
  92886. */
  92887. readonly hasLODLevels: boolean;
  92888. /**
  92889. * Gets the list of MeshLODLevel associated with the current mesh
  92890. * @returns an array of MeshLODLevel
  92891. */
  92892. getLODLevels(): MeshLODLevel[];
  92893. private _sortLODLevels;
  92894. /**
  92895. * Add a mesh as LOD level triggered at the given distance.
  92896. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92897. * @param distance The distance from the center of the object to show this level
  92898. * @param mesh The mesh to be added as LOD level (can be null)
  92899. * @return This mesh (for chaining)
  92900. */
  92901. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92902. /**
  92903. * Returns the LOD level mesh at the passed distance or null if not found.
  92904. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92905. * @param distance The distance from the center of the object to show this level
  92906. * @returns a Mesh or `null`
  92907. */
  92908. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92909. /**
  92910. * Remove a mesh from the LOD array
  92911. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92912. * @param mesh defines the mesh to be removed
  92913. * @return This mesh (for chaining)
  92914. */
  92915. removeLODLevel(mesh: Mesh): Mesh;
  92916. /**
  92917. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92918. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92919. * @param camera defines the camera to use to compute distance
  92920. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92921. * @return This mesh (for chaining)
  92922. */
  92923. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92924. /**
  92925. * Gets the mesh internal Geometry object
  92926. */
  92927. readonly geometry: Nullable<Geometry>;
  92928. /**
  92929. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  92930. * @returns the total number of vertices
  92931. */
  92932. getTotalVertices(): number;
  92933. /**
  92934. * Returns the content of an associated vertex buffer
  92935. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92936. * - VertexBuffer.PositionKind
  92937. * - VertexBuffer.UVKind
  92938. * - VertexBuffer.UV2Kind
  92939. * - VertexBuffer.UV3Kind
  92940. * - VertexBuffer.UV4Kind
  92941. * - VertexBuffer.UV5Kind
  92942. * - VertexBuffer.UV6Kind
  92943. * - VertexBuffer.ColorKind
  92944. * - VertexBuffer.MatricesIndicesKind
  92945. * - VertexBuffer.MatricesIndicesExtraKind
  92946. * - VertexBuffer.MatricesWeightsKind
  92947. * - VertexBuffer.MatricesWeightsExtraKind
  92948. * @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
  92949. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  92950. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  92951. */
  92952. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92953. /**
  92954. * Returns the mesh VertexBuffer object from the requested `kind`
  92955. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92956. * - VertexBuffer.PositionKind
  92957. * - VertexBuffer.NormalKind
  92958. * - VertexBuffer.UVKind
  92959. * - VertexBuffer.UV2Kind
  92960. * - VertexBuffer.UV3Kind
  92961. * - VertexBuffer.UV4Kind
  92962. * - VertexBuffer.UV5Kind
  92963. * - VertexBuffer.UV6Kind
  92964. * - VertexBuffer.ColorKind
  92965. * - VertexBuffer.MatricesIndicesKind
  92966. * - VertexBuffer.MatricesIndicesExtraKind
  92967. * - VertexBuffer.MatricesWeightsKind
  92968. * - VertexBuffer.MatricesWeightsExtraKind
  92969. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  92970. */
  92971. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92972. /**
  92973. * Tests if a specific vertex buffer is associated with this mesh
  92974. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92975. * - VertexBuffer.PositionKind
  92976. * - VertexBuffer.NormalKind
  92977. * - VertexBuffer.UVKind
  92978. * - VertexBuffer.UV2Kind
  92979. * - VertexBuffer.UV3Kind
  92980. * - VertexBuffer.UV4Kind
  92981. * - VertexBuffer.UV5Kind
  92982. * - VertexBuffer.UV6Kind
  92983. * - VertexBuffer.ColorKind
  92984. * - VertexBuffer.MatricesIndicesKind
  92985. * - VertexBuffer.MatricesIndicesExtraKind
  92986. * - VertexBuffer.MatricesWeightsKind
  92987. * - VertexBuffer.MatricesWeightsExtraKind
  92988. * @returns a boolean
  92989. */
  92990. isVerticesDataPresent(kind: string): boolean;
  92991. /**
  92992. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92993. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92994. * - VertexBuffer.PositionKind
  92995. * - VertexBuffer.UVKind
  92996. * - VertexBuffer.UV2Kind
  92997. * - VertexBuffer.UV3Kind
  92998. * - VertexBuffer.UV4Kind
  92999. * - VertexBuffer.UV5Kind
  93000. * - VertexBuffer.UV6Kind
  93001. * - VertexBuffer.ColorKind
  93002. * - VertexBuffer.MatricesIndicesKind
  93003. * - VertexBuffer.MatricesIndicesExtraKind
  93004. * - VertexBuffer.MatricesWeightsKind
  93005. * - VertexBuffer.MatricesWeightsExtraKind
  93006. * @returns a boolean
  93007. */
  93008. isVertexBufferUpdatable(kind: string): boolean;
  93009. /**
  93010. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  93011. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93012. * - VertexBuffer.PositionKind
  93013. * - VertexBuffer.NormalKind
  93014. * - VertexBuffer.UVKind
  93015. * - VertexBuffer.UV2Kind
  93016. * - VertexBuffer.UV3Kind
  93017. * - VertexBuffer.UV4Kind
  93018. * - VertexBuffer.UV5Kind
  93019. * - VertexBuffer.UV6Kind
  93020. * - VertexBuffer.ColorKind
  93021. * - VertexBuffer.MatricesIndicesKind
  93022. * - VertexBuffer.MatricesIndicesExtraKind
  93023. * - VertexBuffer.MatricesWeightsKind
  93024. * - VertexBuffer.MatricesWeightsExtraKind
  93025. * @returns an array of strings
  93026. */
  93027. getVerticesDataKinds(): string[];
  93028. /**
  93029. * Returns a positive integer : the total number of indices in this mesh geometry.
  93030. * @returns the numner of indices or zero if the mesh has no geometry.
  93031. */
  93032. getTotalIndices(): number;
  93033. /**
  93034. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93035. * @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.
  93036. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93037. * @returns the indices array or an empty array if the mesh has no geometry
  93038. */
  93039. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93040. readonly isBlocked: boolean;
  93041. /**
  93042. * Determine if the current mesh is ready to be rendered
  93043. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93044. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  93045. * @returns true if all associated assets are ready (material, textures, shaders)
  93046. */
  93047. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  93048. /**
  93049. * 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.
  93050. */
  93051. readonly areNormalsFrozen: boolean;
  93052. /**
  93053. * 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.
  93054. * @returns the current mesh
  93055. */
  93056. freezeNormals(): Mesh;
  93057. /**
  93058. * 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
  93059. * @returns the current mesh
  93060. */
  93061. unfreezeNormals(): Mesh;
  93062. /**
  93063. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  93064. */
  93065. overridenInstanceCount: number;
  93066. /** @hidden */
  93067. _preActivate(): Mesh;
  93068. /** @hidden */
  93069. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93070. /** @hidden */
  93071. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  93072. /**
  93073. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93074. * This means the mesh underlying bounding box and sphere are recomputed.
  93075. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93076. * @returns the current mesh
  93077. */
  93078. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  93079. /** @hidden */
  93080. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  93081. /**
  93082. * This function will subdivide the mesh into multiple submeshes
  93083. * @param count defines the expected number of submeshes
  93084. */
  93085. subdivide(count: number): void;
  93086. /**
  93087. * Copy a FloatArray into a specific associated vertex buffer
  93088. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93089. * - VertexBuffer.PositionKind
  93090. * - VertexBuffer.UVKind
  93091. * - VertexBuffer.UV2Kind
  93092. * - VertexBuffer.UV3Kind
  93093. * - VertexBuffer.UV4Kind
  93094. * - VertexBuffer.UV5Kind
  93095. * - VertexBuffer.UV6Kind
  93096. * - VertexBuffer.ColorKind
  93097. * - VertexBuffer.MatricesIndicesKind
  93098. * - VertexBuffer.MatricesIndicesExtraKind
  93099. * - VertexBuffer.MatricesWeightsKind
  93100. * - VertexBuffer.MatricesWeightsExtraKind
  93101. * @param data defines the data source
  93102. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93103. * @param stride defines the data stride size (can be null)
  93104. * @returns the current mesh
  93105. */
  93106. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93107. /**
  93108. * Delete a vertex buffer associated with this mesh
  93109. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  93110. * - VertexBuffer.PositionKind
  93111. * - VertexBuffer.UVKind
  93112. * - VertexBuffer.UV2Kind
  93113. * - VertexBuffer.UV3Kind
  93114. * - VertexBuffer.UV4Kind
  93115. * - VertexBuffer.UV5Kind
  93116. * - VertexBuffer.UV6Kind
  93117. * - VertexBuffer.ColorKind
  93118. * - VertexBuffer.MatricesIndicesKind
  93119. * - VertexBuffer.MatricesIndicesExtraKind
  93120. * - VertexBuffer.MatricesWeightsKind
  93121. * - VertexBuffer.MatricesWeightsExtraKind
  93122. */
  93123. removeVerticesData(kind: string): void;
  93124. /**
  93125. * Flags an associated vertex buffer as updatable
  93126. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  93127. * - VertexBuffer.PositionKind
  93128. * - VertexBuffer.UVKind
  93129. * - VertexBuffer.UV2Kind
  93130. * - VertexBuffer.UV3Kind
  93131. * - VertexBuffer.UV4Kind
  93132. * - VertexBuffer.UV5Kind
  93133. * - VertexBuffer.UV6Kind
  93134. * - VertexBuffer.ColorKind
  93135. * - VertexBuffer.MatricesIndicesKind
  93136. * - VertexBuffer.MatricesIndicesExtraKind
  93137. * - VertexBuffer.MatricesWeightsKind
  93138. * - VertexBuffer.MatricesWeightsExtraKind
  93139. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93140. */
  93141. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  93142. /**
  93143. * Sets the mesh global Vertex Buffer
  93144. * @param buffer defines the buffer to use
  93145. * @returns the current mesh
  93146. */
  93147. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  93148. /**
  93149. * Update a specific associated vertex buffer
  93150. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93151. * - VertexBuffer.PositionKind
  93152. * - VertexBuffer.UVKind
  93153. * - VertexBuffer.UV2Kind
  93154. * - VertexBuffer.UV3Kind
  93155. * - VertexBuffer.UV4Kind
  93156. * - VertexBuffer.UV5Kind
  93157. * - VertexBuffer.UV6Kind
  93158. * - VertexBuffer.ColorKind
  93159. * - VertexBuffer.MatricesIndicesKind
  93160. * - VertexBuffer.MatricesIndicesExtraKind
  93161. * - VertexBuffer.MatricesWeightsKind
  93162. * - VertexBuffer.MatricesWeightsExtraKind
  93163. * @param data defines the data source
  93164. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93165. * @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)
  93166. * @returns the current mesh
  93167. */
  93168. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93169. /**
  93170. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  93171. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  93172. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  93173. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  93174. * @returns the current mesh
  93175. */
  93176. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  93177. /**
  93178. * Creates a un-shared specific occurence of the geometry for the mesh.
  93179. * @returns the current mesh
  93180. */
  93181. makeGeometryUnique(): Mesh;
  93182. /**
  93183. * Set the index buffer of this mesh
  93184. * @param indices defines the source data
  93185. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  93186. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  93187. * @returns the current mesh
  93188. */
  93189. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  93190. /**
  93191. * Update the current index buffer
  93192. * @param indices defines the source data
  93193. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93194. * @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)
  93195. * @returns the current mesh
  93196. */
  93197. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93198. /**
  93199. * Invert the geometry to move from a right handed system to a left handed one.
  93200. * @returns the current mesh
  93201. */
  93202. toLeftHanded(): Mesh;
  93203. /** @hidden */
  93204. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93205. /** @hidden */
  93206. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93207. /**
  93208. * Registers for this mesh a javascript function called just before the rendering process
  93209. * @param func defines the function to call before rendering this mesh
  93210. * @returns the current mesh
  93211. */
  93212. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93213. /**
  93214. * Disposes a previously registered javascript function called before the rendering
  93215. * @param func defines the function to remove
  93216. * @returns the current mesh
  93217. */
  93218. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93219. /**
  93220. * Registers for this mesh a javascript function called just after the rendering is complete
  93221. * @param func defines the function to call after rendering this mesh
  93222. * @returns the current mesh
  93223. */
  93224. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93225. /**
  93226. * Disposes a previously registered javascript function called after the rendering.
  93227. * @param func defines the function to remove
  93228. * @returns the current mesh
  93229. */
  93230. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93231. /** @hidden */
  93232. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  93233. /** @hidden */
  93234. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  93235. /** @hidden */
  93236. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  93237. /** @hidden */
  93238. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  93239. /** @hidden */
  93240. _rebuild(): void;
  93241. /** @hidden */
  93242. _freeze(): void;
  93243. /** @hidden */
  93244. _unFreeze(): void;
  93245. /**
  93246. * 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
  93247. * @param subMesh defines the subMesh to render
  93248. * @param enableAlphaMode defines if alpha mode can be changed
  93249. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  93250. * @returns the current mesh
  93251. */
  93252. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  93253. private _onBeforeDraw;
  93254. /**
  93255. * Renormalize the mesh and patch it up if there are no weights
  93256. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  93257. * However in the case of zero weights then we set just a single influence to 1.
  93258. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  93259. */
  93260. cleanMatrixWeights(): void;
  93261. private normalizeSkinFourWeights;
  93262. private normalizeSkinWeightsAndExtra;
  93263. /**
  93264. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  93265. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  93266. * the user know there was an issue with importing the mesh
  93267. * @returns a validation object with skinned, valid and report string
  93268. */
  93269. validateSkinning(): {
  93270. skinned: boolean;
  93271. valid: boolean;
  93272. report: string;
  93273. };
  93274. /** @hidden */
  93275. _checkDelayState(): Mesh;
  93276. private _queueLoad;
  93277. /**
  93278. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93279. * A mesh is in the frustum if its bounding box intersects the frustum
  93280. * @param frustumPlanes defines the frustum to test
  93281. * @returns true if the mesh is in the frustum planes
  93282. */
  93283. isInFrustum(frustumPlanes: Plane[]): boolean;
  93284. /**
  93285. * Sets the mesh material by the material or multiMaterial `id` property
  93286. * @param id is a string identifying the material or the multiMaterial
  93287. * @returns the current mesh
  93288. */
  93289. setMaterialByID(id: string): Mesh;
  93290. /**
  93291. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  93292. * @returns an array of IAnimatable
  93293. */
  93294. getAnimatables(): IAnimatable[];
  93295. /**
  93296. * Modifies the mesh geometry according to the passed transformation matrix.
  93297. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  93298. * The mesh normals are modified using the same transformation.
  93299. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93300. * @param transform defines the transform matrix to use
  93301. * @see http://doc.babylonjs.com/resources/baking_transformations
  93302. * @returns the current mesh
  93303. */
  93304. bakeTransformIntoVertices(transform: Matrix): Mesh;
  93305. /**
  93306. * Modifies the mesh geometry according to its own current World Matrix.
  93307. * The mesh World Matrix is then reset.
  93308. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  93309. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93310. * @see http://doc.babylonjs.com/resources/baking_transformations
  93311. * @returns the current mesh
  93312. */
  93313. bakeCurrentTransformIntoVertices(): Mesh;
  93314. /** @hidden */
  93315. readonly _positions: Nullable<Vector3[]>;
  93316. /** @hidden */
  93317. _resetPointsArrayCache(): Mesh;
  93318. /** @hidden */
  93319. _generatePointsArray(): boolean;
  93320. /**
  93321. * Returns a new Mesh object generated from the current mesh properties.
  93322. * This method must not get confused with createInstance()
  93323. * @param name is a string, the name given to the new mesh
  93324. * @param newParent can be any Node object (default `null`)
  93325. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  93326. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  93327. * @returns a new mesh
  93328. */
  93329. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  93330. /**
  93331. * Releases resources associated with this mesh.
  93332. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93333. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93334. */
  93335. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93336. /** @hidden */
  93337. _disposeInstanceSpecificData(): void;
  93338. /**
  93339. * Modifies the mesh geometry according to a displacement map.
  93340. * 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.
  93341. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93342. * @param url is a string, the URL from the image file is to be downloaded.
  93343. * @param minHeight is the lower limit of the displacement.
  93344. * @param maxHeight is the upper limit of the displacement.
  93345. * @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.
  93346. * @param uvOffset is an optional vector2 used to offset UV.
  93347. * @param uvScale is an optional vector2 used to scale UV.
  93348. * @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.
  93349. * @returns the Mesh.
  93350. */
  93351. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93352. /**
  93353. * Modifies the mesh geometry according to a displacementMap buffer.
  93354. * 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.
  93355. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93356. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  93357. * @param heightMapWidth is the width of the buffer image.
  93358. * @param heightMapHeight is the height of the buffer image.
  93359. * @param minHeight is the lower limit of the displacement.
  93360. * @param maxHeight is the upper limit of the displacement.
  93361. * @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.
  93362. * @param uvOffset is an optional vector2 used to offset UV.
  93363. * @param uvScale is an optional vector2 used to scale UV.
  93364. * @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.
  93365. * @returns the Mesh.
  93366. */
  93367. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93368. /**
  93369. * Modify the mesh to get a flat shading rendering.
  93370. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  93371. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  93372. * @returns current mesh
  93373. */
  93374. convertToFlatShadedMesh(): Mesh;
  93375. /**
  93376. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  93377. * In other words, more vertices, no more indices and a single bigger VBO.
  93378. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  93379. * @returns current mesh
  93380. */
  93381. convertToUnIndexedMesh(): Mesh;
  93382. /**
  93383. * Inverses facet orientations.
  93384. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93385. * @param flipNormals will also inverts the normals
  93386. * @returns current mesh
  93387. */
  93388. flipFaces(flipNormals?: boolean): Mesh;
  93389. /**
  93390. * Increase the number of facets and hence vertices in a mesh
  93391. * Vertex normals are interpolated from existing vertex normals
  93392. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93393. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  93394. */
  93395. increaseVertices(numberPerEdge: number): void;
  93396. /**
  93397. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  93398. * This will undo any application of covertToFlatShadedMesh
  93399. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93400. */
  93401. forceSharedVertices(): void;
  93402. /** @hidden */
  93403. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  93404. /** @hidden */
  93405. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  93406. /**
  93407. * Creates a new InstancedMesh object from the mesh model.
  93408. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93409. * @param name defines the name of the new instance
  93410. * @returns a new InstancedMesh
  93411. */
  93412. createInstance(name: string): InstancedMesh;
  93413. /**
  93414. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  93415. * After this call, all the mesh instances have the same submeshes than the current mesh.
  93416. * @returns the current mesh
  93417. */
  93418. synchronizeInstances(): Mesh;
  93419. /**
  93420. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  93421. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  93422. * This should be used together with the simplification to avoid disappearing triangles.
  93423. * @param successCallback an optional success callback to be called after the optimization finished.
  93424. * @returns the current mesh
  93425. */
  93426. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  93427. /**
  93428. * Serialize current mesh
  93429. * @param serializationObject defines the object which will receive the serialization data
  93430. */
  93431. serialize(serializationObject: any): void;
  93432. /** @hidden */
  93433. _syncGeometryWithMorphTargetManager(): void;
  93434. /** @hidden */
  93435. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  93436. /**
  93437. * Returns a new Mesh object parsed from the source provided.
  93438. * @param parsedMesh is the source
  93439. * @param scene defines the hosting scene
  93440. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  93441. * @returns a new Mesh
  93442. */
  93443. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  93444. /**
  93445. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  93446. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93447. * @param name defines the name of the mesh to create
  93448. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  93449. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  93450. * @param closePath creates a seam between the first and the last points of each path of the path array
  93451. * @param offset is taken in account only if the `pathArray` is containing a single path
  93452. * @param scene defines the hosting scene
  93453. * @param updatable defines if the mesh must be flagged as updatable
  93454. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93455. * @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)
  93456. * @returns a new Mesh
  93457. */
  93458. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93459. /**
  93460. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  93461. * @param name defines the name of the mesh to create
  93462. * @param radius sets the radius size (float) of the polygon (default 0.5)
  93463. * @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
  93464. * @param scene defines the hosting scene
  93465. * @param updatable defines if the mesh must be flagged as updatable
  93466. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93467. * @returns a new Mesh
  93468. */
  93469. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93470. /**
  93471. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  93472. * @param name defines the name of the mesh to create
  93473. * @param size sets the size (float) of each box side (default 1)
  93474. * @param scene defines the hosting scene
  93475. * @param updatable defines if the mesh must be flagged as updatable
  93476. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93477. * @returns a new Mesh
  93478. */
  93479. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93480. /**
  93481. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  93482. * @param name defines the name of the mesh to create
  93483. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93484. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93485. * @param scene defines the hosting scene
  93486. * @param updatable defines if the mesh must be flagged as updatable
  93487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93488. * @returns a new Mesh
  93489. */
  93490. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93491. /**
  93492. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  93493. * @param name defines the name of the mesh to create
  93494. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93495. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93496. * @param scene defines the hosting scene
  93497. * @returns a new Mesh
  93498. */
  93499. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  93500. /**
  93501. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  93502. * @param name defines the name of the mesh to create
  93503. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  93504. * @param diameterTop set the top cap diameter (floats, default 1)
  93505. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  93506. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  93507. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  93508. * @param scene defines the hosting scene
  93509. * @param updatable defines if the mesh must be flagged as updatable
  93510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93511. * @returns a new Mesh
  93512. */
  93513. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  93514. /**
  93515. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  93516. * @param name defines the name of the mesh to create
  93517. * @param diameter sets the diameter size (float) of the torus (default 1)
  93518. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  93519. * @param tessellation sets the number of torus sides (postive integer, default 16)
  93520. * @param scene defines the hosting scene
  93521. * @param updatable defines if the mesh must be flagged as updatable
  93522. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93523. * @returns a new Mesh
  93524. */
  93525. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93526. /**
  93527. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  93528. * @param name defines the name of the mesh to create
  93529. * @param radius sets the global radius size (float) of the torus knot (default 2)
  93530. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  93531. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  93532. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  93533. * @param p the number of windings on X axis (positive integers, default 2)
  93534. * @param q the number of windings on Y axis (positive integers, default 3)
  93535. * @param scene defines the hosting scene
  93536. * @param updatable defines if the mesh must be flagged as updatable
  93537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93538. * @returns a new Mesh
  93539. */
  93540. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93541. /**
  93542. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  93543. * @param name defines the name of the mesh to create
  93544. * @param points is an array successive Vector3
  93545. * @param scene defines the hosting scene
  93546. * @param updatable defines if the mesh must be flagged as updatable
  93547. * @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).
  93548. * @returns a new Mesh
  93549. */
  93550. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  93551. /**
  93552. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  93553. * @param name defines the name of the mesh to create
  93554. * @param points is an array successive Vector3
  93555. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  93556. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  93557. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  93558. * @param scene defines the hosting scene
  93559. * @param updatable defines if the mesh must be flagged as updatable
  93560. * @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)
  93561. * @returns a new Mesh
  93562. */
  93563. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  93564. /**
  93565. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  93566. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  93567. * 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.
  93568. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93569. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  93570. * Remember you can only change the shape positions, not their number when updating a polygon.
  93571. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93572. * @param name defines the name of the mesh to create
  93573. * @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
  93574. * @param scene defines the hosting scene
  93575. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93576. * @param updatable defines if the mesh must be flagged as updatable
  93577. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93578. * @param earcutInjection can be used to inject your own earcut reference
  93579. * @returns a new Mesh
  93580. */
  93581. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93582. /**
  93583. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  93584. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  93585. * @param name defines the name of the mesh to create
  93586. * @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
  93587. * @param depth defines the height of extrusion
  93588. * @param scene defines the hosting scene
  93589. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93590. * @param updatable defines if the mesh must be flagged as updatable
  93591. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93592. * @param earcutInjection can be used to inject your own earcut reference
  93593. * @returns a new Mesh
  93594. */
  93595. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93596. /**
  93597. * Creates an extruded shape mesh.
  93598. * 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
  93599. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93600. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93601. * @param name defines the name of the mesh to create
  93602. * @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
  93603. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93604. * @param scale is the value to scale the shape
  93605. * @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
  93606. * @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
  93607. * @param scene defines the hosting scene
  93608. * @param updatable defines if the mesh must be flagged as updatable
  93609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93610. * @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)
  93611. * @returns a new Mesh
  93612. */
  93613. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93614. /**
  93615. * Creates an custom extruded shape mesh.
  93616. * The custom extrusion is a parametric shape.
  93617. * It has no predefined shape. Its final shape will depend on the input parameters.
  93618. * Please consider using the same method from the MeshBuilder class instead
  93619. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93620. * @param name defines the name of the mesh to create
  93621. * @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
  93622. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93623. * @param scaleFunction is a custom Javascript function called on each path point
  93624. * @param rotationFunction is a custom Javascript function called on each path point
  93625. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  93626. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  93627. * @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
  93628. * @param scene defines the hosting scene
  93629. * @param updatable defines if the mesh must be flagged as updatable
  93630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93631. * @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)
  93632. * @returns a new Mesh
  93633. */
  93634. 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;
  93635. /**
  93636. * Creates lathe mesh.
  93637. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  93638. * Please consider using the same method from the MeshBuilder class instead
  93639. * @param name defines the name of the mesh to create
  93640. * @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
  93641. * @param radius is the radius value of the lathe
  93642. * @param tessellation is the side number of the lathe.
  93643. * @param scene defines the hosting scene
  93644. * @param updatable defines if the mesh must be flagged as updatable
  93645. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93646. * @returns a new Mesh
  93647. */
  93648. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93649. /**
  93650. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  93651. * @param name defines the name of the mesh to create
  93652. * @param size sets the size (float) of both sides of the plane at once (default 1)
  93653. * @param scene defines the hosting scene
  93654. * @param updatable defines if the mesh must be flagged as updatable
  93655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93656. * @returns a new Mesh
  93657. */
  93658. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93659. /**
  93660. * Creates a ground mesh.
  93661. * Please consider using the same method from the MeshBuilder class instead
  93662. * @param name defines the name of the mesh to create
  93663. * @param width set the width of the ground
  93664. * @param height set the height of the ground
  93665. * @param subdivisions sets the number of subdivisions per side
  93666. * @param scene defines the hosting scene
  93667. * @param updatable defines if the mesh must be flagged as updatable
  93668. * @returns a new Mesh
  93669. */
  93670. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  93671. /**
  93672. * Creates a tiled ground mesh.
  93673. * Please consider using the same method from the MeshBuilder class instead
  93674. * @param name defines the name of the mesh to create
  93675. * @param xmin set the ground minimum X coordinate
  93676. * @param zmin set the ground minimum Y coordinate
  93677. * @param xmax set the ground maximum X coordinate
  93678. * @param zmax set the ground maximum Z coordinate
  93679. * @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
  93680. * @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
  93681. * @param scene defines the hosting scene
  93682. * @param updatable defines if the mesh must be flagged as updatable
  93683. * @returns a new Mesh
  93684. */
  93685. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  93686. w: number;
  93687. h: number;
  93688. }, precision: {
  93689. w: number;
  93690. h: number;
  93691. }, scene: Scene, updatable?: boolean): Mesh;
  93692. /**
  93693. * Creates a ground mesh from a height map.
  93694. * Please consider using the same method from the MeshBuilder class instead
  93695. * @see http://doc.babylonjs.com/babylon101/height_map
  93696. * @param name defines the name of the mesh to create
  93697. * @param url sets the URL of the height map image resource
  93698. * @param width set the ground width size
  93699. * @param height set the ground height size
  93700. * @param subdivisions sets the number of subdivision per side
  93701. * @param minHeight is the minimum altitude on the ground
  93702. * @param maxHeight is the maximum altitude on the ground
  93703. * @param scene defines the hosting scene
  93704. * @param updatable defines if the mesh must be flagged as updatable
  93705. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  93706. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  93707. * @returns a new Mesh
  93708. */
  93709. 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;
  93710. /**
  93711. * Creates a tube mesh.
  93712. * The tube is a parametric shape.
  93713. * It has no predefined shape. Its final shape will depend on the input parameters.
  93714. * Please consider using the same method from the MeshBuilder class instead
  93715. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93716. * @param name defines the name of the mesh to create
  93717. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  93718. * @param radius sets the tube radius size
  93719. * @param tessellation is the number of sides on the tubular surface
  93720. * @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
  93721. * @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
  93722. * @param scene defines the hosting scene
  93723. * @param updatable defines if the mesh must be flagged as updatable
  93724. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93725. * @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)
  93726. * @returns a new Mesh
  93727. */
  93728. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  93729. (i: number, distance: number): number;
  93730. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93731. /**
  93732. * Creates a polyhedron mesh.
  93733. * Please consider using the same method from the MeshBuilder class instead.
  93734. * * 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
  93735. * * The parameter `size` (positive float, default 1) sets the polygon size
  93736. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  93737. * * 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`
  93738. * * 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
  93739. * * 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)`)
  93740. * * 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
  93741. * * 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
  93742. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93743. * * If you create a double-sided mesh, you can choose what parts of 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
  93744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93745. * @param name defines the name of the mesh to create
  93746. * @param options defines the options used to create the mesh
  93747. * @param scene defines the hosting scene
  93748. * @returns a new Mesh
  93749. */
  93750. static CreatePolyhedron(name: string, options: {
  93751. type?: number;
  93752. size?: number;
  93753. sizeX?: number;
  93754. sizeY?: number;
  93755. sizeZ?: number;
  93756. custom?: any;
  93757. faceUV?: Vector4[];
  93758. faceColors?: Color4[];
  93759. updatable?: boolean;
  93760. sideOrientation?: number;
  93761. }, scene: Scene): Mesh;
  93762. /**
  93763. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93764. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93765. * * 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`)
  93766. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93767. * * 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
  93768. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93769. * * If you create a double-sided mesh, you can choose what parts of 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
  93770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93771. * @param name defines the name of the mesh
  93772. * @param options defines the options used to create the mesh
  93773. * @param scene defines the hosting scene
  93774. * @returns a new Mesh
  93775. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93776. */
  93777. static CreateIcoSphere(name: string, options: {
  93778. radius?: number;
  93779. flat?: boolean;
  93780. subdivisions?: number;
  93781. sideOrientation?: number;
  93782. updatable?: boolean;
  93783. }, scene: Scene): Mesh;
  93784. /**
  93785. * Creates a decal mesh.
  93786. * Please consider using the same method from the MeshBuilder class instead.
  93787. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93788. * @param name defines the name of the mesh
  93789. * @param sourceMesh defines the mesh receiving the decal
  93790. * @param position sets the position of the decal in world coordinates
  93791. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93792. * @param size sets the decal scaling
  93793. * @param angle sets the angle to rotate the decal
  93794. * @returns a new Mesh
  93795. */
  93796. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93797. /**
  93798. * Prepare internal position array for software CPU skinning
  93799. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93800. */
  93801. setPositionsForCPUSkinning(): Float32Array;
  93802. /**
  93803. * Prepare internal normal array for software CPU skinning
  93804. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93805. */
  93806. setNormalsForCPUSkinning(): Float32Array;
  93807. /**
  93808. * Updates the vertex buffer by applying transformation from the bones
  93809. * @param skeleton defines the skeleton to apply to current mesh
  93810. * @returns the current mesh
  93811. */
  93812. applySkeleton(skeleton: Skeleton): Mesh;
  93813. /**
  93814. * 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
  93815. * @param meshes defines the list of meshes to scan
  93816. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93817. */
  93818. static MinMax(meshes: AbstractMesh[]): {
  93819. min: Vector3;
  93820. max: Vector3;
  93821. };
  93822. /**
  93823. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93824. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93825. * @returns a vector3
  93826. */
  93827. static Center(meshesOrMinMaxVector: {
  93828. min: Vector3;
  93829. max: Vector3;
  93830. } | AbstractMesh[]): Vector3;
  93831. /**
  93832. * Merge the array of meshes into a single mesh for performance reasons.
  93833. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93834. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93835. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93836. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93837. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93838. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93839. * @returns a new mesh
  93840. */
  93841. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93842. /** @hidden */
  93843. addInstance(instance: InstancedMesh): void;
  93844. /** @hidden */
  93845. removeInstance(instance: InstancedMesh): void;
  93846. }
  93847. }
  93848. declare module BABYLON {
  93849. /**
  93850. * This is the base class of all the camera used in the application.
  93851. * @see http://doc.babylonjs.com/features/cameras
  93852. */
  93853. export class Camera extends Node {
  93854. /** @hidden */
  93855. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93856. /**
  93857. * This is the default projection mode used by the cameras.
  93858. * It helps recreating a feeling of perspective and better appreciate depth.
  93859. * This is the best way to simulate real life cameras.
  93860. */
  93861. static readonly PERSPECTIVE_CAMERA: number;
  93862. /**
  93863. * This helps creating camera with an orthographic mode.
  93864. * 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.
  93865. */
  93866. static readonly ORTHOGRAPHIC_CAMERA: number;
  93867. /**
  93868. * This is the default FOV mode for perspective cameras.
  93869. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93870. */
  93871. static readonly FOVMODE_VERTICAL_FIXED: number;
  93872. /**
  93873. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93874. */
  93875. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93876. /**
  93877. * This specifies ther is no need for a camera rig.
  93878. * Basically only one eye is rendered corresponding to the camera.
  93879. */
  93880. static readonly RIG_MODE_NONE: number;
  93881. /**
  93882. * Simulates a camera Rig with one blue eye and one red eye.
  93883. * This can be use with 3d blue and red glasses.
  93884. */
  93885. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93886. /**
  93887. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93888. */
  93889. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93890. /**
  93891. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93892. */
  93893. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93894. /**
  93895. * Defines that both eyes of the camera will be rendered over under each other.
  93896. */
  93897. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93898. /**
  93899. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93900. */
  93901. static readonly RIG_MODE_VR: number;
  93902. /**
  93903. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93904. */
  93905. static readonly RIG_MODE_WEBVR: number;
  93906. /**
  93907. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93908. */
  93909. static readonly RIG_MODE_CUSTOM: number;
  93910. /**
  93911. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93912. */
  93913. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93914. /**
  93915. * Define the input manager associated with the camera.
  93916. */
  93917. inputs: CameraInputsManager<Camera>;
  93918. /** @hidden */
  93919. _position: Vector3;
  93920. /**
  93921. * Define the current local position of the camera in the scene
  93922. */
  93923. position: Vector3;
  93924. /**
  93925. * The vector the camera should consider as up.
  93926. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93927. */
  93928. upVector: Vector3;
  93929. /**
  93930. * Define the current limit on the left side for an orthographic camera
  93931. * In scene unit
  93932. */
  93933. orthoLeft: Nullable<number>;
  93934. /**
  93935. * Define the current limit on the right side for an orthographic camera
  93936. * In scene unit
  93937. */
  93938. orthoRight: Nullable<number>;
  93939. /**
  93940. * Define the current limit on the bottom side for an orthographic camera
  93941. * In scene unit
  93942. */
  93943. orthoBottom: Nullable<number>;
  93944. /**
  93945. * Define the current limit on the top side for an orthographic camera
  93946. * In scene unit
  93947. */
  93948. orthoTop: Nullable<number>;
  93949. /**
  93950. * Field Of View is set in Radians. (default is 0.8)
  93951. */
  93952. fov: number;
  93953. /**
  93954. * Define the minimum distance the camera can see from.
  93955. * This is important to note that the depth buffer are not infinite and the closer it starts
  93956. * the more your scene might encounter depth fighting issue.
  93957. */
  93958. minZ: number;
  93959. /**
  93960. * Define the maximum distance the camera can see to.
  93961. * This is important to note that the depth buffer are not infinite and the further it end
  93962. * the more your scene might encounter depth fighting issue.
  93963. */
  93964. maxZ: number;
  93965. /**
  93966. * Define the default inertia of the camera.
  93967. * This helps giving a smooth feeling to the camera movement.
  93968. */
  93969. inertia: number;
  93970. /**
  93971. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93972. */
  93973. mode: number;
  93974. /**
  93975. * Define wether the camera is intermediate.
  93976. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93977. */
  93978. isIntermediate: boolean;
  93979. /**
  93980. * Define the viewport of the camera.
  93981. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93982. */
  93983. viewport: Viewport;
  93984. /**
  93985. * Restricts the camera to viewing objects with the same layerMask.
  93986. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93987. */
  93988. layerMask: number;
  93989. /**
  93990. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93991. */
  93992. fovMode: number;
  93993. /**
  93994. * Rig mode of the camera.
  93995. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93996. * This is normally controlled byt the camera themselves as internal use.
  93997. */
  93998. cameraRigMode: number;
  93999. /**
  94000. * Defines the distance between both "eyes" in case of a RIG
  94001. */
  94002. interaxialDistance: number;
  94003. /**
  94004. * Defines if stereoscopic rendering is done side by side or over under.
  94005. */
  94006. isStereoscopicSideBySide: boolean;
  94007. /**
  94008. * 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
  94009. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  94010. * else in the scene. (Eg. security camera)
  94011. *
  94012. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  94013. */
  94014. customRenderTargets: RenderTargetTexture[];
  94015. /**
  94016. * When set, the camera will render to this render target instead of the default canvas
  94017. *
  94018. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  94019. */
  94020. outputRenderTarget: Nullable<RenderTargetTexture>;
  94021. /**
  94022. * Observable triggered when the camera view matrix has changed.
  94023. */
  94024. onViewMatrixChangedObservable: Observable<Camera>;
  94025. /**
  94026. * Observable triggered when the camera Projection matrix has changed.
  94027. */
  94028. onProjectionMatrixChangedObservable: Observable<Camera>;
  94029. /**
  94030. * Observable triggered when the inputs have been processed.
  94031. */
  94032. onAfterCheckInputsObservable: Observable<Camera>;
  94033. /**
  94034. * Observable triggered when reset has been called and applied to the camera.
  94035. */
  94036. onRestoreStateObservable: Observable<Camera>;
  94037. /** @hidden */
  94038. _cameraRigParams: any;
  94039. /** @hidden */
  94040. _rigCameras: Camera[];
  94041. /** @hidden */
  94042. _rigPostProcess: Nullable<PostProcess>;
  94043. protected _webvrViewMatrix: Matrix;
  94044. /** @hidden */
  94045. _skipRendering: boolean;
  94046. /** @hidden */
  94047. _projectionMatrix: Matrix;
  94048. /** @hidden */
  94049. _postProcesses: Nullable<PostProcess>[];
  94050. /** @hidden */
  94051. _activeMeshes: SmartArray<AbstractMesh>;
  94052. protected _globalPosition: Vector3;
  94053. /** @hidden */
  94054. _computedViewMatrix: Matrix;
  94055. private _doNotComputeProjectionMatrix;
  94056. private _transformMatrix;
  94057. private _frustumPlanes;
  94058. private _refreshFrustumPlanes;
  94059. private _storedFov;
  94060. private _stateStored;
  94061. /**
  94062. * Instantiates a new camera object.
  94063. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  94064. * @see http://doc.babylonjs.com/features/cameras
  94065. * @param name Defines the name of the camera in the scene
  94066. * @param position Defines the position of the camera
  94067. * @param scene Defines the scene the camera belongs too
  94068. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  94069. */
  94070. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94071. /**
  94072. * Store current camera state (fov, position, etc..)
  94073. * @returns the camera
  94074. */
  94075. storeState(): Camera;
  94076. /**
  94077. * Restores the camera state values if it has been stored. You must call storeState() first
  94078. */
  94079. protected _restoreStateValues(): boolean;
  94080. /**
  94081. * Restored camera state. You must call storeState() first.
  94082. * @returns true if restored and false otherwise
  94083. */
  94084. restoreState(): boolean;
  94085. /**
  94086. * Gets the class name of the camera.
  94087. * @returns the class name
  94088. */
  94089. getClassName(): string;
  94090. /** @hidden */
  94091. readonly _isCamera: boolean;
  94092. /**
  94093. * Gets a string representation of the camera useful for debug purpose.
  94094. * @param fullDetails Defines that a more verboe level of logging is required
  94095. * @returns the string representation
  94096. */
  94097. toString(fullDetails?: boolean): string;
  94098. /**
  94099. * Gets the current world space position of the camera.
  94100. */
  94101. readonly globalPosition: Vector3;
  94102. /**
  94103. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  94104. * @returns the active meshe list
  94105. */
  94106. getActiveMeshes(): SmartArray<AbstractMesh>;
  94107. /**
  94108. * Check wether a mesh is part of the current active mesh list of the camera
  94109. * @param mesh Defines the mesh to check
  94110. * @returns true if active, false otherwise
  94111. */
  94112. isActiveMesh(mesh: Mesh): boolean;
  94113. /**
  94114. * Is this camera ready to be used/rendered
  94115. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  94116. * @return true if the camera is ready
  94117. */
  94118. isReady(completeCheck?: boolean): boolean;
  94119. /** @hidden */
  94120. _initCache(): void;
  94121. /** @hidden */
  94122. _updateCache(ignoreParentClass?: boolean): void;
  94123. /** @hidden */
  94124. _isSynchronized(): boolean;
  94125. /** @hidden */
  94126. _isSynchronizedViewMatrix(): boolean;
  94127. /** @hidden */
  94128. _isSynchronizedProjectionMatrix(): boolean;
  94129. /**
  94130. * Attach the input controls to a specific dom element to get the input from.
  94131. * @param element Defines the element the controls should be listened from
  94132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94133. */
  94134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94135. /**
  94136. * Detach the current controls from the specified dom element.
  94137. * @param element Defines the element to stop listening the inputs from
  94138. */
  94139. detachControl(element: HTMLElement): void;
  94140. /**
  94141. * Update the camera state according to the different inputs gathered during the frame.
  94142. */
  94143. update(): void;
  94144. /** @hidden */
  94145. _checkInputs(): void;
  94146. /** @hidden */
  94147. readonly rigCameras: Camera[];
  94148. /**
  94149. * Gets the post process used by the rig cameras
  94150. */
  94151. readonly rigPostProcess: Nullable<PostProcess>;
  94152. /**
  94153. * Internal, gets the first post proces.
  94154. * @returns the first post process to be run on this camera.
  94155. */
  94156. _getFirstPostProcess(): Nullable<PostProcess>;
  94157. private _cascadePostProcessesToRigCams;
  94158. /**
  94159. * Attach a post process to the camera.
  94160. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94161. * @param postProcess The post process to attach to the camera
  94162. * @param insertAt The position of the post process in case several of them are in use in the scene
  94163. * @returns the position the post process has been inserted at
  94164. */
  94165. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  94166. /**
  94167. * Detach a post process to the camera.
  94168. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94169. * @param postProcess The post process to detach from the camera
  94170. */
  94171. detachPostProcess(postProcess: PostProcess): void;
  94172. /**
  94173. * Gets the current world matrix of the camera
  94174. */
  94175. getWorldMatrix(): Matrix;
  94176. /** @hidden */
  94177. _getViewMatrix(): Matrix;
  94178. /**
  94179. * Gets the current view matrix of the camera.
  94180. * @param force forces the camera to recompute the matrix without looking at the cached state
  94181. * @returns the view matrix
  94182. */
  94183. getViewMatrix(force?: boolean): Matrix;
  94184. /**
  94185. * Freeze the projection matrix.
  94186. * It will prevent the cache check of the camera projection compute and can speed up perf
  94187. * if no parameter of the camera are meant to change
  94188. * @param projection Defines manually a projection if necessary
  94189. */
  94190. freezeProjectionMatrix(projection?: Matrix): void;
  94191. /**
  94192. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  94193. */
  94194. unfreezeProjectionMatrix(): void;
  94195. /**
  94196. * Gets the current projection matrix of the camera.
  94197. * @param force forces the camera to recompute the matrix without looking at the cached state
  94198. * @returns the projection matrix
  94199. */
  94200. getProjectionMatrix(force?: boolean): Matrix;
  94201. /**
  94202. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  94203. * @returns a Matrix
  94204. */
  94205. getTransformationMatrix(): Matrix;
  94206. private _updateFrustumPlanes;
  94207. /**
  94208. * Checks if a cullable object (mesh...) is in the camera frustum
  94209. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  94210. * @param target The object to check
  94211. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  94212. * @returns true if the object is in frustum otherwise false
  94213. */
  94214. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  94215. /**
  94216. * Checks if a cullable object (mesh...) is in the camera frustum
  94217. * Unlike isInFrustum this cheks the full bounding box
  94218. * @param target The object to check
  94219. * @returns true if the object is in frustum otherwise false
  94220. */
  94221. isCompletelyInFrustum(target: ICullable): boolean;
  94222. /**
  94223. * Gets a ray in the forward direction from the camera.
  94224. * @param length Defines the length of the ray to create
  94225. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  94226. * @param origin Defines the start point of the ray which defaults to the camera position
  94227. * @returns the forward ray
  94228. */
  94229. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  94230. /**
  94231. * Releases resources associated with this node.
  94232. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94233. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94234. */
  94235. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94236. /** @hidden */
  94237. _isLeftCamera: boolean;
  94238. /**
  94239. * Gets the left camera of a rig setup in case of Rigged Camera
  94240. */
  94241. readonly isLeftCamera: boolean;
  94242. /** @hidden */
  94243. _isRightCamera: boolean;
  94244. /**
  94245. * Gets the right camera of a rig setup in case of Rigged Camera
  94246. */
  94247. readonly isRightCamera: boolean;
  94248. /**
  94249. * Gets the left camera of a rig setup in case of Rigged Camera
  94250. */
  94251. readonly leftCamera: Nullable<FreeCamera>;
  94252. /**
  94253. * Gets the right camera of a rig setup in case of Rigged Camera
  94254. */
  94255. readonly rightCamera: Nullable<FreeCamera>;
  94256. /**
  94257. * Gets the left camera target of a rig setup in case of Rigged Camera
  94258. * @returns the target position
  94259. */
  94260. getLeftTarget(): Nullable<Vector3>;
  94261. /**
  94262. * Gets the right camera target of a rig setup in case of Rigged Camera
  94263. * @returns the target position
  94264. */
  94265. getRightTarget(): Nullable<Vector3>;
  94266. /**
  94267. * @hidden
  94268. */
  94269. setCameraRigMode(mode: number, rigParams: any): void;
  94270. /** @hidden */
  94271. static _setStereoscopicRigMode(camera: Camera): void;
  94272. /** @hidden */
  94273. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  94274. /** @hidden */
  94275. static _setVRRigMode(camera: Camera, rigParams: any): void;
  94276. /** @hidden */
  94277. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  94278. /** @hidden */
  94279. _getVRProjectionMatrix(): Matrix;
  94280. protected _updateCameraRotationMatrix(): void;
  94281. protected _updateWebVRCameraRotationMatrix(): void;
  94282. /**
  94283. * This function MUST be overwritten by the different WebVR cameras available.
  94284. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94285. * @hidden
  94286. */
  94287. _getWebVRProjectionMatrix(): Matrix;
  94288. /**
  94289. * This function MUST be overwritten by the different WebVR cameras available.
  94290. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94291. * @hidden
  94292. */
  94293. _getWebVRViewMatrix(): Matrix;
  94294. /** @hidden */
  94295. setCameraRigParameter(name: string, value: any): void;
  94296. /**
  94297. * needs to be overridden by children so sub has required properties to be copied
  94298. * @hidden
  94299. */
  94300. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94301. /**
  94302. * May need to be overridden by children
  94303. * @hidden
  94304. */
  94305. _updateRigCameras(): void;
  94306. /** @hidden */
  94307. _setupInputs(): void;
  94308. /**
  94309. * Serialiaze the camera setup to a json represention
  94310. * @returns the JSON representation
  94311. */
  94312. serialize(): any;
  94313. /**
  94314. * Clones the current camera.
  94315. * @param name The cloned camera name
  94316. * @returns the cloned camera
  94317. */
  94318. clone(name: string): Camera;
  94319. /**
  94320. * Gets the direction of the camera relative to a given local axis.
  94321. * @param localAxis Defines the reference axis to provide a relative direction.
  94322. * @return the direction
  94323. */
  94324. getDirection(localAxis: Vector3): Vector3;
  94325. /**
  94326. * Returns the current camera absolute rotation
  94327. */
  94328. readonly absoluteRotation: Quaternion;
  94329. /**
  94330. * Gets the direction of the camera relative to a given local axis into a passed vector.
  94331. * @param localAxis Defines the reference axis to provide a relative direction.
  94332. * @param result Defines the vector to store the result in
  94333. */
  94334. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  94335. /**
  94336. * Gets a camera constructor for a given camera type
  94337. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  94338. * @param name The name of the camera the result will be able to instantiate
  94339. * @param scene The scene the result will construct the camera in
  94340. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  94341. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  94342. * @returns a factory method to construc the camera
  94343. */
  94344. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  94345. /**
  94346. * Compute the world matrix of the camera.
  94347. * @returns the camera world matrix
  94348. */
  94349. computeWorldMatrix(): Matrix;
  94350. /**
  94351. * Parse a JSON and creates the camera from the parsed information
  94352. * @param parsedCamera The JSON to parse
  94353. * @param scene The scene to instantiate the camera in
  94354. * @returns the newly constructed camera
  94355. */
  94356. static Parse(parsedCamera: any, scene: Scene): Camera;
  94357. }
  94358. }
  94359. declare module BABYLON {
  94360. /**
  94361. * Class containing static functions to help procedurally build meshes
  94362. */
  94363. export class DiscBuilder {
  94364. /**
  94365. * Creates a plane polygonal mesh. By default, this is a disc
  94366. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  94367. * * 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
  94368. * * 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
  94369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94372. * @param name defines the name of the mesh
  94373. * @param options defines the options used to create the mesh
  94374. * @param scene defines the hosting scene
  94375. * @returns the plane polygonal mesh
  94376. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  94377. */
  94378. static CreateDisc(name: string, options: {
  94379. radius?: number;
  94380. tessellation?: number;
  94381. arc?: number;
  94382. updatable?: boolean;
  94383. sideOrientation?: number;
  94384. frontUVs?: Vector4;
  94385. backUVs?: Vector4;
  94386. }, scene?: Nullable<Scene>): Mesh;
  94387. }
  94388. }
  94389. declare module BABYLON {
  94390. /**
  94391. * This represents all the required information to add a fresnel effect on a material:
  94392. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94393. */
  94394. export class FresnelParameters {
  94395. private _isEnabled;
  94396. /**
  94397. * Define if the fresnel effect is enable or not.
  94398. */
  94399. isEnabled: boolean;
  94400. /**
  94401. * Define the color used on edges (grazing angle)
  94402. */
  94403. leftColor: Color3;
  94404. /**
  94405. * Define the color used on center
  94406. */
  94407. rightColor: Color3;
  94408. /**
  94409. * Define bias applied to computed fresnel term
  94410. */
  94411. bias: number;
  94412. /**
  94413. * Defined the power exponent applied to fresnel term
  94414. */
  94415. power: number;
  94416. /**
  94417. * Clones the current fresnel and its valuues
  94418. * @returns a clone fresnel configuration
  94419. */
  94420. clone(): FresnelParameters;
  94421. /**
  94422. * Serializes the current fresnel parameters to a JSON representation.
  94423. * @return the JSON serialization
  94424. */
  94425. serialize(): any;
  94426. /**
  94427. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94428. * @param parsedFresnelParameters Define the JSON representation
  94429. * @returns the parsed parameters
  94430. */
  94431. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94432. }
  94433. }
  94434. declare module BABYLON {
  94435. /**
  94436. * Base class of materials working in push mode in babylon JS
  94437. * @hidden
  94438. */
  94439. export class PushMaterial extends Material {
  94440. protected _activeEffect: Effect;
  94441. protected _normalMatrix: Matrix;
  94442. /**
  94443. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94444. * This means that the material can keep using a previous shader while a new one is being compiled.
  94445. * This is mostly used when shader parallel compilation is supported (true by default)
  94446. */
  94447. allowShaderHotSwapping: boolean;
  94448. constructor(name: string, scene: Scene);
  94449. getEffect(): Effect;
  94450. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94451. /**
  94452. * Binds the given world matrix to the active effect
  94453. *
  94454. * @param world the matrix to bind
  94455. */
  94456. bindOnlyWorldMatrix(world: Matrix): void;
  94457. /**
  94458. * Binds the given normal matrix to the active effect
  94459. *
  94460. * @param normalMatrix the matrix to bind
  94461. */
  94462. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94463. bind(world: Matrix, mesh?: Mesh): void;
  94464. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94465. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94466. }
  94467. }
  94468. declare module BABYLON {
  94469. /**
  94470. * This groups all the flags used to control the materials channel.
  94471. */
  94472. export class MaterialFlags {
  94473. private static _DiffuseTextureEnabled;
  94474. /**
  94475. * Are diffuse textures enabled in the application.
  94476. */
  94477. static DiffuseTextureEnabled: boolean;
  94478. private static _AmbientTextureEnabled;
  94479. /**
  94480. * Are ambient textures enabled in the application.
  94481. */
  94482. static AmbientTextureEnabled: boolean;
  94483. private static _OpacityTextureEnabled;
  94484. /**
  94485. * Are opacity textures enabled in the application.
  94486. */
  94487. static OpacityTextureEnabled: boolean;
  94488. private static _ReflectionTextureEnabled;
  94489. /**
  94490. * Are reflection textures enabled in the application.
  94491. */
  94492. static ReflectionTextureEnabled: boolean;
  94493. private static _EmissiveTextureEnabled;
  94494. /**
  94495. * Are emissive textures enabled in the application.
  94496. */
  94497. static EmissiveTextureEnabled: boolean;
  94498. private static _SpecularTextureEnabled;
  94499. /**
  94500. * Are specular textures enabled in the application.
  94501. */
  94502. static SpecularTextureEnabled: boolean;
  94503. private static _BumpTextureEnabled;
  94504. /**
  94505. * Are bump textures enabled in the application.
  94506. */
  94507. static BumpTextureEnabled: boolean;
  94508. private static _LightmapTextureEnabled;
  94509. /**
  94510. * Are lightmap textures enabled in the application.
  94511. */
  94512. static LightmapTextureEnabled: boolean;
  94513. private static _RefractionTextureEnabled;
  94514. /**
  94515. * Are refraction textures enabled in the application.
  94516. */
  94517. static RefractionTextureEnabled: boolean;
  94518. private static _ColorGradingTextureEnabled;
  94519. /**
  94520. * Are color grading textures enabled in the application.
  94521. */
  94522. static ColorGradingTextureEnabled: boolean;
  94523. private static _FresnelEnabled;
  94524. /**
  94525. * Are fresnels enabled in the application.
  94526. */
  94527. static FresnelEnabled: boolean;
  94528. private static _ClearCoatTextureEnabled;
  94529. /**
  94530. * Are clear coat textures enabled in the application.
  94531. */
  94532. static ClearCoatTextureEnabled: boolean;
  94533. private static _ClearCoatBumpTextureEnabled;
  94534. /**
  94535. * Are clear coat bump textures enabled in the application.
  94536. */
  94537. static ClearCoatBumpTextureEnabled: boolean;
  94538. private static _ClearCoatTintTextureEnabled;
  94539. /**
  94540. * Are clear coat tint textures enabled in the application.
  94541. */
  94542. static ClearCoatTintTextureEnabled: boolean;
  94543. private static _SheenTextureEnabled;
  94544. /**
  94545. * Are sheen textures enabled in the application.
  94546. */
  94547. static SheenTextureEnabled: boolean;
  94548. private static _AnisotropicTextureEnabled;
  94549. /**
  94550. * Are anisotropic textures enabled in the application.
  94551. */
  94552. static AnisotropicTextureEnabled: boolean;
  94553. private static _ThicknessTextureEnabled;
  94554. /**
  94555. * Are thickness textures enabled in the application.
  94556. */
  94557. static ThicknessTextureEnabled: boolean;
  94558. }
  94559. }
  94560. declare module BABYLON {
  94561. /** @hidden */
  94562. export var defaultFragmentDeclaration: {
  94563. name: string;
  94564. shader: string;
  94565. };
  94566. }
  94567. declare module BABYLON {
  94568. /** @hidden */
  94569. export var defaultUboDeclaration: {
  94570. name: string;
  94571. shader: string;
  94572. };
  94573. }
  94574. declare module BABYLON {
  94575. /** @hidden */
  94576. export var lightFragmentDeclaration: {
  94577. name: string;
  94578. shader: string;
  94579. };
  94580. }
  94581. declare module BABYLON {
  94582. /** @hidden */
  94583. export var lightUboDeclaration: {
  94584. name: string;
  94585. shader: string;
  94586. };
  94587. }
  94588. declare module BABYLON {
  94589. /** @hidden */
  94590. export var lightsFragmentFunctions: {
  94591. name: string;
  94592. shader: string;
  94593. };
  94594. }
  94595. declare module BABYLON {
  94596. /** @hidden */
  94597. export var shadowsFragmentFunctions: {
  94598. name: string;
  94599. shader: string;
  94600. };
  94601. }
  94602. declare module BABYLON {
  94603. /** @hidden */
  94604. export var fresnelFunction: {
  94605. name: string;
  94606. shader: string;
  94607. };
  94608. }
  94609. declare module BABYLON {
  94610. /** @hidden */
  94611. export var reflectionFunction: {
  94612. name: string;
  94613. shader: string;
  94614. };
  94615. }
  94616. declare module BABYLON {
  94617. /** @hidden */
  94618. export var bumpFragmentFunctions: {
  94619. name: string;
  94620. shader: string;
  94621. };
  94622. }
  94623. declare module BABYLON {
  94624. /** @hidden */
  94625. export var logDepthDeclaration: {
  94626. name: string;
  94627. shader: string;
  94628. };
  94629. }
  94630. declare module BABYLON {
  94631. /** @hidden */
  94632. export var bumpFragment: {
  94633. name: string;
  94634. shader: string;
  94635. };
  94636. }
  94637. declare module BABYLON {
  94638. /** @hidden */
  94639. export var depthPrePass: {
  94640. name: string;
  94641. shader: string;
  94642. };
  94643. }
  94644. declare module BABYLON {
  94645. /** @hidden */
  94646. export var lightFragment: {
  94647. name: string;
  94648. shader: string;
  94649. };
  94650. }
  94651. declare module BABYLON {
  94652. /** @hidden */
  94653. export var logDepthFragment: {
  94654. name: string;
  94655. shader: string;
  94656. };
  94657. }
  94658. declare module BABYLON {
  94659. /** @hidden */
  94660. export var defaultPixelShader: {
  94661. name: string;
  94662. shader: string;
  94663. };
  94664. }
  94665. declare module BABYLON {
  94666. /** @hidden */
  94667. export var defaultVertexDeclaration: {
  94668. name: string;
  94669. shader: string;
  94670. };
  94671. }
  94672. declare module BABYLON {
  94673. /** @hidden */
  94674. export var bumpVertexDeclaration: {
  94675. name: string;
  94676. shader: string;
  94677. };
  94678. }
  94679. declare module BABYLON {
  94680. /** @hidden */
  94681. export var bumpVertex: {
  94682. name: string;
  94683. shader: string;
  94684. };
  94685. }
  94686. declare module BABYLON {
  94687. /** @hidden */
  94688. export var fogVertex: {
  94689. name: string;
  94690. shader: string;
  94691. };
  94692. }
  94693. declare module BABYLON {
  94694. /** @hidden */
  94695. export var shadowsVertex: {
  94696. name: string;
  94697. shader: string;
  94698. };
  94699. }
  94700. declare module BABYLON {
  94701. /** @hidden */
  94702. export var pointCloudVertex: {
  94703. name: string;
  94704. shader: string;
  94705. };
  94706. }
  94707. declare module BABYLON {
  94708. /** @hidden */
  94709. export var logDepthVertex: {
  94710. name: string;
  94711. shader: string;
  94712. };
  94713. }
  94714. declare module BABYLON {
  94715. /** @hidden */
  94716. export var defaultVertexShader: {
  94717. name: string;
  94718. shader: string;
  94719. };
  94720. }
  94721. declare module BABYLON {
  94722. /** @hidden */
  94723. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94724. MAINUV1: boolean;
  94725. MAINUV2: boolean;
  94726. DIFFUSE: boolean;
  94727. DIFFUSEDIRECTUV: number;
  94728. AMBIENT: boolean;
  94729. AMBIENTDIRECTUV: number;
  94730. OPACITY: boolean;
  94731. OPACITYDIRECTUV: number;
  94732. OPACITYRGB: boolean;
  94733. REFLECTION: boolean;
  94734. EMISSIVE: boolean;
  94735. EMISSIVEDIRECTUV: number;
  94736. SPECULAR: boolean;
  94737. SPECULARDIRECTUV: number;
  94738. BUMP: boolean;
  94739. BUMPDIRECTUV: number;
  94740. PARALLAX: boolean;
  94741. PARALLAXOCCLUSION: boolean;
  94742. SPECULAROVERALPHA: boolean;
  94743. CLIPPLANE: boolean;
  94744. CLIPPLANE2: boolean;
  94745. CLIPPLANE3: boolean;
  94746. CLIPPLANE4: boolean;
  94747. ALPHATEST: boolean;
  94748. DEPTHPREPASS: boolean;
  94749. ALPHAFROMDIFFUSE: boolean;
  94750. POINTSIZE: boolean;
  94751. FOG: boolean;
  94752. SPECULARTERM: boolean;
  94753. DIFFUSEFRESNEL: boolean;
  94754. OPACITYFRESNEL: boolean;
  94755. REFLECTIONFRESNEL: boolean;
  94756. REFRACTIONFRESNEL: boolean;
  94757. EMISSIVEFRESNEL: boolean;
  94758. FRESNEL: boolean;
  94759. NORMAL: boolean;
  94760. UV1: boolean;
  94761. UV2: boolean;
  94762. VERTEXCOLOR: boolean;
  94763. VERTEXALPHA: boolean;
  94764. NUM_BONE_INFLUENCERS: number;
  94765. BonesPerMesh: number;
  94766. BONETEXTURE: boolean;
  94767. INSTANCES: boolean;
  94768. GLOSSINESS: boolean;
  94769. ROUGHNESS: boolean;
  94770. EMISSIVEASILLUMINATION: boolean;
  94771. LINKEMISSIVEWITHDIFFUSE: boolean;
  94772. REFLECTIONFRESNELFROMSPECULAR: boolean;
  94773. LIGHTMAP: boolean;
  94774. LIGHTMAPDIRECTUV: number;
  94775. OBJECTSPACE_NORMALMAP: boolean;
  94776. USELIGHTMAPASSHADOWMAP: boolean;
  94777. REFLECTIONMAP_3D: boolean;
  94778. REFLECTIONMAP_SPHERICAL: boolean;
  94779. REFLECTIONMAP_PLANAR: boolean;
  94780. REFLECTIONMAP_CUBIC: boolean;
  94781. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  94782. REFLECTIONMAP_PROJECTION: boolean;
  94783. REFLECTIONMAP_SKYBOX: boolean;
  94784. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  94785. REFLECTIONMAP_EXPLICIT: boolean;
  94786. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  94787. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  94788. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  94789. INVERTCUBICMAP: boolean;
  94790. LOGARITHMICDEPTH: boolean;
  94791. REFRACTION: boolean;
  94792. REFRACTIONMAP_3D: boolean;
  94793. REFLECTIONOVERALPHA: boolean;
  94794. TWOSIDEDLIGHTING: boolean;
  94795. SHADOWFLOAT: boolean;
  94796. MORPHTARGETS: boolean;
  94797. MORPHTARGETS_NORMAL: boolean;
  94798. MORPHTARGETS_TANGENT: boolean;
  94799. MORPHTARGETS_UV: boolean;
  94800. NUM_MORPH_INFLUENCERS: number;
  94801. NONUNIFORMSCALING: boolean;
  94802. PREMULTIPLYALPHA: boolean;
  94803. IMAGEPROCESSING: boolean;
  94804. VIGNETTE: boolean;
  94805. VIGNETTEBLENDMODEMULTIPLY: boolean;
  94806. VIGNETTEBLENDMODEOPAQUE: boolean;
  94807. TONEMAPPING: boolean;
  94808. TONEMAPPING_ACES: boolean;
  94809. CONTRAST: boolean;
  94810. COLORCURVES: boolean;
  94811. COLORGRADING: boolean;
  94812. COLORGRADING3D: boolean;
  94813. SAMPLER3DGREENDEPTH: boolean;
  94814. SAMPLER3DBGRMAP: boolean;
  94815. IMAGEPROCESSINGPOSTPROCESS: boolean;
  94816. MULTIVIEW: boolean;
  94817. /**
  94818. * If the reflection texture on this material is in linear color space
  94819. * @hidden
  94820. */
  94821. IS_REFLECTION_LINEAR: boolean;
  94822. /**
  94823. * If the refraction texture on this material is in linear color space
  94824. * @hidden
  94825. */
  94826. IS_REFRACTION_LINEAR: boolean;
  94827. EXPOSURE: boolean;
  94828. constructor();
  94829. setReflectionMode(modeToEnable: string): void;
  94830. }
  94831. /**
  94832. * This is the default material used in Babylon. It is the best trade off between quality
  94833. * and performances.
  94834. * @see http://doc.babylonjs.com/babylon101/materials
  94835. */
  94836. export class StandardMaterial extends PushMaterial {
  94837. private _diffuseTexture;
  94838. /**
  94839. * The basic texture of the material as viewed under a light.
  94840. */
  94841. diffuseTexture: Nullable<BaseTexture>;
  94842. private _ambientTexture;
  94843. /**
  94844. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  94845. */
  94846. ambientTexture: Nullable<BaseTexture>;
  94847. private _opacityTexture;
  94848. /**
  94849. * Define the transparency of the material from a texture.
  94850. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  94851. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  94852. */
  94853. opacityTexture: Nullable<BaseTexture>;
  94854. private _reflectionTexture;
  94855. /**
  94856. * Define the texture used to display the reflection.
  94857. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94858. */
  94859. reflectionTexture: Nullable<BaseTexture>;
  94860. private _emissiveTexture;
  94861. /**
  94862. * Define texture of the material as if self lit.
  94863. * This will be mixed in the final result even in the absence of light.
  94864. */
  94865. emissiveTexture: Nullable<BaseTexture>;
  94866. private _specularTexture;
  94867. /**
  94868. * Define how the color and intensity of the highlight given by the light in the material.
  94869. */
  94870. specularTexture: Nullable<BaseTexture>;
  94871. private _bumpTexture;
  94872. /**
  94873. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  94874. * 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.
  94875. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  94876. */
  94877. bumpTexture: Nullable<BaseTexture>;
  94878. private _lightmapTexture;
  94879. /**
  94880. * Complex lighting can be computationally expensive to compute at runtime.
  94881. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  94882. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  94883. */
  94884. lightmapTexture: Nullable<BaseTexture>;
  94885. private _refractionTexture;
  94886. /**
  94887. * Define the texture used to display the refraction.
  94888. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94889. */
  94890. refractionTexture: Nullable<BaseTexture>;
  94891. /**
  94892. * The color of the material lit by the environmental background lighting.
  94893. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  94894. */
  94895. ambientColor: Color3;
  94896. /**
  94897. * The basic color of the material as viewed under a light.
  94898. */
  94899. diffuseColor: Color3;
  94900. /**
  94901. * Define how the color and intensity of the highlight given by the light in the material.
  94902. */
  94903. specularColor: Color3;
  94904. /**
  94905. * Define the color of the material as if self lit.
  94906. * This will be mixed in the final result even in the absence of light.
  94907. */
  94908. emissiveColor: Color3;
  94909. /**
  94910. * Defines how sharp are the highlights in the material.
  94911. * The bigger the value the sharper giving a more glossy feeling to the result.
  94912. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  94913. */
  94914. specularPower: number;
  94915. private _useAlphaFromDiffuseTexture;
  94916. /**
  94917. * Does the transparency come from the diffuse texture alpha channel.
  94918. */
  94919. useAlphaFromDiffuseTexture: boolean;
  94920. private _useEmissiveAsIllumination;
  94921. /**
  94922. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  94923. */
  94924. useEmissiveAsIllumination: boolean;
  94925. private _linkEmissiveWithDiffuse;
  94926. /**
  94927. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  94928. * the emissive level when the final color is close to one.
  94929. */
  94930. linkEmissiveWithDiffuse: boolean;
  94931. private _useSpecularOverAlpha;
  94932. /**
  94933. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  94934. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  94935. */
  94936. useSpecularOverAlpha: boolean;
  94937. private _useReflectionOverAlpha;
  94938. /**
  94939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  94940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  94941. */
  94942. useReflectionOverAlpha: boolean;
  94943. private _disableLighting;
  94944. /**
  94945. * Does lights from the scene impacts this material.
  94946. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  94947. */
  94948. disableLighting: boolean;
  94949. private _useObjectSpaceNormalMap;
  94950. /**
  94951. * Allows using an object space normal map (instead of tangent space).
  94952. */
  94953. useObjectSpaceNormalMap: boolean;
  94954. private _useParallax;
  94955. /**
  94956. * Is parallax enabled or not.
  94957. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  94958. */
  94959. useParallax: boolean;
  94960. private _useParallaxOcclusion;
  94961. /**
  94962. * Is parallax occlusion enabled or not.
  94963. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  94964. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  94965. */
  94966. useParallaxOcclusion: boolean;
  94967. /**
  94968. * 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.
  94969. */
  94970. parallaxScaleBias: number;
  94971. private _roughness;
  94972. /**
  94973. * Helps to define how blurry the reflections should appears in the material.
  94974. */
  94975. roughness: number;
  94976. /**
  94977. * In case of refraction, define the value of the index of refraction.
  94978. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94979. */
  94980. indexOfRefraction: number;
  94981. /**
  94982. * Invert the refraction texture alongside the y axis.
  94983. * It can be useful with procedural textures or probe for instance.
  94984. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94985. */
  94986. invertRefractionY: boolean;
  94987. /**
  94988. * Defines the alpha limits in alpha test mode.
  94989. */
  94990. alphaCutOff: number;
  94991. private _useLightmapAsShadowmap;
  94992. /**
  94993. * In case of light mapping, define whether the map contains light or shadow informations.
  94994. */
  94995. useLightmapAsShadowmap: boolean;
  94996. private _diffuseFresnelParameters;
  94997. /**
  94998. * Define the diffuse fresnel parameters of the material.
  94999. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95000. */
  95001. diffuseFresnelParameters: FresnelParameters;
  95002. private _opacityFresnelParameters;
  95003. /**
  95004. * Define the opacity fresnel parameters of the material.
  95005. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95006. */
  95007. opacityFresnelParameters: FresnelParameters;
  95008. private _reflectionFresnelParameters;
  95009. /**
  95010. * Define the reflection fresnel parameters of the material.
  95011. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95012. */
  95013. reflectionFresnelParameters: FresnelParameters;
  95014. private _refractionFresnelParameters;
  95015. /**
  95016. * Define the refraction fresnel parameters of the material.
  95017. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95018. */
  95019. refractionFresnelParameters: FresnelParameters;
  95020. private _emissiveFresnelParameters;
  95021. /**
  95022. * Define the emissive fresnel parameters of the material.
  95023. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95024. */
  95025. emissiveFresnelParameters: FresnelParameters;
  95026. private _useReflectionFresnelFromSpecular;
  95027. /**
  95028. * If true automatically deducts the fresnels values from the material specularity.
  95029. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95030. */
  95031. useReflectionFresnelFromSpecular: boolean;
  95032. private _useGlossinessFromSpecularMapAlpha;
  95033. /**
  95034. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95035. */
  95036. useGlossinessFromSpecularMapAlpha: boolean;
  95037. private _maxSimultaneousLights;
  95038. /**
  95039. * Defines the maximum number of lights that can be used in the material
  95040. */
  95041. maxSimultaneousLights: number;
  95042. private _invertNormalMapX;
  95043. /**
  95044. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95045. */
  95046. invertNormalMapX: boolean;
  95047. private _invertNormalMapY;
  95048. /**
  95049. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95050. */
  95051. invertNormalMapY: boolean;
  95052. private _twoSidedLighting;
  95053. /**
  95054. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95055. */
  95056. twoSidedLighting: boolean;
  95057. /**
  95058. * Default configuration related to image processing available in the standard Material.
  95059. */
  95060. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95061. /**
  95062. * Gets the image processing configuration used either in this material.
  95063. */
  95064. /**
  95065. * Sets the Default image processing configuration used either in the this material.
  95066. *
  95067. * If sets to null, the scene one is in use.
  95068. */
  95069. imageProcessingConfiguration: ImageProcessingConfiguration;
  95070. /**
  95071. * Keep track of the image processing observer to allow dispose and replace.
  95072. */
  95073. private _imageProcessingObserver;
  95074. /**
  95075. * Attaches a new image processing configuration to the Standard Material.
  95076. * @param configuration
  95077. */
  95078. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95079. /**
  95080. * Gets wether the color curves effect is enabled.
  95081. */
  95082. /**
  95083. * Sets wether the color curves effect is enabled.
  95084. */
  95085. cameraColorCurvesEnabled: boolean;
  95086. /**
  95087. * Gets wether the color grading effect is enabled.
  95088. */
  95089. /**
  95090. * Gets wether the color grading effect is enabled.
  95091. */
  95092. cameraColorGradingEnabled: boolean;
  95093. /**
  95094. * Gets wether tonemapping is enabled or not.
  95095. */
  95096. /**
  95097. * Sets wether tonemapping is enabled or not
  95098. */
  95099. cameraToneMappingEnabled: boolean;
  95100. /**
  95101. * The camera exposure used on this material.
  95102. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95103. * This corresponds to a photographic exposure.
  95104. */
  95105. /**
  95106. * The camera exposure used on this material.
  95107. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95108. * This corresponds to a photographic exposure.
  95109. */
  95110. cameraExposure: number;
  95111. /**
  95112. * Gets The camera contrast used on this material.
  95113. */
  95114. /**
  95115. * Sets The camera contrast used on this material.
  95116. */
  95117. cameraContrast: number;
  95118. /**
  95119. * Gets the Color Grading 2D Lookup Texture.
  95120. */
  95121. /**
  95122. * Sets the Color Grading 2D Lookup Texture.
  95123. */
  95124. cameraColorGradingTexture: Nullable<BaseTexture>;
  95125. /**
  95126. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95127. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95128. * 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;
  95129. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95130. */
  95131. /**
  95132. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95133. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95134. * 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;
  95135. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95136. */
  95137. cameraColorCurves: Nullable<ColorCurves>;
  95138. /**
  95139. * Custom callback helping to override the default shader used in the material.
  95140. */
  95141. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95142. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95143. protected _worldViewProjectionMatrix: Matrix;
  95144. protected _globalAmbientColor: Color3;
  95145. protected _useLogarithmicDepth: boolean;
  95146. protected _rebuildInParallel: boolean;
  95147. /**
  95148. * Instantiates a new standard material.
  95149. * This is the default material used in Babylon. It is the best trade off between quality
  95150. * and performances.
  95151. * @see http://doc.babylonjs.com/babylon101/materials
  95152. * @param name Define the name of the material in the scene
  95153. * @param scene Define the scene the material belong to
  95154. */
  95155. constructor(name: string, scene: Scene);
  95156. /**
  95157. * Gets a boolean indicating that current material needs to register RTT
  95158. */
  95159. readonly hasRenderTargetTextures: boolean;
  95160. /**
  95161. * Gets the current class name of the material e.g. "StandardMaterial"
  95162. * Mainly use in serialization.
  95163. * @returns the class name
  95164. */
  95165. getClassName(): string;
  95166. /**
  95167. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95168. * You can try switching to logarithmic depth.
  95169. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95170. */
  95171. useLogarithmicDepth: boolean;
  95172. /**
  95173. * Specifies if the material will require alpha blending
  95174. * @returns a boolean specifying if alpha blending is needed
  95175. */
  95176. needAlphaBlending(): boolean;
  95177. /**
  95178. * Specifies if this material should be rendered in alpha test mode
  95179. * @returns a boolean specifying if an alpha test is needed.
  95180. */
  95181. needAlphaTesting(): boolean;
  95182. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95183. /**
  95184. * Get the texture used for alpha test purpose.
  95185. * @returns the diffuse texture in case of the standard material.
  95186. */
  95187. getAlphaTestTexture(): Nullable<BaseTexture>;
  95188. /**
  95189. * Get if the submesh is ready to be used and all its information available.
  95190. * Child classes can use it to update shaders
  95191. * @param mesh defines the mesh to check
  95192. * @param subMesh defines which submesh to check
  95193. * @param useInstances specifies that instances should be used
  95194. * @returns a boolean indicating that the submesh is ready or not
  95195. */
  95196. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95197. /**
  95198. * Builds the material UBO layouts.
  95199. * Used internally during the effect preparation.
  95200. */
  95201. buildUniformLayout(): void;
  95202. /**
  95203. * Unbinds the material from the mesh
  95204. */
  95205. unbind(): void;
  95206. /**
  95207. * Binds the submesh to this material by preparing the effect and shader to draw
  95208. * @param world defines the world transformation matrix
  95209. * @param mesh defines the mesh containing the submesh
  95210. * @param subMesh defines the submesh to bind the material to
  95211. */
  95212. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95213. /**
  95214. * Get the list of animatables in the material.
  95215. * @returns the list of animatables object used in the material
  95216. */
  95217. getAnimatables(): IAnimatable[];
  95218. /**
  95219. * Gets the active textures from the material
  95220. * @returns an array of textures
  95221. */
  95222. getActiveTextures(): BaseTexture[];
  95223. /**
  95224. * Specifies if the material uses a texture
  95225. * @param texture defines the texture to check against the material
  95226. * @returns a boolean specifying if the material uses the texture
  95227. */
  95228. hasTexture(texture: BaseTexture): boolean;
  95229. /**
  95230. * Disposes the material
  95231. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95232. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95233. */
  95234. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95235. /**
  95236. * Makes a duplicate of the material, and gives it a new name
  95237. * @param name defines the new name for the duplicated material
  95238. * @returns the cloned material
  95239. */
  95240. clone(name: string): StandardMaterial;
  95241. /**
  95242. * Serializes this material in a JSON representation
  95243. * @returns the serialized material object
  95244. */
  95245. serialize(): any;
  95246. /**
  95247. * Creates a standard material from parsed material data
  95248. * @param source defines the JSON representation of the material
  95249. * @param scene defines the hosting scene
  95250. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95251. * @returns a new standard material
  95252. */
  95253. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95254. /**
  95255. * Are diffuse textures enabled in the application.
  95256. */
  95257. static DiffuseTextureEnabled: boolean;
  95258. /**
  95259. * Are ambient textures enabled in the application.
  95260. */
  95261. static AmbientTextureEnabled: boolean;
  95262. /**
  95263. * Are opacity textures enabled in the application.
  95264. */
  95265. static OpacityTextureEnabled: boolean;
  95266. /**
  95267. * Are reflection textures enabled in the application.
  95268. */
  95269. static ReflectionTextureEnabled: boolean;
  95270. /**
  95271. * Are emissive textures enabled in the application.
  95272. */
  95273. static EmissiveTextureEnabled: boolean;
  95274. /**
  95275. * Are specular textures enabled in the application.
  95276. */
  95277. static SpecularTextureEnabled: boolean;
  95278. /**
  95279. * Are bump textures enabled in the application.
  95280. */
  95281. static BumpTextureEnabled: boolean;
  95282. /**
  95283. * Are lightmap textures enabled in the application.
  95284. */
  95285. static LightmapTextureEnabled: boolean;
  95286. /**
  95287. * Are refraction textures enabled in the application.
  95288. */
  95289. static RefractionTextureEnabled: boolean;
  95290. /**
  95291. * Are color grading textures enabled in the application.
  95292. */
  95293. static ColorGradingTextureEnabled: boolean;
  95294. /**
  95295. * Are fresnels enabled in the application.
  95296. */
  95297. static FresnelEnabled: boolean;
  95298. }
  95299. }
  95300. declare module BABYLON {
  95301. /**
  95302. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  95303. *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.
  95304. * The SPS is also a particle system. It provides some methods to manage the particles.
  95305. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  95306. *
  95307. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  95308. */
  95309. export class SolidParticleSystem implements IDisposable {
  95310. /**
  95311. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  95312. * Example : var p = SPS.particles[i];
  95313. */
  95314. particles: SolidParticle[];
  95315. /**
  95316. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  95317. */
  95318. nbParticles: number;
  95319. /**
  95320. * If the particles must ever face the camera (default false). Useful for planar particles.
  95321. */
  95322. billboard: boolean;
  95323. /**
  95324. * Recompute normals when adding a shape
  95325. */
  95326. recomputeNormals: boolean;
  95327. /**
  95328. * This a counter ofr your own usage. It's not set by any SPS functions.
  95329. */
  95330. counter: number;
  95331. /**
  95332. * The SPS name. This name is also given to the underlying mesh.
  95333. */
  95334. name: string;
  95335. /**
  95336. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  95337. */
  95338. mesh: Mesh;
  95339. /**
  95340. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  95341. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  95342. */
  95343. vars: any;
  95344. /**
  95345. * This array is populated when the SPS is set as 'pickable'.
  95346. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  95347. * Each element of this array is an object `{idx: int, faceId: int}`.
  95348. * `idx` is the picked particle index in the `SPS.particles` array
  95349. * `faceId` is the picked face index counted within this particle.
  95350. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  95351. */
  95352. pickedParticles: {
  95353. idx: number;
  95354. faceId: number;
  95355. }[];
  95356. /**
  95357. * This array is populated when `enableDepthSort` is set to true.
  95358. * Each element of this array is an instance of the class DepthSortedParticle.
  95359. */
  95360. depthSortedParticles: DepthSortedParticle[];
  95361. /**
  95362. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  95363. * @hidden
  95364. */
  95365. _bSphereOnly: boolean;
  95366. /**
  95367. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  95368. * @hidden
  95369. */
  95370. _bSphereRadiusFactor: number;
  95371. private _scene;
  95372. private _positions;
  95373. private _indices;
  95374. private _normals;
  95375. private _colors;
  95376. private _uvs;
  95377. private _indices32;
  95378. private _positions32;
  95379. private _normals32;
  95380. private _fixedNormal32;
  95381. private _colors32;
  95382. private _uvs32;
  95383. private _index;
  95384. private _updatable;
  95385. private _pickable;
  95386. private _isVisibilityBoxLocked;
  95387. private _alwaysVisible;
  95388. private _depthSort;
  95389. private _expandable;
  95390. private _shapeCounter;
  95391. private _copy;
  95392. private _color;
  95393. private _computeParticleColor;
  95394. private _computeParticleTexture;
  95395. private _computeParticleRotation;
  95396. private _computeParticleVertex;
  95397. private _computeBoundingBox;
  95398. private _depthSortParticles;
  95399. private _camera;
  95400. private _mustUnrotateFixedNormals;
  95401. private _particlesIntersect;
  95402. private _needs32Bits;
  95403. private _isNotBuilt;
  95404. private _lastParticleId;
  95405. private _idxOfId;
  95406. private _multimaterialEnabled;
  95407. private _useModelMaterial;
  95408. private _indicesByMaterial;
  95409. private _materialIndexes;
  95410. private _depthSortFunction;
  95411. private _materialSortFunction;
  95412. private _materials;
  95413. private _multimaterial;
  95414. private _materialIndexesById;
  95415. private _defaultMaterial;
  95416. private _autoUpdateSubMeshes;
  95417. /**
  95418. * Creates a SPS (Solid Particle System) object.
  95419. * @param name (String) is the SPS name, this will be the underlying mesh name.
  95420. * @param scene (Scene) is the scene in which the SPS is added.
  95421. * @param options defines the options of the sps e.g.
  95422. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  95423. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  95424. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  95425. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  95426. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  95427. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  95428. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  95429. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  95430. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  95431. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  95432. */
  95433. constructor(name: string, scene: Scene, options?: {
  95434. updatable?: boolean;
  95435. isPickable?: boolean;
  95436. enableDepthSort?: boolean;
  95437. particleIntersection?: boolean;
  95438. boundingSphereOnly?: boolean;
  95439. bSphereRadiusFactor?: number;
  95440. expandable?: boolean;
  95441. useModelMaterial?: boolean;
  95442. enableMultiMaterial?: boolean;
  95443. });
  95444. /**
  95445. * Builds the SPS underlying mesh. Returns a standard Mesh.
  95446. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  95447. * @returns the created mesh
  95448. */
  95449. buildMesh(): Mesh;
  95450. /**
  95451. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  95452. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  95453. * Thus the particles generated from `digest()` have their property `position` set yet.
  95454. * @param mesh ( Mesh ) is the mesh to be digested
  95455. * @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
  95456. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  95457. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  95458. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95459. * @returns the current SPS
  95460. */
  95461. digest(mesh: Mesh, options?: {
  95462. facetNb?: number;
  95463. number?: number;
  95464. delta?: number;
  95465. storage?: [];
  95466. }): SolidParticleSystem;
  95467. /**
  95468. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  95469. * @hidden
  95470. */
  95471. private _unrotateFixedNormals;
  95472. /**
  95473. * Resets the temporary working copy particle
  95474. * @hidden
  95475. */
  95476. private _resetCopy;
  95477. /**
  95478. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  95479. * @param p the current index in the positions array to be updated
  95480. * @param ind the current index in the indices array
  95481. * @param shape a Vector3 array, the shape geometry
  95482. * @param positions the positions array to be updated
  95483. * @param meshInd the shape indices array
  95484. * @param indices the indices array to be updated
  95485. * @param meshUV the shape uv array
  95486. * @param uvs the uv array to be updated
  95487. * @param meshCol the shape color array
  95488. * @param colors the color array to be updated
  95489. * @param meshNor the shape normals array
  95490. * @param normals the normals array to be updated
  95491. * @param idx the particle index
  95492. * @param idxInShape the particle index in its shape
  95493. * @param options the addShape() method passed options
  95494. * @model the particle model
  95495. * @hidden
  95496. */
  95497. private _meshBuilder;
  95498. /**
  95499. * Returns a shape Vector3 array from positions float array
  95500. * @param positions float array
  95501. * @returns a vector3 array
  95502. * @hidden
  95503. */
  95504. private _posToShape;
  95505. /**
  95506. * Returns a shapeUV array from a float uvs (array deep copy)
  95507. * @param uvs as a float array
  95508. * @returns a shapeUV array
  95509. * @hidden
  95510. */
  95511. private _uvsToShapeUV;
  95512. /**
  95513. * Adds a new particle object in the particles array
  95514. * @param idx particle index in particles array
  95515. * @param id particle id
  95516. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  95517. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  95518. * @param model particle ModelShape object
  95519. * @param shapeId model shape identifier
  95520. * @param idxInShape index of the particle in the current model
  95521. * @param bInfo model bounding info object
  95522. * @param storage target storage array, if any
  95523. * @hidden
  95524. */
  95525. private _addParticle;
  95526. /**
  95527. * Adds some particles to the SPS from the model shape. Returns the shape id.
  95528. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  95529. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  95530. * @param nb (positive integer) the number of particles to be created from this model
  95531. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  95532. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  95533. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95534. * @returns the number of shapes in the system
  95535. */
  95536. addShape(mesh: Mesh, nb: number, options?: {
  95537. positionFunction?: any;
  95538. vertexFunction?: any;
  95539. storage?: [];
  95540. }): number;
  95541. /**
  95542. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  95543. * @hidden
  95544. */
  95545. private _rebuildParticle;
  95546. /**
  95547. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  95548. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  95549. * @returns the SPS.
  95550. */
  95551. rebuildMesh(reset?: boolean): SolidParticleSystem;
  95552. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  95553. * Returns an array with the removed particles.
  95554. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  95555. * The SPS can't be empty so at least one particle needs to remain in place.
  95556. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  95557. * @param start index of the first particle to remove
  95558. * @param end index of the last particle to remove (included)
  95559. * @returns an array populated with the removed particles
  95560. */
  95561. removeParticles(start: number, end: number): SolidParticle[];
  95562. /**
  95563. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  95564. * @param solidParticleArray an array populated with Solid Particles objects
  95565. * @returns the SPS
  95566. */
  95567. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  95568. /**
  95569. * Creates a new particle and modifies the SPS mesh geometry :
  95570. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  95571. * - calls _addParticle() to populate the particle array
  95572. * factorized code from addShape() and insertParticlesFromArray()
  95573. * @param idx particle index in the particles array
  95574. * @param i particle index in its shape
  95575. * @param modelShape particle ModelShape object
  95576. * @param shape shape vertex array
  95577. * @param meshInd shape indices array
  95578. * @param meshUV shape uv array
  95579. * @param meshCol shape color array
  95580. * @param meshNor shape normals array
  95581. * @param bbInfo shape bounding info
  95582. * @param storage target particle storage
  95583. * @options addShape() passed options
  95584. * @hidden
  95585. */
  95586. private _insertNewParticle;
  95587. /**
  95588. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  95589. * This method calls `updateParticle()` for each particle of the SPS.
  95590. * For an animated SPS, it is usually called within the render loop.
  95591. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  95592. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  95593. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  95594. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  95595. * @returns the SPS.
  95596. */
  95597. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  95598. /**
  95599. * Disposes the SPS.
  95600. */
  95601. dispose(): void;
  95602. /**
  95603. * Returns a SolidParticle object from its identifier : particle.id
  95604. * @param id (integer) the particle Id
  95605. * @returns the searched particle or null if not found in the SPS.
  95606. */
  95607. getParticleById(id: number): Nullable<SolidParticle>;
  95608. /**
  95609. * Returns a new array populated with the particles having the passed shapeId.
  95610. * @param shapeId (integer) the shape identifier
  95611. * @returns a new solid particle array
  95612. */
  95613. getParticlesByShapeId(shapeId: number): SolidParticle[];
  95614. /**
  95615. * Populates the passed array "ref" with the particles having the passed shapeId.
  95616. * @param shapeId the shape identifier
  95617. * @returns the SPS
  95618. * @param ref
  95619. */
  95620. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  95621. /**
  95622. * Computes the required SubMeshes according the materials assigned to the particles.
  95623. * @returns the solid particle system.
  95624. * Does nothing if called before the SPS mesh is built.
  95625. */
  95626. computeSubMeshes(): SolidParticleSystem;
  95627. /**
  95628. * Sorts the solid particles by material when MultiMaterial is enabled.
  95629. * Updates the indices32 array.
  95630. * Updates the indicesByMaterial array.
  95631. * Updates the mesh indices array.
  95632. * @returns the SPS
  95633. * @hidden
  95634. */
  95635. private _sortParticlesByMaterial;
  95636. /**
  95637. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  95638. * @hidden
  95639. */
  95640. private _setMaterialIndexesById;
  95641. /**
  95642. * Returns an array with unique values of Materials from the passed array
  95643. * @param array the material array to be checked and filtered
  95644. * @hidden
  95645. */
  95646. private _filterUniqueMaterialId;
  95647. /**
  95648. * Sets a new Standard Material as _defaultMaterial if not already set.
  95649. * @hidden
  95650. */
  95651. private _setDefaultMaterial;
  95652. /**
  95653. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  95654. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95655. * @returns the SPS.
  95656. */
  95657. refreshVisibleSize(): SolidParticleSystem;
  95658. /**
  95659. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  95660. * @param size the size (float) of the visibility box
  95661. * note : this doesn't lock the SPS mesh bounding box.
  95662. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95663. */
  95664. setVisibilityBox(size: number): void;
  95665. /**
  95666. * Gets whether the SPS as always visible or not
  95667. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95668. */
  95669. /**
  95670. * Sets the SPS as always visible or not
  95671. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95672. */
  95673. isAlwaysVisible: boolean;
  95674. /**
  95675. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  95676. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95677. */
  95678. /**
  95679. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  95680. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95681. */
  95682. isVisibilityBoxLocked: boolean;
  95683. /**
  95684. * Tells to `setParticles()` to compute the particle rotations or not.
  95685. * Default value : true. The SPS is faster when it's set to false.
  95686. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  95687. */
  95688. /**
  95689. * Gets if `setParticles()` computes the particle rotations or not.
  95690. * Default value : true. The SPS is faster when it's set to false.
  95691. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  95692. */
  95693. computeParticleRotation: boolean;
  95694. /**
  95695. * Tells to `setParticles()` to compute the particle colors or not.
  95696. * Default value : true. The SPS is faster when it's set to false.
  95697. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  95698. */
  95699. /**
  95700. * Gets if `setParticles()` computes the particle colors or not.
  95701. * Default value : true. The SPS is faster when it's set to false.
  95702. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  95703. */
  95704. computeParticleColor: boolean;
  95705. /**
  95706. * Gets if `setParticles()` computes the particle textures or not.
  95707. * Default value : true. The SPS is faster when it's set to false.
  95708. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  95709. */
  95710. computeParticleTexture: boolean;
  95711. /**
  95712. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  95713. * Default value : false. The SPS is faster when it's set to false.
  95714. * Note : the particle custom vertex positions aren't stored values.
  95715. */
  95716. /**
  95717. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  95718. * Default value : false. The SPS is faster when it's set to false.
  95719. * Note : the particle custom vertex positions aren't stored values.
  95720. */
  95721. computeParticleVertex: boolean;
  95722. /**
  95723. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  95724. */
  95725. /**
  95726. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  95727. */
  95728. computeBoundingBox: boolean;
  95729. /**
  95730. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  95731. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  95732. * Default : `true`
  95733. */
  95734. /**
  95735. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  95736. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  95737. * Default : `true`
  95738. */
  95739. depthSortParticles: boolean;
  95740. /**
  95741. * Gets if the SPS is created as expandable at construction time.
  95742. * Default : `false`
  95743. */
  95744. readonly expandable: boolean;
  95745. /**
  95746. * Gets if the SPS supports the Multi Materials
  95747. */
  95748. readonly multimaterialEnabled: boolean;
  95749. /**
  95750. * Gets if the SPS uses the model materials for its own multimaterial.
  95751. */
  95752. readonly useModelMaterial: boolean;
  95753. /**
  95754. * The SPS used material array.
  95755. */
  95756. readonly materials: Material[];
  95757. /**
  95758. * Sets the SPS MultiMaterial from the passed materials.
  95759. * Note : the passed array is internally copied and not used then by reference.
  95760. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  95761. */
  95762. setMultiMaterial(materials: Material[]): void;
  95763. /**
  95764. * The SPS computed multimaterial object
  95765. */
  95766. multimaterial: MultiMaterial;
  95767. /**
  95768. * If the subMeshes must be updated on the next call to setParticles()
  95769. */
  95770. autoUpdateSubMeshes: boolean;
  95771. /**
  95772. * This function does nothing. It may be overwritten to set all the particle first values.
  95773. * The SPS doesn't call this function, you may have to call it by your own.
  95774. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95775. */
  95776. initParticles(): void;
  95777. /**
  95778. * This function does nothing. It may be overwritten to recycle a particle.
  95779. * The SPS doesn't call this function, you may have to call it by your own.
  95780. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95781. * @param particle The particle to recycle
  95782. * @returns the recycled particle
  95783. */
  95784. recycleParticle(particle: SolidParticle): SolidParticle;
  95785. /**
  95786. * Updates a particle : this function should be overwritten by the user.
  95787. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  95788. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95789. * @example : just set a particle position or velocity and recycle conditions
  95790. * @param particle The particle to update
  95791. * @returns the updated particle
  95792. */
  95793. updateParticle(particle: SolidParticle): SolidParticle;
  95794. /**
  95795. * Updates a vertex of a particle : it can be overwritten by the user.
  95796. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  95797. * @param particle the current particle
  95798. * @param vertex the current index of the current particle
  95799. * @param pt the index of the current vertex in the particle shape
  95800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  95801. * @example : just set a vertex particle position
  95802. * @returns the updated vertex
  95803. */
  95804. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  95805. /**
  95806. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  95807. * This does nothing and may be overwritten by the user.
  95808. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95809. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95810. * @param update the boolean update value actually passed to setParticles()
  95811. */
  95812. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  95813. /**
  95814. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  95815. * This will be passed three parameters.
  95816. * This does nothing and may be overwritten by the user.
  95817. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95818. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95819. * @param update the boolean update value actually passed to setParticles()
  95820. */
  95821. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  95822. }
  95823. }
  95824. declare module BABYLON {
  95825. /**
  95826. * Represents one particle of a solid particle system.
  95827. */
  95828. export class SolidParticle {
  95829. /**
  95830. * particle global index
  95831. */
  95832. idx: number;
  95833. /**
  95834. * particle identifier
  95835. */
  95836. id: number;
  95837. /**
  95838. * The color of the particle
  95839. */
  95840. color: Nullable<Color4>;
  95841. /**
  95842. * The world space position of the particle.
  95843. */
  95844. position: Vector3;
  95845. /**
  95846. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  95847. */
  95848. rotation: Vector3;
  95849. /**
  95850. * The world space rotation quaternion of the particle.
  95851. */
  95852. rotationQuaternion: Nullable<Quaternion>;
  95853. /**
  95854. * The scaling of the particle.
  95855. */
  95856. scaling: Vector3;
  95857. /**
  95858. * The uvs of the particle.
  95859. */
  95860. uvs: Vector4;
  95861. /**
  95862. * The current speed of the particle.
  95863. */
  95864. velocity: Vector3;
  95865. /**
  95866. * The pivot point in the particle local space.
  95867. */
  95868. pivot: Vector3;
  95869. /**
  95870. * Must the particle be translated from its pivot point in its local space ?
  95871. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  95872. * Default : false
  95873. */
  95874. translateFromPivot: boolean;
  95875. /**
  95876. * Is the particle active or not ?
  95877. */
  95878. alive: boolean;
  95879. /**
  95880. * Is the particle visible or not ?
  95881. */
  95882. isVisible: boolean;
  95883. /**
  95884. * Index of this particle in the global "positions" array (Internal use)
  95885. * @hidden
  95886. */
  95887. _pos: number;
  95888. /**
  95889. * @hidden Index of this particle in the global "indices" array (Internal use)
  95890. */
  95891. _ind: number;
  95892. /**
  95893. * @hidden ModelShape of this particle (Internal use)
  95894. */
  95895. _model: ModelShape;
  95896. /**
  95897. * ModelShape id of this particle
  95898. */
  95899. shapeId: number;
  95900. /**
  95901. * Index of the particle in its shape id
  95902. */
  95903. idxInShape: number;
  95904. /**
  95905. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  95906. */
  95907. _modelBoundingInfo: BoundingInfo;
  95908. /**
  95909. * @hidden Particle BoundingInfo object (Internal use)
  95910. */
  95911. _boundingInfo: BoundingInfo;
  95912. /**
  95913. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  95914. */
  95915. _sps: SolidParticleSystem;
  95916. /**
  95917. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  95918. */
  95919. _stillInvisible: boolean;
  95920. /**
  95921. * @hidden Last computed particle rotation matrix
  95922. */
  95923. _rotationMatrix: number[];
  95924. /**
  95925. * Parent particle Id, if any.
  95926. * Default null.
  95927. */
  95928. parentId: Nullable<number>;
  95929. /**
  95930. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  95931. */
  95932. materialIndex: Nullable<number>;
  95933. /**
  95934. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  95935. * The possible values are :
  95936. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  95937. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  95938. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  95939. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  95940. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  95941. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  95942. * */
  95943. cullingStrategy: number;
  95944. /**
  95945. * @hidden Internal global position in the SPS.
  95946. */
  95947. _globalPosition: Vector3;
  95948. /**
  95949. * Creates a Solid Particle object.
  95950. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  95951. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  95952. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  95953. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  95954. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  95955. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  95956. * @param shapeId (integer) is the model shape identifier in the SPS.
  95957. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  95958. * @param sps defines the sps it is associated to
  95959. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  95960. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  95961. */
  95962. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  95963. /**
  95964. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  95965. * @param target the particle target
  95966. * @returns the current particle
  95967. */
  95968. copyToRef(target: SolidParticle): SolidParticle;
  95969. /**
  95970. * Legacy support, changed scale to scaling
  95971. */
  95972. /**
  95973. * Legacy support, changed scale to scaling
  95974. */
  95975. scale: Vector3;
  95976. /**
  95977. * Legacy support, changed quaternion to rotationQuaternion
  95978. */
  95979. /**
  95980. * Legacy support, changed quaternion to rotationQuaternion
  95981. */
  95982. quaternion: Nullable<Quaternion>;
  95983. /**
  95984. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  95985. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  95986. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  95987. * @returns true if it intersects
  95988. */
  95989. intersectsMesh(target: Mesh | SolidParticle): boolean;
  95990. /**
  95991. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  95992. * A particle is in the frustum if its bounding box intersects the frustum
  95993. * @param frustumPlanes defines the frustum to test
  95994. * @returns true if the particle is in the frustum planes
  95995. */
  95996. isInFrustum(frustumPlanes: Plane[]): boolean;
  95997. /**
  95998. * get the rotation matrix of the particle
  95999. * @hidden
  96000. */
  96001. getRotationMatrix(m: Matrix): void;
  96002. }
  96003. /**
  96004. * Represents the shape of the model used by one particle of a solid particle system.
  96005. * SPS internal tool, don't use it manually.
  96006. */
  96007. export class ModelShape {
  96008. /**
  96009. * The shape id
  96010. * @hidden
  96011. */
  96012. shapeID: number;
  96013. /**
  96014. * flat array of model positions (internal use)
  96015. * @hidden
  96016. */
  96017. _shape: Vector3[];
  96018. /**
  96019. * flat array of model UVs (internal use)
  96020. * @hidden
  96021. */
  96022. _shapeUV: number[];
  96023. /**
  96024. * color array of the model
  96025. * @hidden
  96026. */
  96027. _shapeColors: number[];
  96028. /**
  96029. * indices array of the model
  96030. * @hidden
  96031. */
  96032. _indices: number[];
  96033. /**
  96034. * normals array of the model
  96035. * @hidden
  96036. */
  96037. _normals: number[];
  96038. /**
  96039. * length of the shape in the model indices array (internal use)
  96040. * @hidden
  96041. */
  96042. _indicesLength: number;
  96043. /**
  96044. * Custom position function (internal use)
  96045. * @hidden
  96046. */
  96047. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  96048. /**
  96049. * Custom vertex function (internal use)
  96050. * @hidden
  96051. */
  96052. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  96053. /**
  96054. * Model material (internal use)
  96055. * @hidden
  96056. */
  96057. _material: Nullable<Material>;
  96058. /**
  96059. * 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.
  96060. * SPS internal tool, don't use it manually.
  96061. * @hidden
  96062. */
  96063. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  96064. }
  96065. /**
  96066. * Represents a Depth Sorted Particle in the solid particle system.
  96067. * @hidden
  96068. */
  96069. export class DepthSortedParticle {
  96070. /**
  96071. * Index of the particle in the "indices" array
  96072. */
  96073. ind: number;
  96074. /**
  96075. * Length of the particle shape in the "indices" array
  96076. */
  96077. indicesLength: number;
  96078. /**
  96079. * Squared distance from the particle to the camera
  96080. */
  96081. sqDistance: number;
  96082. /**
  96083. * Material index when used with MultiMaterials
  96084. */
  96085. materialIndex: number;
  96086. /**
  96087. * Creates a new sorted particle
  96088. * @param materialIndex
  96089. */
  96090. constructor(ind: number, indLength: number, materialIndex: number);
  96091. }
  96092. }
  96093. declare module BABYLON {
  96094. /**
  96095. * @hidden
  96096. */
  96097. export class _MeshCollisionData {
  96098. _checkCollisions: boolean;
  96099. _collisionMask: number;
  96100. _collisionGroup: number;
  96101. _collider: Nullable<Collider>;
  96102. _oldPositionForCollisions: Vector3;
  96103. _diffPositionForCollisions: Vector3;
  96104. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  96105. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  96106. }
  96107. }
  96108. declare module BABYLON {
  96109. /** @hidden */
  96110. class _FacetDataStorage {
  96111. facetPositions: Vector3[];
  96112. facetNormals: Vector3[];
  96113. facetPartitioning: number[][];
  96114. facetNb: number;
  96115. partitioningSubdivisions: number;
  96116. partitioningBBoxRatio: number;
  96117. facetDataEnabled: boolean;
  96118. facetParameters: any;
  96119. bbSize: Vector3;
  96120. subDiv: {
  96121. max: number;
  96122. X: number;
  96123. Y: number;
  96124. Z: number;
  96125. };
  96126. facetDepthSort: boolean;
  96127. facetDepthSortEnabled: boolean;
  96128. depthSortedIndices: IndicesArray;
  96129. depthSortedFacets: {
  96130. ind: number;
  96131. sqDistance: number;
  96132. }[];
  96133. facetDepthSortFunction: (f1: {
  96134. ind: number;
  96135. sqDistance: number;
  96136. }, f2: {
  96137. ind: number;
  96138. sqDistance: number;
  96139. }) => number;
  96140. facetDepthSortFrom: Vector3;
  96141. facetDepthSortOrigin: Vector3;
  96142. invertedMatrix: Matrix;
  96143. }
  96144. /**
  96145. * @hidden
  96146. **/
  96147. class _InternalAbstractMeshDataInfo {
  96148. _hasVertexAlpha: boolean;
  96149. _useVertexColors: boolean;
  96150. _numBoneInfluencers: number;
  96151. _applyFog: boolean;
  96152. _receiveShadows: boolean;
  96153. _facetData: _FacetDataStorage;
  96154. _visibility: number;
  96155. _skeleton: Nullable<Skeleton>;
  96156. _layerMask: number;
  96157. _computeBonesUsingShaders: boolean;
  96158. _isActive: boolean;
  96159. _onlyForInstances: boolean;
  96160. _isActiveIntermediate: boolean;
  96161. _onlyForInstancesIntermediate: boolean;
  96162. _actAsRegularMesh: boolean;
  96163. }
  96164. /**
  96165. * Class used to store all common mesh properties
  96166. */
  96167. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  96168. /** No occlusion */
  96169. static OCCLUSION_TYPE_NONE: number;
  96170. /** Occlusion set to optimisitic */
  96171. static OCCLUSION_TYPE_OPTIMISTIC: number;
  96172. /** Occlusion set to strict */
  96173. static OCCLUSION_TYPE_STRICT: number;
  96174. /** Use an accurante occlusion algorithm */
  96175. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  96176. /** Use a conservative occlusion algorithm */
  96177. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  96178. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  96179. * Test order :
  96180. * Is the bounding sphere outside the frustum ?
  96181. * If not, are the bounding box vertices outside the frustum ?
  96182. * It not, then the cullable object is in the frustum.
  96183. */
  96184. static readonly CULLINGSTRATEGY_STANDARD: number;
  96185. /** Culling strategy : Bounding Sphere Only.
  96186. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  96187. * It's also less accurate than the standard because some not visible objects can still be selected.
  96188. * Test : is the bounding sphere outside the frustum ?
  96189. * If not, then the cullable object is in the frustum.
  96190. */
  96191. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  96192. /** Culling strategy : Optimistic Inclusion.
  96193. * This in an inclusion test first, then the standard exclusion test.
  96194. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  96195. * 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.
  96196. * Anyway, it's as accurate as the standard strategy.
  96197. * Test :
  96198. * Is the cullable object bounding sphere center in the frustum ?
  96199. * If not, apply the default culling strategy.
  96200. */
  96201. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  96202. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  96203. * This in an inclusion test first, then the bounding sphere only exclusion test.
  96204. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  96205. * 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.
  96206. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  96207. * Test :
  96208. * Is the cullable object bounding sphere center in the frustum ?
  96209. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  96210. */
  96211. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  96212. /**
  96213. * No billboard
  96214. */
  96215. static readonly BILLBOARDMODE_NONE: number;
  96216. /** Billboard on X axis */
  96217. static readonly BILLBOARDMODE_X: number;
  96218. /** Billboard on Y axis */
  96219. static readonly BILLBOARDMODE_Y: number;
  96220. /** Billboard on Z axis */
  96221. static readonly BILLBOARDMODE_Z: number;
  96222. /** Billboard on all axes */
  96223. static readonly BILLBOARDMODE_ALL: number;
  96224. /** Billboard on using position instead of orientation */
  96225. static readonly BILLBOARDMODE_USE_POSITION: number;
  96226. /** @hidden */
  96227. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  96228. /**
  96229. * The culling strategy to use to check whether the mesh must be rendered or not.
  96230. * This value can be changed at any time and will be used on the next render mesh selection.
  96231. * The possible values are :
  96232. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96233. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96234. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96235. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96236. * Please read each static variable documentation to get details about the culling process.
  96237. * */
  96238. cullingStrategy: number;
  96239. /**
  96240. * Gets the number of facets in the mesh
  96241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96242. */
  96243. readonly facetNb: number;
  96244. /**
  96245. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  96246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96247. */
  96248. partitioningSubdivisions: number;
  96249. /**
  96250. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  96251. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  96252. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96253. */
  96254. partitioningBBoxRatio: number;
  96255. /**
  96256. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  96257. * Works only for updatable meshes.
  96258. * Doesn't work with multi-materials
  96259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96260. */
  96261. mustDepthSortFacets: boolean;
  96262. /**
  96263. * The location (Vector3) where the facet depth sort must be computed from.
  96264. * By default, the active camera position.
  96265. * Used only when facet depth sort is enabled
  96266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96267. */
  96268. facetDepthSortFrom: Vector3;
  96269. /**
  96270. * gets a boolean indicating if facetData is enabled
  96271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96272. */
  96273. readonly isFacetDataEnabled: boolean;
  96274. /** @hidden */
  96275. _updateNonUniformScalingState(value: boolean): boolean;
  96276. /**
  96277. * An event triggered when this mesh collides with another one
  96278. */
  96279. onCollideObservable: Observable<AbstractMesh>;
  96280. /** Set a function to call when this mesh collides with another one */
  96281. onCollide: () => void;
  96282. /**
  96283. * An event triggered when the collision's position changes
  96284. */
  96285. onCollisionPositionChangeObservable: Observable<Vector3>;
  96286. /** Set a function to call when the collision's position changes */
  96287. onCollisionPositionChange: () => void;
  96288. /**
  96289. * An event triggered when material is changed
  96290. */
  96291. onMaterialChangedObservable: Observable<AbstractMesh>;
  96292. /**
  96293. * Gets or sets the orientation for POV movement & rotation
  96294. */
  96295. definedFacingForward: boolean;
  96296. /** @hidden */
  96297. _occlusionQuery: Nullable<WebGLQuery>;
  96298. /** @hidden */
  96299. _renderingGroup: Nullable<RenderingGroup>;
  96300. /**
  96301. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96302. */
  96303. /**
  96304. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96305. */
  96306. visibility: number;
  96307. /** Gets or sets the alpha index used to sort transparent meshes
  96308. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  96309. */
  96310. alphaIndex: number;
  96311. /**
  96312. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  96313. */
  96314. isVisible: boolean;
  96315. /**
  96316. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  96317. */
  96318. isPickable: boolean;
  96319. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  96320. showSubMeshesBoundingBox: boolean;
  96321. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  96322. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  96323. */
  96324. isBlocker: boolean;
  96325. /**
  96326. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  96327. */
  96328. enablePointerMoveEvents: boolean;
  96329. /**
  96330. * Specifies the rendering group id for this mesh (0 by default)
  96331. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  96332. */
  96333. renderingGroupId: number;
  96334. private _material;
  96335. /** Gets or sets current material */
  96336. material: Nullable<Material>;
  96337. /**
  96338. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  96339. * @see http://doc.babylonjs.com/babylon101/shadows
  96340. */
  96341. receiveShadows: boolean;
  96342. /** Defines color to use when rendering outline */
  96343. outlineColor: Color3;
  96344. /** Define width to use when rendering outline */
  96345. outlineWidth: number;
  96346. /** Defines color to use when rendering overlay */
  96347. overlayColor: Color3;
  96348. /** Defines alpha to use when rendering overlay */
  96349. overlayAlpha: number;
  96350. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  96351. hasVertexAlpha: boolean;
  96352. /** 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) */
  96353. useVertexColors: boolean;
  96354. /**
  96355. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  96356. */
  96357. computeBonesUsingShaders: boolean;
  96358. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  96359. numBoneInfluencers: number;
  96360. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  96361. applyFog: boolean;
  96362. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  96363. useOctreeForRenderingSelection: boolean;
  96364. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  96365. useOctreeForPicking: boolean;
  96366. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  96367. useOctreeForCollisions: boolean;
  96368. /**
  96369. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  96370. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  96371. */
  96372. layerMask: number;
  96373. /**
  96374. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  96375. */
  96376. alwaysSelectAsActiveMesh: boolean;
  96377. /**
  96378. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  96379. */
  96380. doNotSyncBoundingInfo: boolean;
  96381. /**
  96382. * Gets or sets the current action manager
  96383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96384. */
  96385. actionManager: Nullable<AbstractActionManager>;
  96386. private _meshCollisionData;
  96387. /**
  96388. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  96389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96390. */
  96391. ellipsoid: Vector3;
  96392. /**
  96393. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  96394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96395. */
  96396. ellipsoidOffset: Vector3;
  96397. /**
  96398. * Gets or sets a collision mask used to mask collisions (default is -1).
  96399. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96400. */
  96401. collisionMask: number;
  96402. /**
  96403. * Gets or sets the current collision group mask (-1 by default).
  96404. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96405. */
  96406. collisionGroup: number;
  96407. /**
  96408. * Defines edge width used when edgesRenderer is enabled
  96409. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96410. */
  96411. edgesWidth: number;
  96412. /**
  96413. * Defines edge color used when edgesRenderer is enabled
  96414. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96415. */
  96416. edgesColor: Color4;
  96417. /** @hidden */
  96418. _edgesRenderer: Nullable<IEdgesRenderer>;
  96419. /** @hidden */
  96420. _masterMesh: Nullable<AbstractMesh>;
  96421. /** @hidden */
  96422. _boundingInfo: Nullable<BoundingInfo>;
  96423. /** @hidden */
  96424. _renderId: number;
  96425. /**
  96426. * Gets or sets the list of subMeshes
  96427. * @see http://doc.babylonjs.com/how_to/multi_materials
  96428. */
  96429. subMeshes: SubMesh[];
  96430. /** @hidden */
  96431. _intersectionsInProgress: AbstractMesh[];
  96432. /** @hidden */
  96433. _unIndexed: boolean;
  96434. /** @hidden */
  96435. _lightSources: Light[];
  96436. /** Gets the list of lights affecting that mesh */
  96437. readonly lightSources: Light[];
  96438. /** @hidden */
  96439. readonly _positions: Nullable<Vector3[]>;
  96440. /** @hidden */
  96441. _waitingData: {
  96442. lods: Nullable<any>;
  96443. actions: Nullable<any>;
  96444. freezeWorldMatrix: Nullable<boolean>;
  96445. };
  96446. /** @hidden */
  96447. _bonesTransformMatrices: Nullable<Float32Array>;
  96448. /** @hidden */
  96449. _transformMatrixTexture: Nullable<RawTexture>;
  96450. /**
  96451. * Gets or sets a skeleton to apply skining transformations
  96452. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96453. */
  96454. skeleton: Nullable<Skeleton>;
  96455. /**
  96456. * An event triggered when the mesh is rebuilt.
  96457. */
  96458. onRebuildObservable: Observable<AbstractMesh>;
  96459. /**
  96460. * Creates a new AbstractMesh
  96461. * @param name defines the name of the mesh
  96462. * @param scene defines the hosting scene
  96463. */
  96464. constructor(name: string, scene?: Nullable<Scene>);
  96465. /**
  96466. * Returns the string "AbstractMesh"
  96467. * @returns "AbstractMesh"
  96468. */
  96469. getClassName(): string;
  96470. /**
  96471. * Gets a string representation of the current mesh
  96472. * @param fullDetails defines a boolean indicating if full details must be included
  96473. * @returns a string representation of the current mesh
  96474. */
  96475. toString(fullDetails?: boolean): string;
  96476. /**
  96477. * @hidden
  96478. */
  96479. protected _getEffectiveParent(): Nullable<Node>;
  96480. /** @hidden */
  96481. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  96482. /** @hidden */
  96483. _rebuild(): void;
  96484. /** @hidden */
  96485. _resyncLightSources(): void;
  96486. /** @hidden */
  96487. _resyncLightSource(light: Light): void;
  96488. /** @hidden */
  96489. _unBindEffect(): void;
  96490. /** @hidden */
  96491. _removeLightSource(light: Light, dispose: boolean): void;
  96492. private _markSubMeshesAsDirty;
  96493. /** @hidden */
  96494. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  96495. /** @hidden */
  96496. _markSubMeshesAsAttributesDirty(): void;
  96497. /** @hidden */
  96498. _markSubMeshesAsMiscDirty(): void;
  96499. /**
  96500. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  96501. */
  96502. scaling: Vector3;
  96503. /**
  96504. * Returns true if the mesh is blocked. Implemented by child classes
  96505. */
  96506. readonly isBlocked: boolean;
  96507. /**
  96508. * Returns the mesh itself by default. Implemented by child classes
  96509. * @param camera defines the camera to use to pick the right LOD level
  96510. * @returns the currentAbstractMesh
  96511. */
  96512. getLOD(camera: Camera): Nullable<AbstractMesh>;
  96513. /**
  96514. * Returns 0 by default. Implemented by child classes
  96515. * @returns an integer
  96516. */
  96517. getTotalVertices(): number;
  96518. /**
  96519. * Returns a positive integer : the total number of indices in this mesh geometry.
  96520. * @returns the numner of indices or zero if the mesh has no geometry.
  96521. */
  96522. getTotalIndices(): number;
  96523. /**
  96524. * Returns null by default. Implemented by child classes
  96525. * @returns null
  96526. */
  96527. getIndices(): Nullable<IndicesArray>;
  96528. /**
  96529. * Returns the array of the requested vertex data kind. Implemented by child classes
  96530. * @param kind defines the vertex data kind to use
  96531. * @returns null
  96532. */
  96533. getVerticesData(kind: string): Nullable<FloatArray>;
  96534. /**
  96535. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96536. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96537. * Note that a new underlying VertexBuffer object is created each call.
  96538. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96539. * @param kind defines vertex data kind:
  96540. * * VertexBuffer.PositionKind
  96541. * * VertexBuffer.UVKind
  96542. * * VertexBuffer.UV2Kind
  96543. * * VertexBuffer.UV3Kind
  96544. * * VertexBuffer.UV4Kind
  96545. * * VertexBuffer.UV5Kind
  96546. * * VertexBuffer.UV6Kind
  96547. * * VertexBuffer.ColorKind
  96548. * * VertexBuffer.MatricesIndicesKind
  96549. * * VertexBuffer.MatricesIndicesExtraKind
  96550. * * VertexBuffer.MatricesWeightsKind
  96551. * * VertexBuffer.MatricesWeightsExtraKind
  96552. * @param data defines the data source
  96553. * @param updatable defines if the data must be flagged as updatable (or static)
  96554. * @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
  96555. * @returns the current mesh
  96556. */
  96557. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96558. /**
  96559. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96560. * If the mesh has no geometry, it is simply returned as it is.
  96561. * @param kind defines vertex data kind:
  96562. * * VertexBuffer.PositionKind
  96563. * * VertexBuffer.UVKind
  96564. * * VertexBuffer.UV2Kind
  96565. * * VertexBuffer.UV3Kind
  96566. * * VertexBuffer.UV4Kind
  96567. * * VertexBuffer.UV5Kind
  96568. * * VertexBuffer.UV6Kind
  96569. * * VertexBuffer.ColorKind
  96570. * * VertexBuffer.MatricesIndicesKind
  96571. * * VertexBuffer.MatricesIndicesExtraKind
  96572. * * VertexBuffer.MatricesWeightsKind
  96573. * * VertexBuffer.MatricesWeightsExtraKind
  96574. * @param data defines the data source
  96575. * @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
  96576. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  96577. * @returns the current mesh
  96578. */
  96579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  96580. /**
  96581. * Sets the mesh indices,
  96582. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96583. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  96584. * @param totalVertices Defines the total number of vertices
  96585. * @returns the current mesh
  96586. */
  96587. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  96588. /**
  96589. * Gets a boolean indicating if specific vertex data is present
  96590. * @param kind defines the vertex data kind to use
  96591. * @returns true is data kind is present
  96592. */
  96593. isVerticesDataPresent(kind: string): boolean;
  96594. /**
  96595. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  96596. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  96597. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  96598. * @returns a BoundingInfo
  96599. */
  96600. getBoundingInfo(): BoundingInfo;
  96601. /**
  96602. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  96603. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  96604. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  96605. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96606. * @returns the current mesh
  96607. */
  96608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  96609. /**
  96610. * Overwrite the current bounding info
  96611. * @param boundingInfo defines the new bounding info
  96612. * @returns the current mesh
  96613. */
  96614. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  96615. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  96616. readonly useBones: boolean;
  96617. /** @hidden */
  96618. _preActivate(): void;
  96619. /** @hidden */
  96620. _preActivateForIntermediateRendering(renderId: number): void;
  96621. /** @hidden */
  96622. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96623. /** @hidden */
  96624. _postActivate(): void;
  96625. /** @hidden */
  96626. _freeze(): void;
  96627. /** @hidden */
  96628. _unFreeze(): void;
  96629. /**
  96630. * Gets the current world matrix
  96631. * @returns a Matrix
  96632. */
  96633. getWorldMatrix(): Matrix;
  96634. /** @hidden */
  96635. _getWorldMatrixDeterminant(): number;
  96636. /**
  96637. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  96638. */
  96639. readonly isAnInstance: boolean;
  96640. /**
  96641. * Gets a boolean indicating if this mesh has instances
  96642. */
  96643. readonly hasInstances: boolean;
  96644. /**
  96645. * Perform relative position change from the point of view of behind the front of the mesh.
  96646. * This is performed taking into account the meshes current rotation, so you do not have to care.
  96647. * Supports definition of mesh facing forward or backward
  96648. * @param amountRight defines the distance on the right axis
  96649. * @param amountUp defines the distance on the up axis
  96650. * @param amountForward defines the distance on the forward axis
  96651. * @returns the current mesh
  96652. */
  96653. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  96654. /**
  96655. * Calculate relative position change from the point of view of behind the front of the mesh.
  96656. * This is performed taking into account the meshes current rotation, so you do not have to care.
  96657. * Supports definition of mesh facing forward or backward
  96658. * @param amountRight defines the distance on the right axis
  96659. * @param amountUp defines the distance on the up axis
  96660. * @param amountForward defines the distance on the forward axis
  96661. * @returns the new displacement vector
  96662. */
  96663. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  96664. /**
  96665. * Perform relative rotation change from the point of view of behind the front of the mesh.
  96666. * Supports definition of mesh facing forward or backward
  96667. * @param flipBack defines the flip
  96668. * @param twirlClockwise defines the twirl
  96669. * @param tiltRight defines the tilt
  96670. * @returns the current mesh
  96671. */
  96672. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  96673. /**
  96674. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  96675. * Supports definition of mesh facing forward or backward.
  96676. * @param flipBack defines the flip
  96677. * @param twirlClockwise defines the twirl
  96678. * @param tiltRight defines the tilt
  96679. * @returns the new rotation vector
  96680. */
  96681. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  96682. /**
  96683. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96684. * This means the mesh underlying bounding box and sphere are recomputed.
  96685. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96686. * @returns the current mesh
  96687. */
  96688. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  96689. /** @hidden */
  96690. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  96691. /** @hidden */
  96692. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  96693. /** @hidden */
  96694. _updateBoundingInfo(): AbstractMesh;
  96695. /** @hidden */
  96696. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  96697. /** @hidden */
  96698. protected _afterComputeWorldMatrix(): void;
  96699. /** @hidden */
  96700. readonly _effectiveMesh: AbstractMesh;
  96701. /**
  96702. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  96703. * A mesh is in the frustum if its bounding box intersects the frustum
  96704. * @param frustumPlanes defines the frustum to test
  96705. * @returns true if the mesh is in the frustum planes
  96706. */
  96707. isInFrustum(frustumPlanes: Plane[]): boolean;
  96708. /**
  96709. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  96710. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  96711. * @param frustumPlanes defines the frustum to test
  96712. * @returns true if the mesh is completely in the frustum planes
  96713. */
  96714. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96715. /**
  96716. * True if the mesh intersects another mesh or a SolidParticle object
  96717. * @param mesh defines a target mesh or SolidParticle to test
  96718. * @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)
  96719. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  96720. * @returns true if there is an intersection
  96721. */
  96722. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  96723. /**
  96724. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  96725. * @param point defines the point to test
  96726. * @returns true if there is an intersection
  96727. */
  96728. intersectsPoint(point: Vector3): boolean;
  96729. /**
  96730. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  96731. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96732. */
  96733. checkCollisions: boolean;
  96734. /**
  96735. * Gets Collider object used to compute collisions (not physics)
  96736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96737. */
  96738. readonly collider: Nullable<Collider>;
  96739. /**
  96740. * Move the mesh using collision engine
  96741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96742. * @param displacement defines the requested displacement vector
  96743. * @returns the current mesh
  96744. */
  96745. moveWithCollisions(displacement: Vector3): AbstractMesh;
  96746. private _onCollisionPositionChange;
  96747. /** @hidden */
  96748. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  96749. /** @hidden */
  96750. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  96751. /** @hidden */
  96752. _checkCollision(collider: Collider): AbstractMesh;
  96753. /** @hidden */
  96754. _generatePointsArray(): boolean;
  96755. /**
  96756. * Checks if the passed Ray intersects with the mesh
  96757. * @param ray defines the ray to use
  96758. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  96759. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96760. * @returns the picking info
  96761. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  96762. */
  96763. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  96764. /**
  96765. * Clones the current mesh
  96766. * @param name defines the mesh name
  96767. * @param newParent defines the new mesh parent
  96768. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  96769. * @returns the new mesh
  96770. */
  96771. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  96772. /**
  96773. * Disposes all the submeshes of the current meshnp
  96774. * @returns the current mesh
  96775. */
  96776. releaseSubMeshes(): AbstractMesh;
  96777. /**
  96778. * Releases resources associated with this abstract mesh.
  96779. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96780. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96781. */
  96782. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96783. /**
  96784. * Adds the passed mesh as a child to the current mesh
  96785. * @param mesh defines the child mesh
  96786. * @returns the current mesh
  96787. */
  96788. addChild(mesh: AbstractMesh): AbstractMesh;
  96789. /**
  96790. * Removes the passed mesh from the current mesh children list
  96791. * @param mesh defines the child mesh
  96792. * @returns the current mesh
  96793. */
  96794. removeChild(mesh: AbstractMesh): AbstractMesh;
  96795. /** @hidden */
  96796. private _initFacetData;
  96797. /**
  96798. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  96799. * This method can be called within the render loop.
  96800. * 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
  96801. * @returns the current mesh
  96802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96803. */
  96804. updateFacetData(): AbstractMesh;
  96805. /**
  96806. * Returns the facetLocalNormals array.
  96807. * The normals are expressed in the mesh local spac
  96808. * @returns an array of Vector3
  96809. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96810. */
  96811. getFacetLocalNormals(): Vector3[];
  96812. /**
  96813. * Returns the facetLocalPositions array.
  96814. * The facet positions are expressed in the mesh local space
  96815. * @returns an array of Vector3
  96816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96817. */
  96818. getFacetLocalPositions(): Vector3[];
  96819. /**
  96820. * Returns the facetLocalPartioning array
  96821. * @returns an array of array of numbers
  96822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96823. */
  96824. getFacetLocalPartitioning(): number[][];
  96825. /**
  96826. * Returns the i-th facet position in the world system.
  96827. * This method allocates a new Vector3 per call
  96828. * @param i defines the facet index
  96829. * @returns a new Vector3
  96830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96831. */
  96832. getFacetPosition(i: number): Vector3;
  96833. /**
  96834. * Sets the reference Vector3 with the i-th facet position in the world system
  96835. * @param i defines the facet index
  96836. * @param ref defines the target vector
  96837. * @returns the current mesh
  96838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96839. */
  96840. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  96841. /**
  96842. * Returns the i-th facet normal in the world system.
  96843. * This method allocates a new Vector3 per call
  96844. * @param i defines the facet index
  96845. * @returns a new Vector3
  96846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96847. */
  96848. getFacetNormal(i: number): Vector3;
  96849. /**
  96850. * Sets the reference Vector3 with the i-th facet normal in the world system
  96851. * @param i defines the facet index
  96852. * @param ref defines the target vector
  96853. * @returns the current mesh
  96854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96855. */
  96856. getFacetNormalToRef(i: number, ref: Vector3): this;
  96857. /**
  96858. * 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)
  96859. * @param x defines x coordinate
  96860. * @param y defines y coordinate
  96861. * @param z defines z coordinate
  96862. * @returns the array of facet indexes
  96863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96864. */
  96865. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  96866. /**
  96867. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  96868. * @param projected sets as the (x,y,z) world projection on the facet
  96869. * @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
  96870. * @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
  96871. * @param x defines x coordinate
  96872. * @param y defines y coordinate
  96873. * @param z defines z coordinate
  96874. * @returns the face index if found (or null instead)
  96875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96876. */
  96877. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  96878. /**
  96879. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  96880. * @param projected sets as the (x,y,z) local projection on the facet
  96881. * @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
  96882. * @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
  96883. * @param x defines x coordinate
  96884. * @param y defines y coordinate
  96885. * @param z defines z coordinate
  96886. * @returns the face index if found (or null instead)
  96887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96888. */
  96889. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  96890. /**
  96891. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  96892. * @returns the parameters
  96893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96894. */
  96895. getFacetDataParameters(): any;
  96896. /**
  96897. * Disables the feature FacetData and frees the related memory
  96898. * @returns the current mesh
  96899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96900. */
  96901. disableFacetData(): AbstractMesh;
  96902. /**
  96903. * Updates the AbstractMesh indices array
  96904. * @param indices defines the data source
  96905. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  96906. * @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)
  96907. * @returns the current mesh
  96908. */
  96909. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  96910. /**
  96911. * Creates new normals data for the mesh
  96912. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  96913. * @returns the current mesh
  96914. */
  96915. createNormals(updatable: boolean): AbstractMesh;
  96916. /**
  96917. * Align the mesh with a normal
  96918. * @param normal defines the normal to use
  96919. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  96920. * @returns the current mesh
  96921. */
  96922. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  96923. /** @hidden */
  96924. _checkOcclusionQuery(): boolean;
  96925. /**
  96926. * Disables the mesh edge rendering mode
  96927. * @returns the currentAbstractMesh
  96928. */
  96929. disableEdgesRendering(): AbstractMesh;
  96930. /**
  96931. * Enables the edge rendering mode on the mesh.
  96932. * This mode makes the mesh edges visible
  96933. * @param epsilon defines the maximal distance between two angles to detect a face
  96934. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96935. * @returns the currentAbstractMesh
  96936. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96937. */
  96938. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96939. }
  96940. }
  96941. declare module BABYLON {
  96942. /**
  96943. * Interface used to define ActionEvent
  96944. */
  96945. export interface IActionEvent {
  96946. /** The mesh or sprite that triggered the action */
  96947. source: any;
  96948. /** The X mouse cursor position at the time of the event */
  96949. pointerX: number;
  96950. /** The Y mouse cursor position at the time of the event */
  96951. pointerY: number;
  96952. /** The mesh that is currently pointed at (can be null) */
  96953. meshUnderPointer: Nullable<AbstractMesh>;
  96954. /** the original (browser) event that triggered the ActionEvent */
  96955. sourceEvent?: any;
  96956. /** additional data for the event */
  96957. additionalData?: any;
  96958. }
  96959. /**
  96960. * ActionEvent is the event being sent when an action is triggered.
  96961. */
  96962. export class ActionEvent implements IActionEvent {
  96963. /** The mesh or sprite that triggered the action */
  96964. source: any;
  96965. /** The X mouse cursor position at the time of the event */
  96966. pointerX: number;
  96967. /** The Y mouse cursor position at the time of the event */
  96968. pointerY: number;
  96969. /** The mesh that is currently pointed at (can be null) */
  96970. meshUnderPointer: Nullable<AbstractMesh>;
  96971. /** the original (browser) event that triggered the ActionEvent */
  96972. sourceEvent?: any;
  96973. /** additional data for the event */
  96974. additionalData?: any;
  96975. /**
  96976. * Creates a new ActionEvent
  96977. * @param source The mesh or sprite that triggered the action
  96978. * @param pointerX The X mouse cursor position at the time of the event
  96979. * @param pointerY The Y mouse cursor position at the time of the event
  96980. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  96981. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  96982. * @param additionalData additional data for the event
  96983. */
  96984. constructor(
  96985. /** The mesh or sprite that triggered the action */
  96986. source: any,
  96987. /** The X mouse cursor position at the time of the event */
  96988. pointerX: number,
  96989. /** The Y mouse cursor position at the time of the event */
  96990. pointerY: number,
  96991. /** The mesh that is currently pointed at (can be null) */
  96992. meshUnderPointer: Nullable<AbstractMesh>,
  96993. /** the original (browser) event that triggered the ActionEvent */
  96994. sourceEvent?: any,
  96995. /** additional data for the event */
  96996. additionalData?: any);
  96997. /**
  96998. * Helper function to auto-create an ActionEvent from a source mesh.
  96999. * @param source The source mesh that triggered the event
  97000. * @param evt The original (browser) event
  97001. * @param additionalData additional data for the event
  97002. * @returns the new ActionEvent
  97003. */
  97004. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  97005. /**
  97006. * Helper function to auto-create an ActionEvent from a source sprite
  97007. * @param source The source sprite that triggered the event
  97008. * @param scene Scene associated with the sprite
  97009. * @param evt The original (browser) event
  97010. * @param additionalData additional data for the event
  97011. * @returns the new ActionEvent
  97012. */
  97013. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  97014. /**
  97015. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  97016. * @param scene the scene where the event occurred
  97017. * @param evt The original (browser) event
  97018. * @returns the new ActionEvent
  97019. */
  97020. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  97021. /**
  97022. * Helper function to auto-create an ActionEvent from a primitive
  97023. * @param prim defines the target primitive
  97024. * @param pointerPos defines the pointer position
  97025. * @param evt The original (browser) event
  97026. * @param additionalData additional data for the event
  97027. * @returns the new ActionEvent
  97028. */
  97029. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  97030. }
  97031. }
  97032. declare module BABYLON {
  97033. /**
  97034. * Abstract class used to decouple action Manager from scene and meshes.
  97035. * Do not instantiate.
  97036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97037. */
  97038. export abstract class AbstractActionManager implements IDisposable {
  97039. /** Gets the list of active triggers */
  97040. static Triggers: {
  97041. [key: string]: number;
  97042. };
  97043. /** Gets the cursor to use when hovering items */
  97044. hoverCursor: string;
  97045. /** Gets the list of actions */
  97046. actions: IAction[];
  97047. /**
  97048. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  97049. */
  97050. isRecursive: boolean;
  97051. /**
  97052. * Releases all associated resources
  97053. */
  97054. abstract dispose(): void;
  97055. /**
  97056. * Does this action manager has pointer triggers
  97057. */
  97058. abstract readonly hasPointerTriggers: boolean;
  97059. /**
  97060. * Does this action manager has pick triggers
  97061. */
  97062. abstract readonly hasPickTriggers: boolean;
  97063. /**
  97064. * Process a specific trigger
  97065. * @param trigger defines the trigger to process
  97066. * @param evt defines the event details to be processed
  97067. */
  97068. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  97069. /**
  97070. * Does this action manager handles actions of any of the given triggers
  97071. * @param triggers defines the triggers to be tested
  97072. * @return a boolean indicating whether one (or more) of the triggers is handled
  97073. */
  97074. abstract hasSpecificTriggers(triggers: number[]): boolean;
  97075. /**
  97076. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  97077. * speed.
  97078. * @param triggerA defines the trigger to be tested
  97079. * @param triggerB defines the trigger to be tested
  97080. * @return a boolean indicating whether one (or more) of the triggers is handled
  97081. */
  97082. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  97083. /**
  97084. * Does this action manager handles actions of a given trigger
  97085. * @param trigger defines the trigger to be tested
  97086. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  97087. * @return whether the trigger is handled
  97088. */
  97089. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  97090. /**
  97091. * Serialize this manager to a JSON object
  97092. * @param name defines the property name to store this manager
  97093. * @returns a JSON representation of this manager
  97094. */
  97095. abstract serialize(name: string): any;
  97096. /**
  97097. * Registers an action to this action manager
  97098. * @param action defines the action to be registered
  97099. * @return the action amended (prepared) after registration
  97100. */
  97101. abstract registerAction(action: IAction): Nullable<IAction>;
  97102. /**
  97103. * Unregisters an action to this action manager
  97104. * @param action defines the action to be unregistered
  97105. * @return a boolean indicating whether the action has been unregistered
  97106. */
  97107. abstract unregisterAction(action: IAction): Boolean;
  97108. /**
  97109. * Does exist one action manager with at least one trigger
  97110. **/
  97111. static readonly HasTriggers: boolean;
  97112. /**
  97113. * Does exist one action manager with at least one pick trigger
  97114. **/
  97115. static readonly HasPickTriggers: boolean;
  97116. /**
  97117. * Does exist one action manager that handles actions of a given trigger
  97118. * @param trigger defines the trigger to be tested
  97119. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  97120. **/
  97121. static HasSpecificTrigger(trigger: number): boolean;
  97122. }
  97123. }
  97124. declare module BABYLON {
  97125. /**
  97126. * Defines how a node can be built from a string name.
  97127. */
  97128. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  97129. /**
  97130. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  97131. */
  97132. export class Node implements IBehaviorAware<Node> {
  97133. /** @hidden */
  97134. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  97135. private static _NodeConstructors;
  97136. /**
  97137. * Add a new node constructor
  97138. * @param type defines the type name of the node to construct
  97139. * @param constructorFunc defines the constructor function
  97140. */
  97141. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  97142. /**
  97143. * Returns a node constructor based on type name
  97144. * @param type defines the type name
  97145. * @param name defines the new node name
  97146. * @param scene defines the hosting scene
  97147. * @param options defines optional options to transmit to constructors
  97148. * @returns the new constructor or null
  97149. */
  97150. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  97151. /**
  97152. * Gets or sets the name of the node
  97153. */
  97154. name: string;
  97155. /**
  97156. * Gets or sets the id of the node
  97157. */
  97158. id: string;
  97159. /**
  97160. * Gets or sets the unique id of the node
  97161. */
  97162. uniqueId: number;
  97163. /**
  97164. * Gets or sets a string used to store user defined state for the node
  97165. */
  97166. state: string;
  97167. /**
  97168. * Gets or sets an object used to store user defined information for the node
  97169. */
  97170. metadata: any;
  97171. /**
  97172. * For internal use only. Please do not use.
  97173. */
  97174. reservedDataStore: any;
  97175. /**
  97176. * List of inspectable custom properties (used by the Inspector)
  97177. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97178. */
  97179. inspectableCustomProperties: IInspectable[];
  97180. private _doNotSerialize;
  97181. /**
  97182. * Gets or sets a boolean used to define if the node must be serialized
  97183. */
  97184. doNotSerialize: boolean;
  97185. /** @hidden */
  97186. _isDisposed: boolean;
  97187. /**
  97188. * Gets a list of Animations associated with the node
  97189. */
  97190. animations: Animation[];
  97191. protected _ranges: {
  97192. [name: string]: Nullable<AnimationRange>;
  97193. };
  97194. /**
  97195. * Callback raised when the node is ready to be used
  97196. */
  97197. onReady: Nullable<(node: Node) => void>;
  97198. private _isEnabled;
  97199. private _isParentEnabled;
  97200. private _isReady;
  97201. /** @hidden */
  97202. _currentRenderId: number;
  97203. private _parentUpdateId;
  97204. /** @hidden */
  97205. _childUpdateId: number;
  97206. /** @hidden */
  97207. _waitingParentId: Nullable<string>;
  97208. /** @hidden */
  97209. _scene: Scene;
  97210. /** @hidden */
  97211. _cache: any;
  97212. private _parentNode;
  97213. private _children;
  97214. /** @hidden */
  97215. _worldMatrix: Matrix;
  97216. /** @hidden */
  97217. _worldMatrixDeterminant: number;
  97218. /** @hidden */
  97219. _worldMatrixDeterminantIsDirty: boolean;
  97220. /** @hidden */
  97221. private _sceneRootNodesIndex;
  97222. /**
  97223. * Gets a boolean indicating if the node has been disposed
  97224. * @returns true if the node was disposed
  97225. */
  97226. isDisposed(): boolean;
  97227. /**
  97228. * Gets or sets the parent of the node (without keeping the current position in the scene)
  97229. * @see https://doc.babylonjs.com/how_to/parenting
  97230. */
  97231. parent: Nullable<Node>;
  97232. /** @hidden */
  97233. _addToSceneRootNodes(): void;
  97234. /** @hidden */
  97235. _removeFromSceneRootNodes(): void;
  97236. private _animationPropertiesOverride;
  97237. /**
  97238. * Gets or sets the animation properties override
  97239. */
  97240. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97241. /**
  97242. * Gets a string idenfifying the name of the class
  97243. * @returns "Node" string
  97244. */
  97245. getClassName(): string;
  97246. /** @hidden */
  97247. readonly _isNode: boolean;
  97248. /**
  97249. * An event triggered when the mesh is disposed
  97250. */
  97251. onDisposeObservable: Observable<Node>;
  97252. private _onDisposeObserver;
  97253. /**
  97254. * Sets a callback that will be raised when the node will be disposed
  97255. */
  97256. onDispose: () => void;
  97257. /**
  97258. * Creates a new Node
  97259. * @param name the name and id to be given to this node
  97260. * @param scene the scene this node will be added to
  97261. */
  97262. constructor(name: string, scene?: Nullable<Scene>);
  97263. /**
  97264. * Gets the scene of the node
  97265. * @returns a scene
  97266. */
  97267. getScene(): Scene;
  97268. /**
  97269. * Gets the engine of the node
  97270. * @returns a Engine
  97271. */
  97272. getEngine(): Engine;
  97273. private _behaviors;
  97274. /**
  97275. * Attach a behavior to the node
  97276. * @see http://doc.babylonjs.com/features/behaviour
  97277. * @param behavior defines the behavior to attach
  97278. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  97279. * @returns the current Node
  97280. */
  97281. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  97282. /**
  97283. * Remove an attached behavior
  97284. * @see http://doc.babylonjs.com/features/behaviour
  97285. * @param behavior defines the behavior to attach
  97286. * @returns the current Node
  97287. */
  97288. removeBehavior(behavior: Behavior<Node>): Node;
  97289. /**
  97290. * Gets the list of attached behaviors
  97291. * @see http://doc.babylonjs.com/features/behaviour
  97292. */
  97293. readonly behaviors: Behavior<Node>[];
  97294. /**
  97295. * Gets an attached behavior by name
  97296. * @param name defines the name of the behavior to look for
  97297. * @see http://doc.babylonjs.com/features/behaviour
  97298. * @returns null if behavior was not found else the requested behavior
  97299. */
  97300. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  97301. /**
  97302. * Returns the latest update of the World matrix
  97303. * @returns a Matrix
  97304. */
  97305. getWorldMatrix(): Matrix;
  97306. /** @hidden */
  97307. _getWorldMatrixDeterminant(): number;
  97308. /**
  97309. * Returns directly the latest state of the mesh World matrix.
  97310. * A Matrix is returned.
  97311. */
  97312. readonly worldMatrixFromCache: Matrix;
  97313. /** @hidden */
  97314. _initCache(): void;
  97315. /** @hidden */
  97316. updateCache(force?: boolean): void;
  97317. /** @hidden */
  97318. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97319. /** @hidden */
  97320. _updateCache(ignoreParentClass?: boolean): void;
  97321. /** @hidden */
  97322. _isSynchronized(): boolean;
  97323. /** @hidden */
  97324. _markSyncedWithParent(): void;
  97325. /** @hidden */
  97326. isSynchronizedWithParent(): boolean;
  97327. /** @hidden */
  97328. isSynchronized(): boolean;
  97329. /**
  97330. * Is this node ready to be used/rendered
  97331. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97332. * @return true if the node is ready
  97333. */
  97334. isReady(completeCheck?: boolean): boolean;
  97335. /**
  97336. * Is this node enabled?
  97337. * 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
  97338. * @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
  97339. * @return whether this node (and its parent) is enabled
  97340. */
  97341. isEnabled(checkAncestors?: boolean): boolean;
  97342. /** @hidden */
  97343. protected _syncParentEnabledState(): void;
  97344. /**
  97345. * Set the enabled state of this node
  97346. * @param value defines the new enabled state
  97347. */
  97348. setEnabled(value: boolean): void;
  97349. /**
  97350. * Is this node a descendant of the given node?
  97351. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  97352. * @param ancestor defines the parent node to inspect
  97353. * @returns a boolean indicating if this node is a descendant of the given node
  97354. */
  97355. isDescendantOf(ancestor: Node): boolean;
  97356. /** @hidden */
  97357. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  97358. /**
  97359. * Will return all nodes that have this node as ascendant
  97360. * @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
  97361. * @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
  97362. * @return all children nodes of all types
  97363. */
  97364. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  97365. /**
  97366. * Get all child-meshes of this node
  97367. * @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)
  97368. * @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
  97369. * @returns an array of AbstractMesh
  97370. */
  97371. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  97372. /**
  97373. * Get all direct children of this node
  97374. * @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
  97375. * @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)
  97376. * @returns an array of Node
  97377. */
  97378. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  97379. /** @hidden */
  97380. _setReady(state: boolean): void;
  97381. /**
  97382. * Get an animation by name
  97383. * @param name defines the name of the animation to look for
  97384. * @returns null if not found else the requested animation
  97385. */
  97386. getAnimationByName(name: string): Nullable<Animation>;
  97387. /**
  97388. * Creates an animation range for this node
  97389. * @param name defines the name of the range
  97390. * @param from defines the starting key
  97391. * @param to defines the end key
  97392. */
  97393. createAnimationRange(name: string, from: number, to: number): void;
  97394. /**
  97395. * Delete a specific animation range
  97396. * @param name defines the name of the range to delete
  97397. * @param deleteFrames defines if animation frames from the range must be deleted as well
  97398. */
  97399. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97400. /**
  97401. * Get an animation range by name
  97402. * @param name defines the name of the animation range to look for
  97403. * @returns null if not found else the requested animation range
  97404. */
  97405. getAnimationRange(name: string): Nullable<AnimationRange>;
  97406. /**
  97407. * Gets the list of all animation ranges defined on this node
  97408. * @returns an array
  97409. */
  97410. getAnimationRanges(): Nullable<AnimationRange>[];
  97411. /**
  97412. * Will start the animation sequence
  97413. * @param name defines the range frames for animation sequence
  97414. * @param loop defines if the animation should loop (false by default)
  97415. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  97416. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  97417. * @returns the object created for this animation. If range does not exist, it will return null
  97418. */
  97419. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97420. /**
  97421. * Serialize animation ranges into a JSON compatible object
  97422. * @returns serialization object
  97423. */
  97424. serializeAnimationRanges(): any;
  97425. /**
  97426. * Computes the world matrix of the node
  97427. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97428. * @returns the world matrix
  97429. */
  97430. computeWorldMatrix(force?: boolean): Matrix;
  97431. /**
  97432. * Releases resources associated with this node.
  97433. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97434. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97435. */
  97436. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97437. /**
  97438. * Parse animation range data from a serialization object and store them into a given node
  97439. * @param node defines where to store the animation ranges
  97440. * @param parsedNode defines the serialization object to read data from
  97441. * @param scene defines the hosting scene
  97442. */
  97443. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  97444. /**
  97445. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  97446. * @param includeDescendants Include bounding info from descendants as well (true by default)
  97447. * @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
  97448. * @returns the new bounding vectors
  97449. */
  97450. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  97451. min: Vector3;
  97452. max: Vector3;
  97453. };
  97454. }
  97455. }
  97456. declare module BABYLON {
  97457. /**
  97458. * @hidden
  97459. */
  97460. export class _IAnimationState {
  97461. key: number;
  97462. repeatCount: number;
  97463. workValue?: any;
  97464. loopMode?: number;
  97465. offsetValue?: any;
  97466. highLimitValue?: any;
  97467. }
  97468. /**
  97469. * Class used to store any kind of animation
  97470. */
  97471. export class Animation {
  97472. /**Name of the animation */
  97473. name: string;
  97474. /**Property to animate */
  97475. targetProperty: string;
  97476. /**The frames per second of the animation */
  97477. framePerSecond: number;
  97478. /**The data type of the animation */
  97479. dataType: number;
  97480. /**The loop mode of the animation */
  97481. loopMode?: number | undefined;
  97482. /**Specifies if blending should be enabled */
  97483. enableBlending?: boolean | undefined;
  97484. /**
  97485. * Use matrix interpolation instead of using direct key value when animating matrices
  97486. */
  97487. static AllowMatricesInterpolation: boolean;
  97488. /**
  97489. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  97490. */
  97491. static AllowMatrixDecomposeForInterpolation: boolean;
  97492. /**
  97493. * Stores the key frames of the animation
  97494. */
  97495. private _keys;
  97496. /**
  97497. * Stores the easing function of the animation
  97498. */
  97499. private _easingFunction;
  97500. /**
  97501. * @hidden Internal use only
  97502. */
  97503. _runtimeAnimations: RuntimeAnimation[];
  97504. /**
  97505. * The set of event that will be linked to this animation
  97506. */
  97507. private _events;
  97508. /**
  97509. * Stores an array of target property paths
  97510. */
  97511. targetPropertyPath: string[];
  97512. /**
  97513. * Stores the blending speed of the animation
  97514. */
  97515. blendingSpeed: number;
  97516. /**
  97517. * Stores the animation ranges for the animation
  97518. */
  97519. private _ranges;
  97520. /**
  97521. * @hidden Internal use
  97522. */
  97523. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  97524. /**
  97525. * Sets up an animation
  97526. * @param property The property to animate
  97527. * @param animationType The animation type to apply
  97528. * @param framePerSecond The frames per second of the animation
  97529. * @param easingFunction The easing function used in the animation
  97530. * @returns The created animation
  97531. */
  97532. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  97533. /**
  97534. * Create and start an animation on a node
  97535. * @param name defines the name of the global animation that will be run on all nodes
  97536. * @param node defines the root node where the animation will take place
  97537. * @param targetProperty defines property to animate
  97538. * @param framePerSecond defines the number of frame per second yo use
  97539. * @param totalFrame defines the number of frames in total
  97540. * @param from defines the initial value
  97541. * @param to defines the final value
  97542. * @param loopMode defines which loop mode you want to use (off by default)
  97543. * @param easingFunction defines the easing function to use (linear by default)
  97544. * @param onAnimationEnd defines the callback to call when animation end
  97545. * @returns the animatable created for this animation
  97546. */
  97547. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97548. /**
  97549. * Create and start an animation on a node and its descendants
  97550. * @param name defines the name of the global animation that will be run on all nodes
  97551. * @param node defines the root node where the animation will take place
  97552. * @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
  97553. * @param targetProperty defines property to animate
  97554. * @param framePerSecond defines the number of frame per second to use
  97555. * @param totalFrame defines the number of frames in total
  97556. * @param from defines the initial value
  97557. * @param to defines the final value
  97558. * @param loopMode defines which loop mode you want to use (off by default)
  97559. * @param easingFunction defines the easing function to use (linear by default)
  97560. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97561. * @returns the list of animatables created for all nodes
  97562. * @example https://www.babylonjs-playground.com/#MH0VLI
  97563. */
  97564. 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[]>;
  97565. /**
  97566. * Creates a new animation, merges it with the existing animations and starts it
  97567. * @param name Name of the animation
  97568. * @param node Node which contains the scene that begins the animations
  97569. * @param targetProperty Specifies which property to animate
  97570. * @param framePerSecond The frames per second of the animation
  97571. * @param totalFrame The total number of frames
  97572. * @param from The frame at the beginning of the animation
  97573. * @param to The frame at the end of the animation
  97574. * @param loopMode Specifies the loop mode of the animation
  97575. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  97576. * @param onAnimationEnd Callback to run once the animation is complete
  97577. * @returns Nullable animation
  97578. */
  97579. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97580. /**
  97581. * Transition property of an host to the target Value
  97582. * @param property The property to transition
  97583. * @param targetValue The target Value of the property
  97584. * @param host The object where the property to animate belongs
  97585. * @param scene Scene used to run the animation
  97586. * @param frameRate Framerate (in frame/s) to use
  97587. * @param transition The transition type we want to use
  97588. * @param duration The duration of the animation, in milliseconds
  97589. * @param onAnimationEnd Callback trigger at the end of the animation
  97590. * @returns Nullable animation
  97591. */
  97592. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  97593. /**
  97594. * Return the array of runtime animations currently using this animation
  97595. */
  97596. readonly runtimeAnimations: RuntimeAnimation[];
  97597. /**
  97598. * Specifies if any of the runtime animations are currently running
  97599. */
  97600. readonly hasRunningRuntimeAnimations: boolean;
  97601. /**
  97602. * Initializes the animation
  97603. * @param name Name of the animation
  97604. * @param targetProperty Property to animate
  97605. * @param framePerSecond The frames per second of the animation
  97606. * @param dataType The data type of the animation
  97607. * @param loopMode The loop mode of the animation
  97608. * @param enableBlending Specifies if blending should be enabled
  97609. */
  97610. constructor(
  97611. /**Name of the animation */
  97612. name: string,
  97613. /**Property to animate */
  97614. targetProperty: string,
  97615. /**The frames per second of the animation */
  97616. framePerSecond: number,
  97617. /**The data type of the animation */
  97618. dataType: number,
  97619. /**The loop mode of the animation */
  97620. loopMode?: number | undefined,
  97621. /**Specifies if blending should be enabled */
  97622. enableBlending?: boolean | undefined);
  97623. /**
  97624. * Converts the animation to a string
  97625. * @param fullDetails support for multiple levels of logging within scene loading
  97626. * @returns String form of the animation
  97627. */
  97628. toString(fullDetails?: boolean): string;
  97629. /**
  97630. * Add an event to this animation
  97631. * @param event Event to add
  97632. */
  97633. addEvent(event: AnimationEvent): void;
  97634. /**
  97635. * Remove all events found at the given frame
  97636. * @param frame The frame to remove events from
  97637. */
  97638. removeEvents(frame: number): void;
  97639. /**
  97640. * Retrieves all the events from the animation
  97641. * @returns Events from the animation
  97642. */
  97643. getEvents(): AnimationEvent[];
  97644. /**
  97645. * Creates an animation range
  97646. * @param name Name of the animation range
  97647. * @param from Starting frame of the animation range
  97648. * @param to Ending frame of the animation
  97649. */
  97650. createRange(name: string, from: number, to: number): void;
  97651. /**
  97652. * Deletes an animation range by name
  97653. * @param name Name of the animation range to delete
  97654. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  97655. */
  97656. deleteRange(name: string, deleteFrames?: boolean): void;
  97657. /**
  97658. * Gets the animation range by name, or null if not defined
  97659. * @param name Name of the animation range
  97660. * @returns Nullable animation range
  97661. */
  97662. getRange(name: string): Nullable<AnimationRange>;
  97663. /**
  97664. * Gets the key frames from the animation
  97665. * @returns The key frames of the animation
  97666. */
  97667. getKeys(): Array<IAnimationKey>;
  97668. /**
  97669. * Gets the highest frame rate of the animation
  97670. * @returns Highest frame rate of the animation
  97671. */
  97672. getHighestFrame(): number;
  97673. /**
  97674. * Gets the easing function of the animation
  97675. * @returns Easing function of the animation
  97676. */
  97677. getEasingFunction(): IEasingFunction;
  97678. /**
  97679. * Sets the easing function of the animation
  97680. * @param easingFunction A custom mathematical formula for animation
  97681. */
  97682. setEasingFunction(easingFunction: EasingFunction): void;
  97683. /**
  97684. * Interpolates a scalar linearly
  97685. * @param startValue Start value of the animation curve
  97686. * @param endValue End value of the animation curve
  97687. * @param gradient Scalar amount to interpolate
  97688. * @returns Interpolated scalar value
  97689. */
  97690. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  97691. /**
  97692. * Interpolates a scalar cubically
  97693. * @param startValue Start value of the animation curve
  97694. * @param outTangent End tangent of the animation
  97695. * @param endValue End value of the animation curve
  97696. * @param inTangent Start tangent of the animation curve
  97697. * @param gradient Scalar amount to interpolate
  97698. * @returns Interpolated scalar value
  97699. */
  97700. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  97701. /**
  97702. * Interpolates a quaternion using a spherical linear interpolation
  97703. * @param startValue Start value of the animation curve
  97704. * @param endValue End value of the animation curve
  97705. * @param gradient Scalar amount to interpolate
  97706. * @returns Interpolated quaternion value
  97707. */
  97708. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  97709. /**
  97710. * Interpolates a quaternion cubically
  97711. * @param startValue Start value of the animation curve
  97712. * @param outTangent End tangent of the animation curve
  97713. * @param endValue End value of the animation curve
  97714. * @param inTangent Start tangent of the animation curve
  97715. * @param gradient Scalar amount to interpolate
  97716. * @returns Interpolated quaternion value
  97717. */
  97718. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  97719. /**
  97720. * Interpolates a Vector3 linearl
  97721. * @param startValue Start value of the animation curve
  97722. * @param endValue End value of the animation curve
  97723. * @param gradient Scalar amount to interpolate
  97724. * @returns Interpolated scalar value
  97725. */
  97726. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  97727. /**
  97728. * Interpolates a Vector3 cubically
  97729. * @param startValue Start value of the animation curve
  97730. * @param outTangent End tangent of the animation
  97731. * @param endValue End value of the animation curve
  97732. * @param inTangent Start tangent of the animation curve
  97733. * @param gradient Scalar amount to interpolate
  97734. * @returns InterpolatedVector3 value
  97735. */
  97736. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  97737. /**
  97738. * Interpolates a Vector2 linearly
  97739. * @param startValue Start value of the animation curve
  97740. * @param endValue End value of the animation curve
  97741. * @param gradient Scalar amount to interpolate
  97742. * @returns Interpolated Vector2 value
  97743. */
  97744. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  97745. /**
  97746. * Interpolates a Vector2 cubically
  97747. * @param startValue Start value of the animation curve
  97748. * @param outTangent End tangent of the animation
  97749. * @param endValue End value of the animation curve
  97750. * @param inTangent Start tangent of the animation curve
  97751. * @param gradient Scalar amount to interpolate
  97752. * @returns Interpolated Vector2 value
  97753. */
  97754. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  97755. /**
  97756. * Interpolates a size linearly
  97757. * @param startValue Start value of the animation curve
  97758. * @param endValue End value of the animation curve
  97759. * @param gradient Scalar amount to interpolate
  97760. * @returns Interpolated Size value
  97761. */
  97762. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  97763. /**
  97764. * Interpolates a Color3 linearly
  97765. * @param startValue Start value of the animation curve
  97766. * @param endValue End value of the animation curve
  97767. * @param gradient Scalar amount to interpolate
  97768. * @returns Interpolated Color3 value
  97769. */
  97770. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  97771. /**
  97772. * Interpolates a Color4 linearly
  97773. * @param startValue Start value of the animation curve
  97774. * @param endValue End value of the animation curve
  97775. * @param gradient Scalar amount to interpolate
  97776. * @returns Interpolated Color3 value
  97777. */
  97778. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  97779. /**
  97780. * @hidden Internal use only
  97781. */
  97782. _getKeyValue(value: any): any;
  97783. /**
  97784. * @hidden Internal use only
  97785. */
  97786. _interpolate(currentFrame: number, state: _IAnimationState): any;
  97787. /**
  97788. * Defines the function to use to interpolate matrices
  97789. * @param startValue defines the start matrix
  97790. * @param endValue defines the end matrix
  97791. * @param gradient defines the gradient between both matrices
  97792. * @param result defines an optional target matrix where to store the interpolation
  97793. * @returns the interpolated matrix
  97794. */
  97795. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  97796. /**
  97797. * Makes a copy of the animation
  97798. * @returns Cloned animation
  97799. */
  97800. clone(): Animation;
  97801. /**
  97802. * Sets the key frames of the animation
  97803. * @param values The animation key frames to set
  97804. */
  97805. setKeys(values: Array<IAnimationKey>): void;
  97806. /**
  97807. * Serializes the animation to an object
  97808. * @returns Serialized object
  97809. */
  97810. serialize(): any;
  97811. /**
  97812. * Float animation type
  97813. */
  97814. static readonly ANIMATIONTYPE_FLOAT: number;
  97815. /**
  97816. * Vector3 animation type
  97817. */
  97818. static readonly ANIMATIONTYPE_VECTOR3: number;
  97819. /**
  97820. * Quaternion animation type
  97821. */
  97822. static readonly ANIMATIONTYPE_QUATERNION: number;
  97823. /**
  97824. * Matrix animation type
  97825. */
  97826. static readonly ANIMATIONTYPE_MATRIX: number;
  97827. /**
  97828. * Color3 animation type
  97829. */
  97830. static readonly ANIMATIONTYPE_COLOR3: number;
  97831. /**
  97832. * Color3 animation type
  97833. */
  97834. static readonly ANIMATIONTYPE_COLOR4: number;
  97835. /**
  97836. * Vector2 animation type
  97837. */
  97838. static readonly ANIMATIONTYPE_VECTOR2: number;
  97839. /**
  97840. * Size animation type
  97841. */
  97842. static readonly ANIMATIONTYPE_SIZE: number;
  97843. /**
  97844. * Relative Loop Mode
  97845. */
  97846. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  97847. /**
  97848. * Cycle Loop Mode
  97849. */
  97850. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  97851. /**
  97852. * Constant Loop Mode
  97853. */
  97854. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  97855. /** @hidden */
  97856. static _UniversalLerp(left: any, right: any, amount: number): any;
  97857. /**
  97858. * Parses an animation object and creates an animation
  97859. * @param parsedAnimation Parsed animation object
  97860. * @returns Animation object
  97861. */
  97862. static Parse(parsedAnimation: any): Animation;
  97863. /**
  97864. * Appends the serialized animations from the source animations
  97865. * @param source Source containing the animations
  97866. * @param destination Target to store the animations
  97867. */
  97868. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  97869. }
  97870. }
  97871. declare module BABYLON {
  97872. /**
  97873. * Interface containing an array of animations
  97874. */
  97875. export interface IAnimatable {
  97876. /**
  97877. * Array of animations
  97878. */
  97879. animations: Nullable<Array<Animation>>;
  97880. }
  97881. }
  97882. declare module BABYLON {
  97883. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  97884. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97885. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97886. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97887. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97888. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97889. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97890. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97891. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97892. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97893. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97894. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97895. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97896. /**
  97897. * Decorator used to define property that can be serialized as reference to a camera
  97898. * @param sourceName defines the name of the property to decorate
  97899. */
  97900. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97901. /**
  97902. * Class used to help serialization objects
  97903. */
  97904. export class SerializationHelper {
  97905. /** @hidden */
  97906. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  97907. /** @hidden */
  97908. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  97909. /** @hidden */
  97910. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  97911. /** @hidden */
  97912. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  97913. /**
  97914. * Appends the serialized animations from the source animations
  97915. * @param source Source containing the animations
  97916. * @param destination Target to store the animations
  97917. */
  97918. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  97919. /**
  97920. * Static function used to serialized a specific entity
  97921. * @param entity defines the entity to serialize
  97922. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  97923. * @returns a JSON compatible object representing the serialization of the entity
  97924. */
  97925. static Serialize<T>(entity: T, serializationObject?: any): any;
  97926. /**
  97927. * Creates a new entity from a serialization data object
  97928. * @param creationFunction defines a function used to instanciated the new entity
  97929. * @param source defines the source serialization data
  97930. * @param scene defines the hosting scene
  97931. * @param rootUrl defines the root url for resources
  97932. * @returns a new entity
  97933. */
  97934. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  97935. /**
  97936. * Clones an object
  97937. * @param creationFunction defines the function used to instanciate the new object
  97938. * @param source defines the source object
  97939. * @returns the cloned object
  97940. */
  97941. static Clone<T>(creationFunction: () => T, source: T): T;
  97942. /**
  97943. * Instanciates a new object based on a source one (some data will be shared between both object)
  97944. * @param creationFunction defines the function used to instanciate the new object
  97945. * @param source defines the source object
  97946. * @returns the new object
  97947. */
  97948. static Instanciate<T>(creationFunction: () => T, source: T): T;
  97949. }
  97950. }
  97951. declare module BABYLON {
  97952. /**
  97953. * Class used to manipulate GUIDs
  97954. */
  97955. export class GUID {
  97956. /**
  97957. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97958. * Be aware Math.random() could cause collisions, but:
  97959. * "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"
  97960. * @returns a pseudo random id
  97961. */
  97962. static RandomId(): string;
  97963. }
  97964. }
  97965. declare module BABYLON {
  97966. /**
  97967. * Base class of all the textures in babylon.
  97968. * It groups all the common properties the materials, post process, lights... might need
  97969. * in order to make a correct use of the texture.
  97970. */
  97971. export class BaseTexture implements IAnimatable {
  97972. /**
  97973. * Default anisotropic filtering level for the application.
  97974. * It is set to 4 as a good tradeoff between perf and quality.
  97975. */
  97976. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  97977. /**
  97978. * Gets or sets the unique id of the texture
  97979. */
  97980. uniqueId: number;
  97981. /**
  97982. * Define the name of the texture.
  97983. */
  97984. name: string;
  97985. /**
  97986. * Gets or sets an object used to store user defined information.
  97987. */
  97988. metadata: any;
  97989. /**
  97990. * For internal use only. Please do not use.
  97991. */
  97992. reservedDataStore: any;
  97993. private _hasAlpha;
  97994. /**
  97995. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  97996. */
  97997. hasAlpha: boolean;
  97998. /**
  97999. * Defines if the alpha value should be determined via the rgb values.
  98000. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  98001. */
  98002. getAlphaFromRGB: boolean;
  98003. /**
  98004. * Intensity or strength of the texture.
  98005. * It is commonly used by materials to fine tune the intensity of the texture
  98006. */
  98007. level: number;
  98008. /**
  98009. * Define the UV chanel to use starting from 0 and defaulting to 0.
  98010. * This is part of the texture as textures usually maps to one uv set.
  98011. */
  98012. coordinatesIndex: number;
  98013. private _coordinatesMode;
  98014. /**
  98015. * How a texture is mapped.
  98016. *
  98017. * | Value | Type | Description |
  98018. * | ----- | ----------------------------------- | ----------- |
  98019. * | 0 | EXPLICIT_MODE | |
  98020. * | 1 | SPHERICAL_MODE | |
  98021. * | 2 | PLANAR_MODE | |
  98022. * | 3 | CUBIC_MODE | |
  98023. * | 4 | PROJECTION_MODE | |
  98024. * | 5 | SKYBOX_MODE | |
  98025. * | 6 | INVCUBIC_MODE | |
  98026. * | 7 | EQUIRECTANGULAR_MODE | |
  98027. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  98028. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  98029. */
  98030. coordinatesMode: number;
  98031. /**
  98032. * | Value | Type | Description |
  98033. * | ----- | ------------------ | ----------- |
  98034. * | 0 | CLAMP_ADDRESSMODE | |
  98035. * | 1 | WRAP_ADDRESSMODE | |
  98036. * | 2 | MIRROR_ADDRESSMODE | |
  98037. */
  98038. wrapU: number;
  98039. /**
  98040. * | Value | Type | Description |
  98041. * | ----- | ------------------ | ----------- |
  98042. * | 0 | CLAMP_ADDRESSMODE | |
  98043. * | 1 | WRAP_ADDRESSMODE | |
  98044. * | 2 | MIRROR_ADDRESSMODE | |
  98045. */
  98046. wrapV: number;
  98047. /**
  98048. * | Value | Type | Description |
  98049. * | ----- | ------------------ | ----------- |
  98050. * | 0 | CLAMP_ADDRESSMODE | |
  98051. * | 1 | WRAP_ADDRESSMODE | |
  98052. * | 2 | MIRROR_ADDRESSMODE | |
  98053. */
  98054. wrapR: number;
  98055. /**
  98056. * With compliant hardware and browser (supporting anisotropic filtering)
  98057. * this defines the level of anisotropic filtering in the texture.
  98058. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  98059. */
  98060. anisotropicFilteringLevel: number;
  98061. /**
  98062. * Define if the texture is a cube texture or if false a 2d texture.
  98063. */
  98064. isCube: boolean;
  98065. /**
  98066. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  98067. */
  98068. is3D: boolean;
  98069. /**
  98070. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  98071. */
  98072. is2DArray: boolean;
  98073. /**
  98074. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  98075. * HDR texture are usually stored in linear space.
  98076. * This only impacts the PBR and Background materials
  98077. */
  98078. gammaSpace: boolean;
  98079. /**
  98080. * Gets or sets whether or not the texture contains RGBD data.
  98081. */
  98082. isRGBD: boolean;
  98083. /**
  98084. * Is Z inverted in the texture (useful in a cube texture).
  98085. */
  98086. invertZ: boolean;
  98087. /**
  98088. * Are mip maps generated for this texture or not.
  98089. */
  98090. readonly noMipmap: boolean;
  98091. /**
  98092. * @hidden
  98093. */
  98094. lodLevelInAlpha: boolean;
  98095. /**
  98096. * With prefiltered texture, defined the offset used during the prefiltering steps.
  98097. */
  98098. lodGenerationOffset: number;
  98099. /**
  98100. * With prefiltered texture, defined the scale used during the prefiltering steps.
  98101. */
  98102. lodGenerationScale: number;
  98103. /**
  98104. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  98105. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  98106. * average roughness values.
  98107. */
  98108. linearSpecularLOD: boolean;
  98109. /**
  98110. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  98111. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  98112. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  98113. */
  98114. irradianceTexture: Nullable<BaseTexture>;
  98115. /**
  98116. * Define if the texture is a render target.
  98117. */
  98118. isRenderTarget: boolean;
  98119. /**
  98120. * Define the unique id of the texture in the scene.
  98121. */
  98122. readonly uid: string;
  98123. /**
  98124. * Return a string representation of the texture.
  98125. * @returns the texture as a string
  98126. */
  98127. toString(): string;
  98128. /**
  98129. * Get the class name of the texture.
  98130. * @returns "BaseTexture"
  98131. */
  98132. getClassName(): string;
  98133. /**
  98134. * Define the list of animation attached to the texture.
  98135. */
  98136. animations: Animation[];
  98137. /**
  98138. * An event triggered when the texture is disposed.
  98139. */
  98140. onDisposeObservable: Observable<BaseTexture>;
  98141. private _onDisposeObserver;
  98142. /**
  98143. * Callback triggered when the texture has been disposed.
  98144. * Kept for back compatibility, you can use the onDisposeObservable instead.
  98145. */
  98146. onDispose: () => void;
  98147. /**
  98148. * Define the current state of the loading sequence when in delayed load mode.
  98149. */
  98150. delayLoadState: number;
  98151. private _scene;
  98152. /** @hidden */
  98153. _texture: Nullable<InternalTexture>;
  98154. private _uid;
  98155. /**
  98156. * Define if the texture is preventinga material to render or not.
  98157. * If not and the texture is not ready, the engine will use a default black texture instead.
  98158. */
  98159. readonly isBlocking: boolean;
  98160. /**
  98161. * Instantiates a new BaseTexture.
  98162. * Base class of all the textures in babylon.
  98163. * It groups all the common properties the materials, post process, lights... might need
  98164. * in order to make a correct use of the texture.
  98165. * @param scene Define the scene the texture blongs to
  98166. */
  98167. constructor(scene: Nullable<Scene>);
  98168. /**
  98169. * Get the scene the texture belongs to.
  98170. * @returns the scene or null if undefined
  98171. */
  98172. getScene(): Nullable<Scene>;
  98173. /**
  98174. * Get the texture transform matrix used to offset tile the texture for istance.
  98175. * @returns the transformation matrix
  98176. */
  98177. getTextureMatrix(): Matrix;
  98178. /**
  98179. * Get the texture reflection matrix used to rotate/transform the reflection.
  98180. * @returns the reflection matrix
  98181. */
  98182. getReflectionTextureMatrix(): Matrix;
  98183. /**
  98184. * Get the underlying lower level texture from Babylon.
  98185. * @returns the insternal texture
  98186. */
  98187. getInternalTexture(): Nullable<InternalTexture>;
  98188. /**
  98189. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  98190. * @returns true if ready or not blocking
  98191. */
  98192. isReadyOrNotBlocking(): boolean;
  98193. /**
  98194. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  98195. * @returns true if fully ready
  98196. */
  98197. isReady(): boolean;
  98198. private _cachedSize;
  98199. /**
  98200. * Get the size of the texture.
  98201. * @returns the texture size.
  98202. */
  98203. getSize(): ISize;
  98204. /**
  98205. * Get the base size of the texture.
  98206. * It can be different from the size if the texture has been resized for POT for instance
  98207. * @returns the base size
  98208. */
  98209. getBaseSize(): ISize;
  98210. /**
  98211. * Update the sampling mode of the texture.
  98212. * Default is Trilinear mode.
  98213. *
  98214. * | Value | Type | Description |
  98215. * | ----- | ------------------ | ----------- |
  98216. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  98217. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  98218. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  98219. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  98220. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  98221. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  98222. * | 7 | NEAREST_LINEAR | |
  98223. * | 8 | NEAREST_NEAREST | |
  98224. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  98225. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  98226. * | 11 | LINEAR_LINEAR | |
  98227. * | 12 | LINEAR_NEAREST | |
  98228. *
  98229. * > _mag_: magnification filter (close to the viewer)
  98230. * > _min_: minification filter (far from the viewer)
  98231. * > _mip_: filter used between mip map levels
  98232. *@param samplingMode Define the new sampling mode of the texture
  98233. */
  98234. updateSamplingMode(samplingMode: number): void;
  98235. /**
  98236. * Scales the texture if is `canRescale()`
  98237. * @param ratio the resize factor we want to use to rescale
  98238. */
  98239. scale(ratio: number): void;
  98240. /**
  98241. * Get if the texture can rescale.
  98242. */
  98243. readonly canRescale: boolean;
  98244. /** @hidden */
  98245. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  98246. /** @hidden */
  98247. _rebuild(): void;
  98248. /**
  98249. * Triggers the load sequence in delayed load mode.
  98250. */
  98251. delayLoad(): void;
  98252. /**
  98253. * Clones the texture.
  98254. * @returns the cloned texture
  98255. */
  98256. clone(): Nullable<BaseTexture>;
  98257. /**
  98258. * Get the texture underlying type (INT, FLOAT...)
  98259. */
  98260. readonly textureType: number;
  98261. /**
  98262. * Get the texture underlying format (RGB, RGBA...)
  98263. */
  98264. readonly textureFormat: number;
  98265. /**
  98266. * Indicates that textures need to be re-calculated for all materials
  98267. */
  98268. protected _markAllSubMeshesAsTexturesDirty(): void;
  98269. /**
  98270. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  98271. * This will returns an RGBA array buffer containing either in values (0-255) or
  98272. * float values (0-1) depending of the underlying buffer type.
  98273. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  98274. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  98275. * @param buffer defines a user defined buffer to fill with data (can be null)
  98276. * @returns The Array buffer containing the pixels data.
  98277. */
  98278. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  98279. /**
  98280. * Release and destroy the underlying lower level texture aka internalTexture.
  98281. */
  98282. releaseInternalTexture(): void;
  98283. /** @hidden */
  98284. readonly _lodTextureHigh: Nullable<BaseTexture>;
  98285. /** @hidden */
  98286. readonly _lodTextureMid: Nullable<BaseTexture>;
  98287. /** @hidden */
  98288. readonly _lodTextureLow: Nullable<BaseTexture>;
  98289. /**
  98290. * Dispose the texture and release its associated resources.
  98291. */
  98292. dispose(): void;
  98293. /**
  98294. * Serialize the texture into a JSON representation that can be parsed later on.
  98295. * @returns the JSON representation of the texture
  98296. */
  98297. serialize(): any;
  98298. /**
  98299. * Helper function to be called back once a list of texture contains only ready textures.
  98300. * @param textures Define the list of textures to wait for
  98301. * @param callback Define the callback triggered once the entire list will be ready
  98302. */
  98303. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  98304. }
  98305. }
  98306. declare module BABYLON {
  98307. /**
  98308. * Options to be used when creating an effect.
  98309. */
  98310. export interface IEffectCreationOptions {
  98311. /**
  98312. * Atrributes that will be used in the shader.
  98313. */
  98314. attributes: string[];
  98315. /**
  98316. * Uniform varible names that will be set in the shader.
  98317. */
  98318. uniformsNames: string[];
  98319. /**
  98320. * Uniform buffer variable names that will be set in the shader.
  98321. */
  98322. uniformBuffersNames: string[];
  98323. /**
  98324. * Sampler texture variable names that will be set in the shader.
  98325. */
  98326. samplers: string[];
  98327. /**
  98328. * Define statements that will be set in the shader.
  98329. */
  98330. defines: any;
  98331. /**
  98332. * Possible fallbacks for this effect to improve performance when needed.
  98333. */
  98334. fallbacks: Nullable<IEffectFallbacks>;
  98335. /**
  98336. * Callback that will be called when the shader is compiled.
  98337. */
  98338. onCompiled: Nullable<(effect: Effect) => void>;
  98339. /**
  98340. * Callback that will be called if an error occurs during shader compilation.
  98341. */
  98342. onError: Nullable<(effect: Effect, errors: string) => void>;
  98343. /**
  98344. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98345. */
  98346. indexParameters?: any;
  98347. /**
  98348. * Max number of lights that can be used in the shader.
  98349. */
  98350. maxSimultaneousLights?: number;
  98351. /**
  98352. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  98353. */
  98354. transformFeedbackVaryings?: Nullable<string[]>;
  98355. }
  98356. /**
  98357. * Effect containing vertex and fragment shader that can be executed on an object.
  98358. */
  98359. export class Effect implements IDisposable {
  98360. /**
  98361. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  98362. */
  98363. static ShadersRepository: string;
  98364. /**
  98365. * Name of the effect.
  98366. */
  98367. name: any;
  98368. /**
  98369. * String container all the define statements that should be set on the shader.
  98370. */
  98371. defines: string;
  98372. /**
  98373. * Callback that will be called when the shader is compiled.
  98374. */
  98375. onCompiled: Nullable<(effect: Effect) => void>;
  98376. /**
  98377. * Callback that will be called if an error occurs during shader compilation.
  98378. */
  98379. onError: Nullable<(effect: Effect, errors: string) => void>;
  98380. /**
  98381. * Callback that will be called when effect is bound.
  98382. */
  98383. onBind: Nullable<(effect: Effect) => void>;
  98384. /**
  98385. * Unique ID of the effect.
  98386. */
  98387. uniqueId: number;
  98388. /**
  98389. * Observable that will be called when the shader is compiled.
  98390. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  98391. */
  98392. onCompileObservable: Observable<Effect>;
  98393. /**
  98394. * Observable that will be called if an error occurs during shader compilation.
  98395. */
  98396. onErrorObservable: Observable<Effect>;
  98397. /** @hidden */
  98398. _onBindObservable: Nullable<Observable<Effect>>;
  98399. /**
  98400. * Observable that will be called when effect is bound.
  98401. */
  98402. readonly onBindObservable: Observable<Effect>;
  98403. /** @hidden */
  98404. _bonesComputationForcedToCPU: boolean;
  98405. private static _uniqueIdSeed;
  98406. private _engine;
  98407. private _uniformBuffersNames;
  98408. private _uniformsNames;
  98409. private _samplerList;
  98410. private _samplers;
  98411. private _isReady;
  98412. private _compilationError;
  98413. private _allFallbacksProcessed;
  98414. private _attributesNames;
  98415. private _attributes;
  98416. private _uniforms;
  98417. /**
  98418. * Key for the effect.
  98419. * @hidden
  98420. */
  98421. _key: string;
  98422. private _indexParameters;
  98423. private _fallbacks;
  98424. private _vertexSourceCode;
  98425. private _fragmentSourceCode;
  98426. private _vertexSourceCodeOverride;
  98427. private _fragmentSourceCodeOverride;
  98428. private _transformFeedbackVaryings;
  98429. /**
  98430. * Compiled shader to webGL program.
  98431. * @hidden
  98432. */
  98433. _pipelineContext: Nullable<IPipelineContext>;
  98434. private _valueCache;
  98435. private static _baseCache;
  98436. /**
  98437. * Instantiates an effect.
  98438. * An effect can be used to create/manage/execute vertex and fragment shaders.
  98439. * @param baseName Name of the effect.
  98440. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  98441. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  98442. * @param samplers List of sampler variables that will be passed to the shader.
  98443. * @param engine Engine to be used to render the effect
  98444. * @param defines Define statements to be added to the shader.
  98445. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  98446. * @param onCompiled Callback that will be called when the shader is compiled.
  98447. * @param onError Callback that will be called if an error occurs during shader compilation.
  98448. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98449. */
  98450. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  98451. private _useFinalCode;
  98452. /**
  98453. * Unique key for this effect
  98454. */
  98455. readonly key: string;
  98456. /**
  98457. * If the effect has been compiled and prepared.
  98458. * @returns if the effect is compiled and prepared.
  98459. */
  98460. isReady(): boolean;
  98461. private _isReadyInternal;
  98462. /**
  98463. * The engine the effect was initialized with.
  98464. * @returns the engine.
  98465. */
  98466. getEngine(): Engine;
  98467. /**
  98468. * The pipeline context for this effect
  98469. * @returns the associated pipeline context
  98470. */
  98471. getPipelineContext(): Nullable<IPipelineContext>;
  98472. /**
  98473. * The set of names of attribute variables for the shader.
  98474. * @returns An array of attribute names.
  98475. */
  98476. getAttributesNames(): string[];
  98477. /**
  98478. * Returns the attribute at the given index.
  98479. * @param index The index of the attribute.
  98480. * @returns The location of the attribute.
  98481. */
  98482. getAttributeLocation(index: number): number;
  98483. /**
  98484. * Returns the attribute based on the name of the variable.
  98485. * @param name of the attribute to look up.
  98486. * @returns the attribute location.
  98487. */
  98488. getAttributeLocationByName(name: string): number;
  98489. /**
  98490. * The number of attributes.
  98491. * @returns the numnber of attributes.
  98492. */
  98493. getAttributesCount(): number;
  98494. /**
  98495. * Gets the index of a uniform variable.
  98496. * @param uniformName of the uniform to look up.
  98497. * @returns the index.
  98498. */
  98499. getUniformIndex(uniformName: string): number;
  98500. /**
  98501. * Returns the attribute based on the name of the variable.
  98502. * @param uniformName of the uniform to look up.
  98503. * @returns the location of the uniform.
  98504. */
  98505. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  98506. /**
  98507. * Returns an array of sampler variable names
  98508. * @returns The array of sampler variable neames.
  98509. */
  98510. getSamplers(): string[];
  98511. /**
  98512. * The error from the last compilation.
  98513. * @returns the error string.
  98514. */
  98515. getCompilationError(): string;
  98516. /**
  98517. * Gets a boolean indicating that all fallbacks were used during compilation
  98518. * @returns true if all fallbacks were used
  98519. */
  98520. allFallbacksProcessed(): boolean;
  98521. /**
  98522. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  98523. * @param func The callback to be used.
  98524. */
  98525. executeWhenCompiled(func: (effect: Effect) => void): void;
  98526. private _checkIsReady;
  98527. private _loadShader;
  98528. /**
  98529. * Recompiles the webGL program
  98530. * @param vertexSourceCode The source code for the vertex shader.
  98531. * @param fragmentSourceCode The source code for the fragment shader.
  98532. * @param onCompiled Callback called when completed.
  98533. * @param onError Callback called on error.
  98534. * @hidden
  98535. */
  98536. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  98537. /**
  98538. * Prepares the effect
  98539. * @hidden
  98540. */
  98541. _prepareEffect(): void;
  98542. private _processCompilationErrors;
  98543. /**
  98544. * Checks if the effect is supported. (Must be called after compilation)
  98545. */
  98546. readonly isSupported: boolean;
  98547. /**
  98548. * Binds a texture to the engine to be used as output of the shader.
  98549. * @param channel Name of the output variable.
  98550. * @param texture Texture to bind.
  98551. * @hidden
  98552. */
  98553. _bindTexture(channel: string, texture: InternalTexture): void;
  98554. /**
  98555. * Sets a texture on the engine to be used in the shader.
  98556. * @param channel Name of the sampler variable.
  98557. * @param texture Texture to set.
  98558. */
  98559. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  98560. /**
  98561. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  98562. * @param channel Name of the sampler variable.
  98563. * @param texture Texture to set.
  98564. */
  98565. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  98566. /**
  98567. * Sets an array of textures on the engine to be used in the shader.
  98568. * @param channel Name of the variable.
  98569. * @param textures Textures to set.
  98570. */
  98571. setTextureArray(channel: string, textures: BaseTexture[]): void;
  98572. /**
  98573. * 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)
  98574. * @param channel Name of the sampler variable.
  98575. * @param postProcess Post process to get the input texture from.
  98576. */
  98577. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  98578. /**
  98579. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  98580. * 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)
  98581. * @param channel Name of the sampler variable.
  98582. * @param postProcess Post process to get the output texture from.
  98583. */
  98584. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  98585. /** @hidden */
  98586. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  98587. /** @hidden */
  98588. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  98589. /** @hidden */
  98590. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  98591. /** @hidden */
  98592. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  98593. /**
  98594. * Binds a buffer to a uniform.
  98595. * @param buffer Buffer to bind.
  98596. * @param name Name of the uniform variable to bind to.
  98597. */
  98598. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  98599. /**
  98600. * Binds block to a uniform.
  98601. * @param blockName Name of the block to bind.
  98602. * @param index Index to bind.
  98603. */
  98604. bindUniformBlock(blockName: string, index: number): void;
  98605. /**
  98606. * Sets an interger value on a uniform variable.
  98607. * @param uniformName Name of the variable.
  98608. * @param value Value to be set.
  98609. * @returns this effect.
  98610. */
  98611. setInt(uniformName: string, value: number): Effect;
  98612. /**
  98613. * Sets an int array on a uniform variable.
  98614. * @param uniformName Name of the variable.
  98615. * @param array array to be set.
  98616. * @returns this effect.
  98617. */
  98618. setIntArray(uniformName: string, array: Int32Array): Effect;
  98619. /**
  98620. * 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)
  98621. * @param uniformName Name of the variable.
  98622. * @param array array to be set.
  98623. * @returns this effect.
  98624. */
  98625. setIntArray2(uniformName: string, array: Int32Array): Effect;
  98626. /**
  98627. * 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)
  98628. * @param uniformName Name of the variable.
  98629. * @param array array to be set.
  98630. * @returns this effect.
  98631. */
  98632. setIntArray3(uniformName: string, array: Int32Array): Effect;
  98633. /**
  98634. * 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)
  98635. * @param uniformName Name of the variable.
  98636. * @param array array to be set.
  98637. * @returns this effect.
  98638. */
  98639. setIntArray4(uniformName: string, array: Int32Array): Effect;
  98640. /**
  98641. * Sets an float array on a uniform variable.
  98642. * @param uniformName Name of the variable.
  98643. * @param array array to be set.
  98644. * @returns this effect.
  98645. */
  98646. setFloatArray(uniformName: string, array: Float32Array): Effect;
  98647. /**
  98648. * 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)
  98649. * @param uniformName Name of the variable.
  98650. * @param array array to be set.
  98651. * @returns this effect.
  98652. */
  98653. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  98654. /**
  98655. * 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)
  98656. * @param uniformName Name of the variable.
  98657. * @param array array to be set.
  98658. * @returns this effect.
  98659. */
  98660. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  98661. /**
  98662. * 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)
  98663. * @param uniformName Name of the variable.
  98664. * @param array array to be set.
  98665. * @returns this effect.
  98666. */
  98667. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  98668. /**
  98669. * Sets an array on a uniform variable.
  98670. * @param uniformName Name of the variable.
  98671. * @param array array to be set.
  98672. * @returns this effect.
  98673. */
  98674. setArray(uniformName: string, array: number[]): Effect;
  98675. /**
  98676. * 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)
  98677. * @param uniformName Name of the variable.
  98678. * @param array array to be set.
  98679. * @returns this effect.
  98680. */
  98681. setArray2(uniformName: string, array: number[]): Effect;
  98682. /**
  98683. * 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)
  98684. * @param uniformName Name of the variable.
  98685. * @param array array to be set.
  98686. * @returns this effect.
  98687. */
  98688. setArray3(uniformName: string, array: number[]): Effect;
  98689. /**
  98690. * 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)
  98691. * @param uniformName Name of the variable.
  98692. * @param array array to be set.
  98693. * @returns this effect.
  98694. */
  98695. setArray4(uniformName: string, array: number[]): Effect;
  98696. /**
  98697. * Sets matrices on a uniform variable.
  98698. * @param uniformName Name of the variable.
  98699. * @param matrices matrices to be set.
  98700. * @returns this effect.
  98701. */
  98702. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  98703. /**
  98704. * Sets matrix on a uniform variable.
  98705. * @param uniformName Name of the variable.
  98706. * @param matrix matrix to be set.
  98707. * @returns this effect.
  98708. */
  98709. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  98710. /**
  98711. * 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)
  98712. * @param uniformName Name of the variable.
  98713. * @param matrix matrix to be set.
  98714. * @returns this effect.
  98715. */
  98716. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  98717. /**
  98718. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  98719. * @param uniformName Name of the variable.
  98720. * @param matrix matrix to be set.
  98721. * @returns this effect.
  98722. */
  98723. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  98724. /**
  98725. * Sets a float on a uniform variable.
  98726. * @param uniformName Name of the variable.
  98727. * @param value value to be set.
  98728. * @returns this effect.
  98729. */
  98730. setFloat(uniformName: string, value: number): Effect;
  98731. /**
  98732. * Sets a boolean on a uniform variable.
  98733. * @param uniformName Name of the variable.
  98734. * @param bool value to be set.
  98735. * @returns this effect.
  98736. */
  98737. setBool(uniformName: string, bool: boolean): Effect;
  98738. /**
  98739. * Sets a Vector2 on a uniform variable.
  98740. * @param uniformName Name of the variable.
  98741. * @param vector2 vector2 to be set.
  98742. * @returns this effect.
  98743. */
  98744. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  98745. /**
  98746. * Sets a float2 on a uniform variable.
  98747. * @param uniformName Name of the variable.
  98748. * @param x First float in float2.
  98749. * @param y Second float in float2.
  98750. * @returns this effect.
  98751. */
  98752. setFloat2(uniformName: string, x: number, y: number): Effect;
  98753. /**
  98754. * Sets a Vector3 on a uniform variable.
  98755. * @param uniformName Name of the variable.
  98756. * @param vector3 Value to be set.
  98757. * @returns this effect.
  98758. */
  98759. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  98760. /**
  98761. * Sets a float3 on a uniform variable.
  98762. * @param uniformName Name of the variable.
  98763. * @param x First float in float3.
  98764. * @param y Second float in float3.
  98765. * @param z Third float in float3.
  98766. * @returns this effect.
  98767. */
  98768. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  98769. /**
  98770. * Sets a Vector4 on a uniform variable.
  98771. * @param uniformName Name of the variable.
  98772. * @param vector4 Value to be set.
  98773. * @returns this effect.
  98774. */
  98775. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  98776. /**
  98777. * Sets a float4 on a uniform variable.
  98778. * @param uniformName Name of the variable.
  98779. * @param x First float in float4.
  98780. * @param y Second float in float4.
  98781. * @param z Third float in float4.
  98782. * @param w Fourth float in float4.
  98783. * @returns this effect.
  98784. */
  98785. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  98786. /**
  98787. * Sets a Color3 on a uniform variable.
  98788. * @param uniformName Name of the variable.
  98789. * @param color3 Value to be set.
  98790. * @returns this effect.
  98791. */
  98792. setColor3(uniformName: string, color3: IColor3Like): Effect;
  98793. /**
  98794. * Sets a Color4 on a uniform variable.
  98795. * @param uniformName Name of the variable.
  98796. * @param color3 Value to be set.
  98797. * @param alpha Alpha value to be set.
  98798. * @returns this effect.
  98799. */
  98800. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  98801. /**
  98802. * Sets a Color4 on a uniform variable
  98803. * @param uniformName defines the name of the variable
  98804. * @param color4 defines the value to be set
  98805. * @returns this effect.
  98806. */
  98807. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  98808. /** Release all associated resources */
  98809. dispose(): void;
  98810. /**
  98811. * This function will add a new shader to the shader store
  98812. * @param name the name of the shader
  98813. * @param pixelShader optional pixel shader content
  98814. * @param vertexShader optional vertex shader content
  98815. */
  98816. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  98817. /**
  98818. * Store of each shader (The can be looked up using effect.key)
  98819. */
  98820. static ShadersStore: {
  98821. [key: string]: string;
  98822. };
  98823. /**
  98824. * Store of each included file for a shader (The can be looked up using effect.key)
  98825. */
  98826. static IncludesShadersStore: {
  98827. [key: string]: string;
  98828. };
  98829. /**
  98830. * Resets the cache of effects.
  98831. */
  98832. static ResetCache(): void;
  98833. }
  98834. }
  98835. declare module BABYLON {
  98836. /**
  98837. * Interface used to describe the capabilities of the engine relatively to the current browser
  98838. */
  98839. export interface EngineCapabilities {
  98840. /** Maximum textures units per fragment shader */
  98841. maxTexturesImageUnits: number;
  98842. /** Maximum texture units per vertex shader */
  98843. maxVertexTextureImageUnits: number;
  98844. /** Maximum textures units in the entire pipeline */
  98845. maxCombinedTexturesImageUnits: number;
  98846. /** Maximum texture size */
  98847. maxTextureSize: number;
  98848. /** Maximum texture samples */
  98849. maxSamples?: number;
  98850. /** Maximum cube texture size */
  98851. maxCubemapTextureSize: number;
  98852. /** Maximum render texture size */
  98853. maxRenderTextureSize: number;
  98854. /** Maximum number of vertex attributes */
  98855. maxVertexAttribs: number;
  98856. /** Maximum number of varyings */
  98857. maxVaryingVectors: number;
  98858. /** Maximum number of uniforms per vertex shader */
  98859. maxVertexUniformVectors: number;
  98860. /** Maximum number of uniforms per fragment shader */
  98861. maxFragmentUniformVectors: number;
  98862. /** Defines if standard derivates (dx/dy) are supported */
  98863. standardDerivatives: boolean;
  98864. /** Defines if s3tc texture compression is supported */
  98865. s3tc?: WEBGL_compressed_texture_s3tc;
  98866. /** Defines if pvrtc texture compression is supported */
  98867. pvrtc: any;
  98868. /** Defines if etc1 texture compression is supported */
  98869. etc1: any;
  98870. /** Defines if etc2 texture compression is supported */
  98871. etc2: any;
  98872. /** Defines if astc texture compression is supported */
  98873. astc: any;
  98874. /** Defines if float textures are supported */
  98875. textureFloat: boolean;
  98876. /** Defines if vertex array objects are supported */
  98877. vertexArrayObject: boolean;
  98878. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  98879. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  98880. /** Gets the maximum level of anisotropy supported */
  98881. maxAnisotropy: number;
  98882. /** Defines if instancing is supported */
  98883. instancedArrays: boolean;
  98884. /** Defines if 32 bits indices are supported */
  98885. uintIndices: boolean;
  98886. /** Defines if high precision shaders are supported */
  98887. highPrecisionShaderSupported: boolean;
  98888. /** Defines if depth reading in the fragment shader is supported */
  98889. fragmentDepthSupported: boolean;
  98890. /** Defines if float texture linear filtering is supported*/
  98891. textureFloatLinearFiltering: boolean;
  98892. /** Defines if rendering to float textures is supported */
  98893. textureFloatRender: boolean;
  98894. /** Defines if half float textures are supported*/
  98895. textureHalfFloat: boolean;
  98896. /** Defines if half float texture linear filtering is supported*/
  98897. textureHalfFloatLinearFiltering: boolean;
  98898. /** Defines if rendering to half float textures is supported */
  98899. textureHalfFloatRender: boolean;
  98900. /** Defines if textureLOD shader command is supported */
  98901. textureLOD: boolean;
  98902. /** Defines if draw buffers extension is supported */
  98903. drawBuffersExtension: boolean;
  98904. /** Defines if depth textures are supported */
  98905. depthTextureExtension: boolean;
  98906. /** Defines if float color buffer are supported */
  98907. colorBufferFloat: boolean;
  98908. /** Gets disjoint timer query extension (null if not supported) */
  98909. timerQuery?: EXT_disjoint_timer_query;
  98910. /** Defines if timestamp can be used with timer query */
  98911. canUseTimestampForTimerQuery: boolean;
  98912. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  98913. multiview?: any;
  98914. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  98915. oculusMultiview?: any;
  98916. /** Function used to let the system compiles shaders in background */
  98917. parallelShaderCompile?: {
  98918. COMPLETION_STATUS_KHR: number;
  98919. };
  98920. /** Max number of texture samples for MSAA */
  98921. maxMSAASamples: number;
  98922. /** Defines if the blend min max extension is supported */
  98923. blendMinMax: boolean;
  98924. }
  98925. }
  98926. declare module BABYLON {
  98927. /**
  98928. * @hidden
  98929. **/
  98930. export class DepthCullingState {
  98931. private _isDepthTestDirty;
  98932. private _isDepthMaskDirty;
  98933. private _isDepthFuncDirty;
  98934. private _isCullFaceDirty;
  98935. private _isCullDirty;
  98936. private _isZOffsetDirty;
  98937. private _isFrontFaceDirty;
  98938. private _depthTest;
  98939. private _depthMask;
  98940. private _depthFunc;
  98941. private _cull;
  98942. private _cullFace;
  98943. private _zOffset;
  98944. private _frontFace;
  98945. /**
  98946. * Initializes the state.
  98947. */
  98948. constructor();
  98949. readonly isDirty: boolean;
  98950. zOffset: number;
  98951. cullFace: Nullable<number>;
  98952. cull: Nullable<boolean>;
  98953. depthFunc: Nullable<number>;
  98954. depthMask: boolean;
  98955. depthTest: boolean;
  98956. frontFace: Nullable<number>;
  98957. reset(): void;
  98958. apply(gl: WebGLRenderingContext): void;
  98959. }
  98960. }
  98961. declare module BABYLON {
  98962. /**
  98963. * @hidden
  98964. **/
  98965. export class StencilState {
  98966. /** 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 */
  98967. static readonly ALWAYS: number;
  98968. /** Passed to stencilOperation to specify that stencil value must be kept */
  98969. static readonly KEEP: number;
  98970. /** Passed to stencilOperation to specify that stencil value must be replaced */
  98971. static readonly REPLACE: number;
  98972. private _isStencilTestDirty;
  98973. private _isStencilMaskDirty;
  98974. private _isStencilFuncDirty;
  98975. private _isStencilOpDirty;
  98976. private _stencilTest;
  98977. private _stencilMask;
  98978. private _stencilFunc;
  98979. private _stencilFuncRef;
  98980. private _stencilFuncMask;
  98981. private _stencilOpStencilFail;
  98982. private _stencilOpDepthFail;
  98983. private _stencilOpStencilDepthPass;
  98984. readonly isDirty: boolean;
  98985. stencilFunc: number;
  98986. stencilFuncRef: number;
  98987. stencilFuncMask: number;
  98988. stencilOpStencilFail: number;
  98989. stencilOpDepthFail: number;
  98990. stencilOpStencilDepthPass: number;
  98991. stencilMask: number;
  98992. stencilTest: boolean;
  98993. constructor();
  98994. reset(): void;
  98995. apply(gl: WebGLRenderingContext): void;
  98996. }
  98997. }
  98998. declare module BABYLON {
  98999. /**
  99000. * @hidden
  99001. **/
  99002. export class AlphaState {
  99003. private _isAlphaBlendDirty;
  99004. private _isBlendFunctionParametersDirty;
  99005. private _isBlendEquationParametersDirty;
  99006. private _isBlendConstantsDirty;
  99007. private _alphaBlend;
  99008. private _blendFunctionParameters;
  99009. private _blendEquationParameters;
  99010. private _blendConstants;
  99011. /**
  99012. * Initializes the state.
  99013. */
  99014. constructor();
  99015. readonly isDirty: boolean;
  99016. alphaBlend: boolean;
  99017. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  99018. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  99019. setAlphaEquationParameters(rgb: number, alpha: number): void;
  99020. reset(): void;
  99021. apply(gl: WebGLRenderingContext): void;
  99022. }
  99023. }
  99024. declare module BABYLON {
  99025. /** @hidden */
  99026. export class WebGL2ShaderProcessor implements IShaderProcessor {
  99027. attributeProcessor(attribute: string): string;
  99028. varyingProcessor(varying: string, isFragment: boolean): string;
  99029. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  99030. }
  99031. }
  99032. declare module BABYLON {
  99033. /**
  99034. * Interface for attribute information associated with buffer instanciation
  99035. */
  99036. export interface InstancingAttributeInfo {
  99037. /**
  99038. * Index/offset of the attribute in the vertex shader
  99039. */
  99040. index: number;
  99041. /**
  99042. * size of the attribute, 1, 2, 3 or 4
  99043. */
  99044. attributeSize: number;
  99045. /**
  99046. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  99047. * default is FLOAT
  99048. */
  99049. attributeType: number;
  99050. /**
  99051. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  99052. */
  99053. normalized: boolean;
  99054. /**
  99055. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  99056. */
  99057. offset: number;
  99058. /**
  99059. * Name of the GLSL attribute, for debugging purpose only
  99060. */
  99061. attributeName: string;
  99062. }
  99063. }
  99064. declare module BABYLON {
  99065. interface ThinEngine {
  99066. /**
  99067. * Update a video texture
  99068. * @param texture defines the texture to update
  99069. * @param video defines the video element to use
  99070. * @param invertY defines if data must be stored with Y axis inverted
  99071. */
  99072. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  99073. }
  99074. }
  99075. declare module BABYLON {
  99076. /**
  99077. * Settings for finer control over video usage
  99078. */
  99079. export interface VideoTextureSettings {
  99080. /**
  99081. * Applies `autoplay` to video, if specified
  99082. */
  99083. autoPlay?: boolean;
  99084. /**
  99085. * Applies `loop` to video, if specified
  99086. */
  99087. loop?: boolean;
  99088. /**
  99089. * Automatically updates internal texture from video at every frame in the render loop
  99090. */
  99091. autoUpdateTexture: boolean;
  99092. /**
  99093. * Image src displayed during the video loading or until the user interacts with the video.
  99094. */
  99095. poster?: string;
  99096. }
  99097. /**
  99098. * If you want to display a video in your scene, this is the special texture for that.
  99099. * This special texture works similar to other textures, with the exception of a few parameters.
  99100. * @see https://doc.babylonjs.com/how_to/video_texture
  99101. */
  99102. export class VideoTexture extends Texture {
  99103. /**
  99104. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  99105. */
  99106. readonly autoUpdateTexture: boolean;
  99107. /**
  99108. * The video instance used by the texture internally
  99109. */
  99110. readonly video: HTMLVideoElement;
  99111. private _onUserActionRequestedObservable;
  99112. /**
  99113. * Event triggerd when a dom action is required by the user to play the video.
  99114. * This happens due to recent changes in browser policies preventing video to auto start.
  99115. */
  99116. readonly onUserActionRequestedObservable: Observable<Texture>;
  99117. private _generateMipMaps;
  99118. private _engine;
  99119. private _stillImageCaptured;
  99120. private _displayingPosterTexture;
  99121. private _settings;
  99122. private _createInternalTextureOnEvent;
  99123. private _frameId;
  99124. /**
  99125. * Creates a video texture.
  99126. * If you want to display a video in your scene, this is the special texture for that.
  99127. * This special texture works similar to other textures, with the exception of a few parameters.
  99128. * @see https://doc.babylonjs.com/how_to/video_texture
  99129. * @param name optional name, will detect from video source, if not defined
  99130. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  99131. * @param scene is obviously the current scene.
  99132. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  99133. * @param invertY is false by default but can be used to invert video on Y axis
  99134. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  99135. * @param settings allows finer control over video usage
  99136. */
  99137. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  99138. private _getName;
  99139. private _getVideo;
  99140. private _createInternalTexture;
  99141. private reset;
  99142. /**
  99143. * @hidden Internal method to initiate `update`.
  99144. */
  99145. _rebuild(): void;
  99146. /**
  99147. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  99148. */
  99149. update(): void;
  99150. /**
  99151. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  99152. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  99153. */
  99154. updateTexture(isVisible: boolean): void;
  99155. protected _updateInternalTexture: () => void;
  99156. /**
  99157. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  99158. * @param url New url.
  99159. */
  99160. updateURL(url: string): void;
  99161. /**
  99162. * Dispose the texture and release its associated resources.
  99163. */
  99164. dispose(): void;
  99165. /**
  99166. * Creates a video texture straight from a stream.
  99167. * @param scene Define the scene the texture should be created in
  99168. * @param stream Define the stream the texture should be created from
  99169. * @returns The created video texture as a promise
  99170. */
  99171. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  99172. /**
  99173. * Creates a video texture straight from your WebCam video feed.
  99174. * @param scene Define the scene the texture should be created in
  99175. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99176. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99177. * @returns The created video texture as a promise
  99178. */
  99179. static CreateFromWebCamAsync(scene: Scene, constraints: {
  99180. minWidth: number;
  99181. maxWidth: number;
  99182. minHeight: number;
  99183. maxHeight: number;
  99184. deviceId: string;
  99185. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  99186. /**
  99187. * Creates a video texture straight from your WebCam video feed.
  99188. * @param scene Define the scene the texture should be created in
  99189. * @param onReady Define a callback to triggered once the texture will be ready
  99190. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99191. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99192. */
  99193. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  99194. minWidth: number;
  99195. maxWidth: number;
  99196. minHeight: number;
  99197. maxHeight: number;
  99198. deviceId: string;
  99199. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  99200. }
  99201. }
  99202. declare module BABYLON {
  99203. /**
  99204. * Defines the interface used by objects working like Scene
  99205. * @hidden
  99206. */
  99207. interface ISceneLike {
  99208. _addPendingData(data: any): void;
  99209. _removePendingData(data: any): void;
  99210. offlineProvider: IOfflineProvider;
  99211. }
  99212. /** Interface defining initialization parameters for Engine class */
  99213. export interface EngineOptions extends WebGLContextAttributes {
  99214. /**
  99215. * Defines if the engine should no exceed a specified device ratio
  99216. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  99217. */
  99218. limitDeviceRatio?: number;
  99219. /**
  99220. * Defines if webvr should be enabled automatically
  99221. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99222. */
  99223. autoEnableWebVR?: boolean;
  99224. /**
  99225. * Defines if webgl2 should be turned off even if supported
  99226. * @see http://doc.babylonjs.com/features/webgl2
  99227. */
  99228. disableWebGL2Support?: boolean;
  99229. /**
  99230. * Defines if webaudio should be initialized as well
  99231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99232. */
  99233. audioEngine?: boolean;
  99234. /**
  99235. * Defines if animations should run using a deterministic lock step
  99236. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99237. */
  99238. deterministicLockstep?: boolean;
  99239. /** Defines the maximum steps to use with deterministic lock step mode */
  99240. lockstepMaxSteps?: number;
  99241. /** Defines the seconds between each deterministic lock step */
  99242. timeStep?: number;
  99243. /**
  99244. * Defines that engine should ignore context lost events
  99245. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  99246. */
  99247. doNotHandleContextLost?: boolean;
  99248. /**
  99249. * Defines that engine should ignore modifying touch action attribute and style
  99250. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  99251. */
  99252. doNotHandleTouchAction?: boolean;
  99253. /**
  99254. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  99255. */
  99256. useHighPrecisionFloats?: boolean;
  99257. }
  99258. /**
  99259. * The base engine class (root of all engines)
  99260. */
  99261. export class ThinEngine {
  99262. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  99263. static ExceptionList: ({
  99264. key: string;
  99265. capture: string;
  99266. captureConstraint: number;
  99267. targets: string[];
  99268. } | {
  99269. key: string;
  99270. capture: null;
  99271. captureConstraint: null;
  99272. targets: string[];
  99273. })[];
  99274. /** @hidden */
  99275. static _TextureLoaders: IInternalTextureLoader[];
  99276. /**
  99277. * Returns the current npm package of the sdk
  99278. */
  99279. static readonly NpmPackage: string;
  99280. /**
  99281. * Returns the current version of the framework
  99282. */
  99283. static readonly Version: string;
  99284. /**
  99285. * Returns a string describing the current engine
  99286. */
  99287. readonly description: string;
  99288. /**
  99289. * Gets or sets the epsilon value used by collision engine
  99290. */
  99291. static CollisionsEpsilon: number;
  99292. /**
  99293. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  99294. */
  99295. static ShadersRepository: string;
  99296. /** @hidden */
  99297. _shaderProcessor: IShaderProcessor;
  99298. /**
  99299. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  99300. */
  99301. forcePOTTextures: boolean;
  99302. /**
  99303. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  99304. */
  99305. isFullscreen: boolean;
  99306. /**
  99307. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  99308. */
  99309. cullBackFaces: boolean;
  99310. /**
  99311. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  99312. */
  99313. renderEvenInBackground: boolean;
  99314. /**
  99315. * Gets or sets a boolean indicating that cache can be kept between frames
  99316. */
  99317. preventCacheWipeBetweenFrames: boolean;
  99318. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  99319. validateShaderPrograms: boolean;
  99320. /**
  99321. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  99322. * This can provide greater z depth for distant objects.
  99323. */
  99324. useReverseDepthBuffer: boolean;
  99325. /**
  99326. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  99327. */
  99328. disableUniformBuffers: boolean;
  99329. /** @hidden */
  99330. _uniformBuffers: UniformBuffer[];
  99331. /**
  99332. * Gets a boolean indicating that the engine supports uniform buffers
  99333. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  99334. */
  99335. readonly supportsUniformBuffers: boolean;
  99336. /** @hidden */
  99337. _gl: WebGLRenderingContext;
  99338. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  99339. protected _windowIsBackground: boolean;
  99340. protected _webGLVersion: number;
  99341. protected _creationOptions: EngineOptions;
  99342. protected _highPrecisionShadersAllowed: boolean;
  99343. /** @hidden */
  99344. readonly _shouldUseHighPrecisionShader: boolean;
  99345. /**
  99346. * Gets a boolean indicating that only power of 2 textures are supported
  99347. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  99348. */
  99349. readonly needPOTTextures: boolean;
  99350. /** @hidden */
  99351. _badOS: boolean;
  99352. /** @hidden */
  99353. _badDesktopOS: boolean;
  99354. private _hardwareScalingLevel;
  99355. /** @hidden */
  99356. _caps: EngineCapabilities;
  99357. private _isStencilEnable;
  99358. protected _colorWrite: boolean;
  99359. private _glVersion;
  99360. private _glRenderer;
  99361. private _glVendor;
  99362. /** @hidden */
  99363. _videoTextureSupported: boolean;
  99364. protected _renderingQueueLaunched: boolean;
  99365. protected _activeRenderLoops: (() => void)[];
  99366. /**
  99367. * Observable signaled when a context lost event is raised
  99368. */
  99369. onContextLostObservable: Observable<ThinEngine>;
  99370. /**
  99371. * Observable signaled when a context restored event is raised
  99372. */
  99373. onContextRestoredObservable: Observable<ThinEngine>;
  99374. private _onContextLost;
  99375. private _onContextRestored;
  99376. protected _contextWasLost: boolean;
  99377. /** @hidden */
  99378. _doNotHandleContextLost: boolean;
  99379. /**
  99380. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  99381. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  99382. */
  99383. doNotHandleContextLost: boolean;
  99384. /**
  99385. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  99386. */
  99387. disableVertexArrayObjects: boolean;
  99388. /** @hidden */
  99389. protected _depthCullingState: DepthCullingState;
  99390. /** @hidden */
  99391. protected _stencilState: StencilState;
  99392. /** @hidden */
  99393. protected _alphaState: AlphaState;
  99394. /** @hidden */
  99395. _internalTexturesCache: InternalTexture[];
  99396. /** @hidden */
  99397. protected _activeChannel: number;
  99398. private _currentTextureChannel;
  99399. /** @hidden */
  99400. protected _boundTexturesCache: {
  99401. [key: string]: Nullable<InternalTexture>;
  99402. };
  99403. /** @hidden */
  99404. protected _currentEffect: Nullable<Effect>;
  99405. /** @hidden */
  99406. protected _currentProgram: Nullable<WebGLProgram>;
  99407. private _compiledEffects;
  99408. private _vertexAttribArraysEnabled;
  99409. /** @hidden */
  99410. protected _cachedViewport: Nullable<IViewportLike>;
  99411. private _cachedVertexArrayObject;
  99412. /** @hidden */
  99413. protected _cachedVertexBuffers: any;
  99414. /** @hidden */
  99415. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  99416. /** @hidden */
  99417. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  99418. /** @hidden */
  99419. _currentRenderTarget: Nullable<InternalTexture>;
  99420. private _uintIndicesCurrentlySet;
  99421. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  99422. /** @hidden */
  99423. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  99424. private _currentBufferPointers;
  99425. private _currentInstanceLocations;
  99426. private _currentInstanceBuffers;
  99427. private _textureUnits;
  99428. /** @hidden */
  99429. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99430. /** @hidden */
  99431. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99432. /** @hidden */
  99433. _boundRenderFunction: any;
  99434. private _vaoRecordInProgress;
  99435. private _mustWipeVertexAttributes;
  99436. private _emptyTexture;
  99437. private _emptyCubeTexture;
  99438. private _emptyTexture3D;
  99439. private _emptyTexture2DArray;
  99440. /** @hidden */
  99441. _frameHandler: number;
  99442. private _nextFreeTextureSlots;
  99443. private _maxSimultaneousTextures;
  99444. private _activeRequests;
  99445. protected _texturesSupported: string[];
  99446. /** @hidden */
  99447. _textureFormatInUse: Nullable<string>;
  99448. protected readonly _supportsHardwareTextureRescaling: boolean;
  99449. /**
  99450. * Gets the list of texture formats supported
  99451. */
  99452. readonly texturesSupported: Array<string>;
  99453. /**
  99454. * Gets the list of texture formats in use
  99455. */
  99456. readonly textureFormatInUse: Nullable<string>;
  99457. /**
  99458. * Gets the current viewport
  99459. */
  99460. readonly currentViewport: Nullable<IViewportLike>;
  99461. /**
  99462. * Gets the default empty texture
  99463. */
  99464. readonly emptyTexture: InternalTexture;
  99465. /**
  99466. * Gets the default empty 3D texture
  99467. */
  99468. readonly emptyTexture3D: InternalTexture;
  99469. /**
  99470. * Gets the default empty 2D array texture
  99471. */
  99472. readonly emptyTexture2DArray: InternalTexture;
  99473. /**
  99474. * Gets the default empty cube texture
  99475. */
  99476. readonly emptyCubeTexture: InternalTexture;
  99477. /**
  99478. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  99479. */
  99480. readonly premultipliedAlpha: boolean;
  99481. /**
  99482. * Observable event triggered before each texture is initialized
  99483. */
  99484. onBeforeTextureInitObservable: Observable<Texture>;
  99485. /**
  99486. * Creates a new engine
  99487. * @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
  99488. * @param antialias defines enable antialiasing (default: false)
  99489. * @param options defines further options to be sent to the getContext() function
  99490. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99491. */
  99492. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99493. private _rebuildInternalTextures;
  99494. private _rebuildEffects;
  99495. /**
  99496. * Gets a boolean indicating if all created effects are ready
  99497. * @returns true if all effects are ready
  99498. */
  99499. areAllEffectsReady(): boolean;
  99500. protected _rebuildBuffers(): void;
  99501. private _initGLContext;
  99502. /**
  99503. * Gets version of the current webGL context
  99504. */
  99505. readonly webGLVersion: number;
  99506. /**
  99507. * Gets a string idenfifying the name of the class
  99508. * @returns "Engine" string
  99509. */
  99510. getClassName(): string;
  99511. /**
  99512. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  99513. */
  99514. readonly isStencilEnable: boolean;
  99515. /** @hidden */
  99516. _prepareWorkingCanvas(): void;
  99517. /**
  99518. * Reset the texture cache to empty state
  99519. */
  99520. resetTextureCache(): void;
  99521. /**
  99522. * Gets an object containing information about the current webGL context
  99523. * @returns an object containing the vender, the renderer and the version of the current webGL context
  99524. */
  99525. getGlInfo(): {
  99526. vendor: string;
  99527. renderer: string;
  99528. version: string;
  99529. };
  99530. /**
  99531. * Defines the hardware scaling level.
  99532. * By default the hardware scaling level is computed from the window device ratio.
  99533. * 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.
  99534. * @param level defines the level to use
  99535. */
  99536. setHardwareScalingLevel(level: number): void;
  99537. /**
  99538. * Gets the current hardware scaling level.
  99539. * By default the hardware scaling level is computed from the window device ratio.
  99540. * 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.
  99541. * @returns a number indicating the current hardware scaling level
  99542. */
  99543. getHardwareScalingLevel(): number;
  99544. /**
  99545. * Gets the list of loaded textures
  99546. * @returns an array containing all loaded textures
  99547. */
  99548. getLoadedTexturesCache(): InternalTexture[];
  99549. /**
  99550. * Gets the object containing all engine capabilities
  99551. * @returns the EngineCapabilities object
  99552. */
  99553. getCaps(): EngineCapabilities;
  99554. /**
  99555. * stop executing a render loop function and remove it from the execution array
  99556. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  99557. */
  99558. stopRenderLoop(renderFunction?: () => void): void;
  99559. /** @hidden */
  99560. _renderLoop(): void;
  99561. /**
  99562. * Gets the HTML canvas attached with the current webGL context
  99563. * @returns a HTML canvas
  99564. */
  99565. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  99566. /**
  99567. * Gets host window
  99568. * @returns the host window object
  99569. */
  99570. getHostWindow(): Nullable<Window>;
  99571. /**
  99572. * Gets the current render width
  99573. * @param useScreen defines if screen size must be used (or the current render target if any)
  99574. * @returns a number defining the current render width
  99575. */
  99576. getRenderWidth(useScreen?: boolean): number;
  99577. /**
  99578. * Gets the current render height
  99579. * @param useScreen defines if screen size must be used (or the current render target if any)
  99580. * @returns a number defining the current render height
  99581. */
  99582. getRenderHeight(useScreen?: boolean): number;
  99583. /**
  99584. * Can be used to override the current requestAnimationFrame requester.
  99585. * @hidden
  99586. */
  99587. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  99588. /**
  99589. * Register and execute a render loop. The engine can have more than one render function
  99590. * @param renderFunction defines the function to continuously execute
  99591. */
  99592. runRenderLoop(renderFunction: () => void): void;
  99593. /**
  99594. * Clear the current render buffer or the current render target (if any is set up)
  99595. * @param color defines the color to use
  99596. * @param backBuffer defines if the back buffer must be cleared
  99597. * @param depth defines if the depth buffer must be cleared
  99598. * @param stencil defines if the stencil buffer must be cleared
  99599. */
  99600. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99601. private _viewportCached;
  99602. /** @hidden */
  99603. _viewport(x: number, y: number, width: number, height: number): void;
  99604. /**
  99605. * Set the WebGL's viewport
  99606. * @param viewport defines the viewport element to be used
  99607. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  99608. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  99609. */
  99610. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  99611. /**
  99612. * Begin a new frame
  99613. */
  99614. beginFrame(): void;
  99615. /**
  99616. * Enf the current frame
  99617. */
  99618. endFrame(): void;
  99619. /**
  99620. * Resize the view according to the canvas' size
  99621. */
  99622. resize(): void;
  99623. /**
  99624. * Force a specific size of the canvas
  99625. * @param width defines the new canvas' width
  99626. * @param height defines the new canvas' height
  99627. */
  99628. setSize(width: number, height: number): void;
  99629. /**
  99630. * Binds the frame buffer to the specified texture.
  99631. * @param texture The texture to render to or null for the default canvas
  99632. * @param faceIndex The face of the texture to render to in case of cube texture
  99633. * @param requiredWidth The width of the target to render to
  99634. * @param requiredHeight The height of the target to render to
  99635. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  99636. * @param depthStencilTexture The depth stencil texture to use to render
  99637. * @param lodLevel defines le lod level to bind to the frame buffer
  99638. */
  99639. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  99640. /** @hidden */
  99641. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  99642. /**
  99643. * Unbind the current render target texture from the webGL context
  99644. * @param texture defines the render target texture to unbind
  99645. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99646. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99647. */
  99648. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99649. /**
  99650. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  99651. */
  99652. flushFramebuffer(): void;
  99653. /**
  99654. * Unbind the current render target and bind the default framebuffer
  99655. */
  99656. restoreDefaultFramebuffer(): void;
  99657. /** @hidden */
  99658. protected _resetVertexBufferBinding(): void;
  99659. /**
  99660. * Creates a vertex buffer
  99661. * @param data the data for the vertex buffer
  99662. * @returns the new WebGL static buffer
  99663. */
  99664. createVertexBuffer(data: DataArray): DataBuffer;
  99665. private _createVertexBuffer;
  99666. /**
  99667. * Creates a dynamic vertex buffer
  99668. * @param data the data for the dynamic vertex buffer
  99669. * @returns the new WebGL dynamic buffer
  99670. */
  99671. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  99672. protected _resetIndexBufferBinding(): void;
  99673. /**
  99674. * Creates a new index buffer
  99675. * @param indices defines the content of the index buffer
  99676. * @param updatable defines if the index buffer must be updatable
  99677. * @returns a new webGL buffer
  99678. */
  99679. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  99680. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  99681. /**
  99682. * Bind a webGL buffer to the webGL context
  99683. * @param buffer defines the buffer to bind
  99684. */
  99685. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  99686. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  99687. private bindBuffer;
  99688. /**
  99689. * update the bound buffer with the given data
  99690. * @param data defines the data to update
  99691. */
  99692. updateArrayBuffer(data: Float32Array): void;
  99693. private _vertexAttribPointer;
  99694. private _bindIndexBufferWithCache;
  99695. private _bindVertexBuffersAttributes;
  99696. /**
  99697. * Records a vertex array object
  99698. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  99699. * @param vertexBuffers defines the list of vertex buffers to store
  99700. * @param indexBuffer defines the index buffer to store
  99701. * @param effect defines the effect to store
  99702. * @returns the new vertex array object
  99703. */
  99704. recordVertexArrayObject(vertexBuffers: {
  99705. [key: string]: VertexBuffer;
  99706. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  99707. /**
  99708. * Bind a specific vertex array object
  99709. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  99710. * @param vertexArrayObject defines the vertex array object to bind
  99711. * @param indexBuffer defines the index buffer to bind
  99712. */
  99713. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  99714. /**
  99715. * Bind webGl buffers directly to the webGL context
  99716. * @param vertexBuffer defines the vertex buffer to bind
  99717. * @param indexBuffer defines the index buffer to bind
  99718. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  99719. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  99720. * @param effect defines the effect associated with the vertex buffer
  99721. */
  99722. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  99723. private _unbindVertexArrayObject;
  99724. /**
  99725. * Bind a list of vertex buffers to the webGL context
  99726. * @param vertexBuffers defines the list of vertex buffers to bind
  99727. * @param indexBuffer defines the index buffer to bind
  99728. * @param effect defines the effect associated with the vertex buffers
  99729. */
  99730. bindBuffers(vertexBuffers: {
  99731. [key: string]: Nullable<VertexBuffer>;
  99732. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  99733. /**
  99734. * Unbind all instance attributes
  99735. */
  99736. unbindInstanceAttributes(): void;
  99737. /**
  99738. * Release and free the memory of a vertex array object
  99739. * @param vao defines the vertex array object to delete
  99740. */
  99741. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  99742. /** @hidden */
  99743. _releaseBuffer(buffer: DataBuffer): boolean;
  99744. protected _deleteBuffer(buffer: DataBuffer): void;
  99745. /**
  99746. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  99747. * @param instancesBuffer defines the webGL buffer to update and bind
  99748. * @param data defines the data to store in the buffer
  99749. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  99750. */
  99751. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  99752. /**
  99753. * Apply all cached states (depth, culling, stencil and alpha)
  99754. */
  99755. applyStates(): void;
  99756. /**
  99757. * Send a draw order
  99758. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  99759. * @param indexStart defines the starting index
  99760. * @param indexCount defines the number of index to draw
  99761. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99762. */
  99763. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99764. /**
  99765. * Draw a list of points
  99766. * @param verticesStart defines the index of first vertex to draw
  99767. * @param verticesCount defines the count of vertices to draw
  99768. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99769. */
  99770. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99771. /**
  99772. * Draw a list of unindexed primitives
  99773. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  99774. * @param verticesStart defines the index of first vertex to draw
  99775. * @param verticesCount defines the count of vertices to draw
  99776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99777. */
  99778. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99779. /**
  99780. * Draw a list of indexed primitives
  99781. * @param fillMode defines the primitive to use
  99782. * @param indexStart defines the starting index
  99783. * @param indexCount defines the number of index to draw
  99784. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99785. */
  99786. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99787. /**
  99788. * Draw a list of unindexed primitives
  99789. * @param fillMode defines the primitive to use
  99790. * @param verticesStart defines the index of first vertex to draw
  99791. * @param verticesCount defines the count of vertices to draw
  99792. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99793. */
  99794. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99795. private _drawMode;
  99796. /** @hidden */
  99797. protected _reportDrawCall(): void;
  99798. /** @hidden */
  99799. _releaseEffect(effect: Effect): void;
  99800. /** @hidden */
  99801. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99802. /**
  99803. * Create a new effect (used to store vertex/fragment shaders)
  99804. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  99805. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  99806. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  99807. * @param samplers defines an array of string used to represent textures
  99808. * @param defines defines the string containing the defines to use to compile the shaders
  99809. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  99810. * @param onCompiled defines a function to call when the effect creation is successful
  99811. * @param onError defines a function to call when the effect creation has failed
  99812. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  99813. * @returns the new Effect
  99814. */
  99815. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  99816. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  99817. private _compileShader;
  99818. private _compileRawShader;
  99819. /**
  99820. * Directly creates a webGL program
  99821. * @param pipelineContext defines the pipeline context to attach to
  99822. * @param vertexCode defines the vertex shader code to use
  99823. * @param fragmentCode defines the fragment shader code to use
  99824. * @param context defines the webGL context to use (if not set, the current one will be used)
  99825. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  99826. * @returns the new webGL program
  99827. */
  99828. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99829. /**
  99830. * Creates a webGL program
  99831. * @param pipelineContext defines the pipeline context to attach to
  99832. * @param vertexCode defines the vertex shader code to use
  99833. * @param fragmentCode defines the fragment shader code to use
  99834. * @param defines defines the string containing the defines to use to compile the shaders
  99835. * @param context defines the webGL context to use (if not set, the current one will be used)
  99836. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  99837. * @returns the new webGL program
  99838. */
  99839. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99840. /**
  99841. * Creates a new pipeline context
  99842. * @returns the new pipeline
  99843. */
  99844. createPipelineContext(): IPipelineContext;
  99845. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99846. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  99847. /** @hidden */
  99848. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  99849. /** @hidden */
  99850. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  99851. /** @hidden */
  99852. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  99853. /**
  99854. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  99855. * @param pipelineContext defines the pipeline context to use
  99856. * @param uniformsNames defines the list of uniform names
  99857. * @returns an array of webGL uniform locations
  99858. */
  99859. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  99860. /**
  99861. * Gets the lsit of active attributes for a given webGL program
  99862. * @param pipelineContext defines the pipeline context to use
  99863. * @param attributesNames defines the list of attribute names to get
  99864. * @returns an array of indices indicating the offset of each attribute
  99865. */
  99866. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  99867. /**
  99868. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  99869. * @param effect defines the effect to activate
  99870. */
  99871. enableEffect(effect: Nullable<Effect>): void;
  99872. /**
  99873. * Set the value of an uniform to a number (int)
  99874. * @param uniform defines the webGL uniform location where to store the value
  99875. * @param value defines the int number to store
  99876. */
  99877. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  99878. /**
  99879. * Set the value of an uniform to an array of int32
  99880. * @param uniform defines the webGL uniform location where to store the value
  99881. * @param array defines the array of int32 to store
  99882. */
  99883. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99884. /**
  99885. * Set the value of an uniform to an array of int32 (stored as vec2)
  99886. * @param uniform defines the webGL uniform location where to store the value
  99887. * @param array defines the array of int32 to store
  99888. */
  99889. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99890. /**
  99891. * Set the value of an uniform to an array of int32 (stored as vec3)
  99892. * @param uniform defines the webGL uniform location where to store the value
  99893. * @param array defines the array of int32 to store
  99894. */
  99895. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99896. /**
  99897. * Set the value of an uniform to an array of int32 (stored as vec4)
  99898. * @param uniform defines the webGL uniform location where to store the value
  99899. * @param array defines the array of int32 to store
  99900. */
  99901. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99902. /**
  99903. * Set the value of an uniform to an array of number
  99904. * @param uniform defines the webGL uniform location where to store the value
  99905. * @param array defines the array of number to store
  99906. */
  99907. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  99908. /**
  99909. * Set the value of an uniform to an array of number (stored as vec2)
  99910. * @param uniform defines the webGL uniform location where to store the value
  99911. * @param array defines the array of number to store
  99912. */
  99913. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  99914. /**
  99915. * Set the value of an uniform to an array of number (stored as vec3)
  99916. * @param uniform defines the webGL uniform location where to store the value
  99917. * @param array defines the array of number to store
  99918. */
  99919. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  99920. /**
  99921. * Set the value of an uniform to an array of number (stored as vec4)
  99922. * @param uniform defines the webGL uniform location where to store the value
  99923. * @param array defines the array of number to store
  99924. */
  99925. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  99926. /**
  99927. * Set the value of an uniform to an array of float32 (stored as matrices)
  99928. * @param uniform defines the webGL uniform location where to store the value
  99929. * @param matrices defines the array of float32 to store
  99930. */
  99931. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  99932. /**
  99933. * Set the value of an uniform to a matrix (3x3)
  99934. * @param uniform defines the webGL uniform location where to store the value
  99935. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  99936. */
  99937. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  99938. /**
  99939. * Set the value of an uniform to a matrix (2x2)
  99940. * @param uniform defines the webGL uniform location where to store the value
  99941. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  99942. */
  99943. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  99944. /**
  99945. * Set the value of an uniform to a number (float)
  99946. * @param uniform defines the webGL uniform location where to store the value
  99947. * @param value defines the float number to store
  99948. */
  99949. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  99950. /**
  99951. * Set the value of an uniform to a vec2
  99952. * @param uniform defines the webGL uniform location where to store the value
  99953. * @param x defines the 1st component of the value
  99954. * @param y defines the 2nd component of the value
  99955. */
  99956. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  99957. /**
  99958. * Set the value of an uniform to a vec3
  99959. * @param uniform defines the webGL uniform location where to store the value
  99960. * @param x defines the 1st component of the value
  99961. * @param y defines the 2nd component of the value
  99962. * @param z defines the 3rd component of the value
  99963. */
  99964. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  99965. /**
  99966. * Set the value of an uniform to a vec4
  99967. * @param uniform defines the webGL uniform location where to store the value
  99968. * @param x defines the 1st component of the value
  99969. * @param y defines the 2nd component of the value
  99970. * @param z defines the 3rd component of the value
  99971. * @param w defines the 4th component of the value
  99972. */
  99973. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  99974. /**
  99975. * Gets the depth culling state manager
  99976. */
  99977. readonly depthCullingState: DepthCullingState;
  99978. /**
  99979. * Gets the alpha state manager
  99980. */
  99981. readonly alphaState: AlphaState;
  99982. /**
  99983. * Gets the stencil state manager
  99984. */
  99985. readonly stencilState: StencilState;
  99986. /**
  99987. * Clears the list of texture accessible through engine.
  99988. * This can help preventing texture load conflict due to name collision.
  99989. */
  99990. clearInternalTexturesCache(): void;
  99991. /**
  99992. * Force the entire cache to be cleared
  99993. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  99994. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  99995. */
  99996. wipeCaches(bruteForce?: boolean): void;
  99997. /** @hidden */
  99998. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  99999. min: number;
  100000. mag: number;
  100001. };
  100002. /** @hidden */
  100003. _createTexture(): WebGLTexture;
  100004. /**
  100005. * Usually called from Texture.ts.
  100006. * Passed information to create a WebGLTexture
  100007. * @param urlArg defines a value which contains one of the following:
  100008. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  100009. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  100010. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  100011. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  100012. * @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)
  100013. * @param scene needed for loading to the correct scene
  100014. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  100015. * @param onLoad optional callback to be called upon successful completion
  100016. * @param onError optional callback to be called upon failure
  100017. * @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
  100018. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  100019. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  100020. * @param forcedExtension defines the extension to use to pick the right loader
  100021. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  100022. * @param mimeType defines an optional mime type
  100023. * @returns a InternalTexture for assignment back into BABYLON.Texture
  100024. */
  100025. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  100026. /**
  100027. * @hidden
  100028. */
  100029. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100030. /**
  100031. * Creates a raw texture
  100032. * @param data defines the data to store in the texture
  100033. * @param width defines the width of the texture
  100034. * @param height defines the height of the texture
  100035. * @param format defines the format of the data
  100036. * @param generateMipMaps defines if the engine should generate the mip levels
  100037. * @param invertY defines if data must be stored with Y axis inverted
  100038. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  100039. * @param compression defines the compression used (null by default)
  100040. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  100041. * @returns the raw texture inside an InternalTexture
  100042. */
  100043. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  100044. /**
  100045. * Creates a new raw cube texture
  100046. * @param data defines the array of data to use to create each face
  100047. * @param size defines the size of the textures
  100048. * @param format defines the format of the data
  100049. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  100050. * @param generateMipMaps defines if the engine should generate the mip levels
  100051. * @param invertY defines if data must be stored with Y axis inverted
  100052. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100053. * @param compression defines the compression used (null by default)
  100054. * @returns the cube texture as an InternalTexture
  100055. */
  100056. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  100057. /**
  100058. * Creates a new raw 3D texture
  100059. * @param data defines the data used to create the texture
  100060. * @param width defines the width of the texture
  100061. * @param height defines the height of the texture
  100062. * @param depth defines the depth of the texture
  100063. * @param format defines the format of the texture
  100064. * @param generateMipMaps defines if the engine must generate mip levels
  100065. * @param invertY defines if data must be stored with Y axis inverted
  100066. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100067. * @param compression defines the compressed used (can be null)
  100068. * @param textureType defines the compressed used (can be null)
  100069. * @returns a new raw 3D texture (stored in an InternalTexture)
  100070. */
  100071. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100072. /**
  100073. * Creates a new raw 2D array texture
  100074. * @param data defines the data used to create the texture
  100075. * @param width defines the width of the texture
  100076. * @param height defines the height of the texture
  100077. * @param depth defines the number of layers of the texture
  100078. * @param format defines the format of the texture
  100079. * @param generateMipMaps defines if the engine must generate mip levels
  100080. * @param invertY defines if data must be stored with Y axis inverted
  100081. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100082. * @param compression defines the compressed used (can be null)
  100083. * @param textureType defines the compressed used (can be null)
  100084. * @returns a new raw 2D array texture (stored in an InternalTexture)
  100085. */
  100086. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100087. private _unpackFlipYCached;
  100088. /**
  100089. * In case you are sharing the context with other applications, it might
  100090. * be interested to not cache the unpack flip y state to ensure a consistent
  100091. * value would be set.
  100092. */
  100093. enableUnpackFlipYCached: boolean;
  100094. /** @hidden */
  100095. _unpackFlipY(value: boolean): void;
  100096. /** @hidden */
  100097. _getUnpackAlignement(): number;
  100098. /**
  100099. * Update the sampling mode of a given texture
  100100. * @param samplingMode defines the required sampling mode
  100101. * @param texture defines the texture to update
  100102. */
  100103. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100104. /** @hidden */
  100105. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  100106. width: number;
  100107. height: number;
  100108. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  100109. /** @hidden */
  100110. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100111. /** @hidden */
  100112. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  100113. /** @hidden */
  100114. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100115. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  100116. private _prepareWebGLTexture;
  100117. /** @hidden */
  100118. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  100119. /** @hidden */
  100120. _releaseFramebufferObjects(texture: InternalTexture): void;
  100121. /** @hidden */
  100122. _releaseTexture(texture: InternalTexture): void;
  100123. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  100124. protected _setProgram(program: WebGLProgram): void;
  100125. protected _boundUniforms: {
  100126. [key: number]: WebGLUniformLocation;
  100127. };
  100128. /**
  100129. * Binds an effect to the webGL context
  100130. * @param effect defines the effect to bind
  100131. */
  100132. bindSamplers(effect: Effect): void;
  100133. private _activateCurrentTexture;
  100134. /** @hidden */
  100135. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  100136. /** @hidden */
  100137. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  100138. /**
  100139. * Unbind all textures from the webGL context
  100140. */
  100141. unbindAllTextures(): void;
  100142. /**
  100143. * Sets a texture to the according uniform.
  100144. * @param channel The texture channel
  100145. * @param uniform The uniform to set
  100146. * @param texture The texture to apply
  100147. */
  100148. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  100149. private _bindSamplerUniformToChannel;
  100150. private _getTextureWrapMode;
  100151. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  100152. /**
  100153. * Sets an array of texture to the webGL context
  100154. * @param channel defines the channel where the texture array must be set
  100155. * @param uniform defines the associated uniform location
  100156. * @param textures defines the array of textures to bind
  100157. */
  100158. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  100159. /** @hidden */
  100160. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  100161. private _setTextureParameterFloat;
  100162. private _setTextureParameterInteger;
  100163. /**
  100164. * Unbind all vertex attributes from the webGL context
  100165. */
  100166. unbindAllAttributes(): void;
  100167. /**
  100168. * 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
  100169. */
  100170. releaseEffects(): void;
  100171. /**
  100172. * Dispose and release all associated resources
  100173. */
  100174. dispose(): void;
  100175. /**
  100176. * Attach a new callback raised when context lost event is fired
  100177. * @param callback defines the callback to call
  100178. */
  100179. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100180. /**
  100181. * Attach a new callback raised when context restored event is fired
  100182. * @param callback defines the callback to call
  100183. */
  100184. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100185. /**
  100186. * Get the current error code of the webGL context
  100187. * @returns the error code
  100188. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100189. */
  100190. getError(): number;
  100191. private _canRenderToFloatFramebuffer;
  100192. private _canRenderToHalfFloatFramebuffer;
  100193. private _canRenderToFramebuffer;
  100194. /** @hidden */
  100195. _getWebGLTextureType(type: number): number;
  100196. /** @hidden */
  100197. _getInternalFormat(format: number): number;
  100198. /** @hidden */
  100199. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  100200. /** @hidden */
  100201. _getRGBAMultiSampleBufferFormat(type: number): number;
  100202. /** @hidden */
  100203. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  100204. /**
  100205. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  100206. * @returns true if the engine can be created
  100207. * @ignorenaming
  100208. */
  100209. static isSupported(): boolean;
  100210. /**
  100211. * Find the next highest power of two.
  100212. * @param x Number to start search from.
  100213. * @return Next highest power of two.
  100214. */
  100215. static CeilingPOT(x: number): number;
  100216. /**
  100217. * Find the next lowest power of two.
  100218. * @param x Number to start search from.
  100219. * @return Next lowest power of two.
  100220. */
  100221. static FloorPOT(x: number): number;
  100222. /**
  100223. * Find the nearest power of two.
  100224. * @param x Number to start search from.
  100225. * @return Next nearest power of two.
  100226. */
  100227. static NearestPOT(x: number): number;
  100228. /**
  100229. * Get the closest exponent of two
  100230. * @param value defines the value to approximate
  100231. * @param max defines the maximum value to return
  100232. * @param mode defines how to define the closest value
  100233. * @returns closest exponent of two of the given value
  100234. */
  100235. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  100236. /**
  100237. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  100238. * @param func - the function to be called
  100239. * @param requester - the object that will request the next frame. Falls back to window.
  100240. * @returns frame number
  100241. */
  100242. static QueueNewFrame(func: () => void, requester?: any): number;
  100243. /**
  100244. * Gets host document
  100245. * @returns the host document object
  100246. */
  100247. getHostDocument(): Document;
  100248. }
  100249. }
  100250. declare module BABYLON {
  100251. /**
  100252. * Class representing spherical harmonics coefficients to the 3rd degree
  100253. */
  100254. export class SphericalHarmonics {
  100255. /**
  100256. * Defines whether or not the harmonics have been prescaled for rendering.
  100257. */
  100258. preScaled: boolean;
  100259. /**
  100260. * The l0,0 coefficients of the spherical harmonics
  100261. */
  100262. l00: Vector3;
  100263. /**
  100264. * The l1,-1 coefficients of the spherical harmonics
  100265. */
  100266. l1_1: Vector3;
  100267. /**
  100268. * The l1,0 coefficients of the spherical harmonics
  100269. */
  100270. l10: Vector3;
  100271. /**
  100272. * The l1,1 coefficients of the spherical harmonics
  100273. */
  100274. l11: Vector3;
  100275. /**
  100276. * The l2,-2 coefficients of the spherical harmonics
  100277. */
  100278. l2_2: Vector3;
  100279. /**
  100280. * The l2,-1 coefficients of the spherical harmonics
  100281. */
  100282. l2_1: Vector3;
  100283. /**
  100284. * The l2,0 coefficients of the spherical harmonics
  100285. */
  100286. l20: Vector3;
  100287. /**
  100288. * The l2,1 coefficients of the spherical harmonics
  100289. */
  100290. l21: Vector3;
  100291. /**
  100292. * The l2,2 coefficients of the spherical harmonics
  100293. */
  100294. l22: Vector3;
  100295. /**
  100296. * Adds a light to the spherical harmonics
  100297. * @param direction the direction of the light
  100298. * @param color the color of the light
  100299. * @param deltaSolidAngle the delta solid angle of the light
  100300. */
  100301. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  100302. /**
  100303. * Scales the spherical harmonics by the given amount
  100304. * @param scale the amount to scale
  100305. */
  100306. scaleInPlace(scale: number): void;
  100307. /**
  100308. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  100309. *
  100310. * ```
  100311. * E_lm = A_l * L_lm
  100312. * ```
  100313. *
  100314. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  100315. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  100316. * the scaling factors are given in equation 9.
  100317. */
  100318. convertIncidentRadianceToIrradiance(): void;
  100319. /**
  100320. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  100321. *
  100322. * ```
  100323. * L = (1/pi) * E * rho
  100324. * ```
  100325. *
  100326. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  100327. */
  100328. convertIrradianceToLambertianRadiance(): void;
  100329. /**
  100330. * Integrates the reconstruction coefficients directly in to the SH preventing further
  100331. * required operations at run time.
  100332. *
  100333. * This is simply done by scaling back the SH with Ylm constants parameter.
  100334. * The trigonometric part being applied by the shader at run time.
  100335. */
  100336. preScaleForRendering(): void;
  100337. /**
  100338. * Constructs a spherical harmonics from an array.
  100339. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  100340. * @returns the spherical harmonics
  100341. */
  100342. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  100343. /**
  100344. * Gets the spherical harmonics from polynomial
  100345. * @param polynomial the spherical polynomial
  100346. * @returns the spherical harmonics
  100347. */
  100348. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  100349. }
  100350. /**
  100351. * Class representing spherical polynomial coefficients to the 3rd degree
  100352. */
  100353. export class SphericalPolynomial {
  100354. private _harmonics;
  100355. /**
  100356. * The spherical harmonics used to create the polynomials.
  100357. */
  100358. readonly preScaledHarmonics: SphericalHarmonics;
  100359. /**
  100360. * The x coefficients of the spherical polynomial
  100361. */
  100362. x: Vector3;
  100363. /**
  100364. * The y coefficients of the spherical polynomial
  100365. */
  100366. y: Vector3;
  100367. /**
  100368. * The z coefficients of the spherical polynomial
  100369. */
  100370. z: Vector3;
  100371. /**
  100372. * The xx coefficients of the spherical polynomial
  100373. */
  100374. xx: Vector3;
  100375. /**
  100376. * The yy coefficients of the spherical polynomial
  100377. */
  100378. yy: Vector3;
  100379. /**
  100380. * The zz coefficients of the spherical polynomial
  100381. */
  100382. zz: Vector3;
  100383. /**
  100384. * The xy coefficients of the spherical polynomial
  100385. */
  100386. xy: Vector3;
  100387. /**
  100388. * The yz coefficients of the spherical polynomial
  100389. */
  100390. yz: Vector3;
  100391. /**
  100392. * The zx coefficients of the spherical polynomial
  100393. */
  100394. zx: Vector3;
  100395. /**
  100396. * Adds an ambient color to the spherical polynomial
  100397. * @param color the color to add
  100398. */
  100399. addAmbient(color: Color3): void;
  100400. /**
  100401. * Scales the spherical polynomial by the given amount
  100402. * @param scale the amount to scale
  100403. */
  100404. scaleInPlace(scale: number): void;
  100405. /**
  100406. * Gets the spherical polynomial from harmonics
  100407. * @param harmonics the spherical harmonics
  100408. * @returns the spherical polynomial
  100409. */
  100410. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  100411. /**
  100412. * Constructs a spherical polynomial from an array.
  100413. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  100414. * @returns the spherical polynomial
  100415. */
  100416. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  100417. }
  100418. }
  100419. declare module BABYLON {
  100420. /**
  100421. * Defines the source of the internal texture
  100422. */
  100423. export enum InternalTextureSource {
  100424. /**
  100425. * The source of the texture data is unknown
  100426. */
  100427. Unknown = 0,
  100428. /**
  100429. * Texture data comes from an URL
  100430. */
  100431. Url = 1,
  100432. /**
  100433. * Texture data is only used for temporary storage
  100434. */
  100435. Temp = 2,
  100436. /**
  100437. * Texture data comes from raw data (ArrayBuffer)
  100438. */
  100439. Raw = 3,
  100440. /**
  100441. * Texture content is dynamic (video or dynamic texture)
  100442. */
  100443. Dynamic = 4,
  100444. /**
  100445. * Texture content is generated by rendering to it
  100446. */
  100447. RenderTarget = 5,
  100448. /**
  100449. * Texture content is part of a multi render target process
  100450. */
  100451. MultiRenderTarget = 6,
  100452. /**
  100453. * Texture data comes from a cube data file
  100454. */
  100455. Cube = 7,
  100456. /**
  100457. * Texture data comes from a raw cube data
  100458. */
  100459. CubeRaw = 8,
  100460. /**
  100461. * Texture data come from a prefiltered cube data file
  100462. */
  100463. CubePrefiltered = 9,
  100464. /**
  100465. * Texture content is raw 3D data
  100466. */
  100467. Raw3D = 10,
  100468. /**
  100469. * Texture content is raw 2D array data
  100470. */
  100471. Raw2DArray = 11,
  100472. /**
  100473. * Texture content is a depth texture
  100474. */
  100475. Depth = 12,
  100476. /**
  100477. * Texture data comes from a raw cube data encoded with RGBD
  100478. */
  100479. CubeRawRGBD = 13
  100480. }
  100481. /**
  100482. * Class used to store data associated with WebGL texture data for the engine
  100483. * This class should not be used directly
  100484. */
  100485. export class InternalTexture {
  100486. /** @hidden */
  100487. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  100488. /**
  100489. * Defines if the texture is ready
  100490. */
  100491. isReady: boolean;
  100492. /**
  100493. * Defines if the texture is a cube texture
  100494. */
  100495. isCube: boolean;
  100496. /**
  100497. * Defines if the texture contains 3D data
  100498. */
  100499. is3D: boolean;
  100500. /**
  100501. * Defines if the texture contains 2D array data
  100502. */
  100503. is2DArray: boolean;
  100504. /**
  100505. * Defines if the texture contains multiview data
  100506. */
  100507. isMultiview: boolean;
  100508. /**
  100509. * Gets the URL used to load this texture
  100510. */
  100511. url: string;
  100512. /**
  100513. * Gets the sampling mode of the texture
  100514. */
  100515. samplingMode: number;
  100516. /**
  100517. * Gets a boolean indicating if the texture needs mipmaps generation
  100518. */
  100519. generateMipMaps: boolean;
  100520. /**
  100521. * Gets the number of samples used by the texture (WebGL2+ only)
  100522. */
  100523. samples: number;
  100524. /**
  100525. * Gets the type of the texture (int, float...)
  100526. */
  100527. type: number;
  100528. /**
  100529. * Gets the format of the texture (RGB, RGBA...)
  100530. */
  100531. format: number;
  100532. /**
  100533. * Observable called when the texture is loaded
  100534. */
  100535. onLoadedObservable: Observable<InternalTexture>;
  100536. /**
  100537. * Gets the width of the texture
  100538. */
  100539. width: number;
  100540. /**
  100541. * Gets the height of the texture
  100542. */
  100543. height: number;
  100544. /**
  100545. * Gets the depth of the texture
  100546. */
  100547. depth: number;
  100548. /**
  100549. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  100550. */
  100551. baseWidth: number;
  100552. /**
  100553. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  100554. */
  100555. baseHeight: number;
  100556. /**
  100557. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  100558. */
  100559. baseDepth: number;
  100560. /**
  100561. * Gets a boolean indicating if the texture is inverted on Y axis
  100562. */
  100563. invertY: boolean;
  100564. /** @hidden */
  100565. _invertVScale: boolean;
  100566. /** @hidden */
  100567. _associatedChannel: number;
  100568. /** @hidden */
  100569. _source: InternalTextureSource;
  100570. /** @hidden */
  100571. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100572. /** @hidden */
  100573. _bufferView: Nullable<ArrayBufferView>;
  100574. /** @hidden */
  100575. _bufferViewArray: Nullable<ArrayBufferView[]>;
  100576. /** @hidden */
  100577. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  100578. /** @hidden */
  100579. _size: number;
  100580. /** @hidden */
  100581. _extension: string;
  100582. /** @hidden */
  100583. _files: Nullable<string[]>;
  100584. /** @hidden */
  100585. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  100586. /** @hidden */
  100587. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  100588. /** @hidden */
  100589. _framebuffer: Nullable<WebGLFramebuffer>;
  100590. /** @hidden */
  100591. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  100592. /** @hidden */
  100593. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  100594. /** @hidden */
  100595. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  100596. /** @hidden */
  100597. _attachments: Nullable<number[]>;
  100598. /** @hidden */
  100599. _cachedCoordinatesMode: Nullable<number>;
  100600. /** @hidden */
  100601. _cachedWrapU: Nullable<number>;
  100602. /** @hidden */
  100603. _cachedWrapV: Nullable<number>;
  100604. /** @hidden */
  100605. _cachedWrapR: Nullable<number>;
  100606. /** @hidden */
  100607. _cachedAnisotropicFilteringLevel: Nullable<number>;
  100608. /** @hidden */
  100609. _isDisabled: boolean;
  100610. /** @hidden */
  100611. _compression: Nullable<string>;
  100612. /** @hidden */
  100613. _generateStencilBuffer: boolean;
  100614. /** @hidden */
  100615. _generateDepthBuffer: boolean;
  100616. /** @hidden */
  100617. _comparisonFunction: number;
  100618. /** @hidden */
  100619. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  100620. /** @hidden */
  100621. _lodGenerationScale: number;
  100622. /** @hidden */
  100623. _lodGenerationOffset: number;
  100624. /** @hidden */
  100625. _colorTextureArray: Nullable<WebGLTexture>;
  100626. /** @hidden */
  100627. _depthStencilTextureArray: Nullable<WebGLTexture>;
  100628. /** @hidden */
  100629. _lodTextureHigh: Nullable<BaseTexture>;
  100630. /** @hidden */
  100631. _lodTextureMid: Nullable<BaseTexture>;
  100632. /** @hidden */
  100633. _lodTextureLow: Nullable<BaseTexture>;
  100634. /** @hidden */
  100635. _isRGBD: boolean;
  100636. /** @hidden */
  100637. _linearSpecularLOD: boolean;
  100638. /** @hidden */
  100639. _irradianceTexture: Nullable<BaseTexture>;
  100640. /** @hidden */
  100641. _webGLTexture: Nullable<WebGLTexture>;
  100642. /** @hidden */
  100643. _references: number;
  100644. private _engine;
  100645. /**
  100646. * Gets the Engine the texture belongs to.
  100647. * @returns The babylon engine
  100648. */
  100649. getEngine(): ThinEngine;
  100650. /**
  100651. * Gets the data source type of the texture
  100652. */
  100653. readonly source: InternalTextureSource;
  100654. /**
  100655. * Creates a new InternalTexture
  100656. * @param engine defines the engine to use
  100657. * @param source defines the type of data that will be used
  100658. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100659. */
  100660. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  100661. /**
  100662. * Increments the number of references (ie. the number of Texture that point to it)
  100663. */
  100664. incrementReferences(): void;
  100665. /**
  100666. * Change the size of the texture (not the size of the content)
  100667. * @param width defines the new width
  100668. * @param height defines the new height
  100669. * @param depth defines the new depth (1 by default)
  100670. */
  100671. updateSize(width: int, height: int, depth?: int): void;
  100672. /** @hidden */
  100673. _rebuild(): void;
  100674. /** @hidden */
  100675. _swapAndDie(target: InternalTexture): void;
  100676. /**
  100677. * Dispose the current allocated resources
  100678. */
  100679. dispose(): void;
  100680. }
  100681. }
  100682. declare module BABYLON {
  100683. /**
  100684. * Class used to work with sound analyzer using fast fourier transform (FFT)
  100685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100686. */
  100687. export class Analyser {
  100688. /**
  100689. * Gets or sets the smoothing
  100690. * @ignorenaming
  100691. */
  100692. SMOOTHING: number;
  100693. /**
  100694. * Gets or sets the FFT table size
  100695. * @ignorenaming
  100696. */
  100697. FFT_SIZE: number;
  100698. /**
  100699. * Gets or sets the bar graph amplitude
  100700. * @ignorenaming
  100701. */
  100702. BARGRAPHAMPLITUDE: number;
  100703. /**
  100704. * Gets or sets the position of the debug canvas
  100705. * @ignorenaming
  100706. */
  100707. DEBUGCANVASPOS: {
  100708. x: number;
  100709. y: number;
  100710. };
  100711. /**
  100712. * Gets or sets the debug canvas size
  100713. * @ignorenaming
  100714. */
  100715. DEBUGCANVASSIZE: {
  100716. width: number;
  100717. height: number;
  100718. };
  100719. private _byteFreqs;
  100720. private _byteTime;
  100721. private _floatFreqs;
  100722. private _webAudioAnalyser;
  100723. private _debugCanvas;
  100724. private _debugCanvasContext;
  100725. private _scene;
  100726. private _registerFunc;
  100727. private _audioEngine;
  100728. /**
  100729. * Creates a new analyser
  100730. * @param scene defines hosting scene
  100731. */
  100732. constructor(scene: Scene);
  100733. /**
  100734. * Get the number of data values you will have to play with for the visualization
  100735. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  100736. * @returns a number
  100737. */
  100738. getFrequencyBinCount(): number;
  100739. /**
  100740. * Gets the current frequency data as a byte array
  100741. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  100742. * @returns a Uint8Array
  100743. */
  100744. getByteFrequencyData(): Uint8Array;
  100745. /**
  100746. * Gets the current waveform as a byte array
  100747. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  100748. * @returns a Uint8Array
  100749. */
  100750. getByteTimeDomainData(): Uint8Array;
  100751. /**
  100752. * Gets the current frequency data as a float array
  100753. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  100754. * @returns a Float32Array
  100755. */
  100756. getFloatFrequencyData(): Float32Array;
  100757. /**
  100758. * Renders the debug canvas
  100759. */
  100760. drawDebugCanvas(): void;
  100761. /**
  100762. * Stops rendering the debug canvas and removes it
  100763. */
  100764. stopDebugCanvas(): void;
  100765. /**
  100766. * Connects two audio nodes
  100767. * @param inputAudioNode defines first node to connect
  100768. * @param outputAudioNode defines second node to connect
  100769. */
  100770. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  100771. /**
  100772. * Releases all associated resources
  100773. */
  100774. dispose(): void;
  100775. }
  100776. }
  100777. declare module BABYLON {
  100778. /**
  100779. * This represents an audio engine and it is responsible
  100780. * to play, synchronize and analyse sounds throughout the application.
  100781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100782. */
  100783. export interface IAudioEngine extends IDisposable {
  100784. /**
  100785. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  100786. */
  100787. readonly canUseWebAudio: boolean;
  100788. /**
  100789. * Gets the current AudioContext if available.
  100790. */
  100791. readonly audioContext: Nullable<AudioContext>;
  100792. /**
  100793. * The master gain node defines the global audio volume of your audio engine.
  100794. */
  100795. readonly masterGain: GainNode;
  100796. /**
  100797. * Gets whether or not mp3 are supported by your browser.
  100798. */
  100799. readonly isMP3supported: boolean;
  100800. /**
  100801. * Gets whether or not ogg are supported by your browser.
  100802. */
  100803. readonly isOGGsupported: boolean;
  100804. /**
  100805. * Defines if Babylon should emit a warning if WebAudio is not supported.
  100806. * @ignoreNaming
  100807. */
  100808. WarnedWebAudioUnsupported: boolean;
  100809. /**
  100810. * Defines if the audio engine relies on a custom unlocked button.
  100811. * In this case, the embedded button will not be displayed.
  100812. */
  100813. useCustomUnlockedButton: boolean;
  100814. /**
  100815. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  100816. */
  100817. readonly unlocked: boolean;
  100818. /**
  100819. * Event raised when audio has been unlocked on the browser.
  100820. */
  100821. onAudioUnlockedObservable: Observable<AudioEngine>;
  100822. /**
  100823. * Event raised when audio has been locked on the browser.
  100824. */
  100825. onAudioLockedObservable: Observable<AudioEngine>;
  100826. /**
  100827. * Flags the audio engine in Locked state.
  100828. * This happens due to new browser policies preventing audio to autoplay.
  100829. */
  100830. lock(): void;
  100831. /**
  100832. * Unlocks the audio engine once a user action has been done on the dom.
  100833. * This is helpful to resume play once browser policies have been satisfied.
  100834. */
  100835. unlock(): void;
  100836. }
  100837. /**
  100838. * This represents the default audio engine used in babylon.
  100839. * It is responsible to play, synchronize and analyse sounds throughout the application.
  100840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100841. */
  100842. export class AudioEngine implements IAudioEngine {
  100843. private _audioContext;
  100844. private _audioContextInitialized;
  100845. private _muteButton;
  100846. private _hostElement;
  100847. /**
  100848. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  100849. */
  100850. canUseWebAudio: boolean;
  100851. /**
  100852. * The master gain node defines the global audio volume of your audio engine.
  100853. */
  100854. masterGain: GainNode;
  100855. /**
  100856. * Defines if Babylon should emit a warning if WebAudio is not supported.
  100857. * @ignoreNaming
  100858. */
  100859. WarnedWebAudioUnsupported: boolean;
  100860. /**
  100861. * Gets whether or not mp3 are supported by your browser.
  100862. */
  100863. isMP3supported: boolean;
  100864. /**
  100865. * Gets whether or not ogg are supported by your browser.
  100866. */
  100867. isOGGsupported: boolean;
  100868. /**
  100869. * Gets whether audio has been unlocked on the device.
  100870. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  100871. * a user interaction has happened.
  100872. */
  100873. unlocked: boolean;
  100874. /**
  100875. * Defines if the audio engine relies on a custom unlocked button.
  100876. * In this case, the embedded button will not be displayed.
  100877. */
  100878. useCustomUnlockedButton: boolean;
  100879. /**
  100880. * Event raised when audio has been unlocked on the browser.
  100881. */
  100882. onAudioUnlockedObservable: Observable<AudioEngine>;
  100883. /**
  100884. * Event raised when audio has been locked on the browser.
  100885. */
  100886. onAudioLockedObservable: Observable<AudioEngine>;
  100887. /**
  100888. * Gets the current AudioContext if available.
  100889. */
  100890. readonly audioContext: Nullable<AudioContext>;
  100891. private _connectedAnalyser;
  100892. /**
  100893. * Instantiates a new audio engine.
  100894. *
  100895. * There should be only one per page as some browsers restrict the number
  100896. * of audio contexts you can create.
  100897. * @param hostElement defines the host element where to display the mute icon if necessary
  100898. */
  100899. constructor(hostElement?: Nullable<HTMLElement>);
  100900. /**
  100901. * Flags the audio engine in Locked state.
  100902. * This happens due to new browser policies preventing audio to autoplay.
  100903. */
  100904. lock(): void;
  100905. /**
  100906. * Unlocks the audio engine once a user action has been done on the dom.
  100907. * This is helpful to resume play once browser policies have been satisfied.
  100908. */
  100909. unlock(): void;
  100910. private _resumeAudioContext;
  100911. private _initializeAudioContext;
  100912. private _tryToRun;
  100913. private _triggerRunningState;
  100914. private _triggerSuspendedState;
  100915. private _displayMuteButton;
  100916. private _moveButtonToTopLeft;
  100917. private _onResize;
  100918. private _hideMuteButton;
  100919. /**
  100920. * Destroy and release the resources associated with the audio ccontext.
  100921. */
  100922. dispose(): void;
  100923. /**
  100924. * Gets the global volume sets on the master gain.
  100925. * @returns the global volume if set or -1 otherwise
  100926. */
  100927. getGlobalVolume(): number;
  100928. /**
  100929. * Sets the global volume of your experience (sets on the master gain).
  100930. * @param newVolume Defines the new global volume of the application
  100931. */
  100932. setGlobalVolume(newVolume: number): void;
  100933. /**
  100934. * Connect the audio engine to an audio analyser allowing some amazing
  100935. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  100936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  100937. * @param analyser The analyser to connect to the engine
  100938. */
  100939. connectToAnalyser(analyser: Analyser): void;
  100940. }
  100941. }
  100942. declare module BABYLON {
  100943. /**
  100944. * Interface used to present a loading screen while loading a scene
  100945. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100946. */
  100947. export interface ILoadingScreen {
  100948. /**
  100949. * Function called to display the loading screen
  100950. */
  100951. displayLoadingUI: () => void;
  100952. /**
  100953. * Function called to hide the loading screen
  100954. */
  100955. hideLoadingUI: () => void;
  100956. /**
  100957. * Gets or sets the color to use for the background
  100958. */
  100959. loadingUIBackgroundColor: string;
  100960. /**
  100961. * Gets or sets the text to display while loading
  100962. */
  100963. loadingUIText: string;
  100964. }
  100965. /**
  100966. * Class used for the default loading screen
  100967. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100968. */
  100969. export class DefaultLoadingScreen implements ILoadingScreen {
  100970. private _renderingCanvas;
  100971. private _loadingText;
  100972. private _loadingDivBackgroundColor;
  100973. private _loadingDiv;
  100974. private _loadingTextDiv;
  100975. /** Gets or sets the logo url to use for the default loading screen */
  100976. static DefaultLogoUrl: string;
  100977. /** Gets or sets the spinner url to use for the default loading screen */
  100978. static DefaultSpinnerUrl: string;
  100979. /**
  100980. * Creates a new default loading screen
  100981. * @param _renderingCanvas defines the canvas used to render the scene
  100982. * @param _loadingText defines the default text to display
  100983. * @param _loadingDivBackgroundColor defines the default background color
  100984. */
  100985. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  100986. /**
  100987. * Function called to display the loading screen
  100988. */
  100989. displayLoadingUI(): void;
  100990. /**
  100991. * Function called to hide the loading screen
  100992. */
  100993. hideLoadingUI(): void;
  100994. /**
  100995. * Gets or sets the text to display while loading
  100996. */
  100997. loadingUIText: string;
  100998. /**
  100999. * Gets or sets the color to use for the background
  101000. */
  101001. loadingUIBackgroundColor: string;
  101002. private _resizeLoadingUI;
  101003. }
  101004. }
  101005. declare module BABYLON {
  101006. /**
  101007. * Interface for any object that can request an animation frame
  101008. */
  101009. export interface ICustomAnimationFrameRequester {
  101010. /**
  101011. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  101012. */
  101013. renderFunction?: Function;
  101014. /**
  101015. * Called to request the next frame to render to
  101016. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  101017. */
  101018. requestAnimationFrame: Function;
  101019. /**
  101020. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  101021. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  101022. */
  101023. requestID?: number;
  101024. }
  101025. }
  101026. declare module BABYLON {
  101027. /**
  101028. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  101029. */
  101030. export class PerformanceMonitor {
  101031. private _enabled;
  101032. private _rollingFrameTime;
  101033. private _lastFrameTimeMs;
  101034. /**
  101035. * constructor
  101036. * @param frameSampleSize The number of samples required to saturate the sliding window
  101037. */
  101038. constructor(frameSampleSize?: number);
  101039. /**
  101040. * Samples current frame
  101041. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  101042. */
  101043. sampleFrame(timeMs?: number): void;
  101044. /**
  101045. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101046. */
  101047. readonly averageFrameTime: number;
  101048. /**
  101049. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101050. */
  101051. readonly averageFrameTimeVariance: number;
  101052. /**
  101053. * Returns the frame time of the most recent frame
  101054. */
  101055. readonly instantaneousFrameTime: number;
  101056. /**
  101057. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  101058. */
  101059. readonly averageFPS: number;
  101060. /**
  101061. * Returns the average framerate in frames per second using the most recent frame time
  101062. */
  101063. readonly instantaneousFPS: number;
  101064. /**
  101065. * Returns true if enough samples have been taken to completely fill the sliding window
  101066. */
  101067. readonly isSaturated: boolean;
  101068. /**
  101069. * Enables contributions to the sliding window sample set
  101070. */
  101071. enable(): void;
  101072. /**
  101073. * Disables contributions to the sliding window sample set
  101074. * Samples will not be interpolated over the disabled period
  101075. */
  101076. disable(): void;
  101077. /**
  101078. * Returns true if sampling is enabled
  101079. */
  101080. readonly isEnabled: boolean;
  101081. /**
  101082. * Resets performance monitor
  101083. */
  101084. reset(): void;
  101085. }
  101086. /**
  101087. * RollingAverage
  101088. *
  101089. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  101090. */
  101091. export class RollingAverage {
  101092. /**
  101093. * Current average
  101094. */
  101095. average: number;
  101096. /**
  101097. * Current variance
  101098. */
  101099. variance: number;
  101100. protected _samples: Array<number>;
  101101. protected _sampleCount: number;
  101102. protected _pos: number;
  101103. protected _m2: number;
  101104. /**
  101105. * constructor
  101106. * @param length The number of samples required to saturate the sliding window
  101107. */
  101108. constructor(length: number);
  101109. /**
  101110. * Adds a sample to the sample set
  101111. * @param v The sample value
  101112. */
  101113. add(v: number): void;
  101114. /**
  101115. * Returns previously added values or null if outside of history or outside the sliding window domain
  101116. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  101117. * @return Value previously recorded with add() or null if outside of range
  101118. */
  101119. history(i: number): number;
  101120. /**
  101121. * Returns true if enough samples have been taken to completely fill the sliding window
  101122. * @return true if sample-set saturated
  101123. */
  101124. isSaturated(): boolean;
  101125. /**
  101126. * Resets the rolling average (equivalent to 0 samples taken so far)
  101127. */
  101128. reset(): void;
  101129. /**
  101130. * Wraps a value around the sample range boundaries
  101131. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  101132. * @return Wrapped position in sample range
  101133. */
  101134. protected _wrapPosition(i: number): number;
  101135. }
  101136. }
  101137. declare module BABYLON {
  101138. /**
  101139. * This class is used to track a performance counter which is number based.
  101140. * The user has access to many properties which give statistics of different nature.
  101141. *
  101142. * The implementer can track two kinds of Performance Counter: time and count.
  101143. * 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.
  101144. * 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.
  101145. */
  101146. export class PerfCounter {
  101147. /**
  101148. * Gets or sets a global boolean to turn on and off all the counters
  101149. */
  101150. static Enabled: boolean;
  101151. /**
  101152. * Returns the smallest value ever
  101153. */
  101154. readonly min: number;
  101155. /**
  101156. * Returns the biggest value ever
  101157. */
  101158. readonly max: number;
  101159. /**
  101160. * Returns the average value since the performance counter is running
  101161. */
  101162. readonly average: number;
  101163. /**
  101164. * Returns the average value of the last second the counter was monitored
  101165. */
  101166. readonly lastSecAverage: number;
  101167. /**
  101168. * Returns the current value
  101169. */
  101170. readonly current: number;
  101171. /**
  101172. * Gets the accumulated total
  101173. */
  101174. readonly total: number;
  101175. /**
  101176. * Gets the total value count
  101177. */
  101178. readonly count: number;
  101179. /**
  101180. * Creates a new counter
  101181. */
  101182. constructor();
  101183. /**
  101184. * Call this method to start monitoring a new frame.
  101185. * 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.
  101186. */
  101187. fetchNewFrame(): void;
  101188. /**
  101189. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  101190. * @param newCount the count value to add to the monitored count
  101191. * @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.
  101192. */
  101193. addCount(newCount: number, fetchResult: boolean): void;
  101194. /**
  101195. * Start monitoring this performance counter
  101196. */
  101197. beginMonitoring(): void;
  101198. /**
  101199. * Compute the time lapsed since the previous beginMonitoring() call.
  101200. * @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
  101201. */
  101202. endMonitoring(newFrame?: boolean): void;
  101203. private _fetchResult;
  101204. private _startMonitoringTime;
  101205. private _min;
  101206. private _max;
  101207. private _average;
  101208. private _current;
  101209. private _totalValueCount;
  101210. private _totalAccumulated;
  101211. private _lastSecAverage;
  101212. private _lastSecAccumulated;
  101213. private _lastSecTime;
  101214. private _lastSecValueCount;
  101215. }
  101216. }
  101217. declare module BABYLON {
  101218. /**
  101219. * Defines the interface used by display changed events
  101220. */
  101221. export interface IDisplayChangedEventArgs {
  101222. /** Gets the vrDisplay object (if any) */
  101223. vrDisplay: Nullable<any>;
  101224. /** Gets a boolean indicating if webVR is supported */
  101225. vrSupported: boolean;
  101226. }
  101227. /**
  101228. * Defines the interface used by objects containing a viewport (like a camera)
  101229. */
  101230. interface IViewportOwnerLike {
  101231. /**
  101232. * Gets or sets the viewport
  101233. */
  101234. viewport: IViewportLike;
  101235. }
  101236. /**
  101237. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  101238. */
  101239. export class Engine extends ThinEngine {
  101240. /** Defines that alpha blending is disabled */
  101241. static readonly ALPHA_DISABLE: number;
  101242. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  101243. static readonly ALPHA_ADD: number;
  101244. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  101245. static readonly ALPHA_COMBINE: number;
  101246. /** Defines that alpha blending to DEST - SRC * DEST */
  101247. static readonly ALPHA_SUBTRACT: number;
  101248. /** Defines that alpha blending to SRC * DEST */
  101249. static readonly ALPHA_MULTIPLY: number;
  101250. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  101251. static readonly ALPHA_MAXIMIZED: number;
  101252. /** Defines that alpha blending to SRC + DEST */
  101253. static readonly ALPHA_ONEONE: number;
  101254. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  101255. static readonly ALPHA_PREMULTIPLIED: number;
  101256. /**
  101257. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  101258. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  101259. */
  101260. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  101261. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  101262. static readonly ALPHA_INTERPOLATE: number;
  101263. /**
  101264. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  101265. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  101266. */
  101267. static readonly ALPHA_SCREENMODE: number;
  101268. /** Defines that the ressource is not delayed*/
  101269. static readonly DELAYLOADSTATE_NONE: number;
  101270. /** Defines that the ressource was successfully delay loaded */
  101271. static readonly DELAYLOADSTATE_LOADED: number;
  101272. /** Defines that the ressource is currently delay loading */
  101273. static readonly DELAYLOADSTATE_LOADING: number;
  101274. /** Defines that the ressource is delayed and has not started loading */
  101275. static readonly DELAYLOADSTATE_NOTLOADED: number;
  101276. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  101277. static readonly NEVER: number;
  101278. /** 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 */
  101279. static readonly ALWAYS: number;
  101280. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  101281. static readonly LESS: number;
  101282. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  101283. static readonly EQUAL: number;
  101284. /** 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 */
  101285. static readonly LEQUAL: number;
  101286. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  101287. static readonly GREATER: number;
  101288. /** 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 */
  101289. static readonly GEQUAL: number;
  101290. /** 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 */
  101291. static readonly NOTEQUAL: number;
  101292. /** Passed to stencilOperation to specify that stencil value must be kept */
  101293. static readonly KEEP: number;
  101294. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101295. static readonly REPLACE: number;
  101296. /** Passed to stencilOperation to specify that stencil value must be incremented */
  101297. static readonly INCR: number;
  101298. /** Passed to stencilOperation to specify that stencil value must be decremented */
  101299. static readonly DECR: number;
  101300. /** Passed to stencilOperation to specify that stencil value must be inverted */
  101301. static readonly INVERT: number;
  101302. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  101303. static readonly INCR_WRAP: number;
  101304. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  101305. static readonly DECR_WRAP: number;
  101306. /** Texture is not repeating outside of 0..1 UVs */
  101307. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  101308. /** Texture is repeating outside of 0..1 UVs */
  101309. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  101310. /** Texture is repeating and mirrored */
  101311. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  101312. /** ALPHA */
  101313. static readonly TEXTUREFORMAT_ALPHA: number;
  101314. /** LUMINANCE */
  101315. static readonly TEXTUREFORMAT_LUMINANCE: number;
  101316. /** LUMINANCE_ALPHA */
  101317. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  101318. /** RGB */
  101319. static readonly TEXTUREFORMAT_RGB: number;
  101320. /** RGBA */
  101321. static readonly TEXTUREFORMAT_RGBA: number;
  101322. /** RED */
  101323. static readonly TEXTUREFORMAT_RED: number;
  101324. /** RED (2nd reference) */
  101325. static readonly TEXTUREFORMAT_R: number;
  101326. /** RG */
  101327. static readonly TEXTUREFORMAT_RG: number;
  101328. /** RED_INTEGER */
  101329. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  101330. /** RED_INTEGER (2nd reference) */
  101331. static readonly TEXTUREFORMAT_R_INTEGER: number;
  101332. /** RG_INTEGER */
  101333. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  101334. /** RGB_INTEGER */
  101335. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  101336. /** RGBA_INTEGER */
  101337. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  101338. /** UNSIGNED_BYTE */
  101339. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  101340. /** UNSIGNED_BYTE (2nd reference) */
  101341. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  101342. /** FLOAT */
  101343. static readonly TEXTURETYPE_FLOAT: number;
  101344. /** HALF_FLOAT */
  101345. static readonly TEXTURETYPE_HALF_FLOAT: number;
  101346. /** BYTE */
  101347. static readonly TEXTURETYPE_BYTE: number;
  101348. /** SHORT */
  101349. static readonly TEXTURETYPE_SHORT: number;
  101350. /** UNSIGNED_SHORT */
  101351. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  101352. /** INT */
  101353. static readonly TEXTURETYPE_INT: number;
  101354. /** UNSIGNED_INT */
  101355. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  101356. /** UNSIGNED_SHORT_4_4_4_4 */
  101357. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  101358. /** UNSIGNED_SHORT_5_5_5_1 */
  101359. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  101360. /** UNSIGNED_SHORT_5_6_5 */
  101361. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  101362. /** UNSIGNED_INT_2_10_10_10_REV */
  101363. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  101364. /** UNSIGNED_INT_24_8 */
  101365. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  101366. /** UNSIGNED_INT_10F_11F_11F_REV */
  101367. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  101368. /** UNSIGNED_INT_5_9_9_9_REV */
  101369. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  101370. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  101371. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  101372. /** nearest is mag = nearest and min = nearest and mip = linear */
  101373. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  101374. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101375. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  101376. /** Trilinear is mag = linear and min = linear and mip = linear */
  101377. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  101378. /** nearest is mag = nearest and min = nearest and mip = linear */
  101379. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  101380. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101381. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  101382. /** Trilinear is mag = linear and min = linear and mip = linear */
  101383. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  101384. /** mag = nearest and min = nearest and mip = nearest */
  101385. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  101386. /** mag = nearest and min = linear and mip = nearest */
  101387. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  101388. /** mag = nearest and min = linear and mip = linear */
  101389. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  101390. /** mag = nearest and min = linear and mip = none */
  101391. static readonly TEXTURE_NEAREST_LINEAR: number;
  101392. /** mag = nearest and min = nearest and mip = none */
  101393. static readonly TEXTURE_NEAREST_NEAREST: number;
  101394. /** mag = linear and min = nearest and mip = nearest */
  101395. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  101396. /** mag = linear and min = nearest and mip = linear */
  101397. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  101398. /** mag = linear and min = linear and mip = none */
  101399. static readonly TEXTURE_LINEAR_LINEAR: number;
  101400. /** mag = linear and min = nearest and mip = none */
  101401. static readonly TEXTURE_LINEAR_NEAREST: number;
  101402. /** Explicit coordinates mode */
  101403. static readonly TEXTURE_EXPLICIT_MODE: number;
  101404. /** Spherical coordinates mode */
  101405. static readonly TEXTURE_SPHERICAL_MODE: number;
  101406. /** Planar coordinates mode */
  101407. static readonly TEXTURE_PLANAR_MODE: number;
  101408. /** Cubic coordinates mode */
  101409. static readonly TEXTURE_CUBIC_MODE: number;
  101410. /** Projection coordinates mode */
  101411. static readonly TEXTURE_PROJECTION_MODE: number;
  101412. /** Skybox coordinates mode */
  101413. static readonly TEXTURE_SKYBOX_MODE: number;
  101414. /** Inverse Cubic coordinates mode */
  101415. static readonly TEXTURE_INVCUBIC_MODE: number;
  101416. /** Equirectangular coordinates mode */
  101417. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  101418. /** Equirectangular Fixed coordinates mode */
  101419. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  101420. /** Equirectangular Fixed Mirrored coordinates mode */
  101421. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101422. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  101423. static readonly SCALEMODE_FLOOR: number;
  101424. /** Defines that texture rescaling will look for the nearest power of 2 size */
  101425. static readonly SCALEMODE_NEAREST: number;
  101426. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  101427. static readonly SCALEMODE_CEILING: number;
  101428. /**
  101429. * Returns the current npm package of the sdk
  101430. */
  101431. static readonly NpmPackage: string;
  101432. /**
  101433. * Returns the current version of the framework
  101434. */
  101435. static readonly Version: string;
  101436. /** Gets the list of created engines */
  101437. static readonly Instances: Engine[];
  101438. /**
  101439. * Gets the latest created engine
  101440. */
  101441. static readonly LastCreatedEngine: Nullable<Engine>;
  101442. /**
  101443. * Gets the latest created scene
  101444. */
  101445. static readonly LastCreatedScene: Nullable<Scene>;
  101446. /**
  101447. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  101448. * @param flag defines which part of the materials must be marked as dirty
  101449. * @param predicate defines a predicate used to filter which materials should be affected
  101450. */
  101451. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101452. /**
  101453. * Method called to create the default loading screen.
  101454. * This can be overriden in your own app.
  101455. * @param canvas The rendering canvas element
  101456. * @returns The loading screen
  101457. */
  101458. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  101459. /**
  101460. * Method called to create the default rescale post process on each engine.
  101461. */
  101462. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  101463. /**
  101464. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  101465. **/
  101466. enableOfflineSupport: boolean;
  101467. /**
  101468. * 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)
  101469. **/
  101470. disableManifestCheck: boolean;
  101471. /**
  101472. * Gets the list of created scenes
  101473. */
  101474. scenes: Scene[];
  101475. /**
  101476. * Event raised when a new scene is created
  101477. */
  101478. onNewSceneAddedObservable: Observable<Scene>;
  101479. /**
  101480. * Gets the list of created postprocesses
  101481. */
  101482. postProcesses: PostProcess[];
  101483. /**
  101484. * Gets a boolean indicating if the pointer is currently locked
  101485. */
  101486. isPointerLock: boolean;
  101487. /**
  101488. * Observable event triggered each time the rendering canvas is resized
  101489. */
  101490. onResizeObservable: Observable<Engine>;
  101491. /**
  101492. * Observable event triggered each time the canvas loses focus
  101493. */
  101494. onCanvasBlurObservable: Observable<Engine>;
  101495. /**
  101496. * Observable event triggered each time the canvas gains focus
  101497. */
  101498. onCanvasFocusObservable: Observable<Engine>;
  101499. /**
  101500. * Observable event triggered each time the canvas receives pointerout event
  101501. */
  101502. onCanvasPointerOutObservable: Observable<PointerEvent>;
  101503. /**
  101504. * Observable raised when the engine begins a new frame
  101505. */
  101506. onBeginFrameObservable: Observable<Engine>;
  101507. /**
  101508. * If set, will be used to request the next animation frame for the render loop
  101509. */
  101510. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  101511. /**
  101512. * Observable raised when the engine ends the current frame
  101513. */
  101514. onEndFrameObservable: Observable<Engine>;
  101515. /**
  101516. * Observable raised when the engine is about to compile a shader
  101517. */
  101518. onBeforeShaderCompilationObservable: Observable<Engine>;
  101519. /**
  101520. * Observable raised when the engine has jsut compiled a shader
  101521. */
  101522. onAfterShaderCompilationObservable: Observable<Engine>;
  101523. /**
  101524. * Gets the audio engine
  101525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101526. * @ignorenaming
  101527. */
  101528. static audioEngine: IAudioEngine;
  101529. /**
  101530. * Default AudioEngine factory responsible of creating the Audio Engine.
  101531. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  101532. */
  101533. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  101534. /**
  101535. * Default offline support factory responsible of creating a tool used to store data locally.
  101536. * By default, this will create a Database object if the workload has been embedded.
  101537. */
  101538. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  101539. private _loadingScreen;
  101540. private _pointerLockRequested;
  101541. private _dummyFramebuffer;
  101542. private _rescalePostProcess;
  101543. /** @hidden */
  101544. protected _alphaMode: number;
  101545. /** @hidden */
  101546. protected _alphaEquation: number;
  101547. private _deterministicLockstep;
  101548. private _lockstepMaxSteps;
  101549. private _timeStep;
  101550. protected readonly _supportsHardwareTextureRescaling: boolean;
  101551. private _fps;
  101552. private _deltaTime;
  101553. /** @hidden */
  101554. _drawCalls: PerfCounter;
  101555. /**
  101556. * Turn this value on if you want to pause FPS computation when in background
  101557. */
  101558. disablePerformanceMonitorInBackground: boolean;
  101559. private _performanceMonitor;
  101560. /**
  101561. * Gets the performance monitor attached to this engine
  101562. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101563. */
  101564. readonly performanceMonitor: PerformanceMonitor;
  101565. private _onFocus;
  101566. private _onBlur;
  101567. private _onCanvasPointerOut;
  101568. private _onCanvasBlur;
  101569. private _onCanvasFocus;
  101570. private _onFullscreenChange;
  101571. private _onPointerLockChange;
  101572. /**
  101573. * Gets the HTML element used to attach event listeners
  101574. * @returns a HTML element
  101575. */
  101576. getInputElement(): Nullable<HTMLElement>;
  101577. /**
  101578. * Creates a new engine
  101579. * @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
  101580. * @param antialias defines enable antialiasing (default: false)
  101581. * @param options defines further options to be sent to the getContext() function
  101582. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101583. */
  101584. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101585. /**
  101586. * Gets current aspect ratio
  101587. * @param viewportOwner defines the camera to use to get the aspect ratio
  101588. * @param useScreen defines if screen size must be used (or the current render target if any)
  101589. * @returns a number defining the aspect ratio
  101590. */
  101591. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  101592. /**
  101593. * Gets current screen aspect ratio
  101594. * @returns a number defining the aspect ratio
  101595. */
  101596. getScreenAspectRatio(): number;
  101597. /**
  101598. * Gets the client rect of the HTML canvas attached with the current webGL context
  101599. * @returns a client rectanglee
  101600. */
  101601. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  101602. /**
  101603. * Gets the client rect of the HTML element used for events
  101604. * @returns a client rectanglee
  101605. */
  101606. getInputElementClientRect(): Nullable<ClientRect>;
  101607. /**
  101608. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  101609. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101610. * @returns true if engine is in deterministic lock step mode
  101611. */
  101612. isDeterministicLockStep(): boolean;
  101613. /**
  101614. * Gets the max steps when engine is running in deterministic lock step
  101615. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101616. * @returns the max steps
  101617. */
  101618. getLockstepMaxSteps(): number;
  101619. /**
  101620. * Returns the time in ms between steps when using deterministic lock step.
  101621. * @returns time step in (ms)
  101622. */
  101623. getTimeStep(): number;
  101624. /**
  101625. * Force the mipmap generation for the given render target texture
  101626. * @param texture defines the render target texture to use
  101627. */
  101628. generateMipMapsForCubemap(texture: InternalTexture): void;
  101629. /** States */
  101630. /**
  101631. * Set various states to the webGL context
  101632. * @param culling defines backface culling state
  101633. * @param zOffset defines the value to apply to zOffset (0 by default)
  101634. * @param force defines if states must be applied even if cache is up to date
  101635. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  101636. */
  101637. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101638. /**
  101639. * Set the z offset to apply to current rendering
  101640. * @param value defines the offset to apply
  101641. */
  101642. setZOffset(value: number): void;
  101643. /**
  101644. * Gets the current value of the zOffset
  101645. * @returns the current zOffset state
  101646. */
  101647. getZOffset(): number;
  101648. /**
  101649. * Enable or disable depth buffering
  101650. * @param enable defines the state to set
  101651. */
  101652. setDepthBuffer(enable: boolean): void;
  101653. /**
  101654. * Gets a boolean indicating if depth writing is enabled
  101655. * @returns the current depth writing state
  101656. */
  101657. getDepthWrite(): boolean;
  101658. /**
  101659. * Enable or disable depth writing
  101660. * @param enable defines the state to set
  101661. */
  101662. setDepthWrite(enable: boolean): void;
  101663. /**
  101664. * Enable or disable color writing
  101665. * @param enable defines the state to set
  101666. */
  101667. setColorWrite(enable: boolean): void;
  101668. /**
  101669. * Gets a boolean indicating if color writing is enabled
  101670. * @returns the current color writing state
  101671. */
  101672. getColorWrite(): boolean;
  101673. /**
  101674. * Sets alpha constants used by some alpha blending modes
  101675. * @param r defines the red component
  101676. * @param g defines the green component
  101677. * @param b defines the blue component
  101678. * @param a defines the alpha component
  101679. */
  101680. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  101681. /**
  101682. * Sets the current alpha mode
  101683. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  101684. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  101685. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101686. */
  101687. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101688. /**
  101689. * Gets the current alpha mode
  101690. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101691. * @returns the current alpha mode
  101692. */
  101693. getAlphaMode(): number;
  101694. /**
  101695. * Sets the current alpha equation
  101696. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  101697. */
  101698. setAlphaEquation(equation: number): void;
  101699. /**
  101700. * Gets the current alpha equation.
  101701. * @returns the current alpha equation
  101702. */
  101703. getAlphaEquation(): number;
  101704. /**
  101705. * Gets a boolean indicating if stencil buffer is enabled
  101706. * @returns the current stencil buffer state
  101707. */
  101708. getStencilBuffer(): boolean;
  101709. /**
  101710. * Enable or disable the stencil buffer
  101711. * @param enable defines if the stencil buffer must be enabled or disabled
  101712. */
  101713. setStencilBuffer(enable: boolean): void;
  101714. /**
  101715. * Gets the current stencil mask
  101716. * @returns a number defining the new stencil mask to use
  101717. */
  101718. getStencilMask(): number;
  101719. /**
  101720. * Sets the current stencil mask
  101721. * @param mask defines the new stencil mask to use
  101722. */
  101723. setStencilMask(mask: number): void;
  101724. /**
  101725. * Gets the current stencil function
  101726. * @returns a number defining the stencil function to use
  101727. */
  101728. getStencilFunction(): number;
  101729. /**
  101730. * Gets the current stencil reference value
  101731. * @returns a number defining the stencil reference value to use
  101732. */
  101733. getStencilFunctionReference(): number;
  101734. /**
  101735. * Gets the current stencil mask
  101736. * @returns a number defining the stencil mask to use
  101737. */
  101738. getStencilFunctionMask(): number;
  101739. /**
  101740. * Sets the current stencil function
  101741. * @param stencilFunc defines the new stencil function to use
  101742. */
  101743. setStencilFunction(stencilFunc: number): void;
  101744. /**
  101745. * Sets the current stencil reference
  101746. * @param reference defines the new stencil reference to use
  101747. */
  101748. setStencilFunctionReference(reference: number): void;
  101749. /**
  101750. * Sets the current stencil mask
  101751. * @param mask defines the new stencil mask to use
  101752. */
  101753. setStencilFunctionMask(mask: number): void;
  101754. /**
  101755. * Gets the current stencil operation when stencil fails
  101756. * @returns a number defining stencil operation to use when stencil fails
  101757. */
  101758. getStencilOperationFail(): number;
  101759. /**
  101760. * Gets the current stencil operation when depth fails
  101761. * @returns a number defining stencil operation to use when depth fails
  101762. */
  101763. getStencilOperationDepthFail(): number;
  101764. /**
  101765. * Gets the current stencil operation when stencil passes
  101766. * @returns a number defining stencil operation to use when stencil passes
  101767. */
  101768. getStencilOperationPass(): number;
  101769. /**
  101770. * Sets the stencil operation to use when stencil fails
  101771. * @param operation defines the stencil operation to use when stencil fails
  101772. */
  101773. setStencilOperationFail(operation: number): void;
  101774. /**
  101775. * Sets the stencil operation to use when depth fails
  101776. * @param operation defines the stencil operation to use when depth fails
  101777. */
  101778. setStencilOperationDepthFail(operation: number): void;
  101779. /**
  101780. * Sets the stencil operation to use when stencil passes
  101781. * @param operation defines the stencil operation to use when stencil passes
  101782. */
  101783. setStencilOperationPass(operation: number): void;
  101784. /**
  101785. * Sets a boolean indicating if the dithering state is enabled or disabled
  101786. * @param value defines the dithering state
  101787. */
  101788. setDitheringState(value: boolean): void;
  101789. /**
  101790. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  101791. * @param value defines the rasterizer state
  101792. */
  101793. setRasterizerState(value: boolean): void;
  101794. /**
  101795. * Gets the current depth function
  101796. * @returns a number defining the depth function
  101797. */
  101798. getDepthFunction(): Nullable<number>;
  101799. /**
  101800. * Sets the current depth function
  101801. * @param depthFunc defines the function to use
  101802. */
  101803. setDepthFunction(depthFunc: number): void;
  101804. /**
  101805. * Sets the current depth function to GREATER
  101806. */
  101807. setDepthFunctionToGreater(): void;
  101808. /**
  101809. * Sets the current depth function to GEQUAL
  101810. */
  101811. setDepthFunctionToGreaterOrEqual(): void;
  101812. /**
  101813. * Sets the current depth function to LESS
  101814. */
  101815. setDepthFunctionToLess(): void;
  101816. /**
  101817. * Sets the current depth function to LEQUAL
  101818. */
  101819. setDepthFunctionToLessOrEqual(): void;
  101820. private _cachedStencilBuffer;
  101821. private _cachedStencilFunction;
  101822. private _cachedStencilMask;
  101823. private _cachedStencilOperationPass;
  101824. private _cachedStencilOperationFail;
  101825. private _cachedStencilOperationDepthFail;
  101826. private _cachedStencilReference;
  101827. /**
  101828. * Caches the the state of the stencil buffer
  101829. */
  101830. cacheStencilState(): void;
  101831. /**
  101832. * Restores the state of the stencil buffer
  101833. */
  101834. restoreStencilState(): void;
  101835. /**
  101836. * Directly set the WebGL Viewport
  101837. * @param x defines the x coordinate of the viewport (in screen space)
  101838. * @param y defines the y coordinate of the viewport (in screen space)
  101839. * @param width defines the width of the viewport (in screen space)
  101840. * @param height defines the height of the viewport (in screen space)
  101841. * @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
  101842. */
  101843. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  101844. /**
  101845. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  101846. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  101847. * @param y defines the y-coordinate of the corner of the clear rectangle
  101848. * @param width defines the width of the clear rectangle
  101849. * @param height defines the height of the clear rectangle
  101850. * @param clearColor defines the clear color
  101851. */
  101852. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  101853. /**
  101854. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  101855. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  101856. * @param y defines the y-coordinate of the corner of the clear rectangle
  101857. * @param width defines the width of the clear rectangle
  101858. * @param height defines the height of the clear rectangle
  101859. */
  101860. enableScissor(x: number, y: number, width: number, height: number): void;
  101861. /**
  101862. * Disable previously set scissor test rectangle
  101863. */
  101864. disableScissor(): void;
  101865. protected _reportDrawCall(): void;
  101866. /**
  101867. * Initializes a webVR display and starts listening to display change events
  101868. * The onVRDisplayChangedObservable will be notified upon these changes
  101869. * @returns The onVRDisplayChangedObservable
  101870. */
  101871. initWebVR(): Observable<IDisplayChangedEventArgs>;
  101872. /** @hidden */
  101873. _prepareVRComponent(): void;
  101874. /** @hidden */
  101875. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  101876. /** @hidden */
  101877. _submitVRFrame(): void;
  101878. /**
  101879. * Call this function to leave webVR mode
  101880. * Will do nothing if webVR is not supported or if there is no webVR device
  101881. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101882. */
  101883. disableVR(): void;
  101884. /**
  101885. * Gets a boolean indicating that the system is in VR mode and is presenting
  101886. * @returns true if VR mode is engaged
  101887. */
  101888. isVRPresenting(): boolean;
  101889. /** @hidden */
  101890. _requestVRFrame(): void;
  101891. /** @hidden */
  101892. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101893. /**
  101894. * Gets the source code of the vertex shader associated with a specific webGL program
  101895. * @param program defines the program to use
  101896. * @returns a string containing the source code of the vertex shader associated with the program
  101897. */
  101898. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  101899. /**
  101900. * Gets the source code of the fragment shader associated with a specific webGL program
  101901. * @param program defines the program to use
  101902. * @returns a string containing the source code of the fragment shader associated with the program
  101903. */
  101904. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  101905. /**
  101906. * Reads pixels from the current frame buffer. Please note that this function can be slow
  101907. * @param x defines the x coordinate of the rectangle where pixels must be read
  101908. * @param y defines the y coordinate of the rectangle where pixels must be read
  101909. * @param width defines the width of the rectangle where pixels must be read
  101910. * @param height defines the height of the rectangle where pixels must be read
  101911. * @returns a Uint8Array containing RGBA colors
  101912. */
  101913. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  101914. /**
  101915. * Sets a depth stencil texture from a render target to the according uniform.
  101916. * @param channel The texture channel
  101917. * @param uniform The uniform to set
  101918. * @param texture The render target texture containing the depth stencil texture to apply
  101919. */
  101920. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  101921. /**
  101922. * Sets a texture to the webGL context from a postprocess
  101923. * @param channel defines the channel to use
  101924. * @param postProcess defines the source postprocess
  101925. */
  101926. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  101927. /**
  101928. * Binds the output of the passed in post process to the texture channel specified
  101929. * @param channel The channel the texture should be bound to
  101930. * @param postProcess The post process which's output should be bound
  101931. */
  101932. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  101933. /** @hidden */
  101934. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  101935. protected _rebuildBuffers(): void;
  101936. /** @hidden */
  101937. _renderFrame(): void;
  101938. _renderLoop(): void;
  101939. /** @hidden */
  101940. _renderViews(): boolean;
  101941. /**
  101942. * Toggle full screen mode
  101943. * @param requestPointerLock defines if a pointer lock should be requested from the user
  101944. */
  101945. switchFullscreen(requestPointerLock: boolean): void;
  101946. /**
  101947. * Enters full screen mode
  101948. * @param requestPointerLock defines if a pointer lock should be requested from the user
  101949. */
  101950. enterFullscreen(requestPointerLock: boolean): void;
  101951. /**
  101952. * Exits full screen mode
  101953. */
  101954. exitFullscreen(): void;
  101955. /**
  101956. * Enters Pointerlock mode
  101957. */
  101958. enterPointerlock(): void;
  101959. /**
  101960. * Exits Pointerlock mode
  101961. */
  101962. exitPointerlock(): void;
  101963. /**
  101964. * Begin a new frame
  101965. */
  101966. beginFrame(): void;
  101967. /**
  101968. * Enf the current frame
  101969. */
  101970. endFrame(): void;
  101971. resize(): void;
  101972. /**
  101973. * Set the compressed texture format to use, based on the formats you have, and the formats
  101974. * supported by the hardware / browser.
  101975. *
  101976. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  101977. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  101978. * to API arguments needed to compressed textures. This puts the burden on the container
  101979. * generator to house the arcane code for determining these for current & future formats.
  101980. *
  101981. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  101982. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  101983. *
  101984. * Note: The result of this call is not taken into account when a texture is base64.
  101985. *
  101986. * @param formatsAvailable defines the list of those format families you have created
  101987. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  101988. *
  101989. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  101990. * @returns The extension selected.
  101991. */
  101992. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  101993. /**
  101994. * Force a specific size of the canvas
  101995. * @param width defines the new canvas' width
  101996. * @param height defines the new canvas' height
  101997. */
  101998. setSize(width: number, height: number): void;
  101999. /**
  102000. * Updates a dynamic vertex buffer.
  102001. * @param vertexBuffer the vertex buffer to update
  102002. * @param data the data used to update the vertex buffer
  102003. * @param byteOffset the byte offset of the data
  102004. * @param byteLength the byte length of the data
  102005. */
  102006. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  102007. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102008. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102009. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102010. _releaseTexture(texture: InternalTexture): void;
  102011. /**
  102012. * @hidden
  102013. * Rescales a texture
  102014. * @param source input texutre
  102015. * @param destination destination texture
  102016. * @param scene scene to use to render the resize
  102017. * @param internalFormat format to use when resizing
  102018. * @param onComplete callback to be called when resize has completed
  102019. */
  102020. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102021. /**
  102022. * Gets the current framerate
  102023. * @returns a number representing the framerate
  102024. */
  102025. getFps(): number;
  102026. /**
  102027. * Gets the time spent between current and previous frame
  102028. * @returns a number representing the delta time in ms
  102029. */
  102030. getDeltaTime(): number;
  102031. private _measureFps;
  102032. /** @hidden */
  102033. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  102034. /**
  102035. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  102036. * @param renderTarget The render target to set the frame buffer for
  102037. */
  102038. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  102039. /**
  102040. * Update a dynamic index buffer
  102041. * @param indexBuffer defines the target index buffer
  102042. * @param indices defines the data to update
  102043. * @param offset defines the offset in the target index buffer where update should start
  102044. */
  102045. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  102046. /**
  102047. * Updates the sample count of a render target texture
  102048. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102049. * @param texture defines the texture to update
  102050. * @param samples defines the sample count to set
  102051. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102052. */
  102053. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  102054. /**
  102055. * Updates a depth texture Comparison Mode and Function.
  102056. * If the comparison Function is equal to 0, the mode will be set to none.
  102057. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  102058. * @param texture The texture to set the comparison function for
  102059. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  102060. */
  102061. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  102062. /**
  102063. * Creates a webGL buffer to use with instanciation
  102064. * @param capacity defines the size of the buffer
  102065. * @returns the webGL buffer
  102066. */
  102067. createInstancesBuffer(capacity: number): DataBuffer;
  102068. /**
  102069. * Delete a webGL buffer used with instanciation
  102070. * @param buffer defines the webGL buffer to delete
  102071. */
  102072. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  102073. /** @hidden */
  102074. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  102075. dispose(): void;
  102076. private _disableTouchAction;
  102077. /**
  102078. * Display the loading screen
  102079. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102080. */
  102081. displayLoadingUI(): void;
  102082. /**
  102083. * Hide the loading screen
  102084. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102085. */
  102086. hideLoadingUI(): void;
  102087. /**
  102088. * Gets the current loading screen object
  102089. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102090. */
  102091. /**
  102092. * Sets the current loading screen object
  102093. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102094. */
  102095. loadingScreen: ILoadingScreen;
  102096. /**
  102097. * Sets the current loading screen text
  102098. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102099. */
  102100. loadingUIText: string;
  102101. /**
  102102. * Sets the current loading screen background color
  102103. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102104. */
  102105. loadingUIBackgroundColor: string;
  102106. /** Pointerlock and fullscreen */
  102107. /**
  102108. * Ask the browser to promote the current element to pointerlock mode
  102109. * @param element defines the DOM element to promote
  102110. */
  102111. static _RequestPointerlock(element: HTMLElement): void;
  102112. /**
  102113. * Asks the browser to exit pointerlock mode
  102114. */
  102115. static _ExitPointerlock(): void;
  102116. /**
  102117. * Ask the browser to promote the current element to fullscreen rendering mode
  102118. * @param element defines the DOM element to promote
  102119. */
  102120. static _RequestFullscreen(element: HTMLElement): void;
  102121. /**
  102122. * Asks the browser to exit fullscreen mode
  102123. */
  102124. static _ExitFullscreen(): void;
  102125. }
  102126. }
  102127. declare module BABYLON {
  102128. /**
  102129. * The engine store class is responsible to hold all the instances of Engine and Scene created
  102130. * during the life time of the application.
  102131. */
  102132. export class EngineStore {
  102133. /** Gets the list of created engines */
  102134. static Instances: Engine[];
  102135. /** @hidden */
  102136. static _LastCreatedScene: Nullable<Scene>;
  102137. /**
  102138. * Gets the latest created engine
  102139. */
  102140. static readonly LastCreatedEngine: Nullable<Engine>;
  102141. /**
  102142. * Gets the latest created scene
  102143. */
  102144. static readonly LastCreatedScene: Nullable<Scene>;
  102145. /**
  102146. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102147. * @ignorenaming
  102148. */
  102149. static UseFallbackTexture: boolean;
  102150. /**
  102151. * Texture content used if a texture cannot loaded
  102152. * @ignorenaming
  102153. */
  102154. static FallbackTexture: string;
  102155. }
  102156. }
  102157. declare module BABYLON {
  102158. /**
  102159. * Helper class that provides a small promise polyfill
  102160. */
  102161. export class PromisePolyfill {
  102162. /**
  102163. * Static function used to check if the polyfill is required
  102164. * If this is the case then the function will inject the polyfill to window.Promise
  102165. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  102166. */
  102167. static Apply(force?: boolean): void;
  102168. }
  102169. }
  102170. declare module BABYLON {
  102171. /**
  102172. * Interface for screenshot methods with describe argument called `size` as object with options
  102173. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  102174. */
  102175. export interface IScreenshotSize {
  102176. /**
  102177. * number in pixels for canvas height
  102178. */
  102179. height?: number;
  102180. /**
  102181. * multiplier allowing render at a higher or lower resolution
  102182. * If value is defined then height and width will be ignored and taken from camera
  102183. */
  102184. precision?: number;
  102185. /**
  102186. * number in pixels for canvas width
  102187. */
  102188. width?: number;
  102189. }
  102190. }
  102191. declare module BABYLON {
  102192. interface IColor4Like {
  102193. r: float;
  102194. g: float;
  102195. b: float;
  102196. a: float;
  102197. }
  102198. /**
  102199. * Class containing a set of static utilities functions
  102200. */
  102201. export class Tools {
  102202. /**
  102203. * Gets or sets the base URL to use to load assets
  102204. */
  102205. static BaseUrl: string;
  102206. /**
  102207. * Enable/Disable Custom HTTP Request Headers globally.
  102208. * default = false
  102209. * @see CustomRequestHeaders
  102210. */
  102211. static UseCustomRequestHeaders: boolean;
  102212. /**
  102213. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  102214. * i.e. when loading files, where the server/service expects an Authorization header
  102215. */
  102216. static CustomRequestHeaders: {
  102217. [key: string]: string;
  102218. };
  102219. /**
  102220. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  102221. */
  102222. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  102223. /**
  102224. * Default behaviour for cors in the application.
  102225. * It can be a string if the expected behavior is identical in the entire app.
  102226. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  102227. */
  102228. static CorsBehavior: string | ((url: string | string[]) => string);
  102229. /**
  102230. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102231. * @ignorenaming
  102232. */
  102233. static UseFallbackTexture: boolean;
  102234. /**
  102235. * Use this object to register external classes like custom textures or material
  102236. * to allow the laoders to instantiate them
  102237. */
  102238. static RegisteredExternalClasses: {
  102239. [key: string]: Object;
  102240. };
  102241. /**
  102242. * Texture content used if a texture cannot loaded
  102243. * @ignorenaming
  102244. */
  102245. static fallbackTexture: string;
  102246. /**
  102247. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102248. * @param u defines the coordinate on X axis
  102249. * @param v defines the coordinate on Y axis
  102250. * @param width defines the width of the source data
  102251. * @param height defines the height of the source data
  102252. * @param pixels defines the source byte array
  102253. * @param color defines the output color
  102254. */
  102255. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  102256. /**
  102257. * Interpolates between a and b via alpha
  102258. * @param a The lower value (returned when alpha = 0)
  102259. * @param b The upper value (returned when alpha = 1)
  102260. * @param alpha The interpolation-factor
  102261. * @return The mixed value
  102262. */
  102263. static Mix(a: number, b: number, alpha: number): number;
  102264. /**
  102265. * Tries to instantiate a new object from a given class name
  102266. * @param className defines the class name to instantiate
  102267. * @returns the new object or null if the system was not able to do the instantiation
  102268. */
  102269. static Instantiate(className: string): any;
  102270. /**
  102271. * Provides a slice function that will work even on IE
  102272. * @param data defines the array to slice
  102273. * @param start defines the start of the data (optional)
  102274. * @param end defines the end of the data (optional)
  102275. * @returns the new sliced array
  102276. */
  102277. static Slice<T>(data: T, start?: number, end?: number): T;
  102278. /**
  102279. * Polyfill for setImmediate
  102280. * @param action defines the action to execute after the current execution block
  102281. */
  102282. static SetImmediate(action: () => void): void;
  102283. /**
  102284. * Function indicating if a number is an exponent of 2
  102285. * @param value defines the value to test
  102286. * @returns true if the value is an exponent of 2
  102287. */
  102288. static IsExponentOfTwo(value: number): boolean;
  102289. private static _tmpFloatArray;
  102290. /**
  102291. * Returns the nearest 32-bit single precision float representation of a Number
  102292. * @param value A Number. If the parameter is of a different type, it will get converted
  102293. * to a number or to NaN if it cannot be converted
  102294. * @returns number
  102295. */
  102296. static FloatRound(value: number): number;
  102297. /**
  102298. * Extracts the filename from a path
  102299. * @param path defines the path to use
  102300. * @returns the filename
  102301. */
  102302. static GetFilename(path: string): string;
  102303. /**
  102304. * Extracts the "folder" part of a path (everything before the filename).
  102305. * @param uri The URI to extract the info from
  102306. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  102307. * @returns The "folder" part of the path
  102308. */
  102309. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  102310. /**
  102311. * Extracts text content from a DOM element hierarchy
  102312. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  102313. */
  102314. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  102315. /**
  102316. * Convert an angle in radians to degrees
  102317. * @param angle defines the angle to convert
  102318. * @returns the angle in degrees
  102319. */
  102320. static ToDegrees(angle: number): number;
  102321. /**
  102322. * Convert an angle in degrees to radians
  102323. * @param angle defines the angle to convert
  102324. * @returns the angle in radians
  102325. */
  102326. static ToRadians(angle: number): number;
  102327. /**
  102328. * Returns an array if obj is not an array
  102329. * @param obj defines the object to evaluate as an array
  102330. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  102331. * @returns either obj directly if obj is an array or a new array containing obj
  102332. */
  102333. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  102334. /**
  102335. * Gets the pointer prefix to use
  102336. * @returns "pointer" if touch is enabled. Else returns "mouse"
  102337. */
  102338. static GetPointerPrefix(): string;
  102339. /**
  102340. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  102341. * @param url define the url we are trying
  102342. * @param element define the dom element where to configure the cors policy
  102343. */
  102344. static SetCorsBehavior(url: string | string[], element: {
  102345. crossOrigin: string | null;
  102346. }): void;
  102347. /**
  102348. * Removes unwanted characters from an url
  102349. * @param url defines the url to clean
  102350. * @returns the cleaned url
  102351. */
  102352. static CleanUrl(url: string): string;
  102353. /**
  102354. * Gets or sets a function used to pre-process url before using them to load assets
  102355. */
  102356. static PreprocessUrl: (url: string) => string;
  102357. /**
  102358. * Loads an image as an HTMLImageElement.
  102359. * @param input url string, ArrayBuffer, or Blob to load
  102360. * @param onLoad callback called when the image successfully loads
  102361. * @param onError callback called when the image fails to load
  102362. * @param offlineProvider offline provider for caching
  102363. * @param mimeType optional mime type
  102364. * @returns the HTMLImageElement of the loaded image
  102365. */
  102366. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  102367. /**
  102368. * Loads a file from a url
  102369. * @param url url string, ArrayBuffer, or Blob to load
  102370. * @param onSuccess callback called when the file successfully loads
  102371. * @param onProgress callback called while file is loading (if the server supports this mode)
  102372. * @param offlineProvider defines the offline provider for caching
  102373. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102374. * @param onError callback called when the file fails to load
  102375. * @returns a file request object
  102376. */
  102377. 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;
  102378. /**
  102379. * Loads a file from a url
  102380. * @param url the file url to load
  102381. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  102382. */
  102383. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  102384. /**
  102385. * Load a script (identified by an url). When the url returns, the
  102386. * content of this file is added into a new script element, attached to the DOM (body element)
  102387. * @param scriptUrl defines the url of the script to laod
  102388. * @param onSuccess defines the callback called when the script is loaded
  102389. * @param onError defines the callback to call if an error occurs
  102390. * @param scriptId defines the id of the script element
  102391. */
  102392. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  102393. /**
  102394. * Load an asynchronous script (identified by an url). When the url returns, the
  102395. * content of this file is added into a new script element, attached to the DOM (body element)
  102396. * @param scriptUrl defines the url of the script to laod
  102397. * @param scriptId defines the id of the script element
  102398. * @returns a promise request object
  102399. */
  102400. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  102401. /**
  102402. * Loads a file from a blob
  102403. * @param fileToLoad defines the blob to use
  102404. * @param callback defines the callback to call when data is loaded
  102405. * @param progressCallback defines the callback to call during loading process
  102406. * @returns a file request object
  102407. */
  102408. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  102409. /**
  102410. * Reads a file from a File object
  102411. * @param file defines the file to load
  102412. * @param onSuccess defines the callback to call when data is loaded
  102413. * @param onProgress defines the callback to call during loading process
  102414. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  102415. * @param onError defines the callback to call when an error occurs
  102416. * @returns a file request object
  102417. */
  102418. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102419. /**
  102420. * Creates a data url from a given string content
  102421. * @param content defines the content to convert
  102422. * @returns the new data url link
  102423. */
  102424. static FileAsURL(content: string): string;
  102425. /**
  102426. * Format the given number to a specific decimal format
  102427. * @param value defines the number to format
  102428. * @param decimals defines the number of decimals to use
  102429. * @returns the formatted string
  102430. */
  102431. static Format(value: number, decimals?: number): string;
  102432. /**
  102433. * Tries to copy an object by duplicating every property
  102434. * @param source defines the source object
  102435. * @param destination defines the target object
  102436. * @param doNotCopyList defines a list of properties to avoid
  102437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  102438. */
  102439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  102440. /**
  102441. * Gets a boolean indicating if the given object has no own property
  102442. * @param obj defines the object to test
  102443. * @returns true if object has no own property
  102444. */
  102445. static IsEmpty(obj: any): boolean;
  102446. /**
  102447. * Function used to register events at window level
  102448. * @param windowElement defines the Window object to use
  102449. * @param events defines the events to register
  102450. */
  102451. static RegisterTopRootEvents(windowElement: Window, events: {
  102452. name: string;
  102453. handler: Nullable<(e: FocusEvent) => any>;
  102454. }[]): void;
  102455. /**
  102456. * Function used to unregister events from window level
  102457. * @param windowElement defines the Window object to use
  102458. * @param events defines the events to unregister
  102459. */
  102460. static UnregisterTopRootEvents(windowElement: Window, events: {
  102461. name: string;
  102462. handler: Nullable<(e: FocusEvent) => any>;
  102463. }[]): void;
  102464. /**
  102465. * @ignore
  102466. */
  102467. static _ScreenshotCanvas: HTMLCanvasElement;
  102468. /**
  102469. * Dumps the current bound framebuffer
  102470. * @param width defines the rendering width
  102471. * @param height defines the rendering height
  102472. * @param engine defines the hosting engine
  102473. * @param successCallback defines the callback triggered once the data are available
  102474. * @param mimeType defines the mime type of the result
  102475. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  102476. */
  102477. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102478. /**
  102479. * Converts the canvas data to blob.
  102480. * This acts as a polyfill for browsers not supporting the to blob function.
  102481. * @param canvas Defines the canvas to extract the data from
  102482. * @param successCallback Defines the callback triggered once the data are available
  102483. * @param mimeType Defines the mime type of the result
  102484. */
  102485. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  102486. /**
  102487. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  102488. * @param successCallback defines the callback triggered once the data are available
  102489. * @param mimeType defines the mime type of the result
  102490. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  102491. */
  102492. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102493. /**
  102494. * Downloads a blob in the browser
  102495. * @param blob defines the blob to download
  102496. * @param fileName defines the name of the downloaded file
  102497. */
  102498. static Download(blob: Blob, fileName: string): void;
  102499. /**
  102500. * Captures a screenshot of the current rendering
  102501. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102502. * @param engine defines the rendering engine
  102503. * @param camera defines the source camera
  102504. * @param size This parameter can be set to a single number or to an object with the
  102505. * following (optional) properties: precision, width, height. If a single number is passed,
  102506. * it will be used for both width and height. If an object is passed, the screenshot size
  102507. * will be derived from the parameters. The precision property is a multiplier allowing
  102508. * rendering at a higher or lower resolution
  102509. * @param successCallback defines the callback receives a single parameter which contains the
  102510. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102511. * src parameter of an <img> to display it
  102512. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102513. * Check your browser for supported MIME types
  102514. */
  102515. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  102516. /**
  102517. * Captures a screenshot of the current rendering
  102518. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102519. * @param engine defines the rendering engine
  102520. * @param camera defines the source camera
  102521. * @param size This parameter can be set to a single number or to an object with the
  102522. * following (optional) properties: precision, width, height. If a single number is passed,
  102523. * it will be used for both width and height. If an object is passed, the screenshot size
  102524. * will be derived from the parameters. The precision property is a multiplier allowing
  102525. * rendering at a higher or lower resolution
  102526. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102527. * Check your browser for supported MIME types
  102528. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102529. * to the src parameter of an <img> to display it
  102530. */
  102531. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  102532. /**
  102533. * Generates an image screenshot from the specified camera.
  102534. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102535. * @param engine The engine to use for rendering
  102536. * @param camera The camera to use for rendering
  102537. * @param size This parameter can be set to a single number or to an object with the
  102538. * following (optional) properties: precision, width, height. If a single number is passed,
  102539. * it will be used for both width and height. If an object is passed, the screenshot size
  102540. * will be derived from the parameters. The precision property is a multiplier allowing
  102541. * rendering at a higher or lower resolution
  102542. * @param successCallback The callback receives a single parameter which contains the
  102543. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102544. * src parameter of an <img> to display it
  102545. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102546. * Check your browser for supported MIME types
  102547. * @param samples Texture samples (default: 1)
  102548. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102549. * @param fileName A name for for the downloaded file.
  102550. */
  102551. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  102552. /**
  102553. * Generates an image screenshot from the specified camera.
  102554. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102555. * @param engine The engine to use for rendering
  102556. * @param camera The camera to use for rendering
  102557. * @param size This parameter can be set to a single number or to an object with the
  102558. * following (optional) properties: precision, width, height. If a single number is passed,
  102559. * it will be used for both width and height. If an object is passed, the screenshot size
  102560. * will be derived from the parameters. The precision property is a multiplier allowing
  102561. * rendering at a higher or lower resolution
  102562. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102563. * Check your browser for supported MIME types
  102564. * @param samples Texture samples (default: 1)
  102565. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102566. * @param fileName A name for for the downloaded file.
  102567. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102568. * to the src parameter of an <img> to display it
  102569. */
  102570. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  102571. /**
  102572. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102573. * Be aware Math.random() could cause collisions, but:
  102574. * "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"
  102575. * @returns a pseudo random id
  102576. */
  102577. static RandomId(): string;
  102578. /**
  102579. * Test if the given uri is a base64 string
  102580. * @param uri The uri to test
  102581. * @return True if the uri is a base64 string or false otherwise
  102582. */
  102583. static IsBase64(uri: string): boolean;
  102584. /**
  102585. * Decode the given base64 uri.
  102586. * @param uri The uri to decode
  102587. * @return The decoded base64 data.
  102588. */
  102589. static DecodeBase64(uri: string): ArrayBuffer;
  102590. /**
  102591. * Gets the absolute url.
  102592. * @param url the input url
  102593. * @return the absolute url
  102594. */
  102595. static GetAbsoluteUrl(url: string): string;
  102596. /**
  102597. * No log
  102598. */
  102599. static readonly NoneLogLevel: number;
  102600. /**
  102601. * Only message logs
  102602. */
  102603. static readonly MessageLogLevel: number;
  102604. /**
  102605. * Only warning logs
  102606. */
  102607. static readonly WarningLogLevel: number;
  102608. /**
  102609. * Only error logs
  102610. */
  102611. static readonly ErrorLogLevel: number;
  102612. /**
  102613. * All logs
  102614. */
  102615. static readonly AllLogLevel: number;
  102616. /**
  102617. * Gets a value indicating the number of loading errors
  102618. * @ignorenaming
  102619. */
  102620. static readonly errorsCount: number;
  102621. /**
  102622. * Callback called when a new log is added
  102623. */
  102624. static OnNewCacheEntry: (entry: string) => void;
  102625. /**
  102626. * Log a message to the console
  102627. * @param message defines the message to log
  102628. */
  102629. static Log(message: string): void;
  102630. /**
  102631. * Write a warning message to the console
  102632. * @param message defines the message to log
  102633. */
  102634. static Warn(message: string): void;
  102635. /**
  102636. * Write an error message to the console
  102637. * @param message defines the message to log
  102638. */
  102639. static Error(message: string): void;
  102640. /**
  102641. * Gets current log cache (list of logs)
  102642. */
  102643. static readonly LogCache: string;
  102644. /**
  102645. * Clears the log cache
  102646. */
  102647. static ClearLogCache(): void;
  102648. /**
  102649. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  102650. */
  102651. static LogLevels: number;
  102652. /**
  102653. * Checks if the window object exists
  102654. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  102655. */
  102656. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  102657. /**
  102658. * No performance log
  102659. */
  102660. static readonly PerformanceNoneLogLevel: number;
  102661. /**
  102662. * Use user marks to log performance
  102663. */
  102664. static readonly PerformanceUserMarkLogLevel: number;
  102665. /**
  102666. * Log performance to the console
  102667. */
  102668. static readonly PerformanceConsoleLogLevel: number;
  102669. private static _performance;
  102670. /**
  102671. * Sets the current performance log level
  102672. */
  102673. static PerformanceLogLevel: number;
  102674. private static _StartPerformanceCounterDisabled;
  102675. private static _EndPerformanceCounterDisabled;
  102676. private static _StartUserMark;
  102677. private static _EndUserMark;
  102678. private static _StartPerformanceConsole;
  102679. private static _EndPerformanceConsole;
  102680. /**
  102681. * Starts a performance counter
  102682. */
  102683. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  102684. /**
  102685. * Ends a specific performance coutner
  102686. */
  102687. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  102688. /**
  102689. * Gets either window.performance.now() if supported or Date.now() else
  102690. */
  102691. static readonly Now: number;
  102692. /**
  102693. * This method will return the name of the class used to create the instance of the given object.
  102694. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  102695. * @param object the object to get the class name from
  102696. * @param isType defines if the object is actually a type
  102697. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  102698. */
  102699. static GetClassName(object: any, isType?: boolean): string;
  102700. /**
  102701. * Gets the first element of an array satisfying a given predicate
  102702. * @param array defines the array to browse
  102703. * @param predicate defines the predicate to use
  102704. * @returns null if not found or the element
  102705. */
  102706. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  102707. /**
  102708. * This method will return the name of the full name of the class, including its owning module (if any).
  102709. * 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).
  102710. * @param object the object to get the class name from
  102711. * @param isType defines if the object is actually a type
  102712. * @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.
  102713. * @ignorenaming
  102714. */
  102715. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  102716. /**
  102717. * Returns a promise that resolves after the given amount of time.
  102718. * @param delay Number of milliseconds to delay
  102719. * @returns Promise that resolves after the given amount of time
  102720. */
  102721. static DelayAsync(delay: number): Promise<void>;
  102722. }
  102723. /**
  102724. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  102725. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  102726. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  102727. * @param name The name of the class, case should be preserved
  102728. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  102729. */
  102730. export function className(name: string, module?: string): (target: Object) => void;
  102731. /**
  102732. * An implementation of a loop for asynchronous functions.
  102733. */
  102734. export class AsyncLoop {
  102735. /**
  102736. * Defines the number of iterations for the loop
  102737. */
  102738. iterations: number;
  102739. /**
  102740. * Defines the current index of the loop.
  102741. */
  102742. index: number;
  102743. private _done;
  102744. private _fn;
  102745. private _successCallback;
  102746. /**
  102747. * Constructor.
  102748. * @param iterations the number of iterations.
  102749. * @param func the function to run each iteration
  102750. * @param successCallback the callback that will be called upon succesful execution
  102751. * @param offset starting offset.
  102752. */
  102753. constructor(
  102754. /**
  102755. * Defines the number of iterations for the loop
  102756. */
  102757. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  102758. /**
  102759. * Execute the next iteration. Must be called after the last iteration was finished.
  102760. */
  102761. executeNext(): void;
  102762. /**
  102763. * Break the loop and run the success callback.
  102764. */
  102765. breakLoop(): void;
  102766. /**
  102767. * Create and run an async loop.
  102768. * @param iterations the number of iterations.
  102769. * @param fn the function to run each iteration
  102770. * @param successCallback the callback that will be called upon succesful execution
  102771. * @param offset starting offset.
  102772. * @returns the created async loop object
  102773. */
  102774. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  102775. /**
  102776. * A for-loop that will run a given number of iterations synchronous and the rest async.
  102777. * @param iterations total number of iterations
  102778. * @param syncedIterations number of synchronous iterations in each async iteration.
  102779. * @param fn the function to call each iteration.
  102780. * @param callback a success call back that will be called when iterating stops.
  102781. * @param breakFunction a break condition (optional)
  102782. * @param timeout timeout settings for the setTimeout function. default - 0.
  102783. * @returns the created async loop object
  102784. */
  102785. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  102786. }
  102787. }
  102788. declare module BABYLON {
  102789. /**
  102790. * This class implement a typical dictionary using a string as key and the generic type T as value.
  102791. * The underlying implementation relies on an associative array to ensure the best performances.
  102792. * The value can be anything including 'null' but except 'undefined'
  102793. */
  102794. export class StringDictionary<T> {
  102795. /**
  102796. * This will clear this dictionary and copy the content from the 'source' one.
  102797. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  102798. * @param source the dictionary to take the content from and copy to this dictionary
  102799. */
  102800. copyFrom(source: StringDictionary<T>): void;
  102801. /**
  102802. * Get a value based from its key
  102803. * @param key the given key to get the matching value from
  102804. * @return the value if found, otherwise undefined is returned
  102805. */
  102806. get(key: string): T | undefined;
  102807. /**
  102808. * Get a value from its key or add it if it doesn't exist.
  102809. * This method will ensure you that a given key/data will be present in the dictionary.
  102810. * @param key the given key to get the matching value from
  102811. * @param factory the factory that will create the value if the key is not present in the dictionary.
  102812. * The factory will only be invoked if there's no data for the given key.
  102813. * @return the value corresponding to the key.
  102814. */
  102815. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  102816. /**
  102817. * Get a value from its key if present in the dictionary otherwise add it
  102818. * @param key the key to get the value from
  102819. * @param val if there's no such key/value pair in the dictionary add it with this value
  102820. * @return the value corresponding to the key
  102821. */
  102822. getOrAdd(key: string, val: T): T;
  102823. /**
  102824. * Check if there's a given key in the dictionary
  102825. * @param key the key to check for
  102826. * @return true if the key is present, false otherwise
  102827. */
  102828. contains(key: string): boolean;
  102829. /**
  102830. * Add a new key and its corresponding value
  102831. * @param key the key to add
  102832. * @param value the value corresponding to the key
  102833. * @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
  102834. */
  102835. add(key: string, value: T): boolean;
  102836. /**
  102837. * Update a specific value associated to a key
  102838. * @param key defines the key to use
  102839. * @param value defines the value to store
  102840. * @returns true if the value was updated (or false if the key was not found)
  102841. */
  102842. set(key: string, value: T): boolean;
  102843. /**
  102844. * Get the element of the given key and remove it from the dictionary
  102845. * @param key defines the key to search
  102846. * @returns the value associated with the key or null if not found
  102847. */
  102848. getAndRemove(key: string): Nullable<T>;
  102849. /**
  102850. * Remove a key/value from the dictionary.
  102851. * @param key the key to remove
  102852. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  102853. */
  102854. remove(key: string): boolean;
  102855. /**
  102856. * Clear the whole content of the dictionary
  102857. */
  102858. clear(): void;
  102859. /**
  102860. * Gets the current count
  102861. */
  102862. readonly count: number;
  102863. /**
  102864. * Execute a callback on each key/val of the dictionary.
  102865. * Note that you can remove any element in this dictionary in the callback implementation
  102866. * @param callback the callback to execute on a given key/value pair
  102867. */
  102868. forEach(callback: (key: string, val: T) => void): void;
  102869. /**
  102870. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  102871. * If the callback returns null or undefined the method will iterate to the next key/value pair
  102872. * Note that you can remove any element in this dictionary in the callback implementation
  102873. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  102874. * @returns the first item
  102875. */
  102876. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  102877. private _count;
  102878. private _data;
  102879. }
  102880. }
  102881. declare module BABYLON {
  102882. /** @hidden */
  102883. export interface ICollisionCoordinator {
  102884. createCollider(): Collider;
  102885. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  102886. init(scene: Scene): void;
  102887. }
  102888. /** @hidden */
  102889. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  102890. private _scene;
  102891. private _scaledPosition;
  102892. private _scaledVelocity;
  102893. private _finalPosition;
  102894. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  102895. createCollider(): Collider;
  102896. init(scene: Scene): void;
  102897. private _collideWithWorld;
  102898. }
  102899. }
  102900. declare module BABYLON {
  102901. /**
  102902. * Class used to manage all inputs for the scene.
  102903. */
  102904. export class InputManager {
  102905. /** The distance in pixel that you have to move to prevent some events */
  102906. static DragMovementThreshold: number;
  102907. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  102908. static LongPressDelay: number;
  102909. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  102910. static DoubleClickDelay: number;
  102911. /** If you need to check double click without raising a single click at first click, enable this flag */
  102912. static ExclusiveDoubleClickMode: boolean;
  102913. private _wheelEventName;
  102914. private _onPointerMove;
  102915. private _onPointerDown;
  102916. private _onPointerUp;
  102917. private _initClickEvent;
  102918. private _initActionManager;
  102919. private _delayedSimpleClick;
  102920. private _delayedSimpleClickTimeout;
  102921. private _previousDelayedSimpleClickTimeout;
  102922. private _meshPickProceed;
  102923. private _previousButtonPressed;
  102924. private _currentPickResult;
  102925. private _previousPickResult;
  102926. private _totalPointersPressed;
  102927. private _doubleClickOccured;
  102928. private _pointerOverMesh;
  102929. private _pickedDownMesh;
  102930. private _pickedUpMesh;
  102931. private _pointerX;
  102932. private _pointerY;
  102933. private _unTranslatedPointerX;
  102934. private _unTranslatedPointerY;
  102935. private _startingPointerPosition;
  102936. private _previousStartingPointerPosition;
  102937. private _startingPointerTime;
  102938. private _previousStartingPointerTime;
  102939. private _pointerCaptures;
  102940. private _onKeyDown;
  102941. private _onKeyUp;
  102942. private _onCanvasFocusObserver;
  102943. private _onCanvasBlurObserver;
  102944. private _scene;
  102945. /**
  102946. * Creates a new InputManager
  102947. * @param scene defines the hosting scene
  102948. */
  102949. constructor(scene: Scene);
  102950. /**
  102951. * Gets the mesh that is currently under the pointer
  102952. */
  102953. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102954. /**
  102955. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  102956. */
  102957. readonly unTranslatedPointer: Vector2;
  102958. /**
  102959. * Gets or sets the current on-screen X position of the pointer
  102960. */
  102961. pointerX: number;
  102962. /**
  102963. * Gets or sets the current on-screen Y position of the pointer
  102964. */
  102965. pointerY: number;
  102966. private _updatePointerPosition;
  102967. private _processPointerMove;
  102968. private _setRayOnPointerInfo;
  102969. private _checkPrePointerObservable;
  102970. /**
  102971. * Use this method to simulate a pointer move on a mesh
  102972. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102973. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102974. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102975. */
  102976. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  102977. /**
  102978. * Use this method to simulate a pointer down on a mesh
  102979. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102980. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102981. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102982. */
  102983. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  102984. private _processPointerDown;
  102985. /** @hidden */
  102986. _isPointerSwiping(): boolean;
  102987. /**
  102988. * Use this method to simulate a pointer up on a mesh
  102989. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102990. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102991. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102992. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102993. */
  102994. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  102995. private _processPointerUp;
  102996. /**
  102997. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102998. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102999. * @returns true if the pointer was captured
  103000. */
  103001. isPointerCaptured(pointerId?: number): boolean;
  103002. /**
  103003. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  103004. * @param attachUp defines if you want to attach events to pointerup
  103005. * @param attachDown defines if you want to attach events to pointerdown
  103006. * @param attachMove defines if you want to attach events to pointermove
  103007. */
  103008. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  103009. /**
  103010. * Detaches all event handlers
  103011. */
  103012. detachControl(): void;
  103013. /**
  103014. * Force the value of meshUnderPointer
  103015. * @param mesh defines the mesh to use
  103016. */
  103017. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103018. /**
  103019. * Gets the mesh under the pointer
  103020. * @returns a Mesh or null if no mesh is under the pointer
  103021. */
  103022. getPointerOverMesh(): Nullable<AbstractMesh>;
  103023. }
  103024. }
  103025. declare module BABYLON {
  103026. /**
  103027. * Helper class used to generate session unique ID
  103028. */
  103029. export class UniqueIdGenerator {
  103030. private static _UniqueIdCounter;
  103031. /**
  103032. * Gets an unique (relatively to the current scene) Id
  103033. */
  103034. static readonly UniqueId: number;
  103035. }
  103036. }
  103037. declare module BABYLON {
  103038. /**
  103039. * This class defines the direct association between an animation and a target
  103040. */
  103041. export class TargetedAnimation {
  103042. /**
  103043. * Animation to perform
  103044. */
  103045. animation: Animation;
  103046. /**
  103047. * Target to animate
  103048. */
  103049. target: any;
  103050. /**
  103051. * Serialize the object
  103052. * @returns the JSON object representing the current entity
  103053. */
  103054. serialize(): any;
  103055. }
  103056. /**
  103057. * Use this class to create coordinated animations on multiple targets
  103058. */
  103059. export class AnimationGroup implements IDisposable {
  103060. /** The name of the animation group */
  103061. name: string;
  103062. private _scene;
  103063. private _targetedAnimations;
  103064. private _animatables;
  103065. private _from;
  103066. private _to;
  103067. private _isStarted;
  103068. private _isPaused;
  103069. private _speedRatio;
  103070. private _loopAnimation;
  103071. /**
  103072. * Gets or sets the unique id of the node
  103073. */
  103074. uniqueId: number;
  103075. /**
  103076. * This observable will notify when one animation have ended
  103077. */
  103078. onAnimationEndObservable: Observable<TargetedAnimation>;
  103079. /**
  103080. * Observer raised when one animation loops
  103081. */
  103082. onAnimationLoopObservable: Observable<TargetedAnimation>;
  103083. /**
  103084. * Observer raised when all animations have looped
  103085. */
  103086. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  103087. /**
  103088. * This observable will notify when all animations have ended.
  103089. */
  103090. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  103091. /**
  103092. * This observable will notify when all animations have paused.
  103093. */
  103094. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  103095. /**
  103096. * This observable will notify when all animations are playing.
  103097. */
  103098. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  103099. /**
  103100. * Gets the first frame
  103101. */
  103102. readonly from: number;
  103103. /**
  103104. * Gets the last frame
  103105. */
  103106. readonly to: number;
  103107. /**
  103108. * Define if the animations are started
  103109. */
  103110. readonly isStarted: boolean;
  103111. /**
  103112. * Gets a value indicating that the current group is playing
  103113. */
  103114. readonly isPlaying: boolean;
  103115. /**
  103116. * Gets or sets the speed ratio to use for all animations
  103117. */
  103118. /**
  103119. * Gets or sets the speed ratio to use for all animations
  103120. */
  103121. speedRatio: number;
  103122. /**
  103123. * Gets or sets if all animations should loop or not
  103124. */
  103125. loopAnimation: boolean;
  103126. /**
  103127. * Gets the targeted animations for this animation group
  103128. */
  103129. readonly targetedAnimations: Array<TargetedAnimation>;
  103130. /**
  103131. * returning the list of animatables controlled by this animation group.
  103132. */
  103133. readonly animatables: Array<Animatable>;
  103134. /**
  103135. * Instantiates a new Animation Group.
  103136. * This helps managing several animations at once.
  103137. * @see http://doc.babylonjs.com/how_to/group
  103138. * @param name Defines the name of the group
  103139. * @param scene Defines the scene the group belongs to
  103140. */
  103141. constructor(
  103142. /** The name of the animation group */
  103143. name: string, scene?: Nullable<Scene>);
  103144. /**
  103145. * Add an animation (with its target) in the group
  103146. * @param animation defines the animation we want to add
  103147. * @param target defines the target of the animation
  103148. * @returns the TargetedAnimation object
  103149. */
  103150. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  103151. /**
  103152. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  103153. * It can add constant keys at begin or end
  103154. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  103155. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  103156. * @returns the animation group
  103157. */
  103158. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  103159. private _animationLoopCount;
  103160. private _animationLoopFlags;
  103161. private _processLoop;
  103162. /**
  103163. * Start all animations on given targets
  103164. * @param loop defines if animations must loop
  103165. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  103166. * @param from defines the from key (optional)
  103167. * @param to defines the to key (optional)
  103168. * @returns the current animation group
  103169. */
  103170. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  103171. /**
  103172. * Pause all animations
  103173. * @returns the animation group
  103174. */
  103175. pause(): AnimationGroup;
  103176. /**
  103177. * Play all animations to initial state
  103178. * This function will start() the animations if they were not started or will restart() them if they were paused
  103179. * @param loop defines if animations must loop
  103180. * @returns the animation group
  103181. */
  103182. play(loop?: boolean): AnimationGroup;
  103183. /**
  103184. * Reset all animations to initial state
  103185. * @returns the animation group
  103186. */
  103187. reset(): AnimationGroup;
  103188. /**
  103189. * Restart animations from key 0
  103190. * @returns the animation group
  103191. */
  103192. restart(): AnimationGroup;
  103193. /**
  103194. * Stop all animations
  103195. * @returns the animation group
  103196. */
  103197. stop(): AnimationGroup;
  103198. /**
  103199. * Set animation weight for all animatables
  103200. * @param weight defines the weight to use
  103201. * @return the animationGroup
  103202. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103203. */
  103204. setWeightForAllAnimatables(weight: number): AnimationGroup;
  103205. /**
  103206. * Synchronize and normalize all animatables with a source animatable
  103207. * @param root defines the root animatable to synchronize with
  103208. * @return the animationGroup
  103209. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103210. */
  103211. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  103212. /**
  103213. * Goes to a specific frame in this animation group
  103214. * @param frame the frame number to go to
  103215. * @return the animationGroup
  103216. */
  103217. goToFrame(frame: number): AnimationGroup;
  103218. /**
  103219. * Dispose all associated resources
  103220. */
  103221. dispose(): void;
  103222. private _checkAnimationGroupEnded;
  103223. /**
  103224. * Clone the current animation group and returns a copy
  103225. * @param newName defines the name of the new group
  103226. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  103227. * @returns the new aniamtion group
  103228. */
  103229. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  103230. /**
  103231. * Serializes the animationGroup to an object
  103232. * @returns Serialized object
  103233. */
  103234. serialize(): any;
  103235. /**
  103236. * Returns a new AnimationGroup object parsed from the source provided.
  103237. * @param parsedAnimationGroup defines the source
  103238. * @param scene defines the scene that will receive the animationGroup
  103239. * @returns a new AnimationGroup
  103240. */
  103241. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  103242. /**
  103243. * Returns the string "AnimationGroup"
  103244. * @returns "AnimationGroup"
  103245. */
  103246. getClassName(): string;
  103247. /**
  103248. * Creates a detailled string about the object
  103249. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  103250. * @returns a string representing the object
  103251. */
  103252. toString(fullDetails?: boolean): string;
  103253. }
  103254. }
  103255. declare module BABYLON {
  103256. /**
  103257. * Define an interface for all classes that will hold resources
  103258. */
  103259. export interface IDisposable {
  103260. /**
  103261. * Releases all held resources
  103262. */
  103263. dispose(): void;
  103264. }
  103265. /** Interface defining initialization parameters for Scene class */
  103266. export interface SceneOptions {
  103267. /**
  103268. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  103269. * It will improve performance when the number of geometries becomes important.
  103270. */
  103271. useGeometryUniqueIdsMap?: boolean;
  103272. /**
  103273. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  103274. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103275. */
  103276. useMaterialMeshMap?: boolean;
  103277. /**
  103278. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  103279. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103280. */
  103281. useClonedMeshhMap?: boolean;
  103282. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  103283. virtual?: boolean;
  103284. }
  103285. /**
  103286. * Represents a scene to be rendered by the engine.
  103287. * @see http://doc.babylonjs.com/features/scene
  103288. */
  103289. export class Scene extends AbstractScene implements IAnimatable {
  103290. /** The fog is deactivated */
  103291. static readonly FOGMODE_NONE: number;
  103292. /** The fog density is following an exponential function */
  103293. static readonly FOGMODE_EXP: number;
  103294. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  103295. static readonly FOGMODE_EXP2: number;
  103296. /** The fog density is following a linear function. */
  103297. static readonly FOGMODE_LINEAR: number;
  103298. /**
  103299. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  103300. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103301. */
  103302. static MinDeltaTime: number;
  103303. /**
  103304. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  103305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103306. */
  103307. static MaxDeltaTime: number;
  103308. /**
  103309. * Factory used to create the default material.
  103310. * @param name The name of the material to create
  103311. * @param scene The scene to create the material for
  103312. * @returns The default material
  103313. */
  103314. static DefaultMaterialFactory(scene: Scene): Material;
  103315. /**
  103316. * Factory used to create the a collision coordinator.
  103317. * @returns The collision coordinator
  103318. */
  103319. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  103320. /** @hidden */
  103321. _inputManager: InputManager;
  103322. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  103323. cameraToUseForPointers: Nullable<Camera>;
  103324. /** @hidden */
  103325. readonly _isScene: boolean;
  103326. /**
  103327. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  103328. */
  103329. autoClear: boolean;
  103330. /**
  103331. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  103332. */
  103333. autoClearDepthAndStencil: boolean;
  103334. /**
  103335. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  103336. */
  103337. clearColor: Color4;
  103338. /**
  103339. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  103340. */
  103341. ambientColor: Color3;
  103342. /**
  103343. * This is use to store the default BRDF lookup for PBR materials in your scene.
  103344. * It should only be one of the following (if not the default embedded one):
  103345. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103346. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  103347. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103348. * The material properties need to be setup according to the type of texture in use.
  103349. */
  103350. environmentBRDFTexture: BaseTexture;
  103351. /** @hidden */
  103352. protected _environmentTexture: Nullable<BaseTexture>;
  103353. /**
  103354. * Texture used in all pbr material as the reflection texture.
  103355. * As in the majority of the scene they are the same (exception for multi room and so on),
  103356. * this is easier to reference from here than from all the materials.
  103357. */
  103358. /**
  103359. * Texture used in all pbr material as the reflection texture.
  103360. * As in the majority of the scene they are the same (exception for multi room and so on),
  103361. * this is easier to set here than in all the materials.
  103362. */
  103363. environmentTexture: Nullable<BaseTexture>;
  103364. /** @hidden */
  103365. protected _environmentIntensity: number;
  103366. /**
  103367. * Intensity of the environment in all pbr material.
  103368. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103369. * As in the majority of the scene they are the same (exception for multi room and so on),
  103370. * this is easier to reference from here than from all the materials.
  103371. */
  103372. /**
  103373. * Intensity of the environment in all pbr material.
  103374. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103375. * As in the majority of the scene they are the same (exception for multi room and so on),
  103376. * this is easier to set here than in all the materials.
  103377. */
  103378. environmentIntensity: number;
  103379. /** @hidden */
  103380. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103381. /**
  103382. * Default image processing configuration used either in the rendering
  103383. * Forward main pass or through the imageProcessingPostProcess if present.
  103384. * As in the majority of the scene they are the same (exception for multi camera),
  103385. * this is easier to reference from here than from all the materials and post process.
  103386. *
  103387. * No setter as we it is a shared configuration, you can set the values instead.
  103388. */
  103389. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  103390. private _forceWireframe;
  103391. /**
  103392. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  103393. */
  103394. forceWireframe: boolean;
  103395. private _forcePointsCloud;
  103396. /**
  103397. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  103398. */
  103399. forcePointsCloud: boolean;
  103400. /**
  103401. * Gets or sets the active clipplane 1
  103402. */
  103403. clipPlane: Nullable<Plane>;
  103404. /**
  103405. * Gets or sets the active clipplane 2
  103406. */
  103407. clipPlane2: Nullable<Plane>;
  103408. /**
  103409. * Gets or sets the active clipplane 3
  103410. */
  103411. clipPlane3: Nullable<Plane>;
  103412. /**
  103413. * Gets or sets the active clipplane 4
  103414. */
  103415. clipPlane4: Nullable<Plane>;
  103416. /**
  103417. * Gets or sets a boolean indicating if animations are enabled
  103418. */
  103419. animationsEnabled: boolean;
  103420. private _animationPropertiesOverride;
  103421. /**
  103422. * Gets or sets the animation properties override
  103423. */
  103424. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  103425. /**
  103426. * Gets or sets a boolean indicating if a constant deltatime has to be used
  103427. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  103428. */
  103429. useConstantAnimationDeltaTime: boolean;
  103430. /**
  103431. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  103432. * Please note that it requires to run a ray cast through the scene on every frame
  103433. */
  103434. constantlyUpdateMeshUnderPointer: boolean;
  103435. /**
  103436. * Defines the HTML cursor to use when hovering over interactive elements
  103437. */
  103438. hoverCursor: string;
  103439. /**
  103440. * Defines the HTML default cursor to use (empty by default)
  103441. */
  103442. defaultCursor: string;
  103443. /**
  103444. * Defines wether cursors are handled by the scene.
  103445. */
  103446. doNotHandleCursors: boolean;
  103447. /**
  103448. * This is used to call preventDefault() on pointer down
  103449. * in order to block unwanted artifacts like system double clicks
  103450. */
  103451. preventDefaultOnPointerDown: boolean;
  103452. /**
  103453. * This is used to call preventDefault() on pointer up
  103454. * in order to block unwanted artifacts like system double clicks
  103455. */
  103456. preventDefaultOnPointerUp: boolean;
  103457. /**
  103458. * Gets or sets user defined metadata
  103459. */
  103460. metadata: any;
  103461. /**
  103462. * For internal use only. Please do not use.
  103463. */
  103464. reservedDataStore: any;
  103465. /**
  103466. * Gets the name of the plugin used to load this scene (null by default)
  103467. */
  103468. loadingPluginName: string;
  103469. /**
  103470. * Use this array to add regular expressions used to disable offline support for specific urls
  103471. */
  103472. disableOfflineSupportExceptionRules: RegExp[];
  103473. /**
  103474. * An event triggered when the scene is disposed.
  103475. */
  103476. onDisposeObservable: Observable<Scene>;
  103477. private _onDisposeObserver;
  103478. /** Sets a function to be executed when this scene is disposed. */
  103479. onDispose: () => void;
  103480. /**
  103481. * An event triggered before rendering the scene (right after animations and physics)
  103482. */
  103483. onBeforeRenderObservable: Observable<Scene>;
  103484. private _onBeforeRenderObserver;
  103485. /** Sets a function to be executed before rendering this scene */
  103486. beforeRender: Nullable<() => void>;
  103487. /**
  103488. * An event triggered after rendering the scene
  103489. */
  103490. onAfterRenderObservable: Observable<Scene>;
  103491. /**
  103492. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  103493. */
  103494. onAfterRenderCameraObservable: Observable<Camera>;
  103495. private _onAfterRenderObserver;
  103496. /** Sets a function to be executed after rendering this scene */
  103497. afterRender: Nullable<() => void>;
  103498. /**
  103499. * An event triggered before animating the scene
  103500. */
  103501. onBeforeAnimationsObservable: Observable<Scene>;
  103502. /**
  103503. * An event triggered after animations processing
  103504. */
  103505. onAfterAnimationsObservable: Observable<Scene>;
  103506. /**
  103507. * An event triggered before draw calls are ready to be sent
  103508. */
  103509. onBeforeDrawPhaseObservable: Observable<Scene>;
  103510. /**
  103511. * An event triggered after draw calls have been sent
  103512. */
  103513. onAfterDrawPhaseObservable: Observable<Scene>;
  103514. /**
  103515. * An event triggered when the scene is ready
  103516. */
  103517. onReadyObservable: Observable<Scene>;
  103518. /**
  103519. * An event triggered before rendering a camera
  103520. */
  103521. onBeforeCameraRenderObservable: Observable<Camera>;
  103522. private _onBeforeCameraRenderObserver;
  103523. /** Sets a function to be executed before rendering a camera*/
  103524. beforeCameraRender: () => void;
  103525. /**
  103526. * An event triggered after rendering a camera
  103527. */
  103528. onAfterCameraRenderObservable: Observable<Camera>;
  103529. private _onAfterCameraRenderObserver;
  103530. /** Sets a function to be executed after rendering a camera*/
  103531. afterCameraRender: () => void;
  103532. /**
  103533. * An event triggered when active meshes evaluation is about to start
  103534. */
  103535. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  103536. /**
  103537. * An event triggered when active meshes evaluation is done
  103538. */
  103539. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  103540. /**
  103541. * An event triggered when particles rendering is about to start
  103542. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103543. */
  103544. onBeforeParticlesRenderingObservable: Observable<Scene>;
  103545. /**
  103546. * An event triggered when particles rendering is done
  103547. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103548. */
  103549. onAfterParticlesRenderingObservable: Observable<Scene>;
  103550. /**
  103551. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  103552. */
  103553. onDataLoadedObservable: Observable<Scene>;
  103554. /**
  103555. * An event triggered when a camera is created
  103556. */
  103557. onNewCameraAddedObservable: Observable<Camera>;
  103558. /**
  103559. * An event triggered when a camera is removed
  103560. */
  103561. onCameraRemovedObservable: Observable<Camera>;
  103562. /**
  103563. * An event triggered when a light is created
  103564. */
  103565. onNewLightAddedObservable: Observable<Light>;
  103566. /**
  103567. * An event triggered when a light is removed
  103568. */
  103569. onLightRemovedObservable: Observable<Light>;
  103570. /**
  103571. * An event triggered when a geometry is created
  103572. */
  103573. onNewGeometryAddedObservable: Observable<Geometry>;
  103574. /**
  103575. * An event triggered when a geometry is removed
  103576. */
  103577. onGeometryRemovedObservable: Observable<Geometry>;
  103578. /**
  103579. * An event triggered when a transform node is created
  103580. */
  103581. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  103582. /**
  103583. * An event triggered when a transform node is removed
  103584. */
  103585. onTransformNodeRemovedObservable: Observable<TransformNode>;
  103586. /**
  103587. * An event triggered when a mesh is created
  103588. */
  103589. onNewMeshAddedObservable: Observable<AbstractMesh>;
  103590. /**
  103591. * An event triggered when a mesh is removed
  103592. */
  103593. onMeshRemovedObservable: Observable<AbstractMesh>;
  103594. /**
  103595. * An event triggered when a skeleton is created
  103596. */
  103597. onNewSkeletonAddedObservable: Observable<Skeleton>;
  103598. /**
  103599. * An event triggered when a skeleton is removed
  103600. */
  103601. onSkeletonRemovedObservable: Observable<Skeleton>;
  103602. /**
  103603. * An event triggered when a material is created
  103604. */
  103605. onNewMaterialAddedObservable: Observable<Material>;
  103606. /**
  103607. * An event triggered when a material is removed
  103608. */
  103609. onMaterialRemovedObservable: Observable<Material>;
  103610. /**
  103611. * An event triggered when a texture is created
  103612. */
  103613. onNewTextureAddedObservable: Observable<BaseTexture>;
  103614. /**
  103615. * An event triggered when a texture is removed
  103616. */
  103617. onTextureRemovedObservable: Observable<BaseTexture>;
  103618. /**
  103619. * An event triggered when render targets are about to be rendered
  103620. * Can happen multiple times per frame.
  103621. */
  103622. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  103623. /**
  103624. * An event triggered when render targets were rendered.
  103625. * Can happen multiple times per frame.
  103626. */
  103627. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  103628. /**
  103629. * An event triggered before calculating deterministic simulation step
  103630. */
  103631. onBeforeStepObservable: Observable<Scene>;
  103632. /**
  103633. * An event triggered after calculating deterministic simulation step
  103634. */
  103635. onAfterStepObservable: Observable<Scene>;
  103636. /**
  103637. * An event triggered when the activeCamera property is updated
  103638. */
  103639. onActiveCameraChanged: Observable<Scene>;
  103640. /**
  103641. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  103642. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  103643. * 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)
  103644. */
  103645. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  103646. /**
  103647. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  103648. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  103649. * 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)
  103650. */
  103651. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  103652. /**
  103653. * This Observable will when a mesh has been imported into the scene.
  103654. */
  103655. onMeshImportedObservable: Observable<AbstractMesh>;
  103656. /**
  103657. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  103658. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  103659. */
  103660. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  103661. /** @hidden */
  103662. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  103663. /**
  103664. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  103665. */
  103666. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  103667. /**
  103668. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  103669. */
  103670. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  103671. /**
  103672. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  103673. */
  103674. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  103675. /** Callback called when a pointer move is detected */
  103676. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  103677. /** Callback called when a pointer down is detected */
  103678. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  103679. /** Callback called when a pointer up is detected */
  103680. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  103681. /** Callback called when a pointer pick is detected */
  103682. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  103683. /**
  103684. * 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).
  103685. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  103686. */
  103687. onPrePointerObservable: Observable<PointerInfoPre>;
  103688. /**
  103689. * Observable event triggered each time an input event is received from the rendering canvas
  103690. */
  103691. onPointerObservable: Observable<PointerInfo>;
  103692. /**
  103693. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  103694. */
  103695. readonly unTranslatedPointer: Vector2;
  103696. /**
  103697. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  103698. */
  103699. static DragMovementThreshold: number;
  103700. /**
  103701. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  103702. */
  103703. static LongPressDelay: number;
  103704. /**
  103705. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  103706. */
  103707. static DoubleClickDelay: number;
  103708. /** If you need to check double click without raising a single click at first click, enable this flag */
  103709. static ExclusiveDoubleClickMode: boolean;
  103710. /** @hidden */
  103711. _mirroredCameraPosition: Nullable<Vector3>;
  103712. /**
  103713. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  103714. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  103715. */
  103716. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  103717. /**
  103718. * Observable event triggered each time an keyboard event is received from the hosting window
  103719. */
  103720. onKeyboardObservable: Observable<KeyboardInfo>;
  103721. private _useRightHandedSystem;
  103722. /**
  103723. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  103724. */
  103725. useRightHandedSystem: boolean;
  103726. private _timeAccumulator;
  103727. private _currentStepId;
  103728. private _currentInternalStep;
  103729. /**
  103730. * Sets the step Id used by deterministic lock step
  103731. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103732. * @param newStepId defines the step Id
  103733. */
  103734. setStepId(newStepId: number): void;
  103735. /**
  103736. * Gets the step Id used by deterministic lock step
  103737. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103738. * @returns the step Id
  103739. */
  103740. getStepId(): number;
  103741. /**
  103742. * Gets the internal step used by deterministic lock step
  103743. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103744. * @returns the internal step
  103745. */
  103746. getInternalStep(): number;
  103747. private _fogEnabled;
  103748. /**
  103749. * Gets or sets a boolean indicating if fog is enabled on this scene
  103750. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103751. * (Default is true)
  103752. */
  103753. fogEnabled: boolean;
  103754. private _fogMode;
  103755. /**
  103756. * Gets or sets the fog mode to use
  103757. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103758. * | mode | value |
  103759. * | --- | --- |
  103760. * | FOGMODE_NONE | 0 |
  103761. * | FOGMODE_EXP | 1 |
  103762. * | FOGMODE_EXP2 | 2 |
  103763. * | FOGMODE_LINEAR | 3 |
  103764. */
  103765. fogMode: number;
  103766. /**
  103767. * Gets or sets the fog color to use
  103768. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103769. * (Default is Color3(0.2, 0.2, 0.3))
  103770. */
  103771. fogColor: Color3;
  103772. /**
  103773. * Gets or sets the fog density to use
  103774. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103775. * (Default is 0.1)
  103776. */
  103777. fogDensity: number;
  103778. /**
  103779. * Gets or sets the fog start distance to use
  103780. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103781. * (Default is 0)
  103782. */
  103783. fogStart: number;
  103784. /**
  103785. * Gets or sets the fog end distance to use
  103786. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103787. * (Default is 1000)
  103788. */
  103789. fogEnd: number;
  103790. private _shadowsEnabled;
  103791. /**
  103792. * Gets or sets a boolean indicating if shadows are enabled on this scene
  103793. */
  103794. shadowsEnabled: boolean;
  103795. private _lightsEnabled;
  103796. /**
  103797. * Gets or sets a boolean indicating if lights are enabled on this scene
  103798. */
  103799. lightsEnabled: boolean;
  103800. /** All of the active cameras added to this scene. */
  103801. activeCameras: Camera[];
  103802. /** @hidden */
  103803. _activeCamera: Nullable<Camera>;
  103804. /** Gets or sets the current active camera */
  103805. activeCamera: Nullable<Camera>;
  103806. private _defaultMaterial;
  103807. /** The default material used on meshes when no material is affected */
  103808. /** The default material used on meshes when no material is affected */
  103809. defaultMaterial: Material;
  103810. private _texturesEnabled;
  103811. /**
  103812. * Gets or sets a boolean indicating if textures are enabled on this scene
  103813. */
  103814. texturesEnabled: boolean;
  103815. /**
  103816. * Gets or sets a boolean indicating if particles are enabled on this scene
  103817. */
  103818. particlesEnabled: boolean;
  103819. /**
  103820. * Gets or sets a boolean indicating if sprites are enabled on this scene
  103821. */
  103822. spritesEnabled: boolean;
  103823. private _skeletonsEnabled;
  103824. /**
  103825. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  103826. */
  103827. skeletonsEnabled: boolean;
  103828. /**
  103829. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  103830. */
  103831. lensFlaresEnabled: boolean;
  103832. /**
  103833. * Gets or sets a boolean indicating if collisions are enabled on this scene
  103834. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103835. */
  103836. collisionsEnabled: boolean;
  103837. private _collisionCoordinator;
  103838. /** @hidden */
  103839. readonly collisionCoordinator: ICollisionCoordinator;
  103840. /**
  103841. * Defines the gravity applied to this scene (used only for collisions)
  103842. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103843. */
  103844. gravity: Vector3;
  103845. /**
  103846. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  103847. */
  103848. postProcessesEnabled: boolean;
  103849. /**
  103850. * The list of postprocesses added to the scene
  103851. */
  103852. postProcesses: PostProcess[];
  103853. /**
  103854. * Gets the current postprocess manager
  103855. */
  103856. postProcessManager: PostProcessManager;
  103857. /**
  103858. * Gets or sets a boolean indicating if render targets are enabled on this scene
  103859. */
  103860. renderTargetsEnabled: boolean;
  103861. /**
  103862. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  103863. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  103864. */
  103865. dumpNextRenderTargets: boolean;
  103866. /**
  103867. * The list of user defined render targets added to the scene
  103868. */
  103869. customRenderTargets: RenderTargetTexture[];
  103870. /**
  103871. * Defines if texture loading must be delayed
  103872. * If true, textures will only be loaded when they need to be rendered
  103873. */
  103874. useDelayedTextureLoading: boolean;
  103875. /**
  103876. * Gets the list of meshes imported to the scene through SceneLoader
  103877. */
  103878. importedMeshesFiles: String[];
  103879. /**
  103880. * Gets or sets a boolean indicating if probes are enabled on this scene
  103881. */
  103882. probesEnabled: boolean;
  103883. /**
  103884. * Gets or sets the current offline provider to use to store scene data
  103885. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  103886. */
  103887. offlineProvider: IOfflineProvider;
  103888. /**
  103889. * Gets or sets the action manager associated with the scene
  103890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103891. */
  103892. actionManager: AbstractActionManager;
  103893. private _meshesForIntersections;
  103894. /**
  103895. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  103896. */
  103897. proceduralTexturesEnabled: boolean;
  103898. private _engine;
  103899. private _totalVertices;
  103900. /** @hidden */
  103901. _activeIndices: PerfCounter;
  103902. /** @hidden */
  103903. _activeParticles: PerfCounter;
  103904. /** @hidden */
  103905. _activeBones: PerfCounter;
  103906. private _animationRatio;
  103907. /** @hidden */
  103908. _animationTimeLast: number;
  103909. /** @hidden */
  103910. _animationTime: number;
  103911. /**
  103912. * Gets or sets a general scale for animation speed
  103913. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  103914. */
  103915. animationTimeScale: number;
  103916. /** @hidden */
  103917. _cachedMaterial: Nullable<Material>;
  103918. /** @hidden */
  103919. _cachedEffect: Nullable<Effect>;
  103920. /** @hidden */
  103921. _cachedVisibility: Nullable<number>;
  103922. private _renderId;
  103923. private _frameId;
  103924. private _executeWhenReadyTimeoutId;
  103925. private _intermediateRendering;
  103926. private _viewUpdateFlag;
  103927. private _projectionUpdateFlag;
  103928. /** @hidden */
  103929. _toBeDisposed: Nullable<IDisposable>[];
  103930. private _activeRequests;
  103931. /** @hidden */
  103932. _pendingData: any[];
  103933. private _isDisposed;
  103934. /**
  103935. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  103936. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  103937. */
  103938. dispatchAllSubMeshesOfActiveMeshes: boolean;
  103939. private _activeMeshes;
  103940. private _processedMaterials;
  103941. private _renderTargets;
  103942. /** @hidden */
  103943. _activeParticleSystems: SmartArray<IParticleSystem>;
  103944. private _activeSkeletons;
  103945. private _softwareSkinnedMeshes;
  103946. private _renderingManager;
  103947. /** @hidden */
  103948. _activeAnimatables: Animatable[];
  103949. private _transformMatrix;
  103950. private _sceneUbo;
  103951. /** @hidden */
  103952. _viewMatrix: Matrix;
  103953. private _projectionMatrix;
  103954. /** @hidden */
  103955. _forcedViewPosition: Nullable<Vector3>;
  103956. /** @hidden */
  103957. _frustumPlanes: Plane[];
  103958. /**
  103959. * Gets the list of frustum planes (built from the active camera)
  103960. */
  103961. readonly frustumPlanes: Plane[];
  103962. /**
  103963. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  103964. * This is useful if there are more lights that the maximum simulteanous authorized
  103965. */
  103966. requireLightSorting: boolean;
  103967. /** @hidden */
  103968. readonly useMaterialMeshMap: boolean;
  103969. /** @hidden */
  103970. readonly useClonedMeshhMap: boolean;
  103971. private _externalData;
  103972. private _uid;
  103973. /**
  103974. * @hidden
  103975. * Backing store of defined scene components.
  103976. */
  103977. _components: ISceneComponent[];
  103978. /**
  103979. * @hidden
  103980. * Backing store of defined scene components.
  103981. */
  103982. _serializableComponents: ISceneSerializableComponent[];
  103983. /**
  103984. * List of components to register on the next registration step.
  103985. */
  103986. private _transientComponents;
  103987. /**
  103988. * Registers the transient components if needed.
  103989. */
  103990. private _registerTransientComponents;
  103991. /**
  103992. * @hidden
  103993. * Add a component to the scene.
  103994. * Note that the ccomponent could be registered on th next frame if this is called after
  103995. * the register component stage.
  103996. * @param component Defines the component to add to the scene
  103997. */
  103998. _addComponent(component: ISceneComponent): void;
  103999. /**
  104000. * @hidden
  104001. * Gets a component from the scene.
  104002. * @param name defines the name of the component to retrieve
  104003. * @returns the component or null if not present
  104004. */
  104005. _getComponent(name: string): Nullable<ISceneComponent>;
  104006. /**
  104007. * @hidden
  104008. * Defines the actions happening before camera updates.
  104009. */
  104010. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  104011. /**
  104012. * @hidden
  104013. * Defines the actions happening before clear the canvas.
  104014. */
  104015. _beforeClearStage: Stage<SimpleStageAction>;
  104016. /**
  104017. * @hidden
  104018. * Defines the actions when collecting render targets for the frame.
  104019. */
  104020. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104021. /**
  104022. * @hidden
  104023. * Defines the actions happening for one camera in the frame.
  104024. */
  104025. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104026. /**
  104027. * @hidden
  104028. * Defines the actions happening during the per mesh ready checks.
  104029. */
  104030. _isReadyForMeshStage: Stage<MeshStageAction>;
  104031. /**
  104032. * @hidden
  104033. * Defines the actions happening before evaluate active mesh checks.
  104034. */
  104035. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  104036. /**
  104037. * @hidden
  104038. * Defines the actions happening during the evaluate sub mesh checks.
  104039. */
  104040. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  104041. /**
  104042. * @hidden
  104043. * Defines the actions happening during the active mesh stage.
  104044. */
  104045. _activeMeshStage: Stage<ActiveMeshStageAction>;
  104046. /**
  104047. * @hidden
  104048. * Defines the actions happening during the per camera render target step.
  104049. */
  104050. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  104051. /**
  104052. * @hidden
  104053. * Defines the actions happening just before the active camera is drawing.
  104054. */
  104055. _beforeCameraDrawStage: Stage<CameraStageAction>;
  104056. /**
  104057. * @hidden
  104058. * Defines the actions happening just before a render target is drawing.
  104059. */
  104060. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104061. /**
  104062. * @hidden
  104063. * Defines the actions happening just before a rendering group is drawing.
  104064. */
  104065. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104066. /**
  104067. * @hidden
  104068. * Defines the actions happening just before a mesh is drawing.
  104069. */
  104070. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104071. /**
  104072. * @hidden
  104073. * Defines the actions happening just after a mesh has been drawn.
  104074. */
  104075. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104076. /**
  104077. * @hidden
  104078. * Defines the actions happening just after a rendering group has been drawn.
  104079. */
  104080. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104081. /**
  104082. * @hidden
  104083. * Defines the actions happening just after the active camera has been drawn.
  104084. */
  104085. _afterCameraDrawStage: Stage<CameraStageAction>;
  104086. /**
  104087. * @hidden
  104088. * Defines the actions happening just after a render target has been drawn.
  104089. */
  104090. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104091. /**
  104092. * @hidden
  104093. * Defines the actions happening just after rendering all cameras and computing intersections.
  104094. */
  104095. _afterRenderStage: Stage<SimpleStageAction>;
  104096. /**
  104097. * @hidden
  104098. * Defines the actions happening when a pointer move event happens.
  104099. */
  104100. _pointerMoveStage: Stage<PointerMoveStageAction>;
  104101. /**
  104102. * @hidden
  104103. * Defines the actions happening when a pointer down event happens.
  104104. */
  104105. _pointerDownStage: Stage<PointerUpDownStageAction>;
  104106. /**
  104107. * @hidden
  104108. * Defines the actions happening when a pointer up event happens.
  104109. */
  104110. _pointerUpStage: Stage<PointerUpDownStageAction>;
  104111. /**
  104112. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  104113. */
  104114. private geometriesByUniqueId;
  104115. /**
  104116. * Creates a new Scene
  104117. * @param engine defines the engine to use to render this scene
  104118. * @param options defines the scene options
  104119. */
  104120. constructor(engine: Engine, options?: SceneOptions);
  104121. /**
  104122. * Gets a string idenfifying the name of the class
  104123. * @returns "Scene" string
  104124. */
  104125. getClassName(): string;
  104126. private _defaultMeshCandidates;
  104127. /**
  104128. * @hidden
  104129. */
  104130. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104131. private _defaultSubMeshCandidates;
  104132. /**
  104133. * @hidden
  104134. */
  104135. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104136. /**
  104137. * Sets the default candidate providers for the scene.
  104138. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  104139. * and getCollidingSubMeshCandidates to their default function
  104140. */
  104141. setDefaultCandidateProviders(): void;
  104142. /**
  104143. * Gets the mesh that is currently under the pointer
  104144. */
  104145. readonly meshUnderPointer: Nullable<AbstractMesh>;
  104146. /**
  104147. * Gets or sets the current on-screen X position of the pointer
  104148. */
  104149. pointerX: number;
  104150. /**
  104151. * Gets or sets the current on-screen Y position of the pointer
  104152. */
  104153. pointerY: number;
  104154. /**
  104155. * Gets the cached material (ie. the latest rendered one)
  104156. * @returns the cached material
  104157. */
  104158. getCachedMaterial(): Nullable<Material>;
  104159. /**
  104160. * Gets the cached effect (ie. the latest rendered one)
  104161. * @returns the cached effect
  104162. */
  104163. getCachedEffect(): Nullable<Effect>;
  104164. /**
  104165. * Gets the cached visibility state (ie. the latest rendered one)
  104166. * @returns the cached visibility state
  104167. */
  104168. getCachedVisibility(): Nullable<number>;
  104169. /**
  104170. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  104171. * @param material defines the current material
  104172. * @param effect defines the current effect
  104173. * @param visibility defines the current visibility state
  104174. * @returns true if one parameter is not cached
  104175. */
  104176. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  104177. /**
  104178. * Gets the engine associated with the scene
  104179. * @returns an Engine
  104180. */
  104181. getEngine(): Engine;
  104182. /**
  104183. * Gets the total number of vertices rendered per frame
  104184. * @returns the total number of vertices rendered per frame
  104185. */
  104186. getTotalVertices(): number;
  104187. /**
  104188. * Gets the performance counter for total vertices
  104189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104190. */
  104191. readonly totalVerticesPerfCounter: PerfCounter;
  104192. /**
  104193. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  104194. * @returns the total number of active indices rendered per frame
  104195. */
  104196. getActiveIndices(): number;
  104197. /**
  104198. * Gets the performance counter for active indices
  104199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104200. */
  104201. readonly totalActiveIndicesPerfCounter: PerfCounter;
  104202. /**
  104203. * Gets the total number of active particles rendered per frame
  104204. * @returns the total number of active particles rendered per frame
  104205. */
  104206. getActiveParticles(): number;
  104207. /**
  104208. * Gets the performance counter for active particles
  104209. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104210. */
  104211. readonly activeParticlesPerfCounter: PerfCounter;
  104212. /**
  104213. * Gets the total number of active bones rendered per frame
  104214. * @returns the total number of active bones rendered per frame
  104215. */
  104216. getActiveBones(): number;
  104217. /**
  104218. * Gets the performance counter for active bones
  104219. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104220. */
  104221. readonly activeBonesPerfCounter: PerfCounter;
  104222. /**
  104223. * Gets the array of active meshes
  104224. * @returns an array of AbstractMesh
  104225. */
  104226. getActiveMeshes(): SmartArray<AbstractMesh>;
  104227. /**
  104228. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  104229. * @returns a number
  104230. */
  104231. getAnimationRatio(): number;
  104232. /**
  104233. * Gets an unique Id for the current render phase
  104234. * @returns a number
  104235. */
  104236. getRenderId(): number;
  104237. /**
  104238. * Gets an unique Id for the current frame
  104239. * @returns a number
  104240. */
  104241. getFrameId(): number;
  104242. /** Call this function if you want to manually increment the render Id*/
  104243. incrementRenderId(): void;
  104244. private _createUbo;
  104245. /**
  104246. * Use this method to simulate a pointer move on a mesh
  104247. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104248. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104249. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104250. * @returns the current scene
  104251. */
  104252. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104253. /**
  104254. * Use this method to simulate a pointer down on a mesh
  104255. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104256. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104257. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104258. * @returns the current scene
  104259. */
  104260. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104261. /**
  104262. * Use this method to simulate a pointer up on a mesh
  104263. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104264. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104265. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104266. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  104267. * @returns the current scene
  104268. */
  104269. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  104270. /**
  104271. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  104272. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  104273. * @returns true if the pointer was captured
  104274. */
  104275. isPointerCaptured(pointerId?: number): boolean;
  104276. /**
  104277. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  104278. * @param attachUp defines if you want to attach events to pointerup
  104279. * @param attachDown defines if you want to attach events to pointerdown
  104280. * @param attachMove defines if you want to attach events to pointermove
  104281. */
  104282. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  104283. /** Detaches all event handlers*/
  104284. detachControl(): void;
  104285. /**
  104286. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  104287. * Delay loaded resources are not taking in account
  104288. * @return true if all required resources are ready
  104289. */
  104290. isReady(): boolean;
  104291. /** Resets all cached information relative to material (including effect and visibility) */
  104292. resetCachedMaterial(): void;
  104293. /**
  104294. * Registers a function to be called before every frame render
  104295. * @param func defines the function to register
  104296. */
  104297. registerBeforeRender(func: () => void): void;
  104298. /**
  104299. * Unregisters a function called before every frame render
  104300. * @param func defines the function to unregister
  104301. */
  104302. unregisterBeforeRender(func: () => void): void;
  104303. /**
  104304. * Registers a function to be called after every frame render
  104305. * @param func defines the function to register
  104306. */
  104307. registerAfterRender(func: () => void): void;
  104308. /**
  104309. * Unregisters a function called after every frame render
  104310. * @param func defines the function to unregister
  104311. */
  104312. unregisterAfterRender(func: () => void): void;
  104313. private _executeOnceBeforeRender;
  104314. /**
  104315. * The provided function will run before render once and will be disposed afterwards.
  104316. * A timeout delay can be provided so that the function will be executed in N ms.
  104317. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  104318. * @param func The function to be executed.
  104319. * @param timeout optional delay in ms
  104320. */
  104321. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  104322. /** @hidden */
  104323. _addPendingData(data: any): void;
  104324. /** @hidden */
  104325. _removePendingData(data: any): void;
  104326. /**
  104327. * Returns the number of items waiting to be loaded
  104328. * @returns the number of items waiting to be loaded
  104329. */
  104330. getWaitingItemsCount(): number;
  104331. /**
  104332. * Returns a boolean indicating if the scene is still loading data
  104333. */
  104334. readonly isLoading: boolean;
  104335. /**
  104336. * Registers a function to be executed when the scene is ready
  104337. * @param {Function} func - the function to be executed
  104338. */
  104339. executeWhenReady(func: () => void): void;
  104340. /**
  104341. * Returns a promise that resolves when the scene is ready
  104342. * @returns A promise that resolves when the scene is ready
  104343. */
  104344. whenReadyAsync(): Promise<void>;
  104345. /** @hidden */
  104346. _checkIsReady(): void;
  104347. /**
  104348. * Gets all animatable attached to the scene
  104349. */
  104350. readonly animatables: Animatable[];
  104351. /**
  104352. * Resets the last animation time frame.
  104353. * Useful to override when animations start running when loading a scene for the first time.
  104354. */
  104355. resetLastAnimationTimeFrame(): void;
  104356. /**
  104357. * Gets the current view matrix
  104358. * @returns a Matrix
  104359. */
  104360. getViewMatrix(): Matrix;
  104361. /**
  104362. * Gets the current projection matrix
  104363. * @returns a Matrix
  104364. */
  104365. getProjectionMatrix(): Matrix;
  104366. /**
  104367. * Gets the current transform matrix
  104368. * @returns a Matrix made of View * Projection
  104369. */
  104370. getTransformMatrix(): Matrix;
  104371. /**
  104372. * Sets the current transform matrix
  104373. * @param viewL defines the View matrix to use
  104374. * @param projectionL defines the Projection matrix to use
  104375. * @param viewR defines the right View matrix to use (if provided)
  104376. * @param projectionR defines the right Projection matrix to use (if provided)
  104377. */
  104378. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  104379. /**
  104380. * Gets the uniform buffer used to store scene data
  104381. * @returns a UniformBuffer
  104382. */
  104383. getSceneUniformBuffer(): UniformBuffer;
  104384. /**
  104385. * Gets an unique (relatively to the current scene) Id
  104386. * @returns an unique number for the scene
  104387. */
  104388. getUniqueId(): number;
  104389. /**
  104390. * Add a mesh to the list of scene's meshes
  104391. * @param newMesh defines the mesh to add
  104392. * @param recursive if all child meshes should also be added to the scene
  104393. */
  104394. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  104395. /**
  104396. * Remove a mesh for the list of scene's meshes
  104397. * @param toRemove defines the mesh to remove
  104398. * @param recursive if all child meshes should also be removed from the scene
  104399. * @returns the index where the mesh was in the mesh list
  104400. */
  104401. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  104402. /**
  104403. * Add a transform node to the list of scene's transform nodes
  104404. * @param newTransformNode defines the transform node to add
  104405. */
  104406. addTransformNode(newTransformNode: TransformNode): void;
  104407. /**
  104408. * Remove a transform node for the list of scene's transform nodes
  104409. * @param toRemove defines the transform node to remove
  104410. * @returns the index where the transform node was in the transform node list
  104411. */
  104412. removeTransformNode(toRemove: TransformNode): number;
  104413. /**
  104414. * Remove a skeleton for the list of scene's skeletons
  104415. * @param toRemove defines the skeleton to remove
  104416. * @returns the index where the skeleton was in the skeleton list
  104417. */
  104418. removeSkeleton(toRemove: Skeleton): number;
  104419. /**
  104420. * Remove a morph target for the list of scene's morph targets
  104421. * @param toRemove defines the morph target to remove
  104422. * @returns the index where the morph target was in the morph target list
  104423. */
  104424. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  104425. /**
  104426. * Remove a light for the list of scene's lights
  104427. * @param toRemove defines the light to remove
  104428. * @returns the index where the light was in the light list
  104429. */
  104430. removeLight(toRemove: Light): number;
  104431. /**
  104432. * Remove a camera for the list of scene's cameras
  104433. * @param toRemove defines the camera to remove
  104434. * @returns the index where the camera was in the camera list
  104435. */
  104436. removeCamera(toRemove: Camera): number;
  104437. /**
  104438. * Remove a particle system for the list of scene's particle systems
  104439. * @param toRemove defines the particle system to remove
  104440. * @returns the index where the particle system was in the particle system list
  104441. */
  104442. removeParticleSystem(toRemove: IParticleSystem): number;
  104443. /**
  104444. * Remove a animation for the list of scene's animations
  104445. * @param toRemove defines the animation to remove
  104446. * @returns the index where the animation was in the animation list
  104447. */
  104448. removeAnimation(toRemove: Animation): number;
  104449. /**
  104450. * Will stop the animation of the given target
  104451. * @param target - the target
  104452. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  104453. * @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)
  104454. */
  104455. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  104456. /**
  104457. * Removes the given animation group from this scene.
  104458. * @param toRemove The animation group to remove
  104459. * @returns The index of the removed animation group
  104460. */
  104461. removeAnimationGroup(toRemove: AnimationGroup): number;
  104462. /**
  104463. * Removes the given multi-material from this scene.
  104464. * @param toRemove The multi-material to remove
  104465. * @returns The index of the removed multi-material
  104466. */
  104467. removeMultiMaterial(toRemove: MultiMaterial): number;
  104468. /**
  104469. * Removes the given material from this scene.
  104470. * @param toRemove The material to remove
  104471. * @returns The index of the removed material
  104472. */
  104473. removeMaterial(toRemove: Material): number;
  104474. /**
  104475. * Removes the given action manager from this scene.
  104476. * @param toRemove The action manager to remove
  104477. * @returns The index of the removed action manager
  104478. */
  104479. removeActionManager(toRemove: AbstractActionManager): number;
  104480. /**
  104481. * Removes the given texture from this scene.
  104482. * @param toRemove The texture to remove
  104483. * @returns The index of the removed texture
  104484. */
  104485. removeTexture(toRemove: BaseTexture): number;
  104486. /**
  104487. * Adds the given light to this scene
  104488. * @param newLight The light to add
  104489. */
  104490. addLight(newLight: Light): void;
  104491. /**
  104492. * Sorts the list list based on light priorities
  104493. */
  104494. sortLightsByPriority(): void;
  104495. /**
  104496. * Adds the given camera to this scene
  104497. * @param newCamera The camera to add
  104498. */
  104499. addCamera(newCamera: Camera): void;
  104500. /**
  104501. * Adds the given skeleton to this scene
  104502. * @param newSkeleton The skeleton to add
  104503. */
  104504. addSkeleton(newSkeleton: Skeleton): void;
  104505. /**
  104506. * Adds the given particle system to this scene
  104507. * @param newParticleSystem The particle system to add
  104508. */
  104509. addParticleSystem(newParticleSystem: IParticleSystem): void;
  104510. /**
  104511. * Adds the given animation to this scene
  104512. * @param newAnimation The animation to add
  104513. */
  104514. addAnimation(newAnimation: Animation): void;
  104515. /**
  104516. * Adds the given animation group to this scene.
  104517. * @param newAnimationGroup The animation group to add
  104518. */
  104519. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  104520. /**
  104521. * Adds the given multi-material to this scene
  104522. * @param newMultiMaterial The multi-material to add
  104523. */
  104524. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  104525. /**
  104526. * Adds the given material to this scene
  104527. * @param newMaterial The material to add
  104528. */
  104529. addMaterial(newMaterial: Material): void;
  104530. /**
  104531. * Adds the given morph target to this scene
  104532. * @param newMorphTargetManager The morph target to add
  104533. */
  104534. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  104535. /**
  104536. * Adds the given geometry to this scene
  104537. * @param newGeometry The geometry to add
  104538. */
  104539. addGeometry(newGeometry: Geometry): void;
  104540. /**
  104541. * Adds the given action manager to this scene
  104542. * @param newActionManager The action manager to add
  104543. */
  104544. addActionManager(newActionManager: AbstractActionManager): void;
  104545. /**
  104546. * Adds the given texture to this scene.
  104547. * @param newTexture The texture to add
  104548. */
  104549. addTexture(newTexture: BaseTexture): void;
  104550. /**
  104551. * Switch active camera
  104552. * @param newCamera defines the new active camera
  104553. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  104554. */
  104555. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  104556. /**
  104557. * sets the active camera of the scene using its ID
  104558. * @param id defines the camera's ID
  104559. * @return the new active camera or null if none found.
  104560. */
  104561. setActiveCameraByID(id: string): Nullable<Camera>;
  104562. /**
  104563. * sets the active camera of the scene using its name
  104564. * @param name defines the camera's name
  104565. * @returns the new active camera or null if none found.
  104566. */
  104567. setActiveCameraByName(name: string): Nullable<Camera>;
  104568. /**
  104569. * get an animation group using its name
  104570. * @param name defines the material's name
  104571. * @return the animation group or null if none found.
  104572. */
  104573. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  104574. /**
  104575. * Get a material using its unique id
  104576. * @param uniqueId defines the material's unique id
  104577. * @return the material or null if none found.
  104578. */
  104579. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  104580. /**
  104581. * get a material using its id
  104582. * @param id defines the material's ID
  104583. * @return the material or null if none found.
  104584. */
  104585. getMaterialByID(id: string): Nullable<Material>;
  104586. /**
  104587. * Gets a the last added material using a given id
  104588. * @param id defines the material's ID
  104589. * @return the last material with the given id or null if none found.
  104590. */
  104591. getLastMaterialByID(id: string): Nullable<Material>;
  104592. /**
  104593. * Gets a material using its name
  104594. * @param name defines the material's name
  104595. * @return the material or null if none found.
  104596. */
  104597. getMaterialByName(name: string): Nullable<Material>;
  104598. /**
  104599. * Get a texture using its unique id
  104600. * @param uniqueId defines the texture's unique id
  104601. * @return the texture or null if none found.
  104602. */
  104603. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  104604. /**
  104605. * Gets a camera using its id
  104606. * @param id defines the id to look for
  104607. * @returns the camera or null if not found
  104608. */
  104609. getCameraByID(id: string): Nullable<Camera>;
  104610. /**
  104611. * Gets a camera using its unique id
  104612. * @param uniqueId defines the unique id to look for
  104613. * @returns the camera or null if not found
  104614. */
  104615. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  104616. /**
  104617. * Gets a camera using its name
  104618. * @param name defines the camera's name
  104619. * @return the camera or null if none found.
  104620. */
  104621. getCameraByName(name: string): Nullable<Camera>;
  104622. /**
  104623. * Gets a bone using its id
  104624. * @param id defines the bone's id
  104625. * @return the bone or null if not found
  104626. */
  104627. getBoneByID(id: string): Nullable<Bone>;
  104628. /**
  104629. * Gets a bone using its id
  104630. * @param name defines the bone's name
  104631. * @return the bone or null if not found
  104632. */
  104633. getBoneByName(name: string): Nullable<Bone>;
  104634. /**
  104635. * Gets a light node using its name
  104636. * @param name defines the the light's name
  104637. * @return the light or null if none found.
  104638. */
  104639. getLightByName(name: string): Nullable<Light>;
  104640. /**
  104641. * Gets a light node using its id
  104642. * @param id defines the light's id
  104643. * @return the light or null if none found.
  104644. */
  104645. getLightByID(id: string): Nullable<Light>;
  104646. /**
  104647. * Gets a light node using its scene-generated unique ID
  104648. * @param uniqueId defines the light's unique id
  104649. * @return the light or null if none found.
  104650. */
  104651. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  104652. /**
  104653. * Gets a particle system by id
  104654. * @param id defines the particle system id
  104655. * @return the corresponding system or null if none found
  104656. */
  104657. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  104658. /**
  104659. * Gets a geometry using its ID
  104660. * @param id defines the geometry's id
  104661. * @return the geometry or null if none found.
  104662. */
  104663. getGeometryByID(id: string): Nullable<Geometry>;
  104664. private _getGeometryByUniqueID;
  104665. /**
  104666. * Add a new geometry to this scene
  104667. * @param geometry defines the geometry to be added to the scene.
  104668. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  104669. * @return a boolean defining if the geometry was added or not
  104670. */
  104671. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  104672. /**
  104673. * Removes an existing geometry
  104674. * @param geometry defines the geometry to be removed from the scene
  104675. * @return a boolean defining if the geometry was removed or not
  104676. */
  104677. removeGeometry(geometry: Geometry): boolean;
  104678. /**
  104679. * Gets the list of geometries attached to the scene
  104680. * @returns an array of Geometry
  104681. */
  104682. getGeometries(): Geometry[];
  104683. /**
  104684. * Gets the first added mesh found of a given ID
  104685. * @param id defines the id to search for
  104686. * @return the mesh found or null if not found at all
  104687. */
  104688. getMeshByID(id: string): Nullable<AbstractMesh>;
  104689. /**
  104690. * Gets a list of meshes using their id
  104691. * @param id defines the id to search for
  104692. * @returns a list of meshes
  104693. */
  104694. getMeshesByID(id: string): Array<AbstractMesh>;
  104695. /**
  104696. * Gets the first added transform node found of a given ID
  104697. * @param id defines the id to search for
  104698. * @return the found transform node or null if not found at all.
  104699. */
  104700. getTransformNodeByID(id: string): Nullable<TransformNode>;
  104701. /**
  104702. * Gets a transform node with its auto-generated unique id
  104703. * @param uniqueId efines the unique id to search for
  104704. * @return the found transform node or null if not found at all.
  104705. */
  104706. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  104707. /**
  104708. * Gets a list of transform nodes using their id
  104709. * @param id defines the id to search for
  104710. * @returns a list of transform nodes
  104711. */
  104712. getTransformNodesByID(id: string): Array<TransformNode>;
  104713. /**
  104714. * Gets a mesh with its auto-generated unique id
  104715. * @param uniqueId defines the unique id to search for
  104716. * @return the found mesh or null if not found at all.
  104717. */
  104718. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  104719. /**
  104720. * Gets a the last added mesh using a given id
  104721. * @param id defines the id to search for
  104722. * @return the found mesh or null if not found at all.
  104723. */
  104724. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  104725. /**
  104726. * Gets a the last added node (Mesh, Camera, Light) using a given id
  104727. * @param id defines the id to search for
  104728. * @return the found node or null if not found at all
  104729. */
  104730. getLastEntryByID(id: string): Nullable<Node>;
  104731. /**
  104732. * Gets a node (Mesh, Camera, Light) using a given id
  104733. * @param id defines the id to search for
  104734. * @return the found node or null if not found at all
  104735. */
  104736. getNodeByID(id: string): Nullable<Node>;
  104737. /**
  104738. * Gets a node (Mesh, Camera, Light) using a given name
  104739. * @param name defines the name to search for
  104740. * @return the found node or null if not found at all.
  104741. */
  104742. getNodeByName(name: string): Nullable<Node>;
  104743. /**
  104744. * Gets a mesh using a given name
  104745. * @param name defines the name to search for
  104746. * @return the found mesh or null if not found at all.
  104747. */
  104748. getMeshByName(name: string): Nullable<AbstractMesh>;
  104749. /**
  104750. * Gets a transform node using a given name
  104751. * @param name defines the name to search for
  104752. * @return the found transform node or null if not found at all.
  104753. */
  104754. getTransformNodeByName(name: string): Nullable<TransformNode>;
  104755. /**
  104756. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  104757. * @param id defines the id to search for
  104758. * @return the found skeleton or null if not found at all.
  104759. */
  104760. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  104761. /**
  104762. * Gets a skeleton using a given auto generated unique id
  104763. * @param uniqueId defines the unique id to search for
  104764. * @return the found skeleton or null if not found at all.
  104765. */
  104766. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  104767. /**
  104768. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  104769. * @param id defines the id to search for
  104770. * @return the found skeleton or null if not found at all.
  104771. */
  104772. getSkeletonById(id: string): Nullable<Skeleton>;
  104773. /**
  104774. * Gets a skeleton using a given name
  104775. * @param name defines the name to search for
  104776. * @return the found skeleton or null if not found at all.
  104777. */
  104778. getSkeletonByName(name: string): Nullable<Skeleton>;
  104779. /**
  104780. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  104781. * @param id defines the id to search for
  104782. * @return the found morph target manager or null if not found at all.
  104783. */
  104784. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  104785. /**
  104786. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  104787. * @param id defines the id to search for
  104788. * @return the found morph target or null if not found at all.
  104789. */
  104790. getMorphTargetById(id: string): Nullable<MorphTarget>;
  104791. /**
  104792. * Gets a boolean indicating if the given mesh is active
  104793. * @param mesh defines the mesh to look for
  104794. * @returns true if the mesh is in the active list
  104795. */
  104796. isActiveMesh(mesh: AbstractMesh): boolean;
  104797. /**
  104798. * Return a unique id as a string which can serve as an identifier for the scene
  104799. */
  104800. readonly uid: string;
  104801. /**
  104802. * Add an externaly attached data from its key.
  104803. * This method call will fail and return false, if such key already exists.
  104804. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  104805. * @param key the unique key that identifies the data
  104806. * @param data the data object to associate to the key for this Engine instance
  104807. * @return true if no such key were already present and the data was added successfully, false otherwise
  104808. */
  104809. addExternalData<T>(key: string, data: T): boolean;
  104810. /**
  104811. * Get an externaly attached data from its key
  104812. * @param key the unique key that identifies the data
  104813. * @return the associated data, if present (can be null), or undefined if not present
  104814. */
  104815. getExternalData<T>(key: string): Nullable<T>;
  104816. /**
  104817. * Get an externaly attached data from its key, create it using a factory if it's not already present
  104818. * @param key the unique key that identifies the data
  104819. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  104820. * @return the associated data, can be null if the factory returned null.
  104821. */
  104822. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  104823. /**
  104824. * Remove an externaly attached data from the Engine instance
  104825. * @param key the unique key that identifies the data
  104826. * @return true if the data was successfully removed, false if it doesn't exist
  104827. */
  104828. removeExternalData(key: string): boolean;
  104829. private _evaluateSubMesh;
  104830. /**
  104831. * Clear the processed materials smart array preventing retention point in material dispose.
  104832. */
  104833. freeProcessedMaterials(): void;
  104834. private _preventFreeActiveMeshesAndRenderingGroups;
  104835. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  104836. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  104837. * when disposing several meshes in a row or a hierarchy of meshes.
  104838. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  104839. */
  104840. blockfreeActiveMeshesAndRenderingGroups: boolean;
  104841. /**
  104842. * Clear the active meshes smart array preventing retention point in mesh dispose.
  104843. */
  104844. freeActiveMeshes(): void;
  104845. /**
  104846. * Clear the info related to rendering groups preventing retention points during dispose.
  104847. */
  104848. freeRenderingGroups(): void;
  104849. /** @hidden */
  104850. _isInIntermediateRendering(): boolean;
  104851. /**
  104852. * Lambda returning the list of potentially active meshes.
  104853. */
  104854. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  104855. /**
  104856. * Lambda returning the list of potentially active sub meshes.
  104857. */
  104858. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  104859. /**
  104860. * Lambda returning the list of potentially intersecting sub meshes.
  104861. */
  104862. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  104863. /**
  104864. * Lambda returning the list of potentially colliding sub meshes.
  104865. */
  104866. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  104867. private _activeMeshesFrozen;
  104868. private _skipEvaluateActiveMeshesCompletely;
  104869. /**
  104870. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  104871. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  104872. * @returns the current scene
  104873. */
  104874. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  104875. /**
  104876. * Use this function to restart evaluating active meshes on every frame
  104877. * @returns the current scene
  104878. */
  104879. unfreezeActiveMeshes(): Scene;
  104880. private _evaluateActiveMeshes;
  104881. private _activeMesh;
  104882. /**
  104883. * Update the transform matrix to update from the current active camera
  104884. * @param force defines a boolean used to force the update even if cache is up to date
  104885. */
  104886. updateTransformMatrix(force?: boolean): void;
  104887. private _bindFrameBuffer;
  104888. /** @hidden */
  104889. _allowPostProcessClearColor: boolean;
  104890. /** @hidden */
  104891. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  104892. private _processSubCameras;
  104893. private _checkIntersections;
  104894. /** @hidden */
  104895. _advancePhysicsEngineStep(step: number): void;
  104896. /**
  104897. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  104898. */
  104899. getDeterministicFrameTime: () => number;
  104900. /** @hidden */
  104901. _animate(): void;
  104902. /** Execute all animations (for a frame) */
  104903. animate(): void;
  104904. /**
  104905. * Render the scene
  104906. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  104907. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  104908. */
  104909. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  104910. /**
  104911. * Freeze all materials
  104912. * A frozen material will not be updatable but should be faster to render
  104913. */
  104914. freezeMaterials(): void;
  104915. /**
  104916. * Unfreeze all materials
  104917. * A frozen material will not be updatable but should be faster to render
  104918. */
  104919. unfreezeMaterials(): void;
  104920. /**
  104921. * Releases all held ressources
  104922. */
  104923. dispose(): void;
  104924. /**
  104925. * Gets if the scene is already disposed
  104926. */
  104927. readonly isDisposed: boolean;
  104928. /**
  104929. * Call this function to reduce memory footprint of the scene.
  104930. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  104931. */
  104932. clearCachedVertexData(): void;
  104933. /**
  104934. * This function will remove the local cached buffer data from texture.
  104935. * It will save memory but will prevent the texture from being rebuilt
  104936. */
  104937. cleanCachedTextureBuffer(): void;
  104938. /**
  104939. * Get the world extend vectors with an optional filter
  104940. *
  104941. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  104942. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  104943. */
  104944. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  104945. min: Vector3;
  104946. max: Vector3;
  104947. };
  104948. /**
  104949. * Creates a ray that can be used to pick in the scene
  104950. * @param x defines the x coordinate of the origin (on-screen)
  104951. * @param y defines the y coordinate of the origin (on-screen)
  104952. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  104953. * @param camera defines the camera to use for the picking
  104954. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  104955. * @returns a Ray
  104956. */
  104957. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  104958. /**
  104959. * Creates a ray that can be used to pick in the scene
  104960. * @param x defines the x coordinate of the origin (on-screen)
  104961. * @param y defines the y coordinate of the origin (on-screen)
  104962. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  104963. * @param result defines the ray where to store the picking ray
  104964. * @param camera defines the camera to use for the picking
  104965. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  104966. * @returns the current scene
  104967. */
  104968. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  104969. /**
  104970. * Creates a ray that can be used to pick in the scene
  104971. * @param x defines the x coordinate of the origin (on-screen)
  104972. * @param y defines the y coordinate of the origin (on-screen)
  104973. * @param camera defines the camera to use for the picking
  104974. * @returns a Ray
  104975. */
  104976. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  104977. /**
  104978. * Creates a ray that can be used to pick in the scene
  104979. * @param x defines the x coordinate of the origin (on-screen)
  104980. * @param y defines the y coordinate of the origin (on-screen)
  104981. * @param result defines the ray where to store the picking ray
  104982. * @param camera defines the camera to use for the picking
  104983. * @returns the current scene
  104984. */
  104985. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  104986. /** Launch a ray to try to pick a mesh in the scene
  104987. * @param x position on screen
  104988. * @param y position on screen
  104989. * @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
  104990. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  104991. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  104992. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104993. * @returns a PickingInfo
  104994. */
  104995. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  104996. /** Use the given ray to pick a mesh in the scene
  104997. * @param ray The ray to use to pick meshes
  104998. * @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
  104999. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  105000. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105001. * @returns a PickingInfo
  105002. */
  105003. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105004. /**
  105005. * Launch a ray to try to pick a mesh in the scene
  105006. * @param x X position on screen
  105007. * @param y Y position on screen
  105008. * @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
  105009. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105010. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105011. * @returns an array of PickingInfo
  105012. */
  105013. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105014. /**
  105015. * Launch a ray to try to pick a mesh in the scene
  105016. * @param ray Ray to use
  105017. * @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
  105018. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105019. * @returns an array of PickingInfo
  105020. */
  105021. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105022. /**
  105023. * Force the value of meshUnderPointer
  105024. * @param mesh defines the mesh to use
  105025. */
  105026. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105027. /**
  105028. * Gets the mesh under the pointer
  105029. * @returns a Mesh or null if no mesh is under the pointer
  105030. */
  105031. getPointerOverMesh(): Nullable<AbstractMesh>;
  105032. /** @hidden */
  105033. _rebuildGeometries(): void;
  105034. /** @hidden */
  105035. _rebuildTextures(): void;
  105036. private _getByTags;
  105037. /**
  105038. * Get a list of meshes by tags
  105039. * @param tagsQuery defines the tags query to use
  105040. * @param forEach defines a predicate used to filter results
  105041. * @returns an array of Mesh
  105042. */
  105043. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  105044. /**
  105045. * Get a list of cameras by tags
  105046. * @param tagsQuery defines the tags query to use
  105047. * @param forEach defines a predicate used to filter results
  105048. * @returns an array of Camera
  105049. */
  105050. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  105051. /**
  105052. * Get a list of lights by tags
  105053. * @param tagsQuery defines the tags query to use
  105054. * @param forEach defines a predicate used to filter results
  105055. * @returns an array of Light
  105056. */
  105057. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  105058. /**
  105059. * Get a list of materials by tags
  105060. * @param tagsQuery defines the tags query to use
  105061. * @param forEach defines a predicate used to filter results
  105062. * @returns an array of Material
  105063. */
  105064. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  105065. /**
  105066. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  105067. * This allowed control for front to back rendering or reversly depending of the special needs.
  105068. *
  105069. * @param renderingGroupId The rendering group id corresponding to its index
  105070. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  105071. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  105072. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105073. */
  105074. 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;
  105075. /**
  105076. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105077. *
  105078. * @param renderingGroupId The rendering group id corresponding to its index
  105079. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105080. * @param depth Automatically clears depth between groups if true and autoClear is true.
  105081. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  105082. */
  105083. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  105084. /**
  105085. * Gets the current auto clear configuration for one rendering group of the rendering
  105086. * manager.
  105087. * @param index the rendering group index to get the information for
  105088. * @returns The auto clear setup for the requested rendering group
  105089. */
  105090. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  105091. private _blockMaterialDirtyMechanism;
  105092. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  105093. blockMaterialDirtyMechanism: boolean;
  105094. /**
  105095. * Will flag all materials as dirty to trigger new shader compilation
  105096. * @param flag defines the flag used to specify which material part must be marked as dirty
  105097. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  105098. */
  105099. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105100. /** @hidden */
  105101. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  105102. /** @hidden */
  105103. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105104. /** @hidden */
  105105. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  105106. /** @hidden */
  105107. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  105108. /** @hidden */
  105109. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105110. /** @hidden */
  105111. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105112. }
  105113. }
  105114. declare module BABYLON {
  105115. /**
  105116. * Set of assets to keep when moving a scene into an asset container.
  105117. */
  105118. export class KeepAssets extends AbstractScene {
  105119. }
  105120. /**
  105121. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  105122. */
  105123. export class InstantiatedEntries {
  105124. /**
  105125. * List of new root nodes (eg. nodes with no parent)
  105126. */
  105127. rootNodes: TransformNode[];
  105128. /**
  105129. * List of new skeletons
  105130. */
  105131. skeletons: Skeleton[];
  105132. /**
  105133. * List of new animation groups
  105134. */
  105135. animationGroups: AnimationGroup[];
  105136. }
  105137. /**
  105138. * Container with a set of assets that can be added or removed from a scene.
  105139. */
  105140. export class AssetContainer extends AbstractScene {
  105141. /**
  105142. * The scene the AssetContainer belongs to.
  105143. */
  105144. scene: Scene;
  105145. /**
  105146. * Instantiates an AssetContainer.
  105147. * @param scene The scene the AssetContainer belongs to.
  105148. */
  105149. constructor(scene: Scene);
  105150. /**
  105151. * Instantiate or clone all meshes and add the new ones to the scene.
  105152. * Skeletons and animation groups will all be cloned
  105153. * @param nameFunction defines an optional function used to get new names for clones
  105154. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  105155. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  105156. */
  105157. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  105158. /**
  105159. * Adds all the assets from the container to the scene.
  105160. */
  105161. addAllToScene(): void;
  105162. /**
  105163. * Removes all the assets in the container from the scene
  105164. */
  105165. removeAllFromScene(): void;
  105166. /**
  105167. * Disposes all the assets in the container
  105168. */
  105169. dispose(): void;
  105170. private _moveAssets;
  105171. /**
  105172. * Removes all the assets contained in the scene and adds them to the container.
  105173. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  105174. */
  105175. moveAllFromScene(keepAssets?: KeepAssets): void;
  105176. /**
  105177. * 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.
  105178. * @returns the root mesh
  105179. */
  105180. createRootMesh(): Mesh;
  105181. }
  105182. }
  105183. declare module BABYLON {
  105184. /**
  105185. * Defines how the parser contract is defined.
  105186. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  105187. */
  105188. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  105189. /**
  105190. * Defines how the individual parser contract is defined.
  105191. * These parser can parse an individual asset
  105192. */
  105193. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  105194. /**
  105195. * Base class of the scene acting as a container for the different elements composing a scene.
  105196. * This class is dynamically extended by the different components of the scene increasing
  105197. * flexibility and reducing coupling
  105198. */
  105199. export abstract class AbstractScene {
  105200. /**
  105201. * Stores the list of available parsers in the application.
  105202. */
  105203. private static _BabylonFileParsers;
  105204. /**
  105205. * Stores the list of available individual parsers in the application.
  105206. */
  105207. private static _IndividualBabylonFileParsers;
  105208. /**
  105209. * Adds a parser in the list of available ones
  105210. * @param name Defines the name of the parser
  105211. * @param parser Defines the parser to add
  105212. */
  105213. static AddParser(name: string, parser: BabylonFileParser): void;
  105214. /**
  105215. * Gets a general parser from the list of avaialble ones
  105216. * @param name Defines the name of the parser
  105217. * @returns the requested parser or null
  105218. */
  105219. static GetParser(name: string): Nullable<BabylonFileParser>;
  105220. /**
  105221. * Adds n individual parser in the list of available ones
  105222. * @param name Defines the name of the parser
  105223. * @param parser Defines the parser to add
  105224. */
  105225. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  105226. /**
  105227. * Gets an individual parser from the list of avaialble ones
  105228. * @param name Defines the name of the parser
  105229. * @returns the requested parser or null
  105230. */
  105231. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  105232. /**
  105233. * Parser json data and populate both a scene and its associated container object
  105234. * @param jsonData Defines the data to parse
  105235. * @param scene Defines the scene to parse the data for
  105236. * @param container Defines the container attached to the parsing sequence
  105237. * @param rootUrl Defines the root url of the data
  105238. */
  105239. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  105240. /**
  105241. * Gets the list of root nodes (ie. nodes with no parent)
  105242. */
  105243. rootNodes: Node[];
  105244. /** All of the cameras added to this scene
  105245. * @see http://doc.babylonjs.com/babylon101/cameras
  105246. */
  105247. cameras: Camera[];
  105248. /**
  105249. * All of the lights added to this scene
  105250. * @see http://doc.babylonjs.com/babylon101/lights
  105251. */
  105252. lights: Light[];
  105253. /**
  105254. * All of the (abstract) meshes added to this scene
  105255. */
  105256. meshes: AbstractMesh[];
  105257. /**
  105258. * The list of skeletons added to the scene
  105259. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  105260. */
  105261. skeletons: Skeleton[];
  105262. /**
  105263. * All of the particle systems added to this scene
  105264. * @see http://doc.babylonjs.com/babylon101/particles
  105265. */
  105266. particleSystems: IParticleSystem[];
  105267. /**
  105268. * Gets a list of Animations associated with the scene
  105269. */
  105270. animations: Animation[];
  105271. /**
  105272. * All of the animation groups added to this scene
  105273. * @see http://doc.babylonjs.com/how_to/group
  105274. */
  105275. animationGroups: AnimationGroup[];
  105276. /**
  105277. * All of the multi-materials added to this scene
  105278. * @see http://doc.babylonjs.com/how_to/multi_materials
  105279. */
  105280. multiMaterials: MultiMaterial[];
  105281. /**
  105282. * All of the materials added to this scene
  105283. * In the context of a Scene, it is not supposed to be modified manually.
  105284. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  105285. * Note also that the order of the Material within the array is not significant and might change.
  105286. * @see http://doc.babylonjs.com/babylon101/materials
  105287. */
  105288. materials: Material[];
  105289. /**
  105290. * The list of morph target managers added to the scene
  105291. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  105292. */
  105293. morphTargetManagers: MorphTargetManager[];
  105294. /**
  105295. * The list of geometries used in the scene.
  105296. */
  105297. geometries: Geometry[];
  105298. /**
  105299. * All of the tranform nodes added to this scene
  105300. * In the context of a Scene, it is not supposed to be modified manually.
  105301. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  105302. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  105303. * @see http://doc.babylonjs.com/how_to/transformnode
  105304. */
  105305. transformNodes: TransformNode[];
  105306. /**
  105307. * ActionManagers available on the scene.
  105308. */
  105309. actionManagers: AbstractActionManager[];
  105310. /**
  105311. * Textures to keep.
  105312. */
  105313. textures: BaseTexture[];
  105314. /**
  105315. * Environment texture for the scene
  105316. */
  105317. environmentTexture: Nullable<BaseTexture>;
  105318. }
  105319. }
  105320. declare module BABYLON {
  105321. /**
  105322. * Interface used to define options for Sound class
  105323. */
  105324. export interface ISoundOptions {
  105325. /**
  105326. * Does the sound autoplay once loaded.
  105327. */
  105328. autoplay?: boolean;
  105329. /**
  105330. * Does the sound loop after it finishes playing once.
  105331. */
  105332. loop?: boolean;
  105333. /**
  105334. * Sound's volume
  105335. */
  105336. volume?: number;
  105337. /**
  105338. * Is it a spatial sound?
  105339. */
  105340. spatialSound?: boolean;
  105341. /**
  105342. * Maximum distance to hear that sound
  105343. */
  105344. maxDistance?: number;
  105345. /**
  105346. * Uses user defined attenuation function
  105347. */
  105348. useCustomAttenuation?: boolean;
  105349. /**
  105350. * Define the roll off factor of spatial sounds.
  105351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105352. */
  105353. rolloffFactor?: number;
  105354. /**
  105355. * Define the reference distance the sound should be heard perfectly.
  105356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105357. */
  105358. refDistance?: number;
  105359. /**
  105360. * Define the distance attenuation model the sound will follow.
  105361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105362. */
  105363. distanceModel?: string;
  105364. /**
  105365. * Defines the playback speed (1 by default)
  105366. */
  105367. playbackRate?: number;
  105368. /**
  105369. * Defines if the sound is from a streaming source
  105370. */
  105371. streaming?: boolean;
  105372. /**
  105373. * Defines an optional length (in seconds) inside the sound file
  105374. */
  105375. length?: number;
  105376. /**
  105377. * Defines an optional offset (in seconds) inside the sound file
  105378. */
  105379. offset?: number;
  105380. /**
  105381. * If true, URLs will not be required to state the audio file codec to use.
  105382. */
  105383. skipCodecCheck?: boolean;
  105384. }
  105385. /**
  105386. * Defines a sound that can be played in the application.
  105387. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  105388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105389. */
  105390. export class Sound {
  105391. /**
  105392. * The name of the sound in the scene.
  105393. */
  105394. name: string;
  105395. /**
  105396. * Does the sound autoplay once loaded.
  105397. */
  105398. autoplay: boolean;
  105399. /**
  105400. * Does the sound loop after it finishes playing once.
  105401. */
  105402. loop: boolean;
  105403. /**
  105404. * Does the sound use a custom attenuation curve to simulate the falloff
  105405. * happening when the source gets further away from the camera.
  105406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105407. */
  105408. useCustomAttenuation: boolean;
  105409. /**
  105410. * The sound track id this sound belongs to.
  105411. */
  105412. soundTrackId: number;
  105413. /**
  105414. * Is this sound currently played.
  105415. */
  105416. isPlaying: boolean;
  105417. /**
  105418. * Is this sound currently paused.
  105419. */
  105420. isPaused: boolean;
  105421. /**
  105422. * Does this sound enables spatial sound.
  105423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105424. */
  105425. spatialSound: boolean;
  105426. /**
  105427. * Define the reference distance the sound should be heard perfectly.
  105428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105429. */
  105430. refDistance: number;
  105431. /**
  105432. * Define the roll off factor of spatial sounds.
  105433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105434. */
  105435. rolloffFactor: number;
  105436. /**
  105437. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  105438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105439. */
  105440. maxDistance: number;
  105441. /**
  105442. * Define the distance attenuation model the sound will follow.
  105443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105444. */
  105445. distanceModel: string;
  105446. /**
  105447. * @hidden
  105448. * Back Compat
  105449. **/
  105450. onended: () => any;
  105451. /**
  105452. * Observable event when the current playing sound finishes.
  105453. */
  105454. onEndedObservable: Observable<Sound>;
  105455. private _panningModel;
  105456. private _playbackRate;
  105457. private _streaming;
  105458. private _startTime;
  105459. private _startOffset;
  105460. private _position;
  105461. /** @hidden */
  105462. _positionInEmitterSpace: boolean;
  105463. private _localDirection;
  105464. private _volume;
  105465. private _isReadyToPlay;
  105466. private _isDirectional;
  105467. private _readyToPlayCallback;
  105468. private _audioBuffer;
  105469. private _soundSource;
  105470. private _streamingSource;
  105471. private _soundPanner;
  105472. private _soundGain;
  105473. private _inputAudioNode;
  105474. private _outputAudioNode;
  105475. private _coneInnerAngle;
  105476. private _coneOuterAngle;
  105477. private _coneOuterGain;
  105478. private _scene;
  105479. private _connectedTransformNode;
  105480. private _customAttenuationFunction;
  105481. private _registerFunc;
  105482. private _isOutputConnected;
  105483. private _htmlAudioElement;
  105484. private _urlType;
  105485. private _length?;
  105486. private _offset?;
  105487. /** @hidden */
  105488. static _SceneComponentInitialization: (scene: Scene) => void;
  105489. /**
  105490. * Create a sound and attach it to a scene
  105491. * @param name Name of your sound
  105492. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  105493. * @param scene defines the scene the sound belongs to
  105494. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  105495. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  105496. */
  105497. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  105498. /**
  105499. * Release the sound and its associated resources
  105500. */
  105501. dispose(): void;
  105502. /**
  105503. * Gets if the sounds is ready to be played or not.
  105504. * @returns true if ready, otherwise false
  105505. */
  105506. isReady(): boolean;
  105507. private _soundLoaded;
  105508. /**
  105509. * Sets the data of the sound from an audiobuffer
  105510. * @param audioBuffer The audioBuffer containing the data
  105511. */
  105512. setAudioBuffer(audioBuffer: AudioBuffer): void;
  105513. /**
  105514. * Updates the current sounds options such as maxdistance, loop...
  105515. * @param options A JSON object containing values named as the object properties
  105516. */
  105517. updateOptions(options: ISoundOptions): void;
  105518. private _createSpatialParameters;
  105519. private _updateSpatialParameters;
  105520. /**
  105521. * Switch the panning model to HRTF:
  105522. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105524. */
  105525. switchPanningModelToHRTF(): void;
  105526. /**
  105527. * Switch the panning model to Equal Power:
  105528. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105530. */
  105531. switchPanningModelToEqualPower(): void;
  105532. private _switchPanningModel;
  105533. /**
  105534. * Connect this sound to a sound track audio node like gain...
  105535. * @param soundTrackAudioNode the sound track audio node to connect to
  105536. */
  105537. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  105538. /**
  105539. * Transform this sound into a directional source
  105540. * @param coneInnerAngle Size of the inner cone in degree
  105541. * @param coneOuterAngle Size of the outer cone in degree
  105542. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  105543. */
  105544. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  105545. /**
  105546. * Gets or sets the inner angle for the directional cone.
  105547. */
  105548. /**
  105549. * Gets or sets the inner angle for the directional cone.
  105550. */
  105551. directionalConeInnerAngle: number;
  105552. /**
  105553. * Gets or sets the outer angle for the directional cone.
  105554. */
  105555. /**
  105556. * Gets or sets the outer angle for the directional cone.
  105557. */
  105558. directionalConeOuterAngle: number;
  105559. /**
  105560. * Sets the position of the emitter if spatial sound is enabled
  105561. * @param newPosition Defines the new posisiton
  105562. */
  105563. setPosition(newPosition: Vector3): void;
  105564. /**
  105565. * Sets the local direction of the emitter if spatial sound is enabled
  105566. * @param newLocalDirection Defines the new local direction
  105567. */
  105568. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  105569. private _updateDirection;
  105570. /** @hidden */
  105571. updateDistanceFromListener(): void;
  105572. /**
  105573. * Sets a new custom attenuation function for the sound.
  105574. * @param callback Defines the function used for the attenuation
  105575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105576. */
  105577. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  105578. /**
  105579. * Play the sound
  105580. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  105581. * @param offset (optional) Start the sound at a specific time in seconds
  105582. * @param length (optional) Sound duration (in seconds)
  105583. */
  105584. play(time?: number, offset?: number, length?: number): void;
  105585. private _onended;
  105586. /**
  105587. * Stop the sound
  105588. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  105589. */
  105590. stop(time?: number): void;
  105591. /**
  105592. * Put the sound in pause
  105593. */
  105594. pause(): void;
  105595. /**
  105596. * Sets a dedicated volume for this sounds
  105597. * @param newVolume Define the new volume of the sound
  105598. * @param time Define time for gradual change to new volume
  105599. */
  105600. setVolume(newVolume: number, time?: number): void;
  105601. /**
  105602. * Set the sound play back rate
  105603. * @param newPlaybackRate Define the playback rate the sound should be played at
  105604. */
  105605. setPlaybackRate(newPlaybackRate: number): void;
  105606. /**
  105607. * Gets the volume of the sound.
  105608. * @returns the volume of the sound
  105609. */
  105610. getVolume(): number;
  105611. /**
  105612. * Attach the sound to a dedicated mesh
  105613. * @param transformNode The transform node to connect the sound with
  105614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  105615. */
  105616. attachToMesh(transformNode: TransformNode): void;
  105617. /**
  105618. * Detach the sound from the previously attached mesh
  105619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  105620. */
  105621. detachFromMesh(): void;
  105622. private _onRegisterAfterWorldMatrixUpdate;
  105623. /**
  105624. * Clone the current sound in the scene.
  105625. * @returns the new sound clone
  105626. */
  105627. clone(): Nullable<Sound>;
  105628. /**
  105629. * Gets the current underlying audio buffer containing the data
  105630. * @returns the audio buffer
  105631. */
  105632. getAudioBuffer(): Nullable<AudioBuffer>;
  105633. /**
  105634. * Serializes the Sound in a JSON representation
  105635. * @returns the JSON representation of the sound
  105636. */
  105637. serialize(): any;
  105638. /**
  105639. * Parse a JSON representation of a sound to innstantiate in a given scene
  105640. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  105641. * @param scene Define the scene the new parsed sound should be created in
  105642. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  105643. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  105644. * @returns the newly parsed sound
  105645. */
  105646. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  105647. }
  105648. }
  105649. declare module BABYLON {
  105650. /**
  105651. * This defines an action helpful to play a defined sound on a triggered action.
  105652. */
  105653. export class PlaySoundAction extends Action {
  105654. private _sound;
  105655. /**
  105656. * Instantiate the action
  105657. * @param triggerOptions defines the trigger options
  105658. * @param sound defines the sound to play
  105659. * @param condition defines the trigger related conditions
  105660. */
  105661. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  105662. /** @hidden */
  105663. _prepare(): void;
  105664. /**
  105665. * Execute the action and play the sound.
  105666. */
  105667. execute(): void;
  105668. /**
  105669. * Serializes the actions and its related information.
  105670. * @param parent defines the object to serialize in
  105671. * @returns the serialized object
  105672. */
  105673. serialize(parent: any): any;
  105674. }
  105675. /**
  105676. * This defines an action helpful to stop a defined sound on a triggered action.
  105677. */
  105678. export class StopSoundAction extends Action {
  105679. private _sound;
  105680. /**
  105681. * Instantiate the action
  105682. * @param triggerOptions defines the trigger options
  105683. * @param sound defines the sound to stop
  105684. * @param condition defines the trigger related conditions
  105685. */
  105686. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  105687. /** @hidden */
  105688. _prepare(): void;
  105689. /**
  105690. * Execute the action and stop the sound.
  105691. */
  105692. execute(): void;
  105693. /**
  105694. * Serializes the actions and its related information.
  105695. * @param parent defines the object to serialize in
  105696. * @returns the serialized object
  105697. */
  105698. serialize(parent: any): any;
  105699. }
  105700. }
  105701. declare module BABYLON {
  105702. /**
  105703. * This defines an action responsible to change the value of a property
  105704. * by interpolating between its current value and the newly set one once triggered.
  105705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105706. */
  105707. export class InterpolateValueAction extends Action {
  105708. /**
  105709. * Defines the path of the property where the value should be interpolated
  105710. */
  105711. propertyPath: string;
  105712. /**
  105713. * Defines the target value at the end of the interpolation.
  105714. */
  105715. value: any;
  105716. /**
  105717. * Defines the time it will take for the property to interpolate to the value.
  105718. */
  105719. duration: number;
  105720. /**
  105721. * Defines if the other scene animations should be stopped when the action has been triggered
  105722. */
  105723. stopOtherAnimations?: boolean;
  105724. /**
  105725. * Defines a callback raised once the interpolation animation has been done.
  105726. */
  105727. onInterpolationDone?: () => void;
  105728. /**
  105729. * Observable triggered once the interpolation animation has been done.
  105730. */
  105731. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  105732. private _target;
  105733. private _effectiveTarget;
  105734. private _property;
  105735. /**
  105736. * Instantiate the action
  105737. * @param triggerOptions defines the trigger options
  105738. * @param target defines the object containing the value to interpolate
  105739. * @param propertyPath defines the path to the property in the target object
  105740. * @param value defines the target value at the end of the interpolation
  105741. * @param duration deines the time it will take for the property to interpolate to the value.
  105742. * @param condition defines the trigger related conditions
  105743. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  105744. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  105745. */
  105746. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  105747. /** @hidden */
  105748. _prepare(): void;
  105749. /**
  105750. * Execute the action starts the value interpolation.
  105751. */
  105752. execute(): void;
  105753. /**
  105754. * Serializes the actions and its related information.
  105755. * @param parent defines the object to serialize in
  105756. * @returns the serialized object
  105757. */
  105758. serialize(parent: any): any;
  105759. }
  105760. }
  105761. declare module BABYLON {
  105762. /**
  105763. * Options allowed during the creation of a sound track.
  105764. */
  105765. export interface ISoundTrackOptions {
  105766. /**
  105767. * The volume the sound track should take during creation
  105768. */
  105769. volume?: number;
  105770. /**
  105771. * Define if the sound track is the main sound track of the scene
  105772. */
  105773. mainTrack?: boolean;
  105774. }
  105775. /**
  105776. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  105777. * It will be also used in a future release to apply effects on a specific track.
  105778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  105779. */
  105780. export class SoundTrack {
  105781. /**
  105782. * The unique identifier of the sound track in the scene.
  105783. */
  105784. id: number;
  105785. /**
  105786. * The list of sounds included in the sound track.
  105787. */
  105788. soundCollection: Array<Sound>;
  105789. private _outputAudioNode;
  105790. private _scene;
  105791. private _connectedAnalyser;
  105792. private _options;
  105793. private _isInitialized;
  105794. /**
  105795. * Creates a new sound track.
  105796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  105797. * @param scene Define the scene the sound track belongs to
  105798. * @param options
  105799. */
  105800. constructor(scene: Scene, options?: ISoundTrackOptions);
  105801. private _initializeSoundTrackAudioGraph;
  105802. /**
  105803. * Release the sound track and its associated resources
  105804. */
  105805. dispose(): void;
  105806. /**
  105807. * Adds a sound to this sound track
  105808. * @param sound define the cound to add
  105809. * @ignoreNaming
  105810. */
  105811. AddSound(sound: Sound): void;
  105812. /**
  105813. * Removes a sound to this sound track
  105814. * @param sound define the cound to remove
  105815. * @ignoreNaming
  105816. */
  105817. RemoveSound(sound: Sound): void;
  105818. /**
  105819. * Set a global volume for the full sound track.
  105820. * @param newVolume Define the new volume of the sound track
  105821. */
  105822. setVolume(newVolume: number): void;
  105823. /**
  105824. * Switch the panning model to HRTF:
  105825. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105827. */
  105828. switchPanningModelToHRTF(): void;
  105829. /**
  105830. * Switch the panning model to Equal Power:
  105831. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105833. */
  105834. switchPanningModelToEqualPower(): void;
  105835. /**
  105836. * Connect the sound track to an audio analyser allowing some amazing
  105837. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105839. * @param analyser The analyser to connect to the engine
  105840. */
  105841. connectToAnalyser(analyser: Analyser): void;
  105842. }
  105843. }
  105844. declare module BABYLON {
  105845. interface AbstractScene {
  105846. /**
  105847. * The list of sounds used in the scene.
  105848. */
  105849. sounds: Nullable<Array<Sound>>;
  105850. }
  105851. interface Scene {
  105852. /**
  105853. * @hidden
  105854. * Backing field
  105855. */
  105856. _mainSoundTrack: SoundTrack;
  105857. /**
  105858. * The main sound track played by the scene.
  105859. * It cotains your primary collection of sounds.
  105860. */
  105861. mainSoundTrack: SoundTrack;
  105862. /**
  105863. * The list of sound tracks added to the scene
  105864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105865. */
  105866. soundTracks: Nullable<Array<SoundTrack>>;
  105867. /**
  105868. * Gets a sound using a given name
  105869. * @param name defines the name to search for
  105870. * @return the found sound or null if not found at all.
  105871. */
  105872. getSoundByName(name: string): Nullable<Sound>;
  105873. /**
  105874. * Gets or sets if audio support is enabled
  105875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105876. */
  105877. audioEnabled: boolean;
  105878. /**
  105879. * Gets or sets if audio will be output to headphones
  105880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105881. */
  105882. headphone: boolean;
  105883. /**
  105884. * Gets or sets custom audio listener position provider
  105885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105886. */
  105887. audioListenerPositionProvider: Nullable<() => Vector3>;
  105888. /**
  105889. * Gets or sets a refresh rate when using 3D audio positioning
  105890. */
  105891. audioPositioningRefreshRate: number;
  105892. }
  105893. /**
  105894. * Defines the sound scene component responsible to manage any sounds
  105895. * in a given scene.
  105896. */
  105897. export class AudioSceneComponent implements ISceneSerializableComponent {
  105898. /**
  105899. * The component name helpfull to identify the component in the list of scene components.
  105900. */
  105901. readonly name: string;
  105902. /**
  105903. * The scene the component belongs to.
  105904. */
  105905. scene: Scene;
  105906. private _audioEnabled;
  105907. /**
  105908. * Gets whether audio is enabled or not.
  105909. * Please use related enable/disable method to switch state.
  105910. */
  105911. readonly audioEnabled: boolean;
  105912. private _headphone;
  105913. /**
  105914. * Gets whether audio is outputing to headphone or not.
  105915. * Please use the according Switch methods to change output.
  105916. */
  105917. readonly headphone: boolean;
  105918. /**
  105919. * Gets or sets a refresh rate when using 3D audio positioning
  105920. */
  105921. audioPositioningRefreshRate: number;
  105922. private _audioListenerPositionProvider;
  105923. /**
  105924. * Gets the current audio listener position provider
  105925. */
  105926. /**
  105927. * Sets a custom listener position for all sounds in the scene
  105928. * By default, this is the position of the first active camera
  105929. */
  105930. audioListenerPositionProvider: Nullable<() => Vector3>;
  105931. /**
  105932. * Creates a new instance of the component for the given scene
  105933. * @param scene Defines the scene to register the component in
  105934. */
  105935. constructor(scene: Scene);
  105936. /**
  105937. * Registers the component in a given scene
  105938. */
  105939. register(): void;
  105940. /**
  105941. * Rebuilds the elements related to this component in case of
  105942. * context lost for instance.
  105943. */
  105944. rebuild(): void;
  105945. /**
  105946. * Serializes the component data to the specified json object
  105947. * @param serializationObject The object to serialize to
  105948. */
  105949. serialize(serializationObject: any): void;
  105950. /**
  105951. * Adds all the elements from the container to the scene
  105952. * @param container the container holding the elements
  105953. */
  105954. addFromContainer(container: AbstractScene): void;
  105955. /**
  105956. * Removes all the elements in the container from the scene
  105957. * @param container contains the elements to remove
  105958. * @param dispose if the removed element should be disposed (default: false)
  105959. */
  105960. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  105961. /**
  105962. * Disposes the component and the associated ressources.
  105963. */
  105964. dispose(): void;
  105965. /**
  105966. * Disables audio in the associated scene.
  105967. */
  105968. disableAudio(): void;
  105969. /**
  105970. * Enables audio in the associated scene.
  105971. */
  105972. enableAudio(): void;
  105973. /**
  105974. * Switch audio to headphone output.
  105975. */
  105976. switchAudioModeForHeadphones(): void;
  105977. /**
  105978. * Switch audio to normal speakers.
  105979. */
  105980. switchAudioModeForNormalSpeakers(): void;
  105981. private _cachedCameraDirection;
  105982. private _cachedCameraPosition;
  105983. private _lastCheck;
  105984. private _afterRender;
  105985. }
  105986. }
  105987. declare module BABYLON {
  105988. /**
  105989. * Wraps one or more Sound objects and selects one with random weight for playback.
  105990. */
  105991. export class WeightedSound {
  105992. /** When true a Sound will be selected and played when the current playing Sound completes. */
  105993. loop: boolean;
  105994. private _coneInnerAngle;
  105995. private _coneOuterAngle;
  105996. private _volume;
  105997. /** A Sound is currently playing. */
  105998. isPlaying: boolean;
  105999. /** A Sound is currently paused. */
  106000. isPaused: boolean;
  106001. private _sounds;
  106002. private _weights;
  106003. private _currentIndex?;
  106004. /**
  106005. * Creates a new WeightedSound from the list of sounds given.
  106006. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  106007. * @param sounds Array of Sounds that will be selected from.
  106008. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  106009. */
  106010. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  106011. /**
  106012. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  106013. */
  106014. /**
  106015. * The size of cone in degress for a directional sound in which there will be no attenuation.
  106016. */
  106017. directionalConeInnerAngle: number;
  106018. /**
  106019. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106020. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106021. */
  106022. /**
  106023. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106024. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106025. */
  106026. directionalConeOuterAngle: number;
  106027. /**
  106028. * Playback volume.
  106029. */
  106030. /**
  106031. * Playback volume.
  106032. */
  106033. volume: number;
  106034. private _onended;
  106035. /**
  106036. * Suspend playback
  106037. */
  106038. pause(): void;
  106039. /**
  106040. * Stop playback
  106041. */
  106042. stop(): void;
  106043. /**
  106044. * Start playback.
  106045. * @param startOffset Position the clip head at a specific time in seconds.
  106046. */
  106047. play(startOffset?: number): void;
  106048. }
  106049. }
  106050. declare module BABYLON {
  106051. /**
  106052. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  106053. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106054. */
  106055. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  106056. /**
  106057. * Gets the name of the behavior.
  106058. */
  106059. readonly name: string;
  106060. /**
  106061. * The easing function used by animations
  106062. */
  106063. static EasingFunction: BackEase;
  106064. /**
  106065. * The easing mode used by animations
  106066. */
  106067. static EasingMode: number;
  106068. /**
  106069. * The duration of the animation, in milliseconds
  106070. */
  106071. transitionDuration: number;
  106072. /**
  106073. * Length of the distance animated by the transition when lower radius is reached
  106074. */
  106075. lowerRadiusTransitionRange: number;
  106076. /**
  106077. * Length of the distance animated by the transition when upper radius is reached
  106078. */
  106079. upperRadiusTransitionRange: number;
  106080. private _autoTransitionRange;
  106081. /**
  106082. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106083. */
  106084. /**
  106085. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106086. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  106087. */
  106088. autoTransitionRange: boolean;
  106089. private _attachedCamera;
  106090. private _onAfterCheckInputsObserver;
  106091. private _onMeshTargetChangedObserver;
  106092. /**
  106093. * Initializes the behavior.
  106094. */
  106095. init(): void;
  106096. /**
  106097. * Attaches the behavior to its arc rotate camera.
  106098. * @param camera Defines the camera to attach the behavior to
  106099. */
  106100. attach(camera: ArcRotateCamera): void;
  106101. /**
  106102. * Detaches the behavior from its current arc rotate camera.
  106103. */
  106104. detach(): void;
  106105. private _radiusIsAnimating;
  106106. private _radiusBounceTransition;
  106107. private _animatables;
  106108. private _cachedWheelPrecision;
  106109. /**
  106110. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  106111. * @param radiusLimit The limit to check against.
  106112. * @return Bool to indicate if at limit.
  106113. */
  106114. private _isRadiusAtLimit;
  106115. /**
  106116. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  106117. * @param radiusDelta The delta by which to animate to. Can be negative.
  106118. */
  106119. private _applyBoundRadiusAnimation;
  106120. /**
  106121. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  106122. */
  106123. protected _clearAnimationLocks(): void;
  106124. /**
  106125. * Stops and removes all animations that have been applied to the camera
  106126. */
  106127. stopAllAnimations(): void;
  106128. }
  106129. }
  106130. declare module BABYLON {
  106131. /**
  106132. * 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.
  106133. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106134. */
  106135. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  106136. /**
  106137. * Gets the name of the behavior.
  106138. */
  106139. readonly name: string;
  106140. private _mode;
  106141. private _radiusScale;
  106142. private _positionScale;
  106143. private _defaultElevation;
  106144. private _elevationReturnTime;
  106145. private _elevationReturnWaitTime;
  106146. private _zoomStopsAnimation;
  106147. private _framingTime;
  106148. /**
  106149. * The easing function used by animations
  106150. */
  106151. static EasingFunction: ExponentialEase;
  106152. /**
  106153. * The easing mode used by animations
  106154. */
  106155. static EasingMode: number;
  106156. /**
  106157. * Sets the current mode used by the behavior
  106158. */
  106159. /**
  106160. * Gets current mode used by the behavior.
  106161. */
  106162. mode: number;
  106163. /**
  106164. * Sets the scale applied to the radius (1 by default)
  106165. */
  106166. /**
  106167. * Gets the scale applied to the radius
  106168. */
  106169. radiusScale: number;
  106170. /**
  106171. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106172. */
  106173. /**
  106174. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106175. */
  106176. positionScale: number;
  106177. /**
  106178. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106179. * behaviour is triggered, in radians.
  106180. */
  106181. /**
  106182. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106183. * behaviour is triggered, in radians.
  106184. */
  106185. defaultElevation: number;
  106186. /**
  106187. * Sets the time (in milliseconds) taken to return to the default beta position.
  106188. * Negative value indicates camera should not return to default.
  106189. */
  106190. /**
  106191. * Gets the time (in milliseconds) taken to return to the default beta position.
  106192. * Negative value indicates camera should not return to default.
  106193. */
  106194. elevationReturnTime: number;
  106195. /**
  106196. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106197. */
  106198. /**
  106199. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106200. */
  106201. elevationReturnWaitTime: number;
  106202. /**
  106203. * Sets the flag that indicates if user zooming should stop animation.
  106204. */
  106205. /**
  106206. * Gets the flag that indicates if user zooming should stop animation.
  106207. */
  106208. zoomStopsAnimation: boolean;
  106209. /**
  106210. * Sets the transition time when framing the mesh, in milliseconds
  106211. */
  106212. /**
  106213. * Gets the transition time when framing the mesh, in milliseconds
  106214. */
  106215. framingTime: number;
  106216. /**
  106217. * Define if the behavior should automatically change the configured
  106218. * camera limits and sensibilities.
  106219. */
  106220. autoCorrectCameraLimitsAndSensibility: boolean;
  106221. private _onPrePointerObservableObserver;
  106222. private _onAfterCheckInputsObserver;
  106223. private _onMeshTargetChangedObserver;
  106224. private _attachedCamera;
  106225. private _isPointerDown;
  106226. private _lastInteractionTime;
  106227. /**
  106228. * Initializes the behavior.
  106229. */
  106230. init(): void;
  106231. /**
  106232. * Attaches the behavior to its arc rotate camera.
  106233. * @param camera Defines the camera to attach the behavior to
  106234. */
  106235. attach(camera: ArcRotateCamera): void;
  106236. /**
  106237. * Detaches the behavior from its current arc rotate camera.
  106238. */
  106239. detach(): void;
  106240. private _animatables;
  106241. private _betaIsAnimating;
  106242. private _betaTransition;
  106243. private _radiusTransition;
  106244. private _vectorTransition;
  106245. /**
  106246. * Targets the given mesh and updates zoom level accordingly.
  106247. * @param mesh The mesh to target.
  106248. * @param radius Optional. If a cached radius position already exists, overrides default.
  106249. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106250. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106251. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106252. */
  106253. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106254. /**
  106255. * Targets the given mesh with its children and updates zoom level accordingly.
  106256. * @param mesh The mesh to target.
  106257. * @param radius Optional. If a cached radius position already exists, overrides default.
  106258. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106259. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106260. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106261. */
  106262. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106263. /**
  106264. * Targets the given meshes with their children and updates zoom level accordingly.
  106265. * @param meshes The mesh to target.
  106266. * @param radius Optional. If a cached radius position already exists, overrides default.
  106267. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106268. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106269. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106270. */
  106271. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106272. /**
  106273. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  106274. * @param minimumWorld Determines the smaller position of the bounding box extend
  106275. * @param maximumWorld Determines the bigger position of the bounding box extend
  106276. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106277. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106278. */
  106279. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106280. /**
  106281. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  106282. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  106283. * frustum width.
  106284. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  106285. * to fully enclose the mesh in the viewing frustum.
  106286. */
  106287. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  106288. /**
  106289. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  106290. * is automatically returned to its default position (expected to be above ground plane).
  106291. */
  106292. private _maintainCameraAboveGround;
  106293. /**
  106294. * Returns the frustum slope based on the canvas ratio and camera FOV
  106295. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  106296. */
  106297. private _getFrustumSlope;
  106298. /**
  106299. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  106300. */
  106301. private _clearAnimationLocks;
  106302. /**
  106303. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  106304. */
  106305. private _applyUserInteraction;
  106306. /**
  106307. * Stops and removes all animations that have been applied to the camera
  106308. */
  106309. stopAllAnimations(): void;
  106310. /**
  106311. * Gets a value indicating if the user is moving the camera
  106312. */
  106313. readonly isUserIsMoving: boolean;
  106314. /**
  106315. * The camera can move all the way towards the mesh.
  106316. */
  106317. static IgnoreBoundsSizeMode: number;
  106318. /**
  106319. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  106320. */
  106321. static FitFrustumSidesMode: number;
  106322. }
  106323. }
  106324. declare module BABYLON {
  106325. /**
  106326. * Base class for Camera Pointer Inputs.
  106327. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  106328. * for example usage.
  106329. */
  106330. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  106331. /**
  106332. * Defines the camera the input is attached to.
  106333. */
  106334. abstract camera: Camera;
  106335. /**
  106336. * Whether keyboard modifier keys are pressed at time of last mouse event.
  106337. */
  106338. protected _altKey: boolean;
  106339. protected _ctrlKey: boolean;
  106340. protected _metaKey: boolean;
  106341. protected _shiftKey: boolean;
  106342. /**
  106343. * Which mouse buttons were pressed at time of last mouse event.
  106344. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  106345. */
  106346. protected _buttonsPressed: number;
  106347. /**
  106348. * Defines the buttons associated with the input to handle camera move.
  106349. */
  106350. buttons: number[];
  106351. /**
  106352. * Attach the input controls to a specific dom element to get the input from.
  106353. * @param element Defines the element the controls should be listened from
  106354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106355. */
  106356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106357. /**
  106358. * Detach the current controls from the specified dom element.
  106359. * @param element Defines the element to stop listening the inputs from
  106360. */
  106361. detachControl(element: Nullable<HTMLElement>): void;
  106362. /**
  106363. * Gets the class name of the current input.
  106364. * @returns the class name
  106365. */
  106366. getClassName(): string;
  106367. /**
  106368. * Get the friendly name associated with the input class.
  106369. * @returns the input friendly name
  106370. */
  106371. getSimpleName(): string;
  106372. /**
  106373. * Called on pointer POINTERDOUBLETAP event.
  106374. * Override this method to provide functionality on POINTERDOUBLETAP event.
  106375. */
  106376. protected onDoubleTap(type: string): void;
  106377. /**
  106378. * Called on pointer POINTERMOVE event if only a single touch is active.
  106379. * Override this method to provide functionality.
  106380. */
  106381. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106382. /**
  106383. * Called on pointer POINTERMOVE event if multiple touches are active.
  106384. * Override this method to provide functionality.
  106385. */
  106386. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106387. /**
  106388. * Called on JS contextmenu event.
  106389. * Override this method to provide functionality.
  106390. */
  106391. protected onContextMenu(evt: PointerEvent): void;
  106392. /**
  106393. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106394. * press.
  106395. * Override this method to provide functionality.
  106396. */
  106397. protected onButtonDown(evt: PointerEvent): void;
  106398. /**
  106399. * Called each time a new POINTERUP event occurs. Ie, for each button
  106400. * release.
  106401. * Override this method to provide functionality.
  106402. */
  106403. protected onButtonUp(evt: PointerEvent): void;
  106404. /**
  106405. * Called when window becomes inactive.
  106406. * Override this method to provide functionality.
  106407. */
  106408. protected onLostFocus(): void;
  106409. private _pointerInput;
  106410. private _observer;
  106411. private _onLostFocus;
  106412. private pointA;
  106413. private pointB;
  106414. }
  106415. }
  106416. declare module BABYLON {
  106417. /**
  106418. * Manage the pointers inputs to control an arc rotate camera.
  106419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106420. */
  106421. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  106422. /**
  106423. * Defines the camera the input is attached to.
  106424. */
  106425. camera: ArcRotateCamera;
  106426. /**
  106427. * Gets the class name of the current input.
  106428. * @returns the class name
  106429. */
  106430. getClassName(): string;
  106431. /**
  106432. * Defines the buttons associated with the input to handle camera move.
  106433. */
  106434. buttons: number[];
  106435. /**
  106436. * Defines the pointer angular sensibility along the X axis or how fast is
  106437. * the camera rotating.
  106438. */
  106439. angularSensibilityX: number;
  106440. /**
  106441. * Defines the pointer angular sensibility along the Y axis or how fast is
  106442. * the camera rotating.
  106443. */
  106444. angularSensibilityY: number;
  106445. /**
  106446. * Defines the pointer pinch precision or how fast is the camera zooming.
  106447. */
  106448. pinchPrecision: number;
  106449. /**
  106450. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106451. * from 0.
  106452. * It defines the percentage of current camera.radius to use as delta when
  106453. * pinch zoom is used.
  106454. */
  106455. pinchDeltaPercentage: number;
  106456. /**
  106457. * Defines the pointer panning sensibility or how fast is the camera moving.
  106458. */
  106459. panningSensibility: number;
  106460. /**
  106461. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  106462. */
  106463. multiTouchPanning: boolean;
  106464. /**
  106465. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  106466. * zoom (pinch) through multitouch.
  106467. */
  106468. multiTouchPanAndZoom: boolean;
  106469. /**
  106470. * Revers pinch action direction.
  106471. */
  106472. pinchInwards: boolean;
  106473. private _isPanClick;
  106474. private _twoFingerActivityCount;
  106475. private _isPinching;
  106476. /**
  106477. * Called on pointer POINTERMOVE event if only a single touch is active.
  106478. */
  106479. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106480. /**
  106481. * Called on pointer POINTERDOUBLETAP event.
  106482. */
  106483. protected onDoubleTap(type: string): void;
  106484. /**
  106485. * Called on pointer POINTERMOVE event if multiple touches are active.
  106486. */
  106487. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106488. /**
  106489. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106490. * press.
  106491. */
  106492. protected onButtonDown(evt: PointerEvent): void;
  106493. /**
  106494. * Called each time a new POINTERUP event occurs. Ie, for each button
  106495. * release.
  106496. */
  106497. protected onButtonUp(evt: PointerEvent): void;
  106498. /**
  106499. * Called when window becomes inactive.
  106500. */
  106501. protected onLostFocus(): void;
  106502. }
  106503. }
  106504. declare module BABYLON {
  106505. /**
  106506. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  106507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106508. */
  106509. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  106510. /**
  106511. * Defines the camera the input is attached to.
  106512. */
  106513. camera: ArcRotateCamera;
  106514. /**
  106515. * Defines the list of key codes associated with the up action (increase alpha)
  106516. */
  106517. keysUp: number[];
  106518. /**
  106519. * Defines the list of key codes associated with the down action (decrease alpha)
  106520. */
  106521. keysDown: number[];
  106522. /**
  106523. * Defines the list of key codes associated with the left action (increase beta)
  106524. */
  106525. keysLeft: number[];
  106526. /**
  106527. * Defines the list of key codes associated with the right action (decrease beta)
  106528. */
  106529. keysRight: number[];
  106530. /**
  106531. * Defines the list of key codes associated with the reset action.
  106532. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  106533. */
  106534. keysReset: number[];
  106535. /**
  106536. * Defines the panning sensibility of the inputs.
  106537. * (How fast is the camera paning)
  106538. */
  106539. panningSensibility: number;
  106540. /**
  106541. * Defines the zooming sensibility of the inputs.
  106542. * (How fast is the camera zooming)
  106543. */
  106544. zoomingSensibility: number;
  106545. /**
  106546. * Defines wether maintaining the alt key down switch the movement mode from
  106547. * orientation to zoom.
  106548. */
  106549. useAltToZoom: boolean;
  106550. /**
  106551. * Rotation speed of the camera
  106552. */
  106553. angularSpeed: number;
  106554. private _keys;
  106555. private _ctrlPressed;
  106556. private _altPressed;
  106557. private _onCanvasBlurObserver;
  106558. private _onKeyboardObserver;
  106559. private _engine;
  106560. private _scene;
  106561. /**
  106562. * Attach the input controls to a specific dom element to get the input from.
  106563. * @param element Defines the element the controls should be listened from
  106564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106565. */
  106566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106567. /**
  106568. * Detach the current controls from the specified dom element.
  106569. * @param element Defines the element to stop listening the inputs from
  106570. */
  106571. detachControl(element: Nullable<HTMLElement>): void;
  106572. /**
  106573. * Update the current camera state depending on the inputs that have been used this frame.
  106574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106575. */
  106576. checkInputs(): void;
  106577. /**
  106578. * Gets the class name of the current intput.
  106579. * @returns the class name
  106580. */
  106581. getClassName(): string;
  106582. /**
  106583. * Get the friendly name associated with the input class.
  106584. * @returns the input friendly name
  106585. */
  106586. getSimpleName(): string;
  106587. }
  106588. }
  106589. declare module BABYLON {
  106590. /**
  106591. * Manage the mouse wheel inputs to control an arc rotate camera.
  106592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106593. */
  106594. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  106595. /**
  106596. * Defines the camera the input is attached to.
  106597. */
  106598. camera: ArcRotateCamera;
  106599. /**
  106600. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  106601. */
  106602. wheelPrecision: number;
  106603. /**
  106604. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106605. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106606. */
  106607. wheelDeltaPercentage: number;
  106608. private _wheel;
  106609. private _observer;
  106610. private computeDeltaFromMouseWheelLegacyEvent;
  106611. /**
  106612. * Attach the input controls to a specific dom element to get the input from.
  106613. * @param element Defines the element the controls should be listened from
  106614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106615. */
  106616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106617. /**
  106618. * Detach the current controls from the specified dom element.
  106619. * @param element Defines the element to stop listening the inputs from
  106620. */
  106621. detachControl(element: Nullable<HTMLElement>): void;
  106622. /**
  106623. * Gets the class name of the current intput.
  106624. * @returns the class name
  106625. */
  106626. getClassName(): string;
  106627. /**
  106628. * Get the friendly name associated with the input class.
  106629. * @returns the input friendly name
  106630. */
  106631. getSimpleName(): string;
  106632. }
  106633. }
  106634. declare module BABYLON {
  106635. /**
  106636. * Default Inputs manager for the ArcRotateCamera.
  106637. * It groups all the default supported inputs for ease of use.
  106638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106639. */
  106640. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  106641. /**
  106642. * Instantiates a new ArcRotateCameraInputsManager.
  106643. * @param camera Defines the camera the inputs belong to
  106644. */
  106645. constructor(camera: ArcRotateCamera);
  106646. /**
  106647. * Add mouse wheel input support to the input manager.
  106648. * @returns the current input manager
  106649. */
  106650. addMouseWheel(): ArcRotateCameraInputsManager;
  106651. /**
  106652. * Add pointers input support to the input manager.
  106653. * @returns the current input manager
  106654. */
  106655. addPointers(): ArcRotateCameraInputsManager;
  106656. /**
  106657. * Add keyboard input support to the input manager.
  106658. * @returns the current input manager
  106659. */
  106660. addKeyboard(): ArcRotateCameraInputsManager;
  106661. }
  106662. }
  106663. declare module BABYLON {
  106664. /**
  106665. * This represents an orbital type of camera.
  106666. *
  106667. * 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.
  106668. * 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.
  106669. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  106670. */
  106671. export class ArcRotateCamera extends TargetCamera {
  106672. /**
  106673. * Defines the rotation angle of the camera along the longitudinal axis.
  106674. */
  106675. alpha: number;
  106676. /**
  106677. * Defines the rotation angle of the camera along the latitudinal axis.
  106678. */
  106679. beta: number;
  106680. /**
  106681. * Defines the radius of the camera from it s target point.
  106682. */
  106683. radius: number;
  106684. protected _target: Vector3;
  106685. protected _targetHost: Nullable<AbstractMesh>;
  106686. /**
  106687. * Defines the target point of the camera.
  106688. * The camera looks towards it form the radius distance.
  106689. */
  106690. target: Vector3;
  106691. /**
  106692. * Define the current local position of the camera in the scene
  106693. */
  106694. position: Vector3;
  106695. protected _upVector: Vector3;
  106696. protected _upToYMatrix: Matrix;
  106697. protected _YToUpMatrix: Matrix;
  106698. /**
  106699. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  106700. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  106701. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  106702. */
  106703. upVector: Vector3;
  106704. /**
  106705. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  106706. */
  106707. setMatUp(): void;
  106708. /**
  106709. * Current inertia value on the longitudinal axis.
  106710. * The bigger this number the longer it will take for the camera to stop.
  106711. */
  106712. inertialAlphaOffset: number;
  106713. /**
  106714. * Current inertia value on the latitudinal axis.
  106715. * The bigger this number the longer it will take for the camera to stop.
  106716. */
  106717. inertialBetaOffset: number;
  106718. /**
  106719. * Current inertia value on the radius axis.
  106720. * The bigger this number the longer it will take for the camera to stop.
  106721. */
  106722. inertialRadiusOffset: number;
  106723. /**
  106724. * Minimum allowed angle on the longitudinal axis.
  106725. * This can help limiting how the Camera is able to move in the scene.
  106726. */
  106727. lowerAlphaLimit: Nullable<number>;
  106728. /**
  106729. * Maximum allowed angle on the longitudinal axis.
  106730. * This can help limiting how the Camera is able to move in the scene.
  106731. */
  106732. upperAlphaLimit: Nullable<number>;
  106733. /**
  106734. * Minimum allowed angle on the latitudinal axis.
  106735. * This can help limiting how the Camera is able to move in the scene.
  106736. */
  106737. lowerBetaLimit: number;
  106738. /**
  106739. * Maximum allowed angle on the latitudinal axis.
  106740. * This can help limiting how the Camera is able to move in the scene.
  106741. */
  106742. upperBetaLimit: number;
  106743. /**
  106744. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  106745. * This can help limiting how the Camera is able to move in the scene.
  106746. */
  106747. lowerRadiusLimit: Nullable<number>;
  106748. /**
  106749. * Maximum allowed distance of the camera to the target (The camera can not get further).
  106750. * This can help limiting how the Camera is able to move in the scene.
  106751. */
  106752. upperRadiusLimit: Nullable<number>;
  106753. /**
  106754. * Defines the current inertia value used during panning of the camera along the X axis.
  106755. */
  106756. inertialPanningX: number;
  106757. /**
  106758. * Defines the current inertia value used during panning of the camera along the Y axis.
  106759. */
  106760. inertialPanningY: number;
  106761. /**
  106762. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  106763. * Basically if your fingers moves away from more than this distance you will be considered
  106764. * in pinch mode.
  106765. */
  106766. pinchToPanMaxDistance: number;
  106767. /**
  106768. * Defines the maximum distance the camera can pan.
  106769. * This could help keeping the cammera always in your scene.
  106770. */
  106771. panningDistanceLimit: Nullable<number>;
  106772. /**
  106773. * Defines the target of the camera before paning.
  106774. */
  106775. panningOriginTarget: Vector3;
  106776. /**
  106777. * Defines the value of the inertia used during panning.
  106778. * 0 would mean stop inertia and one would mean no decelleration at all.
  106779. */
  106780. panningInertia: number;
  106781. /**
  106782. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  106783. */
  106784. angularSensibilityX: number;
  106785. /**
  106786. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  106787. */
  106788. angularSensibilityY: number;
  106789. /**
  106790. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  106791. */
  106792. pinchPrecision: number;
  106793. /**
  106794. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  106795. * It will be used instead of pinchDeltaPrecision if different from 0.
  106796. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  106797. */
  106798. pinchDeltaPercentage: number;
  106799. /**
  106800. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  106801. */
  106802. panningSensibility: number;
  106803. /**
  106804. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  106805. */
  106806. keysUp: number[];
  106807. /**
  106808. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  106809. */
  106810. keysDown: number[];
  106811. /**
  106812. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  106813. */
  106814. keysLeft: number[];
  106815. /**
  106816. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  106817. */
  106818. keysRight: number[];
  106819. /**
  106820. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  106821. */
  106822. wheelPrecision: number;
  106823. /**
  106824. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  106825. * It will be used instead of pinchDeltaPrecision if different from 0.
  106826. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  106827. */
  106828. wheelDeltaPercentage: number;
  106829. /**
  106830. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  106831. */
  106832. zoomOnFactor: number;
  106833. /**
  106834. * Defines a screen offset for the camera position.
  106835. */
  106836. targetScreenOffset: Vector2;
  106837. /**
  106838. * Allows the camera to be completely reversed.
  106839. * If false the camera can not arrive upside down.
  106840. */
  106841. allowUpsideDown: boolean;
  106842. /**
  106843. * Define if double tap/click is used to restore the previously saved state of the camera.
  106844. */
  106845. useInputToRestoreState: boolean;
  106846. /** @hidden */
  106847. _viewMatrix: Matrix;
  106848. /** @hidden */
  106849. _useCtrlForPanning: boolean;
  106850. /** @hidden */
  106851. _panningMouseButton: number;
  106852. /**
  106853. * Defines the input associated to the camera.
  106854. */
  106855. inputs: ArcRotateCameraInputsManager;
  106856. /** @hidden */
  106857. _reset: () => void;
  106858. /**
  106859. * Defines the allowed panning axis.
  106860. */
  106861. panningAxis: Vector3;
  106862. protected _localDirection: Vector3;
  106863. protected _transformedDirection: Vector3;
  106864. private _bouncingBehavior;
  106865. /**
  106866. * Gets the bouncing behavior of the camera if it has been enabled.
  106867. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106868. */
  106869. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  106870. /**
  106871. * Defines if the bouncing behavior of the camera is enabled on the camera.
  106872. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106873. */
  106874. useBouncingBehavior: boolean;
  106875. private _framingBehavior;
  106876. /**
  106877. * Gets the framing behavior of the camera if it has been enabled.
  106878. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106879. */
  106880. readonly framingBehavior: Nullable<FramingBehavior>;
  106881. /**
  106882. * Defines if the framing behavior of the camera is enabled on the camera.
  106883. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106884. */
  106885. useFramingBehavior: boolean;
  106886. private _autoRotationBehavior;
  106887. /**
  106888. * Gets the auto rotation behavior of the camera if it has been enabled.
  106889. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  106890. */
  106891. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  106892. /**
  106893. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  106894. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  106895. */
  106896. useAutoRotationBehavior: boolean;
  106897. /**
  106898. * Observable triggered when the mesh target has been changed on the camera.
  106899. */
  106900. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  106901. /**
  106902. * Event raised when the camera is colliding with a mesh.
  106903. */
  106904. onCollide: (collidedMesh: AbstractMesh) => void;
  106905. /**
  106906. * Defines whether the camera should check collision with the objects oh the scene.
  106907. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  106908. */
  106909. checkCollisions: boolean;
  106910. /**
  106911. * Defines the collision radius of the camera.
  106912. * This simulates a sphere around the camera.
  106913. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106914. */
  106915. collisionRadius: Vector3;
  106916. protected _collider: Collider;
  106917. protected _previousPosition: Vector3;
  106918. protected _collisionVelocity: Vector3;
  106919. protected _newPosition: Vector3;
  106920. protected _previousAlpha: number;
  106921. protected _previousBeta: number;
  106922. protected _previousRadius: number;
  106923. protected _collisionTriggered: boolean;
  106924. protected _targetBoundingCenter: Nullable<Vector3>;
  106925. private _computationVector;
  106926. /**
  106927. * Instantiates a new ArcRotateCamera in a given scene
  106928. * @param name Defines the name of the camera
  106929. * @param alpha Defines the camera rotation along the logitudinal axis
  106930. * @param beta Defines the camera rotation along the latitudinal axis
  106931. * @param radius Defines the camera distance from its target
  106932. * @param target Defines the camera target
  106933. * @param scene Defines the scene the camera belongs to
  106934. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  106935. */
  106936. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106937. /** @hidden */
  106938. _initCache(): void;
  106939. /** @hidden */
  106940. _updateCache(ignoreParentClass?: boolean): void;
  106941. protected _getTargetPosition(): Vector3;
  106942. private _storedAlpha;
  106943. private _storedBeta;
  106944. private _storedRadius;
  106945. private _storedTarget;
  106946. private _storedTargetScreenOffset;
  106947. /**
  106948. * Stores the current state of the camera (alpha, beta, radius and target)
  106949. * @returns the camera itself
  106950. */
  106951. storeState(): Camera;
  106952. /**
  106953. * @hidden
  106954. * Restored camera state. You must call storeState() first
  106955. */
  106956. _restoreStateValues(): boolean;
  106957. /** @hidden */
  106958. _isSynchronizedViewMatrix(): boolean;
  106959. /**
  106960. * Attached controls to the current camera.
  106961. * @param element Defines the element the controls should be listened from
  106962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106963. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  106964. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  106965. */
  106966. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  106967. /**
  106968. * Detach the current controls from the camera.
  106969. * The camera will stop reacting to inputs.
  106970. * @param element Defines the element to stop listening the inputs from
  106971. */
  106972. detachControl(element: HTMLElement): void;
  106973. /** @hidden */
  106974. _checkInputs(): void;
  106975. protected _checkLimits(): void;
  106976. /**
  106977. * Rebuilds angles (alpha, beta) and radius from the give position and target
  106978. */
  106979. rebuildAnglesAndRadius(): void;
  106980. /**
  106981. * Use a position to define the current camera related information like alpha, beta and radius
  106982. * @param position Defines the position to set the camera at
  106983. */
  106984. setPosition(position: Vector3): void;
  106985. /**
  106986. * Defines the target the camera should look at.
  106987. * This will automatically adapt alpha beta and radius to fit within the new target.
  106988. * @param target Defines the new target as a Vector or a mesh
  106989. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  106990. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  106991. */
  106992. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  106993. /** @hidden */
  106994. _getViewMatrix(): Matrix;
  106995. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  106996. /**
  106997. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  106998. * @param meshes Defines the mesh to zoom on
  106999. * @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)
  107000. */
  107001. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  107002. /**
  107003. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  107004. * The target will be changed but the radius
  107005. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  107006. * @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)
  107007. */
  107008. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  107009. min: Vector3;
  107010. max: Vector3;
  107011. distance: number;
  107012. }, doNotUpdateMaxZ?: boolean): void;
  107013. /**
  107014. * @override
  107015. * Override Camera.createRigCamera
  107016. */
  107017. createRigCamera(name: string, cameraIndex: number): Camera;
  107018. /**
  107019. * @hidden
  107020. * @override
  107021. * Override Camera._updateRigCameras
  107022. */
  107023. _updateRigCameras(): void;
  107024. /**
  107025. * Destroy the camera and release the current resources hold by it.
  107026. */
  107027. dispose(): void;
  107028. /**
  107029. * Gets the current object class name.
  107030. * @return the class name
  107031. */
  107032. getClassName(): string;
  107033. }
  107034. }
  107035. declare module BABYLON {
  107036. /**
  107037. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  107038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107039. */
  107040. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  107041. /**
  107042. * Gets the name of the behavior.
  107043. */
  107044. readonly name: string;
  107045. private _zoomStopsAnimation;
  107046. private _idleRotationSpeed;
  107047. private _idleRotationWaitTime;
  107048. private _idleRotationSpinupTime;
  107049. /**
  107050. * Sets the flag that indicates if user zooming should stop animation.
  107051. */
  107052. /**
  107053. * Gets the flag that indicates if user zooming should stop animation.
  107054. */
  107055. zoomStopsAnimation: boolean;
  107056. /**
  107057. * Sets the default speed at which the camera rotates around the model.
  107058. */
  107059. /**
  107060. * Gets the default speed at which the camera rotates around the model.
  107061. */
  107062. idleRotationSpeed: number;
  107063. /**
  107064. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  107065. */
  107066. /**
  107067. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  107068. */
  107069. idleRotationWaitTime: number;
  107070. /**
  107071. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107072. */
  107073. /**
  107074. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107075. */
  107076. idleRotationSpinupTime: number;
  107077. /**
  107078. * Gets a value indicating if the camera is currently rotating because of this behavior
  107079. */
  107080. readonly rotationInProgress: boolean;
  107081. private _onPrePointerObservableObserver;
  107082. private _onAfterCheckInputsObserver;
  107083. private _attachedCamera;
  107084. private _isPointerDown;
  107085. private _lastFrameTime;
  107086. private _lastInteractionTime;
  107087. private _cameraRotationSpeed;
  107088. /**
  107089. * Initializes the behavior.
  107090. */
  107091. init(): void;
  107092. /**
  107093. * Attaches the behavior to its arc rotate camera.
  107094. * @param camera Defines the camera to attach the behavior to
  107095. */
  107096. attach(camera: ArcRotateCamera): void;
  107097. /**
  107098. * Detaches the behavior from its current arc rotate camera.
  107099. */
  107100. detach(): void;
  107101. /**
  107102. * Returns true if user is scrolling.
  107103. * @return true if user is scrolling.
  107104. */
  107105. private _userIsZooming;
  107106. private _lastFrameRadius;
  107107. private _shouldAnimationStopForInteraction;
  107108. /**
  107109. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  107110. */
  107111. private _applyUserInteraction;
  107112. private _userIsMoving;
  107113. }
  107114. }
  107115. declare module BABYLON {
  107116. /**
  107117. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  107118. */
  107119. export class AttachToBoxBehavior implements Behavior<Mesh> {
  107120. private ui;
  107121. /**
  107122. * The name of the behavior
  107123. */
  107124. name: string;
  107125. /**
  107126. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  107127. */
  107128. distanceAwayFromFace: number;
  107129. /**
  107130. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  107131. */
  107132. distanceAwayFromBottomOfFace: number;
  107133. private _faceVectors;
  107134. private _target;
  107135. private _scene;
  107136. private _onRenderObserver;
  107137. private _tmpMatrix;
  107138. private _tmpVector;
  107139. /**
  107140. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  107141. * @param ui The transform node that should be attched to the mesh
  107142. */
  107143. constructor(ui: TransformNode);
  107144. /**
  107145. * Initializes the behavior
  107146. */
  107147. init(): void;
  107148. private _closestFace;
  107149. private _zeroVector;
  107150. private _lookAtTmpMatrix;
  107151. private _lookAtToRef;
  107152. /**
  107153. * Attaches the AttachToBoxBehavior to the passed in mesh
  107154. * @param target The mesh that the specified node will be attached to
  107155. */
  107156. attach(target: Mesh): void;
  107157. /**
  107158. * Detaches the behavior from the mesh
  107159. */
  107160. detach(): void;
  107161. }
  107162. }
  107163. declare module BABYLON {
  107164. /**
  107165. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  107166. */
  107167. export class FadeInOutBehavior implements Behavior<Mesh> {
  107168. /**
  107169. * Time in milliseconds to delay before fading in (Default: 0)
  107170. */
  107171. delay: number;
  107172. /**
  107173. * Time in milliseconds for the mesh to fade in (Default: 300)
  107174. */
  107175. fadeInTime: number;
  107176. private _millisecondsPerFrame;
  107177. private _hovered;
  107178. private _hoverValue;
  107179. private _ownerNode;
  107180. /**
  107181. * Instatiates the FadeInOutBehavior
  107182. */
  107183. constructor();
  107184. /**
  107185. * The name of the behavior
  107186. */
  107187. readonly name: string;
  107188. /**
  107189. * Initializes the behavior
  107190. */
  107191. init(): void;
  107192. /**
  107193. * Attaches the fade behavior on the passed in mesh
  107194. * @param ownerNode The mesh that will be faded in/out once attached
  107195. */
  107196. attach(ownerNode: Mesh): void;
  107197. /**
  107198. * Detaches the behavior from the mesh
  107199. */
  107200. detach(): void;
  107201. /**
  107202. * Triggers the mesh to begin fading in or out
  107203. * @param value if the object should fade in or out (true to fade in)
  107204. */
  107205. fadeIn(value: boolean): void;
  107206. private _update;
  107207. private _setAllVisibility;
  107208. }
  107209. }
  107210. declare module BABYLON {
  107211. /**
  107212. * Class containing a set of static utilities functions for managing Pivots
  107213. * @hidden
  107214. */
  107215. export class PivotTools {
  107216. private static _PivotCached;
  107217. private static _OldPivotPoint;
  107218. private static _PivotTranslation;
  107219. private static _PivotTmpVector;
  107220. /** @hidden */
  107221. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  107222. /** @hidden */
  107223. static _RestorePivotPoint(mesh: AbstractMesh): void;
  107224. }
  107225. }
  107226. declare module BABYLON {
  107227. /**
  107228. * Class containing static functions to help procedurally build meshes
  107229. */
  107230. export class PlaneBuilder {
  107231. /**
  107232. * Creates a plane mesh
  107233. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107234. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107235. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107239. * @param name defines the name of the mesh
  107240. * @param options defines the options used to create the mesh
  107241. * @param scene defines the hosting scene
  107242. * @returns the plane mesh
  107243. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107244. */
  107245. static CreatePlane(name: string, options: {
  107246. size?: number;
  107247. width?: number;
  107248. height?: number;
  107249. sideOrientation?: number;
  107250. frontUVs?: Vector4;
  107251. backUVs?: Vector4;
  107252. updatable?: boolean;
  107253. sourcePlane?: Plane;
  107254. }, scene?: Nullable<Scene>): Mesh;
  107255. }
  107256. }
  107257. declare module BABYLON {
  107258. /**
  107259. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  107260. */
  107261. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  107262. private static _AnyMouseID;
  107263. /**
  107264. * Abstract mesh the behavior is set on
  107265. */
  107266. attachedNode: AbstractMesh;
  107267. private _dragPlane;
  107268. private _scene;
  107269. private _pointerObserver;
  107270. private _beforeRenderObserver;
  107271. private static _planeScene;
  107272. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  107273. /**
  107274. * 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)
  107275. */
  107276. maxDragAngle: number;
  107277. /**
  107278. * @hidden
  107279. */
  107280. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  107281. /**
  107282. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107283. */
  107284. currentDraggingPointerID: number;
  107285. /**
  107286. * The last position where the pointer hit the drag plane in world space
  107287. */
  107288. lastDragPosition: Vector3;
  107289. /**
  107290. * If the behavior is currently in a dragging state
  107291. */
  107292. dragging: boolean;
  107293. /**
  107294. * 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)
  107295. */
  107296. dragDeltaRatio: number;
  107297. /**
  107298. * If the drag plane orientation should be updated during the dragging (Default: true)
  107299. */
  107300. updateDragPlane: boolean;
  107301. private _debugMode;
  107302. private _moving;
  107303. /**
  107304. * Fires each time the attached mesh is dragged with the pointer
  107305. * * delta between last drag position and current drag position in world space
  107306. * * dragDistance along the drag axis
  107307. * * dragPlaneNormal normal of the current drag plane used during the drag
  107308. * * dragPlanePoint in world space where the drag intersects the drag plane
  107309. */
  107310. onDragObservable: Observable<{
  107311. delta: Vector3;
  107312. dragPlanePoint: Vector3;
  107313. dragPlaneNormal: Vector3;
  107314. dragDistance: number;
  107315. pointerId: number;
  107316. }>;
  107317. /**
  107318. * Fires each time a drag begins (eg. mouse down on mesh)
  107319. */
  107320. onDragStartObservable: Observable<{
  107321. dragPlanePoint: Vector3;
  107322. pointerId: number;
  107323. }>;
  107324. /**
  107325. * Fires each time a drag ends (eg. mouse release after drag)
  107326. */
  107327. onDragEndObservable: Observable<{
  107328. dragPlanePoint: Vector3;
  107329. pointerId: number;
  107330. }>;
  107331. /**
  107332. * If the attached mesh should be moved when dragged
  107333. */
  107334. moveAttached: boolean;
  107335. /**
  107336. * If the drag behavior will react to drag events (Default: true)
  107337. */
  107338. enabled: boolean;
  107339. /**
  107340. * If pointer events should start and release the drag (Default: true)
  107341. */
  107342. startAndReleaseDragOnPointerEvents: boolean;
  107343. /**
  107344. * If camera controls should be detached during the drag
  107345. */
  107346. detachCameraControls: boolean;
  107347. /**
  107348. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  107349. */
  107350. useObjectOrienationForDragging: boolean;
  107351. private _options;
  107352. /**
  107353. * Creates a pointer drag behavior that can be attached to a mesh
  107354. * @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)
  107355. */
  107356. constructor(options?: {
  107357. dragAxis?: Vector3;
  107358. dragPlaneNormal?: Vector3;
  107359. });
  107360. /**
  107361. * Predicate to determine if it is valid to move the object to a new position when it is moved
  107362. */
  107363. validateDrag: (targetPosition: Vector3) => boolean;
  107364. /**
  107365. * The name of the behavior
  107366. */
  107367. readonly name: string;
  107368. /**
  107369. * Initializes the behavior
  107370. */
  107371. init(): void;
  107372. private _tmpVector;
  107373. private _alternatePickedPoint;
  107374. private _worldDragAxis;
  107375. private _targetPosition;
  107376. private _attachedElement;
  107377. /**
  107378. * Attaches the drag behavior the passed in mesh
  107379. * @param ownerNode The mesh that will be dragged around once attached
  107380. * @param predicate Predicate to use for pick filtering
  107381. */
  107382. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  107383. /**
  107384. * Force relase the drag action by code.
  107385. */
  107386. releaseDrag(): void;
  107387. private _startDragRay;
  107388. private _lastPointerRay;
  107389. /**
  107390. * Simulates the start of a pointer drag event on the behavior
  107391. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  107392. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  107393. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  107394. */
  107395. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  107396. private _startDrag;
  107397. private _dragDelta;
  107398. private _moveDrag;
  107399. private _pickWithRayOnDragPlane;
  107400. private _pointA;
  107401. private _pointB;
  107402. private _pointC;
  107403. private _lineA;
  107404. private _lineB;
  107405. private _localAxis;
  107406. private _lookAt;
  107407. private _updateDragPlanePosition;
  107408. /**
  107409. * Detaches the behavior from the mesh
  107410. */
  107411. detach(): void;
  107412. }
  107413. }
  107414. declare module BABYLON {
  107415. /**
  107416. * A behavior that when attached to a mesh will allow the mesh to be scaled
  107417. */
  107418. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  107419. private _dragBehaviorA;
  107420. private _dragBehaviorB;
  107421. private _startDistance;
  107422. private _initialScale;
  107423. private _targetScale;
  107424. private _ownerNode;
  107425. private _sceneRenderObserver;
  107426. /**
  107427. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  107428. */
  107429. constructor();
  107430. /**
  107431. * The name of the behavior
  107432. */
  107433. readonly name: string;
  107434. /**
  107435. * Initializes the behavior
  107436. */
  107437. init(): void;
  107438. private _getCurrentDistance;
  107439. /**
  107440. * Attaches the scale behavior the passed in mesh
  107441. * @param ownerNode The mesh that will be scaled around once attached
  107442. */
  107443. attach(ownerNode: Mesh): void;
  107444. /**
  107445. * Detaches the behavior from the mesh
  107446. */
  107447. detach(): void;
  107448. }
  107449. }
  107450. declare module BABYLON {
  107451. /**
  107452. * 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
  107453. */
  107454. export class SixDofDragBehavior implements Behavior<Mesh> {
  107455. private static _virtualScene;
  107456. private _ownerNode;
  107457. private _sceneRenderObserver;
  107458. private _scene;
  107459. private _targetPosition;
  107460. private _virtualOriginMesh;
  107461. private _virtualDragMesh;
  107462. private _pointerObserver;
  107463. private _moving;
  107464. private _startingOrientation;
  107465. /**
  107466. * 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)
  107467. */
  107468. private zDragFactor;
  107469. /**
  107470. * If the object should rotate to face the drag origin
  107471. */
  107472. rotateDraggedObject: boolean;
  107473. /**
  107474. * If the behavior is currently in a dragging state
  107475. */
  107476. dragging: boolean;
  107477. /**
  107478. * 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)
  107479. */
  107480. dragDeltaRatio: number;
  107481. /**
  107482. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107483. */
  107484. currentDraggingPointerID: number;
  107485. /**
  107486. * If camera controls should be detached during the drag
  107487. */
  107488. detachCameraControls: boolean;
  107489. /**
  107490. * Fires each time a drag starts
  107491. */
  107492. onDragStartObservable: Observable<{}>;
  107493. /**
  107494. * Fires each time a drag ends (eg. mouse release after drag)
  107495. */
  107496. onDragEndObservable: Observable<{}>;
  107497. /**
  107498. * 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
  107499. */
  107500. constructor();
  107501. /**
  107502. * The name of the behavior
  107503. */
  107504. readonly name: string;
  107505. /**
  107506. * Initializes the behavior
  107507. */
  107508. init(): void;
  107509. /**
  107510. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  107511. */
  107512. private readonly _pointerCamera;
  107513. /**
  107514. * Attaches the scale behavior the passed in mesh
  107515. * @param ownerNode The mesh that will be scaled around once attached
  107516. */
  107517. attach(ownerNode: Mesh): void;
  107518. /**
  107519. * Detaches the behavior from the mesh
  107520. */
  107521. detach(): void;
  107522. }
  107523. }
  107524. declare module BABYLON {
  107525. /**
  107526. * Class used to apply inverse kinematics to bones
  107527. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  107528. */
  107529. export class BoneIKController {
  107530. private static _tmpVecs;
  107531. private static _tmpQuat;
  107532. private static _tmpMats;
  107533. /**
  107534. * Gets or sets the target mesh
  107535. */
  107536. targetMesh: AbstractMesh;
  107537. /** Gets or sets the mesh used as pole */
  107538. poleTargetMesh: AbstractMesh;
  107539. /**
  107540. * Gets or sets the bone used as pole
  107541. */
  107542. poleTargetBone: Nullable<Bone>;
  107543. /**
  107544. * Gets or sets the target position
  107545. */
  107546. targetPosition: Vector3;
  107547. /**
  107548. * Gets or sets the pole target position
  107549. */
  107550. poleTargetPosition: Vector3;
  107551. /**
  107552. * Gets or sets the pole target local offset
  107553. */
  107554. poleTargetLocalOffset: Vector3;
  107555. /**
  107556. * Gets or sets the pole angle
  107557. */
  107558. poleAngle: number;
  107559. /**
  107560. * Gets or sets the mesh associated with the controller
  107561. */
  107562. mesh: AbstractMesh;
  107563. /**
  107564. * 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)
  107565. */
  107566. slerpAmount: number;
  107567. private _bone1Quat;
  107568. private _bone1Mat;
  107569. private _bone2Ang;
  107570. private _bone1;
  107571. private _bone2;
  107572. private _bone1Length;
  107573. private _bone2Length;
  107574. private _maxAngle;
  107575. private _maxReach;
  107576. private _rightHandedSystem;
  107577. private _bendAxis;
  107578. private _slerping;
  107579. private _adjustRoll;
  107580. /**
  107581. * Gets or sets maximum allowed angle
  107582. */
  107583. maxAngle: number;
  107584. /**
  107585. * Creates a new BoneIKController
  107586. * @param mesh defines the mesh to control
  107587. * @param bone defines the bone to control
  107588. * @param options defines options to set up the controller
  107589. */
  107590. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  107591. targetMesh?: AbstractMesh;
  107592. poleTargetMesh?: AbstractMesh;
  107593. poleTargetBone?: Bone;
  107594. poleTargetLocalOffset?: Vector3;
  107595. poleAngle?: number;
  107596. bendAxis?: Vector3;
  107597. maxAngle?: number;
  107598. slerpAmount?: number;
  107599. });
  107600. private _setMaxAngle;
  107601. /**
  107602. * Force the controller to update the bones
  107603. */
  107604. update(): void;
  107605. }
  107606. }
  107607. declare module BABYLON {
  107608. /**
  107609. * Class used to make a bone look toward a point in space
  107610. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  107611. */
  107612. export class BoneLookController {
  107613. private static _tmpVecs;
  107614. private static _tmpQuat;
  107615. private static _tmpMats;
  107616. /**
  107617. * The target Vector3 that the bone will look at
  107618. */
  107619. target: Vector3;
  107620. /**
  107621. * The mesh that the bone is attached to
  107622. */
  107623. mesh: AbstractMesh;
  107624. /**
  107625. * The bone that will be looking to the target
  107626. */
  107627. bone: Bone;
  107628. /**
  107629. * The up axis of the coordinate system that is used when the bone is rotated
  107630. */
  107631. upAxis: Vector3;
  107632. /**
  107633. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  107634. */
  107635. upAxisSpace: Space;
  107636. /**
  107637. * Used to make an adjustment to the yaw of the bone
  107638. */
  107639. adjustYaw: number;
  107640. /**
  107641. * Used to make an adjustment to the pitch of the bone
  107642. */
  107643. adjustPitch: number;
  107644. /**
  107645. * Used to make an adjustment to the roll of the bone
  107646. */
  107647. adjustRoll: number;
  107648. /**
  107649. * 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)
  107650. */
  107651. slerpAmount: number;
  107652. private _minYaw;
  107653. private _maxYaw;
  107654. private _minPitch;
  107655. private _maxPitch;
  107656. private _minYawSin;
  107657. private _minYawCos;
  107658. private _maxYawSin;
  107659. private _maxYawCos;
  107660. private _midYawConstraint;
  107661. private _minPitchTan;
  107662. private _maxPitchTan;
  107663. private _boneQuat;
  107664. private _slerping;
  107665. private _transformYawPitch;
  107666. private _transformYawPitchInv;
  107667. private _firstFrameSkipped;
  107668. private _yawRange;
  107669. private _fowardAxis;
  107670. /**
  107671. * Gets or sets the minimum yaw angle that the bone can look to
  107672. */
  107673. minYaw: number;
  107674. /**
  107675. * Gets or sets the maximum yaw angle that the bone can look to
  107676. */
  107677. maxYaw: number;
  107678. /**
  107679. * Gets or sets the minimum pitch angle that the bone can look to
  107680. */
  107681. minPitch: number;
  107682. /**
  107683. * Gets or sets the maximum pitch angle that the bone can look to
  107684. */
  107685. maxPitch: number;
  107686. /**
  107687. * Create a BoneLookController
  107688. * @param mesh the mesh that the bone belongs to
  107689. * @param bone the bone that will be looking to the target
  107690. * @param target the target Vector3 to look at
  107691. * @param options optional settings:
  107692. * * maxYaw: the maximum angle the bone will yaw to
  107693. * * minYaw: the minimum angle the bone will yaw to
  107694. * * maxPitch: the maximum angle the bone will pitch to
  107695. * * minPitch: the minimum angle the bone will yaw to
  107696. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  107697. * * upAxis: the up axis of the coordinate system
  107698. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  107699. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  107700. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  107701. * * adjustYaw: used to make an adjustment to the yaw of the bone
  107702. * * adjustPitch: used to make an adjustment to the pitch of the bone
  107703. * * adjustRoll: used to make an adjustment to the roll of the bone
  107704. **/
  107705. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  107706. maxYaw?: number;
  107707. minYaw?: number;
  107708. maxPitch?: number;
  107709. minPitch?: number;
  107710. slerpAmount?: number;
  107711. upAxis?: Vector3;
  107712. upAxisSpace?: Space;
  107713. yawAxis?: Vector3;
  107714. pitchAxis?: Vector3;
  107715. adjustYaw?: number;
  107716. adjustPitch?: number;
  107717. adjustRoll?: number;
  107718. });
  107719. /**
  107720. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  107721. */
  107722. update(): void;
  107723. private _getAngleDiff;
  107724. private _getAngleBetween;
  107725. private _isAngleBetween;
  107726. }
  107727. }
  107728. declare module BABYLON {
  107729. /**
  107730. * Manage the gamepad inputs to control an arc rotate camera.
  107731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107732. */
  107733. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  107734. /**
  107735. * Defines the camera the input is attached to.
  107736. */
  107737. camera: ArcRotateCamera;
  107738. /**
  107739. * Defines the gamepad the input is gathering event from.
  107740. */
  107741. gamepad: Nullable<Gamepad>;
  107742. /**
  107743. * Defines the gamepad rotation sensiblity.
  107744. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107745. */
  107746. gamepadRotationSensibility: number;
  107747. /**
  107748. * Defines the gamepad move sensiblity.
  107749. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107750. */
  107751. gamepadMoveSensibility: number;
  107752. private _yAxisScale;
  107753. /**
  107754. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107755. */
  107756. invertYAxis: boolean;
  107757. private _onGamepadConnectedObserver;
  107758. private _onGamepadDisconnectedObserver;
  107759. /**
  107760. * Attach the input controls to a specific dom element to get the input from.
  107761. * @param element Defines the element the controls should be listened from
  107762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107763. */
  107764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107765. /**
  107766. * Detach the current controls from the specified dom element.
  107767. * @param element Defines the element to stop listening the inputs from
  107768. */
  107769. detachControl(element: Nullable<HTMLElement>): void;
  107770. /**
  107771. * Update the current camera state depending on the inputs that have been used this frame.
  107772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107773. */
  107774. checkInputs(): void;
  107775. /**
  107776. * Gets the class name of the current intput.
  107777. * @returns the class name
  107778. */
  107779. getClassName(): string;
  107780. /**
  107781. * Get the friendly name associated with the input class.
  107782. * @returns the input friendly name
  107783. */
  107784. getSimpleName(): string;
  107785. }
  107786. }
  107787. declare module BABYLON {
  107788. interface ArcRotateCameraInputsManager {
  107789. /**
  107790. * Add orientation input support to the input manager.
  107791. * @returns the current input manager
  107792. */
  107793. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  107794. }
  107795. /**
  107796. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  107797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107798. */
  107799. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  107800. /**
  107801. * Defines the camera the input is attached to.
  107802. */
  107803. camera: ArcRotateCamera;
  107804. /**
  107805. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  107806. */
  107807. alphaCorrection: number;
  107808. /**
  107809. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  107810. */
  107811. gammaCorrection: number;
  107812. private _alpha;
  107813. private _gamma;
  107814. private _dirty;
  107815. private _deviceOrientationHandler;
  107816. /**
  107817. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  107818. */
  107819. constructor();
  107820. /**
  107821. * Attach the input controls to a specific dom element to get the input from.
  107822. * @param element Defines the element the controls should be listened from
  107823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107824. */
  107825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107826. /** @hidden */
  107827. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  107828. /**
  107829. * Update the current camera state depending on the inputs that have been used this frame.
  107830. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107831. */
  107832. checkInputs(): void;
  107833. /**
  107834. * Detach the current controls from the specified dom element.
  107835. * @param element Defines the element to stop listening the inputs from
  107836. */
  107837. detachControl(element: Nullable<HTMLElement>): void;
  107838. /**
  107839. * Gets the class name of the current intput.
  107840. * @returns the class name
  107841. */
  107842. getClassName(): string;
  107843. /**
  107844. * Get the friendly name associated with the input class.
  107845. * @returns the input friendly name
  107846. */
  107847. getSimpleName(): string;
  107848. }
  107849. }
  107850. declare module BABYLON {
  107851. /**
  107852. * Listen to mouse events to control the camera.
  107853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107854. */
  107855. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  107856. /**
  107857. * Defines the camera the input is attached to.
  107858. */
  107859. camera: FlyCamera;
  107860. /**
  107861. * Defines if touch is enabled. (Default is true.)
  107862. */
  107863. touchEnabled: boolean;
  107864. /**
  107865. * Defines the buttons associated with the input to handle camera rotation.
  107866. */
  107867. buttons: number[];
  107868. /**
  107869. * Assign buttons for Yaw control.
  107870. */
  107871. buttonsYaw: number[];
  107872. /**
  107873. * Assign buttons for Pitch control.
  107874. */
  107875. buttonsPitch: number[];
  107876. /**
  107877. * Assign buttons for Roll control.
  107878. */
  107879. buttonsRoll: number[];
  107880. /**
  107881. * Detect if any button is being pressed while mouse is moved.
  107882. * -1 = Mouse locked.
  107883. * 0 = Left button.
  107884. * 1 = Middle Button.
  107885. * 2 = Right Button.
  107886. */
  107887. activeButton: number;
  107888. /**
  107889. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  107890. * Higher values reduce its sensitivity.
  107891. */
  107892. angularSensibility: number;
  107893. private _mousemoveCallback;
  107894. private _observer;
  107895. private _rollObserver;
  107896. private previousPosition;
  107897. private noPreventDefault;
  107898. private element;
  107899. /**
  107900. * Listen to mouse events to control the camera.
  107901. * @param touchEnabled Define if touch is enabled. (Default is true.)
  107902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107903. */
  107904. constructor(touchEnabled?: boolean);
  107905. /**
  107906. * Attach the mouse control to the HTML DOM element.
  107907. * @param element Defines the element that listens to the input events.
  107908. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  107909. */
  107910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107911. /**
  107912. * Detach the current controls from the specified dom element.
  107913. * @param element Defines the element to stop listening the inputs from
  107914. */
  107915. detachControl(element: Nullable<HTMLElement>): void;
  107916. /**
  107917. * Gets the class name of the current input.
  107918. * @returns the class name.
  107919. */
  107920. getClassName(): string;
  107921. /**
  107922. * Get the friendly name associated with the input class.
  107923. * @returns the input's friendly name.
  107924. */
  107925. getSimpleName(): string;
  107926. private _pointerInput;
  107927. private _onMouseMove;
  107928. /**
  107929. * Rotate camera by mouse offset.
  107930. */
  107931. private rotateCamera;
  107932. }
  107933. }
  107934. declare module BABYLON {
  107935. /**
  107936. * Default Inputs manager for the FlyCamera.
  107937. * It groups all the default supported inputs for ease of use.
  107938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107939. */
  107940. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  107941. /**
  107942. * Instantiates a new FlyCameraInputsManager.
  107943. * @param camera Defines the camera the inputs belong to.
  107944. */
  107945. constructor(camera: FlyCamera);
  107946. /**
  107947. * Add keyboard input support to the input manager.
  107948. * @returns the new FlyCameraKeyboardMoveInput().
  107949. */
  107950. addKeyboard(): FlyCameraInputsManager;
  107951. /**
  107952. * Add mouse input support to the input manager.
  107953. * @param touchEnabled Enable touch screen support.
  107954. * @returns the new FlyCameraMouseInput().
  107955. */
  107956. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  107957. }
  107958. }
  107959. declare module BABYLON {
  107960. /**
  107961. * This is a flying camera, designed for 3D movement and rotation in all directions,
  107962. * such as in a 3D Space Shooter or a Flight Simulator.
  107963. */
  107964. export class FlyCamera extends TargetCamera {
  107965. /**
  107966. * Define the collision ellipsoid of the camera.
  107967. * This is helpful for simulating a camera body, like a player's body.
  107968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  107969. */
  107970. ellipsoid: Vector3;
  107971. /**
  107972. * Define an offset for the position of the ellipsoid around the camera.
  107973. * This can be helpful if the camera is attached away from the player's body center,
  107974. * such as at its head.
  107975. */
  107976. ellipsoidOffset: Vector3;
  107977. /**
  107978. * Enable or disable collisions of the camera with the rest of the scene objects.
  107979. */
  107980. checkCollisions: boolean;
  107981. /**
  107982. * Enable or disable gravity on the camera.
  107983. */
  107984. applyGravity: boolean;
  107985. /**
  107986. * Define the current direction the camera is moving to.
  107987. */
  107988. cameraDirection: Vector3;
  107989. /**
  107990. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  107991. * This overrides and empties cameraRotation.
  107992. */
  107993. rotationQuaternion: Quaternion;
  107994. /**
  107995. * Track Roll to maintain the wanted Rolling when looking around.
  107996. */
  107997. _trackRoll: number;
  107998. /**
  107999. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  108000. */
  108001. rollCorrect: number;
  108002. /**
  108003. * Mimic a banked turn, Rolling the camera when Yawing.
  108004. * It's recommended to use rollCorrect = 10 for faster banking correction.
  108005. */
  108006. bankedTurn: boolean;
  108007. /**
  108008. * Limit in radians for how much Roll banking will add. (Default: 90°)
  108009. */
  108010. bankedTurnLimit: number;
  108011. /**
  108012. * Value of 0 disables the banked Roll.
  108013. * Value of 1 is equal to the Yaw angle in radians.
  108014. */
  108015. bankedTurnMultiplier: number;
  108016. /**
  108017. * The inputs manager loads all the input sources, such as keyboard and mouse.
  108018. */
  108019. inputs: FlyCameraInputsManager;
  108020. /**
  108021. * Gets the input sensibility for mouse input.
  108022. * Higher values reduce sensitivity.
  108023. */
  108024. /**
  108025. * Sets the input sensibility for a mouse input.
  108026. * Higher values reduce sensitivity.
  108027. */
  108028. angularSensibility: number;
  108029. /**
  108030. * Get the keys for camera movement forward.
  108031. */
  108032. /**
  108033. * Set the keys for camera movement forward.
  108034. */
  108035. keysForward: number[];
  108036. /**
  108037. * Get the keys for camera movement backward.
  108038. */
  108039. keysBackward: number[];
  108040. /**
  108041. * Get the keys for camera movement up.
  108042. */
  108043. /**
  108044. * Set the keys for camera movement up.
  108045. */
  108046. keysUp: number[];
  108047. /**
  108048. * Get the keys for camera movement down.
  108049. */
  108050. /**
  108051. * Set the keys for camera movement down.
  108052. */
  108053. keysDown: number[];
  108054. /**
  108055. * Get the keys for camera movement left.
  108056. */
  108057. /**
  108058. * Set the keys for camera movement left.
  108059. */
  108060. keysLeft: number[];
  108061. /**
  108062. * Set the keys for camera movement right.
  108063. */
  108064. /**
  108065. * Set the keys for camera movement right.
  108066. */
  108067. keysRight: number[];
  108068. /**
  108069. * Event raised when the camera collides with a mesh in the scene.
  108070. */
  108071. onCollide: (collidedMesh: AbstractMesh) => void;
  108072. private _collider;
  108073. private _needMoveForGravity;
  108074. private _oldPosition;
  108075. private _diffPosition;
  108076. private _newPosition;
  108077. /** @hidden */
  108078. _localDirection: Vector3;
  108079. /** @hidden */
  108080. _transformedDirection: Vector3;
  108081. /**
  108082. * Instantiates a FlyCamera.
  108083. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108084. * such as in a 3D Space Shooter or a Flight Simulator.
  108085. * @param name Define the name of the camera in the scene.
  108086. * @param position Define the starting position of the camera in the scene.
  108087. * @param scene Define the scene the camera belongs to.
  108088. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  108089. */
  108090. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108091. /**
  108092. * Attach a control to the HTML DOM element.
  108093. * @param element Defines the element that listens to the input events.
  108094. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  108095. */
  108096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108097. /**
  108098. * Detach a control from the HTML DOM element.
  108099. * The camera will stop reacting to that input.
  108100. * @param element Defines the element that listens to the input events.
  108101. */
  108102. detachControl(element: HTMLElement): void;
  108103. private _collisionMask;
  108104. /**
  108105. * Get the mask that the camera ignores in collision events.
  108106. */
  108107. /**
  108108. * Set the mask that the camera ignores in collision events.
  108109. */
  108110. collisionMask: number;
  108111. /** @hidden */
  108112. _collideWithWorld(displacement: Vector3): void;
  108113. /** @hidden */
  108114. private _onCollisionPositionChange;
  108115. /** @hidden */
  108116. _checkInputs(): void;
  108117. /** @hidden */
  108118. _decideIfNeedsToMove(): boolean;
  108119. /** @hidden */
  108120. _updatePosition(): void;
  108121. /**
  108122. * Restore the Roll to its target value at the rate specified.
  108123. * @param rate - Higher means slower restoring.
  108124. * @hidden
  108125. */
  108126. restoreRoll(rate: number): void;
  108127. /**
  108128. * Destroy the camera and release the current resources held by it.
  108129. */
  108130. dispose(): void;
  108131. /**
  108132. * Get the current object class name.
  108133. * @returns the class name.
  108134. */
  108135. getClassName(): string;
  108136. }
  108137. }
  108138. declare module BABYLON {
  108139. /**
  108140. * Listen to keyboard events to control the camera.
  108141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108142. */
  108143. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  108144. /**
  108145. * Defines the camera the input is attached to.
  108146. */
  108147. camera: FlyCamera;
  108148. /**
  108149. * The list of keyboard keys used to control the forward move of the camera.
  108150. */
  108151. keysForward: number[];
  108152. /**
  108153. * The list of keyboard keys used to control the backward move of the camera.
  108154. */
  108155. keysBackward: number[];
  108156. /**
  108157. * The list of keyboard keys used to control the forward move of the camera.
  108158. */
  108159. keysUp: number[];
  108160. /**
  108161. * The list of keyboard keys used to control the backward move of the camera.
  108162. */
  108163. keysDown: number[];
  108164. /**
  108165. * The list of keyboard keys used to control the right strafe move of the camera.
  108166. */
  108167. keysRight: number[];
  108168. /**
  108169. * The list of keyboard keys used to control the left strafe move of the camera.
  108170. */
  108171. keysLeft: number[];
  108172. private _keys;
  108173. private _onCanvasBlurObserver;
  108174. private _onKeyboardObserver;
  108175. private _engine;
  108176. private _scene;
  108177. /**
  108178. * Attach the input controls to a specific dom element to get the input from.
  108179. * @param element Defines the element the controls should be listened from
  108180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108181. */
  108182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108183. /**
  108184. * Detach the current controls from the specified dom element.
  108185. * @param element Defines the element to stop listening the inputs from
  108186. */
  108187. detachControl(element: Nullable<HTMLElement>): void;
  108188. /**
  108189. * Gets the class name of the current intput.
  108190. * @returns the class name
  108191. */
  108192. getClassName(): string;
  108193. /** @hidden */
  108194. _onLostFocus(e: FocusEvent): void;
  108195. /**
  108196. * Get the friendly name associated with the input class.
  108197. * @returns the input friendly name
  108198. */
  108199. getSimpleName(): string;
  108200. /**
  108201. * Update the current camera state depending on the inputs that have been used this frame.
  108202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108203. */
  108204. checkInputs(): void;
  108205. }
  108206. }
  108207. declare module BABYLON {
  108208. /**
  108209. * Manage the mouse wheel inputs to control a follow camera.
  108210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108211. */
  108212. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  108213. /**
  108214. * Defines the camera the input is attached to.
  108215. */
  108216. camera: FollowCamera;
  108217. /**
  108218. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  108219. */
  108220. axisControlRadius: boolean;
  108221. /**
  108222. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  108223. */
  108224. axisControlHeight: boolean;
  108225. /**
  108226. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  108227. */
  108228. axisControlRotation: boolean;
  108229. /**
  108230. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  108231. * relation to mouseWheel events.
  108232. */
  108233. wheelPrecision: number;
  108234. /**
  108235. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108236. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108237. */
  108238. wheelDeltaPercentage: number;
  108239. private _wheel;
  108240. private _observer;
  108241. /**
  108242. * Attach the input controls to a specific dom element to get the input from.
  108243. * @param element Defines the element the controls should be listened from
  108244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108245. */
  108246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108247. /**
  108248. * Detach the current controls from the specified dom element.
  108249. * @param element Defines the element to stop listening the inputs from
  108250. */
  108251. detachControl(element: Nullable<HTMLElement>): void;
  108252. /**
  108253. * Gets the class name of the current intput.
  108254. * @returns the class name
  108255. */
  108256. getClassName(): string;
  108257. /**
  108258. * Get the friendly name associated with the input class.
  108259. * @returns the input friendly name
  108260. */
  108261. getSimpleName(): string;
  108262. }
  108263. }
  108264. declare module BABYLON {
  108265. /**
  108266. * Manage the pointers inputs to control an follow camera.
  108267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108268. */
  108269. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  108270. /**
  108271. * Defines the camera the input is attached to.
  108272. */
  108273. camera: FollowCamera;
  108274. /**
  108275. * Gets the class name of the current input.
  108276. * @returns the class name
  108277. */
  108278. getClassName(): string;
  108279. /**
  108280. * Defines the pointer angular sensibility along the X axis or how fast is
  108281. * the camera rotating.
  108282. * A negative number will reverse the axis direction.
  108283. */
  108284. angularSensibilityX: number;
  108285. /**
  108286. * Defines the pointer angular sensibility along the Y axis or how fast is
  108287. * the camera rotating.
  108288. * A negative number will reverse the axis direction.
  108289. */
  108290. angularSensibilityY: number;
  108291. /**
  108292. * Defines the pointer pinch precision or how fast is the camera zooming.
  108293. * A negative number will reverse the axis direction.
  108294. */
  108295. pinchPrecision: number;
  108296. /**
  108297. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108298. * from 0.
  108299. * It defines the percentage of current camera.radius to use as delta when
  108300. * pinch zoom is used.
  108301. */
  108302. pinchDeltaPercentage: number;
  108303. /**
  108304. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  108305. */
  108306. axisXControlRadius: boolean;
  108307. /**
  108308. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  108309. */
  108310. axisXControlHeight: boolean;
  108311. /**
  108312. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  108313. */
  108314. axisXControlRotation: boolean;
  108315. /**
  108316. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  108317. */
  108318. axisYControlRadius: boolean;
  108319. /**
  108320. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  108321. */
  108322. axisYControlHeight: boolean;
  108323. /**
  108324. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  108325. */
  108326. axisYControlRotation: boolean;
  108327. /**
  108328. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  108329. */
  108330. axisPinchControlRadius: boolean;
  108331. /**
  108332. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  108333. */
  108334. axisPinchControlHeight: boolean;
  108335. /**
  108336. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  108337. */
  108338. axisPinchControlRotation: boolean;
  108339. /**
  108340. * Log error messages if basic misconfiguration has occurred.
  108341. */
  108342. warningEnable: boolean;
  108343. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108344. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108345. private _warningCounter;
  108346. private _warning;
  108347. }
  108348. }
  108349. declare module BABYLON {
  108350. /**
  108351. * Default Inputs manager for the FollowCamera.
  108352. * It groups all the default supported inputs for ease of use.
  108353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108354. */
  108355. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  108356. /**
  108357. * Instantiates a new FollowCameraInputsManager.
  108358. * @param camera Defines the camera the inputs belong to
  108359. */
  108360. constructor(camera: FollowCamera);
  108361. /**
  108362. * Add keyboard input support to the input manager.
  108363. * @returns the current input manager
  108364. */
  108365. addKeyboard(): FollowCameraInputsManager;
  108366. /**
  108367. * Add mouse wheel input support to the input manager.
  108368. * @returns the current input manager
  108369. */
  108370. addMouseWheel(): FollowCameraInputsManager;
  108371. /**
  108372. * Add pointers input support to the input manager.
  108373. * @returns the current input manager
  108374. */
  108375. addPointers(): FollowCameraInputsManager;
  108376. /**
  108377. * Add orientation input support to the input manager.
  108378. * @returns the current input manager
  108379. */
  108380. addVRDeviceOrientation(): FollowCameraInputsManager;
  108381. }
  108382. }
  108383. declare module BABYLON {
  108384. /**
  108385. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  108386. * an arc rotate version arcFollowCamera are available.
  108387. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108388. */
  108389. export class FollowCamera extends TargetCamera {
  108390. /**
  108391. * Distance the follow camera should follow an object at
  108392. */
  108393. radius: number;
  108394. /**
  108395. * Minimum allowed distance of the camera to the axis of rotation
  108396. * (The camera can not get closer).
  108397. * This can help limiting how the Camera is able to move in the scene.
  108398. */
  108399. lowerRadiusLimit: Nullable<number>;
  108400. /**
  108401. * Maximum allowed distance of the camera to the axis of rotation
  108402. * (The camera can not get further).
  108403. * This can help limiting how the Camera is able to move in the scene.
  108404. */
  108405. upperRadiusLimit: Nullable<number>;
  108406. /**
  108407. * Define a rotation offset between the camera and the object it follows
  108408. */
  108409. rotationOffset: number;
  108410. /**
  108411. * Minimum allowed angle to camera position relative to target object.
  108412. * This can help limiting how the Camera is able to move in the scene.
  108413. */
  108414. lowerRotationOffsetLimit: Nullable<number>;
  108415. /**
  108416. * Maximum allowed angle to camera position relative to target object.
  108417. * This can help limiting how the Camera is able to move in the scene.
  108418. */
  108419. upperRotationOffsetLimit: Nullable<number>;
  108420. /**
  108421. * Define a height offset between the camera and the object it follows.
  108422. * It can help following an object from the top (like a car chaing a plane)
  108423. */
  108424. heightOffset: number;
  108425. /**
  108426. * Minimum allowed height of camera position relative to target object.
  108427. * This can help limiting how the Camera is able to move in the scene.
  108428. */
  108429. lowerHeightOffsetLimit: Nullable<number>;
  108430. /**
  108431. * Maximum allowed height of camera position relative to target object.
  108432. * This can help limiting how the Camera is able to move in the scene.
  108433. */
  108434. upperHeightOffsetLimit: Nullable<number>;
  108435. /**
  108436. * Define how fast the camera can accelerate to follow it s target.
  108437. */
  108438. cameraAcceleration: number;
  108439. /**
  108440. * Define the speed limit of the camera following an object.
  108441. */
  108442. maxCameraSpeed: number;
  108443. /**
  108444. * Define the target of the camera.
  108445. */
  108446. lockedTarget: Nullable<AbstractMesh>;
  108447. /**
  108448. * Defines the input associated with the camera.
  108449. */
  108450. inputs: FollowCameraInputsManager;
  108451. /**
  108452. * Instantiates the follow camera.
  108453. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108454. * @param name Define the name of the camera in the scene
  108455. * @param position Define the position of the camera
  108456. * @param scene Define the scene the camera belong to
  108457. * @param lockedTarget Define the target of the camera
  108458. */
  108459. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  108460. private _follow;
  108461. /**
  108462. * Attached controls to the current camera.
  108463. * @param element Defines the element the controls should be listened from
  108464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108465. */
  108466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108467. /**
  108468. * Detach the current controls from the camera.
  108469. * The camera will stop reacting to inputs.
  108470. * @param element Defines the element to stop listening the inputs from
  108471. */
  108472. detachControl(element: HTMLElement): void;
  108473. /** @hidden */
  108474. _checkInputs(): void;
  108475. private _checkLimits;
  108476. /**
  108477. * Gets the camera class name.
  108478. * @returns the class name
  108479. */
  108480. getClassName(): string;
  108481. }
  108482. /**
  108483. * Arc Rotate version of the follow camera.
  108484. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  108485. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108486. */
  108487. export class ArcFollowCamera extends TargetCamera {
  108488. /** The longitudinal angle of the camera */
  108489. alpha: number;
  108490. /** The latitudinal angle of the camera */
  108491. beta: number;
  108492. /** The radius of the camera from its target */
  108493. radius: number;
  108494. /** Define the camera target (the messh it should follow) */
  108495. target: Nullable<AbstractMesh>;
  108496. private _cartesianCoordinates;
  108497. /**
  108498. * Instantiates a new ArcFollowCamera
  108499. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108500. * @param name Define the name of the camera
  108501. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  108502. * @param beta Define the rotation angle of the camera around the elevation axis
  108503. * @param radius Define the radius of the camera from its target point
  108504. * @param target Define the target of the camera
  108505. * @param scene Define the scene the camera belongs to
  108506. */
  108507. constructor(name: string,
  108508. /** The longitudinal angle of the camera */
  108509. alpha: number,
  108510. /** The latitudinal angle of the camera */
  108511. beta: number,
  108512. /** The radius of the camera from its target */
  108513. radius: number,
  108514. /** Define the camera target (the messh it should follow) */
  108515. target: Nullable<AbstractMesh>, scene: Scene);
  108516. private _follow;
  108517. /** @hidden */
  108518. _checkInputs(): void;
  108519. /**
  108520. * Returns the class name of the object.
  108521. * It is mostly used internally for serialization purposes.
  108522. */
  108523. getClassName(): string;
  108524. }
  108525. }
  108526. declare module BABYLON {
  108527. /**
  108528. * Manage the keyboard inputs to control the movement of a follow camera.
  108529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108530. */
  108531. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  108532. /**
  108533. * Defines the camera the input is attached to.
  108534. */
  108535. camera: FollowCamera;
  108536. /**
  108537. * Defines the list of key codes associated with the up action (increase heightOffset)
  108538. */
  108539. keysHeightOffsetIncr: number[];
  108540. /**
  108541. * Defines the list of key codes associated with the down action (decrease heightOffset)
  108542. */
  108543. keysHeightOffsetDecr: number[];
  108544. /**
  108545. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  108546. */
  108547. keysHeightOffsetModifierAlt: boolean;
  108548. /**
  108549. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  108550. */
  108551. keysHeightOffsetModifierCtrl: boolean;
  108552. /**
  108553. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  108554. */
  108555. keysHeightOffsetModifierShift: boolean;
  108556. /**
  108557. * Defines the list of key codes associated with the left action (increase rotationOffset)
  108558. */
  108559. keysRotationOffsetIncr: number[];
  108560. /**
  108561. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  108562. */
  108563. keysRotationOffsetDecr: number[];
  108564. /**
  108565. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  108566. */
  108567. keysRotationOffsetModifierAlt: boolean;
  108568. /**
  108569. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  108570. */
  108571. keysRotationOffsetModifierCtrl: boolean;
  108572. /**
  108573. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  108574. */
  108575. keysRotationOffsetModifierShift: boolean;
  108576. /**
  108577. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  108578. */
  108579. keysRadiusIncr: number[];
  108580. /**
  108581. * Defines the list of key codes associated with the zoom-out action (increase radius)
  108582. */
  108583. keysRadiusDecr: number[];
  108584. /**
  108585. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  108586. */
  108587. keysRadiusModifierAlt: boolean;
  108588. /**
  108589. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  108590. */
  108591. keysRadiusModifierCtrl: boolean;
  108592. /**
  108593. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  108594. */
  108595. keysRadiusModifierShift: boolean;
  108596. /**
  108597. * Defines the rate of change of heightOffset.
  108598. */
  108599. heightSensibility: number;
  108600. /**
  108601. * Defines the rate of change of rotationOffset.
  108602. */
  108603. rotationSensibility: number;
  108604. /**
  108605. * Defines the rate of change of radius.
  108606. */
  108607. radiusSensibility: number;
  108608. private _keys;
  108609. private _ctrlPressed;
  108610. private _altPressed;
  108611. private _shiftPressed;
  108612. private _onCanvasBlurObserver;
  108613. private _onKeyboardObserver;
  108614. private _engine;
  108615. private _scene;
  108616. /**
  108617. * Attach the input controls to a specific dom element to get the input from.
  108618. * @param element Defines the element the controls should be listened from
  108619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108620. */
  108621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108622. /**
  108623. * Detach the current controls from the specified dom element.
  108624. * @param element Defines the element to stop listening the inputs from
  108625. */
  108626. detachControl(element: Nullable<HTMLElement>): void;
  108627. /**
  108628. * Update the current camera state depending on the inputs that have been used this frame.
  108629. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108630. */
  108631. checkInputs(): void;
  108632. /**
  108633. * Gets the class name of the current input.
  108634. * @returns the class name
  108635. */
  108636. getClassName(): string;
  108637. /**
  108638. * Get the friendly name associated with the input class.
  108639. * @returns the input friendly name
  108640. */
  108641. getSimpleName(): string;
  108642. /**
  108643. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108644. * allow modification of the heightOffset value.
  108645. */
  108646. private _modifierHeightOffset;
  108647. /**
  108648. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108649. * allow modification of the rotationOffset value.
  108650. */
  108651. private _modifierRotationOffset;
  108652. /**
  108653. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108654. * allow modification of the radius value.
  108655. */
  108656. private _modifierRadius;
  108657. }
  108658. }
  108659. declare module BABYLON {
  108660. interface FreeCameraInputsManager {
  108661. /**
  108662. * @hidden
  108663. */
  108664. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  108665. /**
  108666. * Add orientation input support to the input manager.
  108667. * @returns the current input manager
  108668. */
  108669. addDeviceOrientation(): FreeCameraInputsManager;
  108670. }
  108671. /**
  108672. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  108673. * Screen rotation is taken into account.
  108674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108675. */
  108676. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  108677. private _camera;
  108678. private _screenOrientationAngle;
  108679. private _constantTranform;
  108680. private _screenQuaternion;
  108681. private _alpha;
  108682. private _beta;
  108683. private _gamma;
  108684. /**
  108685. * Can be used to detect if a device orientation sensor is availible on a device
  108686. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  108687. * @returns a promise that will resolve on orientation change
  108688. */
  108689. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  108690. /**
  108691. * @hidden
  108692. */
  108693. _onDeviceOrientationChangedObservable: Observable<void>;
  108694. /**
  108695. * Instantiates a new input
  108696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108697. */
  108698. constructor();
  108699. /**
  108700. * Define the camera controlled by the input.
  108701. */
  108702. camera: FreeCamera;
  108703. /**
  108704. * Attach the input controls to a specific dom element to get the input from.
  108705. * @param element Defines the element the controls should be listened from
  108706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108707. */
  108708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108709. private _orientationChanged;
  108710. private _deviceOrientation;
  108711. /**
  108712. * Detach the current controls from the specified dom element.
  108713. * @param element Defines the element to stop listening the inputs from
  108714. */
  108715. detachControl(element: Nullable<HTMLElement>): void;
  108716. /**
  108717. * Update the current camera state depending on the inputs that have been used this frame.
  108718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108719. */
  108720. checkInputs(): void;
  108721. /**
  108722. * Gets the class name of the current intput.
  108723. * @returns the class name
  108724. */
  108725. getClassName(): string;
  108726. /**
  108727. * Get the friendly name associated with the input class.
  108728. * @returns the input friendly name
  108729. */
  108730. getSimpleName(): string;
  108731. }
  108732. }
  108733. declare module BABYLON {
  108734. /**
  108735. * Manage the gamepad inputs to control a free camera.
  108736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108737. */
  108738. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  108739. /**
  108740. * Define the camera the input is attached to.
  108741. */
  108742. camera: FreeCamera;
  108743. /**
  108744. * Define the Gamepad controlling the input
  108745. */
  108746. gamepad: Nullable<Gamepad>;
  108747. /**
  108748. * Defines the gamepad rotation sensiblity.
  108749. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108750. */
  108751. gamepadAngularSensibility: number;
  108752. /**
  108753. * Defines the gamepad move sensiblity.
  108754. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108755. */
  108756. gamepadMoveSensibility: number;
  108757. private _yAxisScale;
  108758. /**
  108759. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  108760. */
  108761. invertYAxis: boolean;
  108762. private _onGamepadConnectedObserver;
  108763. private _onGamepadDisconnectedObserver;
  108764. private _cameraTransform;
  108765. private _deltaTransform;
  108766. private _vector3;
  108767. private _vector2;
  108768. /**
  108769. * Attach the input controls to a specific dom element to get the input from.
  108770. * @param element Defines the element the controls should be listened from
  108771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108772. */
  108773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108774. /**
  108775. * Detach the current controls from the specified dom element.
  108776. * @param element Defines the element to stop listening the inputs from
  108777. */
  108778. detachControl(element: Nullable<HTMLElement>): void;
  108779. /**
  108780. * Update the current camera state depending on the inputs that have been used this frame.
  108781. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108782. */
  108783. checkInputs(): void;
  108784. /**
  108785. * Gets the class name of the current intput.
  108786. * @returns the class name
  108787. */
  108788. getClassName(): string;
  108789. /**
  108790. * Get the friendly name associated with the input class.
  108791. * @returns the input friendly name
  108792. */
  108793. getSimpleName(): string;
  108794. }
  108795. }
  108796. declare module BABYLON {
  108797. /**
  108798. * Defines the potential axis of a Joystick
  108799. */
  108800. export enum JoystickAxis {
  108801. /** X axis */
  108802. X = 0,
  108803. /** Y axis */
  108804. Y = 1,
  108805. /** Z axis */
  108806. Z = 2
  108807. }
  108808. /**
  108809. * Class used to define virtual joystick (used in touch mode)
  108810. */
  108811. export class VirtualJoystick {
  108812. /**
  108813. * Gets or sets a boolean indicating that left and right values must be inverted
  108814. */
  108815. reverseLeftRight: boolean;
  108816. /**
  108817. * Gets or sets a boolean indicating that up and down values must be inverted
  108818. */
  108819. reverseUpDown: boolean;
  108820. /**
  108821. * Gets the offset value for the position (ie. the change of the position value)
  108822. */
  108823. deltaPosition: Vector3;
  108824. /**
  108825. * Gets a boolean indicating if the virtual joystick was pressed
  108826. */
  108827. pressed: boolean;
  108828. /**
  108829. * Canvas the virtual joystick will render onto, default z-index of this is 5
  108830. */
  108831. static Canvas: Nullable<HTMLCanvasElement>;
  108832. private static _globalJoystickIndex;
  108833. private static vjCanvasContext;
  108834. private static vjCanvasWidth;
  108835. private static vjCanvasHeight;
  108836. private static halfWidth;
  108837. private _action;
  108838. private _axisTargetedByLeftAndRight;
  108839. private _axisTargetedByUpAndDown;
  108840. private _joystickSensibility;
  108841. private _inversedSensibility;
  108842. private _joystickPointerID;
  108843. private _joystickColor;
  108844. private _joystickPointerPos;
  108845. private _joystickPreviousPointerPos;
  108846. private _joystickPointerStartPos;
  108847. private _deltaJoystickVector;
  108848. private _leftJoystick;
  108849. private _touches;
  108850. private _onPointerDownHandlerRef;
  108851. private _onPointerMoveHandlerRef;
  108852. private _onPointerUpHandlerRef;
  108853. private _onResize;
  108854. /**
  108855. * Creates a new virtual joystick
  108856. * @param leftJoystick defines that the joystick is for left hand (false by default)
  108857. */
  108858. constructor(leftJoystick?: boolean);
  108859. /**
  108860. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  108861. * @param newJoystickSensibility defines the new sensibility
  108862. */
  108863. setJoystickSensibility(newJoystickSensibility: number): void;
  108864. private _onPointerDown;
  108865. private _onPointerMove;
  108866. private _onPointerUp;
  108867. /**
  108868. * Change the color of the virtual joystick
  108869. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  108870. */
  108871. setJoystickColor(newColor: string): void;
  108872. /**
  108873. * Defines a callback to call when the joystick is touched
  108874. * @param action defines the callback
  108875. */
  108876. setActionOnTouch(action: () => any): void;
  108877. /**
  108878. * Defines which axis you'd like to control for left & right
  108879. * @param axis defines the axis to use
  108880. */
  108881. setAxisForLeftRight(axis: JoystickAxis): void;
  108882. /**
  108883. * Defines which axis you'd like to control for up & down
  108884. * @param axis defines the axis to use
  108885. */
  108886. setAxisForUpDown(axis: JoystickAxis): void;
  108887. private _drawVirtualJoystick;
  108888. /**
  108889. * Release internal HTML canvas
  108890. */
  108891. releaseCanvas(): void;
  108892. }
  108893. }
  108894. declare module BABYLON {
  108895. interface FreeCameraInputsManager {
  108896. /**
  108897. * Add virtual joystick input support to the input manager.
  108898. * @returns the current input manager
  108899. */
  108900. addVirtualJoystick(): FreeCameraInputsManager;
  108901. }
  108902. /**
  108903. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  108904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108905. */
  108906. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  108907. /**
  108908. * Defines the camera the input is attached to.
  108909. */
  108910. camera: FreeCamera;
  108911. private _leftjoystick;
  108912. private _rightjoystick;
  108913. /**
  108914. * Gets the left stick of the virtual joystick.
  108915. * @returns The virtual Joystick
  108916. */
  108917. getLeftJoystick(): VirtualJoystick;
  108918. /**
  108919. * Gets the right stick of the virtual joystick.
  108920. * @returns The virtual Joystick
  108921. */
  108922. getRightJoystick(): VirtualJoystick;
  108923. /**
  108924. * Update the current camera state depending on the inputs that have been used this frame.
  108925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108926. */
  108927. checkInputs(): void;
  108928. /**
  108929. * Attach the input controls to a specific dom element to get the input from.
  108930. * @param element Defines the element the controls should be listened from
  108931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108932. */
  108933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108934. /**
  108935. * Detach the current controls from the specified dom element.
  108936. * @param element Defines the element to stop listening the inputs from
  108937. */
  108938. detachControl(element: Nullable<HTMLElement>): void;
  108939. /**
  108940. * Gets the class name of the current intput.
  108941. * @returns the class name
  108942. */
  108943. getClassName(): string;
  108944. /**
  108945. * Get the friendly name associated with the input class.
  108946. * @returns the input friendly name
  108947. */
  108948. getSimpleName(): string;
  108949. }
  108950. }
  108951. declare module BABYLON {
  108952. /**
  108953. * This represents a FPS type of camera controlled by touch.
  108954. * This is like a universal camera minus the Gamepad controls.
  108955. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108956. */
  108957. export class TouchCamera extends FreeCamera {
  108958. /**
  108959. * Defines the touch sensibility for rotation.
  108960. * The higher the faster.
  108961. */
  108962. touchAngularSensibility: number;
  108963. /**
  108964. * Defines the touch sensibility for move.
  108965. * The higher the faster.
  108966. */
  108967. touchMoveSensibility: number;
  108968. /**
  108969. * Instantiates a new touch camera.
  108970. * This represents a FPS type of camera controlled by touch.
  108971. * This is like a universal camera minus the Gamepad controls.
  108972. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108973. * @param name Define the name of the camera in the scene
  108974. * @param position Define the start position of the camera in the scene
  108975. * @param scene Define the scene the camera belongs to
  108976. */
  108977. constructor(name: string, position: Vector3, scene: Scene);
  108978. /**
  108979. * Gets the current object class name.
  108980. * @return the class name
  108981. */
  108982. getClassName(): string;
  108983. /** @hidden */
  108984. _setupInputs(): void;
  108985. }
  108986. }
  108987. declare module BABYLON {
  108988. /**
  108989. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  108990. * being tilted forward or back and left or right.
  108991. */
  108992. export class DeviceOrientationCamera extends FreeCamera {
  108993. private _initialQuaternion;
  108994. private _quaternionCache;
  108995. private _tmpDragQuaternion;
  108996. private _disablePointerInputWhenUsingDeviceOrientation;
  108997. /**
  108998. * Creates a new device orientation camera
  108999. * @param name The name of the camera
  109000. * @param position The start position camera
  109001. * @param scene The scene the camera belongs to
  109002. */
  109003. constructor(name: string, position: Vector3, scene: Scene);
  109004. /**
  109005. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  109006. */
  109007. disablePointerInputWhenUsingDeviceOrientation: boolean;
  109008. private _dragFactor;
  109009. /**
  109010. * Enabled turning on the y axis when the orientation sensor is active
  109011. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  109012. */
  109013. enableHorizontalDragging(dragFactor?: number): void;
  109014. /**
  109015. * Gets the current instance class name ("DeviceOrientationCamera").
  109016. * This helps avoiding instanceof at run time.
  109017. * @returns the class name
  109018. */
  109019. getClassName(): string;
  109020. /**
  109021. * @hidden
  109022. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  109023. */
  109024. _checkInputs(): void;
  109025. /**
  109026. * Reset the camera to its default orientation on the specified axis only.
  109027. * @param axis The axis to reset
  109028. */
  109029. resetToCurrentRotation(axis?: Axis): void;
  109030. }
  109031. }
  109032. declare module BABYLON {
  109033. /**
  109034. * Defines supported buttons for XBox360 compatible gamepads
  109035. */
  109036. export enum Xbox360Button {
  109037. /** A */
  109038. A = 0,
  109039. /** B */
  109040. B = 1,
  109041. /** X */
  109042. X = 2,
  109043. /** Y */
  109044. Y = 3,
  109045. /** Start */
  109046. Start = 4,
  109047. /** Back */
  109048. Back = 5,
  109049. /** Left button */
  109050. LB = 6,
  109051. /** Right button */
  109052. RB = 7,
  109053. /** Left stick */
  109054. LeftStick = 8,
  109055. /** Right stick */
  109056. RightStick = 9
  109057. }
  109058. /** Defines values for XBox360 DPad */
  109059. export enum Xbox360Dpad {
  109060. /** Up */
  109061. Up = 0,
  109062. /** Down */
  109063. Down = 1,
  109064. /** Left */
  109065. Left = 2,
  109066. /** Right */
  109067. Right = 3
  109068. }
  109069. /**
  109070. * Defines a XBox360 gamepad
  109071. */
  109072. export class Xbox360Pad extends Gamepad {
  109073. private _leftTrigger;
  109074. private _rightTrigger;
  109075. private _onlefttriggerchanged;
  109076. private _onrighttriggerchanged;
  109077. private _onbuttondown;
  109078. private _onbuttonup;
  109079. private _ondpaddown;
  109080. private _ondpadup;
  109081. /** Observable raised when a button is pressed */
  109082. onButtonDownObservable: Observable<Xbox360Button>;
  109083. /** Observable raised when a button is released */
  109084. onButtonUpObservable: Observable<Xbox360Button>;
  109085. /** Observable raised when a pad is pressed */
  109086. onPadDownObservable: Observable<Xbox360Dpad>;
  109087. /** Observable raised when a pad is released */
  109088. onPadUpObservable: Observable<Xbox360Dpad>;
  109089. private _buttonA;
  109090. private _buttonB;
  109091. private _buttonX;
  109092. private _buttonY;
  109093. private _buttonBack;
  109094. private _buttonStart;
  109095. private _buttonLB;
  109096. private _buttonRB;
  109097. private _buttonLeftStick;
  109098. private _buttonRightStick;
  109099. private _dPadUp;
  109100. private _dPadDown;
  109101. private _dPadLeft;
  109102. private _dPadRight;
  109103. private _isXboxOnePad;
  109104. /**
  109105. * Creates a new XBox360 gamepad object
  109106. * @param id defines the id of this gamepad
  109107. * @param index defines its index
  109108. * @param gamepad defines the internal HTML gamepad object
  109109. * @param xboxOne defines if it is a XBox One gamepad
  109110. */
  109111. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  109112. /**
  109113. * Defines the callback to call when left trigger is pressed
  109114. * @param callback defines the callback to use
  109115. */
  109116. onlefttriggerchanged(callback: (value: number) => void): void;
  109117. /**
  109118. * Defines the callback to call when right trigger is pressed
  109119. * @param callback defines the callback to use
  109120. */
  109121. onrighttriggerchanged(callback: (value: number) => void): void;
  109122. /**
  109123. * Gets the left trigger value
  109124. */
  109125. /**
  109126. * Sets the left trigger value
  109127. */
  109128. leftTrigger: number;
  109129. /**
  109130. * Gets the right trigger value
  109131. */
  109132. /**
  109133. * Sets the right trigger value
  109134. */
  109135. rightTrigger: number;
  109136. /**
  109137. * Defines the callback to call when a button is pressed
  109138. * @param callback defines the callback to use
  109139. */
  109140. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  109141. /**
  109142. * Defines the callback to call when a button is released
  109143. * @param callback defines the callback to use
  109144. */
  109145. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  109146. /**
  109147. * Defines the callback to call when a pad is pressed
  109148. * @param callback defines the callback to use
  109149. */
  109150. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  109151. /**
  109152. * Defines the callback to call when a pad is released
  109153. * @param callback defines the callback to use
  109154. */
  109155. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  109156. private _setButtonValue;
  109157. private _setDPadValue;
  109158. /**
  109159. * Gets the value of the `A` button
  109160. */
  109161. /**
  109162. * Sets the value of the `A` button
  109163. */
  109164. buttonA: number;
  109165. /**
  109166. * Gets the value of the `B` button
  109167. */
  109168. /**
  109169. * Sets the value of the `B` button
  109170. */
  109171. buttonB: number;
  109172. /**
  109173. * Gets the value of the `X` button
  109174. */
  109175. /**
  109176. * Sets the value of the `X` button
  109177. */
  109178. buttonX: number;
  109179. /**
  109180. * Gets the value of the `Y` button
  109181. */
  109182. /**
  109183. * Sets the value of the `Y` button
  109184. */
  109185. buttonY: number;
  109186. /**
  109187. * Gets the value of the `Start` button
  109188. */
  109189. /**
  109190. * Sets the value of the `Start` button
  109191. */
  109192. buttonStart: number;
  109193. /**
  109194. * Gets the value of the `Back` button
  109195. */
  109196. /**
  109197. * Sets the value of the `Back` button
  109198. */
  109199. buttonBack: number;
  109200. /**
  109201. * Gets the value of the `Left` button
  109202. */
  109203. /**
  109204. * Sets the value of the `Left` button
  109205. */
  109206. buttonLB: number;
  109207. /**
  109208. * Gets the value of the `Right` button
  109209. */
  109210. /**
  109211. * Sets the value of the `Right` button
  109212. */
  109213. buttonRB: number;
  109214. /**
  109215. * Gets the value of the Left joystick
  109216. */
  109217. /**
  109218. * Sets the value of the Left joystick
  109219. */
  109220. buttonLeftStick: number;
  109221. /**
  109222. * Gets the value of the Right joystick
  109223. */
  109224. /**
  109225. * Sets the value of the Right joystick
  109226. */
  109227. buttonRightStick: number;
  109228. /**
  109229. * Gets the value of D-pad up
  109230. */
  109231. /**
  109232. * Sets the value of D-pad up
  109233. */
  109234. dPadUp: number;
  109235. /**
  109236. * Gets the value of D-pad down
  109237. */
  109238. /**
  109239. * Sets the value of D-pad down
  109240. */
  109241. dPadDown: number;
  109242. /**
  109243. * Gets the value of D-pad left
  109244. */
  109245. /**
  109246. * Sets the value of D-pad left
  109247. */
  109248. dPadLeft: number;
  109249. /**
  109250. * Gets the value of D-pad right
  109251. */
  109252. /**
  109253. * Sets the value of D-pad right
  109254. */
  109255. dPadRight: number;
  109256. /**
  109257. * Force the gamepad to synchronize with device values
  109258. */
  109259. update(): void;
  109260. /**
  109261. * Disposes the gamepad
  109262. */
  109263. dispose(): void;
  109264. }
  109265. }
  109266. declare module BABYLON {
  109267. /**
  109268. * Defines supported buttons for DualShock compatible gamepads
  109269. */
  109270. export enum DualShockButton {
  109271. /** Cross */
  109272. Cross = 0,
  109273. /** Circle */
  109274. Circle = 1,
  109275. /** Square */
  109276. Square = 2,
  109277. /** Triangle */
  109278. Triangle = 3,
  109279. /** Options */
  109280. Options = 4,
  109281. /** Share */
  109282. Share = 5,
  109283. /** L1 */
  109284. L1 = 6,
  109285. /** R1 */
  109286. R1 = 7,
  109287. /** Left stick */
  109288. LeftStick = 8,
  109289. /** Right stick */
  109290. RightStick = 9
  109291. }
  109292. /** Defines values for DualShock DPad */
  109293. export enum DualShockDpad {
  109294. /** Up */
  109295. Up = 0,
  109296. /** Down */
  109297. Down = 1,
  109298. /** Left */
  109299. Left = 2,
  109300. /** Right */
  109301. Right = 3
  109302. }
  109303. /**
  109304. * Defines a DualShock gamepad
  109305. */
  109306. export class DualShockPad extends Gamepad {
  109307. private _leftTrigger;
  109308. private _rightTrigger;
  109309. private _onlefttriggerchanged;
  109310. private _onrighttriggerchanged;
  109311. private _onbuttondown;
  109312. private _onbuttonup;
  109313. private _ondpaddown;
  109314. private _ondpadup;
  109315. /** Observable raised when a button is pressed */
  109316. onButtonDownObservable: Observable<DualShockButton>;
  109317. /** Observable raised when a button is released */
  109318. onButtonUpObservable: Observable<DualShockButton>;
  109319. /** Observable raised when a pad is pressed */
  109320. onPadDownObservable: Observable<DualShockDpad>;
  109321. /** Observable raised when a pad is released */
  109322. onPadUpObservable: Observable<DualShockDpad>;
  109323. private _buttonCross;
  109324. private _buttonCircle;
  109325. private _buttonSquare;
  109326. private _buttonTriangle;
  109327. private _buttonShare;
  109328. private _buttonOptions;
  109329. private _buttonL1;
  109330. private _buttonR1;
  109331. private _buttonLeftStick;
  109332. private _buttonRightStick;
  109333. private _dPadUp;
  109334. private _dPadDown;
  109335. private _dPadLeft;
  109336. private _dPadRight;
  109337. /**
  109338. * Creates a new DualShock gamepad object
  109339. * @param id defines the id of this gamepad
  109340. * @param index defines its index
  109341. * @param gamepad defines the internal HTML gamepad object
  109342. */
  109343. constructor(id: string, index: number, gamepad: any);
  109344. /**
  109345. * Defines the callback to call when left trigger is pressed
  109346. * @param callback defines the callback to use
  109347. */
  109348. onlefttriggerchanged(callback: (value: number) => void): void;
  109349. /**
  109350. * Defines the callback to call when right trigger is pressed
  109351. * @param callback defines the callback to use
  109352. */
  109353. onrighttriggerchanged(callback: (value: number) => void): void;
  109354. /**
  109355. * Gets the left trigger value
  109356. */
  109357. /**
  109358. * Sets the left trigger value
  109359. */
  109360. leftTrigger: number;
  109361. /**
  109362. * Gets the right trigger value
  109363. */
  109364. /**
  109365. * Sets the right trigger value
  109366. */
  109367. rightTrigger: number;
  109368. /**
  109369. * Defines the callback to call when a button is pressed
  109370. * @param callback defines the callback to use
  109371. */
  109372. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  109373. /**
  109374. * Defines the callback to call when a button is released
  109375. * @param callback defines the callback to use
  109376. */
  109377. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  109378. /**
  109379. * Defines the callback to call when a pad is pressed
  109380. * @param callback defines the callback to use
  109381. */
  109382. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  109383. /**
  109384. * Defines the callback to call when a pad is released
  109385. * @param callback defines the callback to use
  109386. */
  109387. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  109388. private _setButtonValue;
  109389. private _setDPadValue;
  109390. /**
  109391. * Gets the value of the `Cross` button
  109392. */
  109393. /**
  109394. * Sets the value of the `Cross` button
  109395. */
  109396. buttonCross: number;
  109397. /**
  109398. * Gets the value of the `Circle` button
  109399. */
  109400. /**
  109401. * Sets the value of the `Circle` button
  109402. */
  109403. buttonCircle: number;
  109404. /**
  109405. * Gets the value of the `Square` button
  109406. */
  109407. /**
  109408. * Sets the value of the `Square` button
  109409. */
  109410. buttonSquare: number;
  109411. /**
  109412. * Gets the value of the `Triangle` button
  109413. */
  109414. /**
  109415. * Sets the value of the `Triangle` button
  109416. */
  109417. buttonTriangle: number;
  109418. /**
  109419. * Gets the value of the `Options` button
  109420. */
  109421. /**
  109422. * Sets the value of the `Options` button
  109423. */
  109424. buttonOptions: number;
  109425. /**
  109426. * Gets the value of the `Share` button
  109427. */
  109428. /**
  109429. * Sets the value of the `Share` button
  109430. */
  109431. buttonShare: number;
  109432. /**
  109433. * Gets the value of the `L1` button
  109434. */
  109435. /**
  109436. * Sets the value of the `L1` button
  109437. */
  109438. buttonL1: number;
  109439. /**
  109440. * Gets the value of the `R1` button
  109441. */
  109442. /**
  109443. * Sets the value of the `R1` button
  109444. */
  109445. buttonR1: number;
  109446. /**
  109447. * Gets the value of the Left joystick
  109448. */
  109449. /**
  109450. * Sets the value of the Left joystick
  109451. */
  109452. buttonLeftStick: number;
  109453. /**
  109454. * Gets the value of the Right joystick
  109455. */
  109456. /**
  109457. * Sets the value of the Right joystick
  109458. */
  109459. buttonRightStick: number;
  109460. /**
  109461. * Gets the value of D-pad up
  109462. */
  109463. /**
  109464. * Sets the value of D-pad up
  109465. */
  109466. dPadUp: number;
  109467. /**
  109468. * Gets the value of D-pad down
  109469. */
  109470. /**
  109471. * Sets the value of D-pad down
  109472. */
  109473. dPadDown: number;
  109474. /**
  109475. * Gets the value of D-pad left
  109476. */
  109477. /**
  109478. * Sets the value of D-pad left
  109479. */
  109480. dPadLeft: number;
  109481. /**
  109482. * Gets the value of D-pad right
  109483. */
  109484. /**
  109485. * Sets the value of D-pad right
  109486. */
  109487. dPadRight: number;
  109488. /**
  109489. * Force the gamepad to synchronize with device values
  109490. */
  109491. update(): void;
  109492. /**
  109493. * Disposes the gamepad
  109494. */
  109495. dispose(): void;
  109496. }
  109497. }
  109498. declare module BABYLON {
  109499. /**
  109500. * Manager for handling gamepads
  109501. */
  109502. export class GamepadManager {
  109503. private _scene?;
  109504. private _babylonGamepads;
  109505. private _oneGamepadConnected;
  109506. /** @hidden */
  109507. _isMonitoring: boolean;
  109508. private _gamepadEventSupported;
  109509. private _gamepadSupport;
  109510. /**
  109511. * observable to be triggered when the gamepad controller has been connected
  109512. */
  109513. onGamepadConnectedObservable: Observable<Gamepad>;
  109514. /**
  109515. * observable to be triggered when the gamepad controller has been disconnected
  109516. */
  109517. onGamepadDisconnectedObservable: Observable<Gamepad>;
  109518. private _onGamepadConnectedEvent;
  109519. private _onGamepadDisconnectedEvent;
  109520. /**
  109521. * Initializes the gamepad manager
  109522. * @param _scene BabylonJS scene
  109523. */
  109524. constructor(_scene?: Scene | undefined);
  109525. /**
  109526. * The gamepads in the game pad manager
  109527. */
  109528. readonly gamepads: Gamepad[];
  109529. /**
  109530. * Get the gamepad controllers based on type
  109531. * @param type The type of gamepad controller
  109532. * @returns Nullable gamepad
  109533. */
  109534. getGamepadByType(type?: number): Nullable<Gamepad>;
  109535. /**
  109536. * Disposes the gamepad manager
  109537. */
  109538. dispose(): void;
  109539. private _addNewGamepad;
  109540. private _startMonitoringGamepads;
  109541. private _stopMonitoringGamepads;
  109542. /** @hidden */
  109543. _checkGamepadsStatus(): void;
  109544. private _updateGamepadObjects;
  109545. }
  109546. }
  109547. declare module BABYLON {
  109548. interface Scene {
  109549. /** @hidden */
  109550. _gamepadManager: Nullable<GamepadManager>;
  109551. /**
  109552. * Gets the gamepad manager associated with the scene
  109553. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  109554. */
  109555. gamepadManager: GamepadManager;
  109556. }
  109557. /**
  109558. * Interface representing a free camera inputs manager
  109559. */
  109560. interface FreeCameraInputsManager {
  109561. /**
  109562. * Adds gamepad input support to the FreeCameraInputsManager.
  109563. * @returns the FreeCameraInputsManager
  109564. */
  109565. addGamepad(): FreeCameraInputsManager;
  109566. }
  109567. /**
  109568. * Interface representing an arc rotate camera inputs manager
  109569. */
  109570. interface ArcRotateCameraInputsManager {
  109571. /**
  109572. * Adds gamepad input support to the ArcRotateCamera InputManager.
  109573. * @returns the camera inputs manager
  109574. */
  109575. addGamepad(): ArcRotateCameraInputsManager;
  109576. }
  109577. /**
  109578. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  109579. */
  109580. export class GamepadSystemSceneComponent implements ISceneComponent {
  109581. /**
  109582. * The component name helpfull to identify the component in the list of scene components.
  109583. */
  109584. readonly name: string;
  109585. /**
  109586. * The scene the component belongs to.
  109587. */
  109588. scene: Scene;
  109589. /**
  109590. * Creates a new instance of the component for the given scene
  109591. * @param scene Defines the scene to register the component in
  109592. */
  109593. constructor(scene: Scene);
  109594. /**
  109595. * Registers the component in a given scene
  109596. */
  109597. register(): void;
  109598. /**
  109599. * Rebuilds the elements related to this component in case of
  109600. * context lost for instance.
  109601. */
  109602. rebuild(): void;
  109603. /**
  109604. * Disposes the component and the associated ressources
  109605. */
  109606. dispose(): void;
  109607. private _beforeCameraUpdate;
  109608. }
  109609. }
  109610. declare module BABYLON {
  109611. /**
  109612. * 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,
  109613. * which still works and will still be found in many Playgrounds.
  109614. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109615. */
  109616. export class UniversalCamera extends TouchCamera {
  109617. /**
  109618. * Defines the gamepad rotation sensiblity.
  109619. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109620. */
  109621. gamepadAngularSensibility: number;
  109622. /**
  109623. * Defines the gamepad move sensiblity.
  109624. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109625. */
  109626. gamepadMoveSensibility: number;
  109627. /**
  109628. * 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,
  109629. * which still works and will still be found in many Playgrounds.
  109630. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109631. * @param name Define the name of the camera in the scene
  109632. * @param position Define the start position of the camera in the scene
  109633. * @param scene Define the scene the camera belongs to
  109634. */
  109635. constructor(name: string, position: Vector3, scene: Scene);
  109636. /**
  109637. * Gets the current object class name.
  109638. * @return the class name
  109639. */
  109640. getClassName(): string;
  109641. }
  109642. }
  109643. declare module BABYLON {
  109644. /**
  109645. * This represents a FPS type of camera. This is only here for back compat purpose.
  109646. * Please use the UniversalCamera instead as both are identical.
  109647. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109648. */
  109649. export class GamepadCamera extends UniversalCamera {
  109650. /**
  109651. * Instantiates a new Gamepad Camera
  109652. * This represents a FPS type of camera. This is only here for back compat purpose.
  109653. * Please use the UniversalCamera instead as both are identical.
  109654. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109655. * @param name Define the name of the camera in the scene
  109656. * @param position Define the start position of the camera in the scene
  109657. * @param scene Define the scene the camera belongs to
  109658. */
  109659. constructor(name: string, position: Vector3, scene: Scene);
  109660. /**
  109661. * Gets the current object class name.
  109662. * @return the class name
  109663. */
  109664. getClassName(): string;
  109665. }
  109666. }
  109667. declare module BABYLON {
  109668. /** @hidden */
  109669. export var passPixelShader: {
  109670. name: string;
  109671. shader: string;
  109672. };
  109673. }
  109674. declare module BABYLON {
  109675. /** @hidden */
  109676. export var passCubePixelShader: {
  109677. name: string;
  109678. shader: string;
  109679. };
  109680. }
  109681. declare module BABYLON {
  109682. /**
  109683. * PassPostProcess which produces an output the same as it's input
  109684. */
  109685. export class PassPostProcess extends PostProcess {
  109686. /**
  109687. * Creates the PassPostProcess
  109688. * @param name The name of the effect.
  109689. * @param options The required width/height ratio to downsize to before computing the render pass.
  109690. * @param camera The camera to apply the render pass to.
  109691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109692. * @param engine The engine which the post process will be applied. (default: current engine)
  109693. * @param reusable If the post process can be reused on the same frame. (default: false)
  109694. * @param textureType The type of texture to be used when performing the post processing.
  109695. * @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)
  109696. */
  109697. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109698. }
  109699. /**
  109700. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  109701. */
  109702. export class PassCubePostProcess extends PostProcess {
  109703. private _face;
  109704. /**
  109705. * Gets or sets the cube face to display.
  109706. * * 0 is +X
  109707. * * 1 is -X
  109708. * * 2 is +Y
  109709. * * 3 is -Y
  109710. * * 4 is +Z
  109711. * * 5 is -Z
  109712. */
  109713. face: number;
  109714. /**
  109715. * Creates the PassCubePostProcess
  109716. * @param name The name of the effect.
  109717. * @param options The required width/height ratio to downsize to before computing the render pass.
  109718. * @param camera The camera to apply the render pass to.
  109719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109720. * @param engine The engine which the post process will be applied. (default: current engine)
  109721. * @param reusable If the post process can be reused on the same frame. (default: false)
  109722. * @param textureType The type of texture to be used when performing the post processing.
  109723. * @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)
  109724. */
  109725. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109726. }
  109727. }
  109728. declare module BABYLON {
  109729. /** @hidden */
  109730. export var anaglyphPixelShader: {
  109731. name: string;
  109732. shader: string;
  109733. };
  109734. }
  109735. declare module BABYLON {
  109736. /**
  109737. * Postprocess used to generate anaglyphic rendering
  109738. */
  109739. export class AnaglyphPostProcess extends PostProcess {
  109740. private _passedProcess;
  109741. /**
  109742. * Creates a new AnaglyphPostProcess
  109743. * @param name defines postprocess name
  109744. * @param options defines creation options or target ratio scale
  109745. * @param rigCameras defines cameras using this postprocess
  109746. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  109747. * @param engine defines hosting engine
  109748. * @param reusable defines if the postprocess will be reused multiple times per frame
  109749. */
  109750. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  109751. }
  109752. }
  109753. declare module BABYLON {
  109754. /**
  109755. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  109756. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109757. */
  109758. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  109759. /**
  109760. * Creates a new AnaglyphArcRotateCamera
  109761. * @param name defines camera name
  109762. * @param alpha defines alpha angle (in radians)
  109763. * @param beta defines beta angle (in radians)
  109764. * @param radius defines radius
  109765. * @param target defines camera target
  109766. * @param interaxialDistance defines distance between each color axis
  109767. * @param scene defines the hosting scene
  109768. */
  109769. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  109770. /**
  109771. * Gets camera class name
  109772. * @returns AnaglyphArcRotateCamera
  109773. */
  109774. getClassName(): string;
  109775. }
  109776. }
  109777. declare module BABYLON {
  109778. /**
  109779. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  109780. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109781. */
  109782. export class AnaglyphFreeCamera extends FreeCamera {
  109783. /**
  109784. * Creates a new AnaglyphFreeCamera
  109785. * @param name defines camera name
  109786. * @param position defines initial position
  109787. * @param interaxialDistance defines distance between each color axis
  109788. * @param scene defines the hosting scene
  109789. */
  109790. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109791. /**
  109792. * Gets camera class name
  109793. * @returns AnaglyphFreeCamera
  109794. */
  109795. getClassName(): string;
  109796. }
  109797. }
  109798. declare module BABYLON {
  109799. /**
  109800. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  109801. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109802. */
  109803. export class AnaglyphGamepadCamera extends GamepadCamera {
  109804. /**
  109805. * Creates a new AnaglyphGamepadCamera
  109806. * @param name defines camera name
  109807. * @param position defines initial position
  109808. * @param interaxialDistance defines distance between each color axis
  109809. * @param scene defines the hosting scene
  109810. */
  109811. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109812. /**
  109813. * Gets camera class name
  109814. * @returns AnaglyphGamepadCamera
  109815. */
  109816. getClassName(): string;
  109817. }
  109818. }
  109819. declare module BABYLON {
  109820. /**
  109821. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  109822. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109823. */
  109824. export class AnaglyphUniversalCamera extends UniversalCamera {
  109825. /**
  109826. * Creates a new AnaglyphUniversalCamera
  109827. * @param name defines camera name
  109828. * @param position defines initial position
  109829. * @param interaxialDistance defines distance between each color axis
  109830. * @param scene defines the hosting scene
  109831. */
  109832. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109833. /**
  109834. * Gets camera class name
  109835. * @returns AnaglyphUniversalCamera
  109836. */
  109837. getClassName(): string;
  109838. }
  109839. }
  109840. declare module BABYLON {
  109841. /** @hidden */
  109842. export var stereoscopicInterlacePixelShader: {
  109843. name: string;
  109844. shader: string;
  109845. };
  109846. }
  109847. declare module BABYLON {
  109848. /**
  109849. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  109850. */
  109851. export class StereoscopicInterlacePostProcess extends PostProcess {
  109852. private _stepSize;
  109853. private _passedProcess;
  109854. /**
  109855. * Initializes a StereoscopicInterlacePostProcess
  109856. * @param name The name of the effect.
  109857. * @param rigCameras The rig cameras to be appled to the post process
  109858. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  109859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109860. * @param engine The engine which the post process will be applied. (default: current engine)
  109861. * @param reusable If the post process can be reused on the same frame. (default: false)
  109862. */
  109863. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109864. }
  109865. }
  109866. declare module BABYLON {
  109867. /**
  109868. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  109869. * @see http://doc.babylonjs.com/features/cameras
  109870. */
  109871. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  109872. /**
  109873. * Creates a new StereoscopicArcRotateCamera
  109874. * @param name defines camera name
  109875. * @param alpha defines alpha angle (in radians)
  109876. * @param beta defines beta angle (in radians)
  109877. * @param radius defines radius
  109878. * @param target defines camera target
  109879. * @param interaxialDistance defines distance between each color axis
  109880. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  109881. * @param scene defines the hosting scene
  109882. */
  109883. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  109884. /**
  109885. * Gets camera class name
  109886. * @returns StereoscopicArcRotateCamera
  109887. */
  109888. getClassName(): string;
  109889. }
  109890. }
  109891. declare module BABYLON {
  109892. /**
  109893. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  109894. * @see http://doc.babylonjs.com/features/cameras
  109895. */
  109896. export class StereoscopicFreeCamera extends FreeCamera {
  109897. /**
  109898. * Creates a new StereoscopicFreeCamera
  109899. * @param name defines camera name
  109900. * @param position defines initial position
  109901. * @param interaxialDistance defines distance between each color axis
  109902. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  109903. * @param scene defines the hosting scene
  109904. */
  109905. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  109906. /**
  109907. * Gets camera class name
  109908. * @returns StereoscopicFreeCamera
  109909. */
  109910. getClassName(): string;
  109911. }
  109912. }
  109913. declare module BABYLON {
  109914. /**
  109915. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  109916. * @see http://doc.babylonjs.com/features/cameras
  109917. */
  109918. export class StereoscopicGamepadCamera extends GamepadCamera {
  109919. /**
  109920. * Creates a new StereoscopicGamepadCamera
  109921. * @param name defines camera name
  109922. * @param position defines initial position
  109923. * @param interaxialDistance defines distance between each color axis
  109924. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  109925. * @param scene defines the hosting scene
  109926. */
  109927. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  109928. /**
  109929. * Gets camera class name
  109930. * @returns StereoscopicGamepadCamera
  109931. */
  109932. getClassName(): string;
  109933. }
  109934. }
  109935. declare module BABYLON {
  109936. /**
  109937. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  109938. * @see http://doc.babylonjs.com/features/cameras
  109939. */
  109940. export class StereoscopicUniversalCamera extends UniversalCamera {
  109941. /**
  109942. * Creates a new StereoscopicUniversalCamera
  109943. * @param name defines camera name
  109944. * @param position defines initial position
  109945. * @param interaxialDistance defines distance between each color axis
  109946. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  109947. * @param scene defines the hosting scene
  109948. */
  109949. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  109950. /**
  109951. * Gets camera class name
  109952. * @returns StereoscopicUniversalCamera
  109953. */
  109954. getClassName(): string;
  109955. }
  109956. }
  109957. declare module BABYLON {
  109958. /**
  109959. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  109960. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  109961. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  109962. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  109963. */
  109964. export class VirtualJoysticksCamera extends FreeCamera {
  109965. /**
  109966. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  109967. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  109968. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  109969. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  109970. * @param name Define the name of the camera in the scene
  109971. * @param position Define the start position of the camera in the scene
  109972. * @param scene Define the scene the camera belongs to
  109973. */
  109974. constructor(name: string, position: Vector3, scene: Scene);
  109975. /**
  109976. * Gets the current object class name.
  109977. * @return the class name
  109978. */
  109979. getClassName(): string;
  109980. }
  109981. }
  109982. declare module BABYLON {
  109983. /**
  109984. * This represents all the required metrics to create a VR camera.
  109985. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  109986. */
  109987. export class VRCameraMetrics {
  109988. /**
  109989. * Define the horizontal resolution off the screen.
  109990. */
  109991. hResolution: number;
  109992. /**
  109993. * Define the vertical resolution off the screen.
  109994. */
  109995. vResolution: number;
  109996. /**
  109997. * Define the horizontal screen size.
  109998. */
  109999. hScreenSize: number;
  110000. /**
  110001. * Define the vertical screen size.
  110002. */
  110003. vScreenSize: number;
  110004. /**
  110005. * Define the vertical screen center position.
  110006. */
  110007. vScreenCenter: number;
  110008. /**
  110009. * Define the distance of the eyes to the screen.
  110010. */
  110011. eyeToScreenDistance: number;
  110012. /**
  110013. * Define the distance between both lenses
  110014. */
  110015. lensSeparationDistance: number;
  110016. /**
  110017. * Define the distance between both viewer's eyes.
  110018. */
  110019. interpupillaryDistance: number;
  110020. /**
  110021. * Define the distortion factor of the VR postprocess.
  110022. * Please, touch with care.
  110023. */
  110024. distortionK: number[];
  110025. /**
  110026. * Define the chromatic aberration correction factors for the VR post process.
  110027. */
  110028. chromaAbCorrection: number[];
  110029. /**
  110030. * Define the scale factor of the post process.
  110031. * The smaller the better but the slower.
  110032. */
  110033. postProcessScaleFactor: number;
  110034. /**
  110035. * Define an offset for the lens center.
  110036. */
  110037. lensCenterOffset: number;
  110038. /**
  110039. * Define if the current vr camera should compensate the distortion of the lense or not.
  110040. */
  110041. compensateDistortion: boolean;
  110042. /**
  110043. * Defines if multiview should be enabled when rendering (Default: false)
  110044. */
  110045. multiviewEnabled: boolean;
  110046. /**
  110047. * Gets the rendering aspect ratio based on the provided resolutions.
  110048. */
  110049. readonly aspectRatio: number;
  110050. /**
  110051. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  110052. */
  110053. readonly aspectRatioFov: number;
  110054. /**
  110055. * @hidden
  110056. */
  110057. readonly leftHMatrix: Matrix;
  110058. /**
  110059. * @hidden
  110060. */
  110061. readonly rightHMatrix: Matrix;
  110062. /**
  110063. * @hidden
  110064. */
  110065. readonly leftPreViewMatrix: Matrix;
  110066. /**
  110067. * @hidden
  110068. */
  110069. readonly rightPreViewMatrix: Matrix;
  110070. /**
  110071. * Get the default VRMetrics based on the most generic setup.
  110072. * @returns the default vr metrics
  110073. */
  110074. static GetDefault(): VRCameraMetrics;
  110075. }
  110076. }
  110077. declare module BABYLON {
  110078. /** @hidden */
  110079. export var vrDistortionCorrectionPixelShader: {
  110080. name: string;
  110081. shader: string;
  110082. };
  110083. }
  110084. declare module BABYLON {
  110085. /**
  110086. * VRDistortionCorrectionPostProcess used for mobile VR
  110087. */
  110088. export class VRDistortionCorrectionPostProcess extends PostProcess {
  110089. private _isRightEye;
  110090. private _distortionFactors;
  110091. private _postProcessScaleFactor;
  110092. private _lensCenterOffset;
  110093. private _scaleIn;
  110094. private _scaleFactor;
  110095. private _lensCenter;
  110096. /**
  110097. * Initializes the VRDistortionCorrectionPostProcess
  110098. * @param name The name of the effect.
  110099. * @param camera The camera to apply the render pass to.
  110100. * @param isRightEye If this is for the right eye distortion
  110101. * @param vrMetrics All the required metrics for the VR camera
  110102. */
  110103. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  110104. }
  110105. }
  110106. declare module BABYLON {
  110107. /**
  110108. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  110109. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110110. */
  110111. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  110112. /**
  110113. * Creates a new VRDeviceOrientationArcRotateCamera
  110114. * @param name defines camera name
  110115. * @param alpha defines the camera rotation along the logitudinal axis
  110116. * @param beta defines the camera rotation along the latitudinal axis
  110117. * @param radius defines the camera distance from its target
  110118. * @param target defines the camera target
  110119. * @param scene defines the scene the camera belongs to
  110120. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110121. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110122. */
  110123. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110124. /**
  110125. * Gets camera class name
  110126. * @returns VRDeviceOrientationArcRotateCamera
  110127. */
  110128. getClassName(): string;
  110129. }
  110130. }
  110131. declare module BABYLON {
  110132. /**
  110133. * Camera used to simulate VR rendering (based on FreeCamera)
  110134. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110135. */
  110136. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  110137. /**
  110138. * Creates a new VRDeviceOrientationFreeCamera
  110139. * @param name defines camera name
  110140. * @param position defines the start position of the camera
  110141. * @param scene defines the scene the camera belongs to
  110142. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110143. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110144. */
  110145. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110146. /**
  110147. * Gets camera class name
  110148. * @returns VRDeviceOrientationFreeCamera
  110149. */
  110150. getClassName(): string;
  110151. }
  110152. }
  110153. declare module BABYLON {
  110154. /**
  110155. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  110156. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110157. */
  110158. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  110159. /**
  110160. * Creates a new VRDeviceOrientationGamepadCamera
  110161. * @param name defines camera name
  110162. * @param position defines the start position of the camera
  110163. * @param scene defines the scene the camera belongs to
  110164. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110165. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110166. */
  110167. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110168. /**
  110169. * Gets camera class name
  110170. * @returns VRDeviceOrientationGamepadCamera
  110171. */
  110172. getClassName(): string;
  110173. }
  110174. }
  110175. declare module BABYLON {
  110176. /** @hidden */
  110177. export var imageProcessingPixelShader: {
  110178. name: string;
  110179. shader: string;
  110180. };
  110181. }
  110182. declare module BABYLON {
  110183. /**
  110184. * ImageProcessingPostProcess
  110185. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  110186. */
  110187. export class ImageProcessingPostProcess extends PostProcess {
  110188. /**
  110189. * Default configuration related to image processing available in the PBR Material.
  110190. */
  110191. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110192. /**
  110193. * Gets the image processing configuration used either in this material.
  110194. */
  110195. /**
  110196. * Sets the Default image processing configuration used either in the this material.
  110197. *
  110198. * If sets to null, the scene one is in use.
  110199. */
  110200. imageProcessingConfiguration: ImageProcessingConfiguration;
  110201. /**
  110202. * Keep track of the image processing observer to allow dispose and replace.
  110203. */
  110204. private _imageProcessingObserver;
  110205. /**
  110206. * Attaches a new image processing configuration to the PBR Material.
  110207. * @param configuration
  110208. */
  110209. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  110210. /**
  110211. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110212. */
  110213. /**
  110214. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110215. */
  110216. colorCurves: Nullable<ColorCurves>;
  110217. /**
  110218. * Gets wether the color curves effect is enabled.
  110219. */
  110220. /**
  110221. * Sets wether the color curves effect is enabled.
  110222. */
  110223. colorCurvesEnabled: boolean;
  110224. /**
  110225. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110226. */
  110227. /**
  110228. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110229. */
  110230. colorGradingTexture: Nullable<BaseTexture>;
  110231. /**
  110232. * Gets wether the color grading effect is enabled.
  110233. */
  110234. /**
  110235. * Gets wether the color grading effect is enabled.
  110236. */
  110237. colorGradingEnabled: boolean;
  110238. /**
  110239. * Gets exposure used in the effect.
  110240. */
  110241. /**
  110242. * Sets exposure used in the effect.
  110243. */
  110244. exposure: number;
  110245. /**
  110246. * Gets wether tonemapping is enabled or not.
  110247. */
  110248. /**
  110249. * Sets wether tonemapping is enabled or not
  110250. */
  110251. toneMappingEnabled: boolean;
  110252. /**
  110253. * Gets the type of tone mapping effect.
  110254. */
  110255. /**
  110256. * Sets the type of tone mapping effect.
  110257. */
  110258. toneMappingType: number;
  110259. /**
  110260. * Gets contrast used in the effect.
  110261. */
  110262. /**
  110263. * Sets contrast used in the effect.
  110264. */
  110265. contrast: number;
  110266. /**
  110267. * Gets Vignette stretch size.
  110268. */
  110269. /**
  110270. * Sets Vignette stretch size.
  110271. */
  110272. vignetteStretch: number;
  110273. /**
  110274. * Gets Vignette centre X Offset.
  110275. */
  110276. /**
  110277. * Sets Vignette centre X Offset.
  110278. */
  110279. vignetteCentreX: number;
  110280. /**
  110281. * Gets Vignette centre Y Offset.
  110282. */
  110283. /**
  110284. * Sets Vignette centre Y Offset.
  110285. */
  110286. vignetteCentreY: number;
  110287. /**
  110288. * Gets Vignette weight or intensity of the vignette effect.
  110289. */
  110290. /**
  110291. * Sets Vignette weight or intensity of the vignette effect.
  110292. */
  110293. vignetteWeight: number;
  110294. /**
  110295. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110296. * if vignetteEnabled is set to true.
  110297. */
  110298. /**
  110299. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110300. * if vignetteEnabled is set to true.
  110301. */
  110302. vignetteColor: Color4;
  110303. /**
  110304. * Gets Camera field of view used by the Vignette effect.
  110305. */
  110306. /**
  110307. * Sets Camera field of view used by the Vignette effect.
  110308. */
  110309. vignetteCameraFov: number;
  110310. /**
  110311. * Gets the vignette blend mode allowing different kind of effect.
  110312. */
  110313. /**
  110314. * Sets the vignette blend mode allowing different kind of effect.
  110315. */
  110316. vignetteBlendMode: number;
  110317. /**
  110318. * Gets wether the vignette effect is enabled.
  110319. */
  110320. /**
  110321. * Sets wether the vignette effect is enabled.
  110322. */
  110323. vignetteEnabled: boolean;
  110324. private _fromLinearSpace;
  110325. /**
  110326. * Gets wether the input of the processing is in Gamma or Linear Space.
  110327. */
  110328. /**
  110329. * Sets wether the input of the processing is in Gamma or Linear Space.
  110330. */
  110331. fromLinearSpace: boolean;
  110332. /**
  110333. * Defines cache preventing GC.
  110334. */
  110335. private _defines;
  110336. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  110337. /**
  110338. * "ImageProcessingPostProcess"
  110339. * @returns "ImageProcessingPostProcess"
  110340. */
  110341. getClassName(): string;
  110342. protected _updateParameters(): void;
  110343. dispose(camera?: Camera): void;
  110344. }
  110345. }
  110346. declare module BABYLON {
  110347. /**
  110348. * Class containing static functions to help procedurally build meshes
  110349. */
  110350. export class GroundBuilder {
  110351. /**
  110352. * Creates a ground mesh
  110353. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110354. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110356. * @param name defines the name of the mesh
  110357. * @param options defines the options used to create the mesh
  110358. * @param scene defines the hosting scene
  110359. * @returns the ground mesh
  110360. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110361. */
  110362. static CreateGround(name: string, options: {
  110363. width?: number;
  110364. height?: number;
  110365. subdivisions?: number;
  110366. subdivisionsX?: number;
  110367. subdivisionsY?: number;
  110368. updatable?: boolean;
  110369. }, scene: any): Mesh;
  110370. /**
  110371. * Creates a tiled ground mesh
  110372. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110373. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110374. * * 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
  110375. * * 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
  110376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110377. * @param name defines the name of the mesh
  110378. * @param options defines the options used to create the mesh
  110379. * @param scene defines the hosting scene
  110380. * @returns the tiled ground mesh
  110381. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110382. */
  110383. static CreateTiledGround(name: string, options: {
  110384. xmin: number;
  110385. zmin: number;
  110386. xmax: number;
  110387. zmax: number;
  110388. subdivisions?: {
  110389. w: number;
  110390. h: number;
  110391. };
  110392. precision?: {
  110393. w: number;
  110394. h: number;
  110395. };
  110396. updatable?: boolean;
  110397. }, scene?: Nullable<Scene>): Mesh;
  110398. /**
  110399. * Creates a ground mesh from a height map
  110400. * * The parameter `url` sets the URL of the height map image resource.
  110401. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110402. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110403. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110404. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110405. * * 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.
  110406. * * 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).
  110407. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110409. * @param name defines the name of the mesh
  110410. * @param url defines the url to the height map
  110411. * @param options defines the options used to create the mesh
  110412. * @param scene defines the hosting scene
  110413. * @returns the ground mesh
  110414. * @see https://doc.babylonjs.com/babylon101/height_map
  110415. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110416. */
  110417. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110418. width?: number;
  110419. height?: number;
  110420. subdivisions?: number;
  110421. minHeight?: number;
  110422. maxHeight?: number;
  110423. colorFilter?: Color3;
  110424. alphaFilter?: number;
  110425. updatable?: boolean;
  110426. onReady?: (mesh: GroundMesh) => void;
  110427. }, scene?: Nullable<Scene>): GroundMesh;
  110428. }
  110429. }
  110430. declare module BABYLON {
  110431. /**
  110432. * Class containing static functions to help procedurally build meshes
  110433. */
  110434. export class TorusBuilder {
  110435. /**
  110436. * Creates a torus mesh
  110437. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110438. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110439. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110443. * @param name defines the name of the mesh
  110444. * @param options defines the options used to create the mesh
  110445. * @param scene defines the hosting scene
  110446. * @returns the torus mesh
  110447. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110448. */
  110449. static CreateTorus(name: string, options: {
  110450. diameter?: number;
  110451. thickness?: number;
  110452. tessellation?: number;
  110453. updatable?: boolean;
  110454. sideOrientation?: number;
  110455. frontUVs?: Vector4;
  110456. backUVs?: Vector4;
  110457. }, scene: any): Mesh;
  110458. }
  110459. }
  110460. declare module BABYLON {
  110461. /**
  110462. * Class containing static functions to help procedurally build meshes
  110463. */
  110464. export class CylinderBuilder {
  110465. /**
  110466. * Creates a cylinder or a cone mesh
  110467. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110468. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110469. * * 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.
  110470. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110471. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110472. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110473. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110474. * * 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).
  110475. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110476. * * 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).
  110477. * * 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
  110478. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110479. * * 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
  110480. * * 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.
  110481. * * If `enclose` is false, a ring surface is one element.
  110482. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110483. * * 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
  110484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110487. * @param name defines the name of the mesh
  110488. * @param options defines the options used to create the mesh
  110489. * @param scene defines the hosting scene
  110490. * @returns the cylinder mesh
  110491. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110492. */
  110493. static CreateCylinder(name: string, options: {
  110494. height?: number;
  110495. diameterTop?: number;
  110496. diameterBottom?: number;
  110497. diameter?: number;
  110498. tessellation?: number;
  110499. subdivisions?: number;
  110500. arc?: number;
  110501. faceColors?: Color4[];
  110502. faceUV?: Vector4[];
  110503. updatable?: boolean;
  110504. hasRings?: boolean;
  110505. enclose?: boolean;
  110506. cap?: number;
  110507. sideOrientation?: number;
  110508. frontUVs?: Vector4;
  110509. backUVs?: Vector4;
  110510. }, scene: any): Mesh;
  110511. }
  110512. }
  110513. declare module BABYLON {
  110514. /**
  110515. * States of the webXR experience
  110516. */
  110517. export enum WebXRState {
  110518. /**
  110519. * Transitioning to being in XR mode
  110520. */
  110521. ENTERING_XR = 0,
  110522. /**
  110523. * Transitioning to non XR mode
  110524. */
  110525. EXITING_XR = 1,
  110526. /**
  110527. * In XR mode and presenting
  110528. */
  110529. IN_XR = 2,
  110530. /**
  110531. * Not entered XR mode
  110532. */
  110533. NOT_IN_XR = 3
  110534. }
  110535. /**
  110536. * Abstraction of the XR render target
  110537. */
  110538. export interface WebXRRenderTarget extends IDisposable {
  110539. /**
  110540. * xrpresent context of the canvas which can be used to display/mirror xr content
  110541. */
  110542. canvasContext: WebGLRenderingContext;
  110543. /**
  110544. * xr layer for the canvas
  110545. */
  110546. xrLayer: Nullable<XRWebGLLayer>;
  110547. /**
  110548. * Initializes the xr layer for the session
  110549. * @param xrSession xr session
  110550. * @returns a promise that will resolve once the XR Layer has been created
  110551. */
  110552. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110553. }
  110554. }
  110555. declare module BABYLON {
  110556. /**
  110557. * COnfiguration object for WebXR output canvas
  110558. */
  110559. export class WebXRManagedOutputCanvasOptions {
  110560. /**
  110561. * Options for this XR Layer output
  110562. */
  110563. canvasOptions: XRWebGLLayerOptions;
  110564. /**
  110565. * CSS styling for a newly created canvas (if not provided)
  110566. */
  110567. newCanvasCssStyle?: string;
  110568. /**
  110569. * Get the default values of the configuration object
  110570. * @returns default values of this configuration object
  110571. */
  110572. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110573. }
  110574. /**
  110575. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110576. */
  110577. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110578. private configuration;
  110579. private _engine;
  110580. private _canvas;
  110581. /**
  110582. * xrpresent context of the canvas which can be used to display/mirror xr content
  110583. */
  110584. canvasContext: WebGLRenderingContext;
  110585. /**
  110586. * xr layer for the canvas
  110587. */
  110588. xrLayer: Nullable<XRWebGLLayer>;
  110589. /**
  110590. * Initializes the xr layer for the session
  110591. * @param xrSession xr session
  110592. * @returns a promise that will resolve once the XR Layer has been created
  110593. */
  110594. initializeXRLayerAsync(xrSession: any): any;
  110595. /**
  110596. * Initializes the canvas to be added/removed upon entering/exiting xr
  110597. * @param engine the Babylon engine
  110598. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110599. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110600. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110601. */
  110602. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110603. /**
  110604. * Disposes of the object
  110605. */
  110606. dispose(): void;
  110607. private _setManagedOutputCanvas;
  110608. private _addCanvas;
  110609. private _removeCanvas;
  110610. }
  110611. }
  110612. declare module BABYLON {
  110613. /**
  110614. * Manages an XRSession to work with Babylon's engine
  110615. * @see https://doc.babylonjs.com/how_to/webxr
  110616. */
  110617. export class WebXRSessionManager implements IDisposable {
  110618. private scene;
  110619. /**
  110620. * Fires every time a new xrFrame arrives which can be used to update the camera
  110621. */
  110622. onXRFrameObservable: Observable<any>;
  110623. /**
  110624. * Fires when the xr session is ended either by the device or manually done
  110625. */
  110626. onXRSessionEnded: Observable<any>;
  110627. /**
  110628. * Underlying xr session
  110629. */
  110630. session: XRSession;
  110631. /**
  110632. * Type of reference space used when creating the session
  110633. */
  110634. referenceSpace: XRReferenceSpace;
  110635. /**
  110636. * Current XR frame
  110637. */
  110638. currentFrame: Nullable<XRFrame>;
  110639. private _xrNavigator;
  110640. private baseLayer;
  110641. private _rttProvider;
  110642. private _sessionEnded;
  110643. /**
  110644. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110645. * @param scene The scene which the session should be created for
  110646. */
  110647. constructor(scene: Scene);
  110648. /**
  110649. * Initializes the manager
  110650. * After initialization enterXR can be called to start an XR session
  110651. * @returns Promise which resolves after it is initialized
  110652. */
  110653. initializeAsync(): Promise<void>;
  110654. /**
  110655. * Initializes an xr session
  110656. * @param xrSessionMode mode to initialize
  110657. * @param optionalFeatures defines optional values to pass to the session builder
  110658. * @returns a promise which will resolve once the session has been initialized
  110659. */
  110660. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  110661. /**
  110662. * Sets the reference space on the xr session
  110663. * @param referenceSpace space to set
  110664. * @returns a promise that will resolve once the reference space has been set
  110665. */
  110666. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110667. /**
  110668. * Updates the render state of the session
  110669. * @param state state to set
  110670. * @returns a promise that resolves once the render state has been updated
  110671. */
  110672. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110673. /**
  110674. * Starts rendering to the xr layer
  110675. * @returns a promise that will resolve once rendering has started
  110676. */
  110677. startRenderingToXRAsync(): Promise<void>;
  110678. /**
  110679. * Gets the correct render target texture to be rendered this frame for this eye
  110680. * @param eye the eye for which to get the render target
  110681. * @returns the render target for the specified eye
  110682. */
  110683. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110684. /**
  110685. * Stops the xrSession and restores the renderloop
  110686. * @returns Promise which resolves after it exits XR
  110687. */
  110688. exitXRAsync(): Promise<void>;
  110689. /**
  110690. * Checks if a session would be supported for the creation options specified
  110691. * @param sessionMode session mode to check if supported eg. immersive-vr
  110692. * @returns true if supported
  110693. */
  110694. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110695. /**
  110696. * Creates a WebXRRenderTarget object for the XR session
  110697. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110698. * @param options optional options to provide when creating a new render target
  110699. * @returns a WebXR render target to which the session can render
  110700. */
  110701. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110702. /**
  110703. * @hidden
  110704. * Converts the render layer of xrSession to a render target
  110705. * @param session session to create render target for
  110706. * @param scene scene the new render target should be created for
  110707. */
  110708. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110709. /**
  110710. * Disposes of the session manager
  110711. */
  110712. dispose(): void;
  110713. /**
  110714. * Gets a promise returning true when fullfiled if the given session mode is supported
  110715. * @param sessionMode defines the session to test
  110716. * @returns a promise
  110717. */
  110718. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110719. }
  110720. }
  110721. declare module BABYLON {
  110722. /**
  110723. * WebXR Camera which holds the views for the xrSession
  110724. * @see https://doc.babylonjs.com/how_to/webxr
  110725. */
  110726. export class WebXRCamera extends FreeCamera {
  110727. /**
  110728. * Is the camera in debug mode. Used when using an emulator
  110729. */
  110730. debugMode: boolean;
  110731. /**
  110732. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110733. * @param name the name of the camera
  110734. * @param scene the scene to add the camera to
  110735. */
  110736. constructor(name: string, scene: Scene);
  110737. private _updateNumberOfRigCameras;
  110738. /** @hidden */
  110739. _updateForDualEyeDebugging(): void;
  110740. /**
  110741. * Updates the cameras position from the current pose information of the XR session
  110742. * @param xrSessionManager the session containing pose information
  110743. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110744. */
  110745. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110746. }
  110747. }
  110748. declare module BABYLON {
  110749. /**
  110750. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110751. * @see https://doc.babylonjs.com/how_to/webxr
  110752. */
  110753. export class WebXRExperienceHelper implements IDisposable {
  110754. private scene;
  110755. /**
  110756. * 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
  110757. */
  110758. container: AbstractMesh;
  110759. /**
  110760. * Camera used to render xr content
  110761. */
  110762. camera: WebXRCamera;
  110763. /**
  110764. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110765. */
  110766. state: WebXRState;
  110767. private _setState;
  110768. private static _TmpVector;
  110769. /**
  110770. * Fires when the state of the experience helper has changed
  110771. */
  110772. onStateChangedObservable: Observable<WebXRState>;
  110773. /** Session manager used to keep track of xr session */
  110774. sessionManager: WebXRSessionManager;
  110775. private _nonVRCamera;
  110776. private _originalSceneAutoClear;
  110777. private _supported;
  110778. /**
  110779. * Creates the experience helper
  110780. * @param scene the scene to attach the experience helper to
  110781. * @returns a promise for the experience helper
  110782. */
  110783. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110784. /**
  110785. * Creates a WebXRExperienceHelper
  110786. * @param scene The scene the helper should be created in
  110787. */
  110788. private constructor();
  110789. /**
  110790. * Exits XR mode and returns the scene to its original state
  110791. * @returns promise that resolves after xr mode has exited
  110792. */
  110793. exitXRAsync(): Promise<void>;
  110794. /**
  110795. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110796. * @param sessionMode options for the XR session
  110797. * @param referenceSpaceType frame of reference of the XR session
  110798. * @param renderTarget the output canvas that will be used to enter XR mode
  110799. * @returns promise that resolves after xr mode has entered
  110800. */
  110801. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  110802. /**
  110803. * Updates the global position of the camera by moving the camera's container
  110804. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110805. * @param position The desired global position of the camera
  110806. */
  110807. setPositionOfCameraUsingContainer(position: Vector3): void;
  110808. /**
  110809. * Rotates the xr camera by rotating the camera's container around the camera's position
  110810. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110811. * @param rotation the desired quaternion rotation to apply to the camera
  110812. */
  110813. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110814. /**
  110815. * Disposes of the experience helper
  110816. */
  110817. dispose(): void;
  110818. }
  110819. }
  110820. declare module BABYLON {
  110821. /**
  110822. * Represents an XR input
  110823. */
  110824. export class WebXRController {
  110825. private scene;
  110826. /** The underlying input source for the controller */
  110827. inputSource: XRInputSource;
  110828. private parentContainer;
  110829. /**
  110830. * 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
  110831. */
  110832. grip?: AbstractMesh;
  110833. /**
  110834. * Pointer which can be used to select objects or attach a visible laser to
  110835. */
  110836. pointer: AbstractMesh;
  110837. private _gamepadMode;
  110838. /**
  110839. * If available, this is the gamepad object related to this controller.
  110840. * Using this object it is possible to get click events and trackpad changes of the
  110841. * webxr controller that is currently being used.
  110842. */
  110843. gamepadController?: WebVRController;
  110844. /**
  110845. * Event that fires when the controller is removed/disposed
  110846. */
  110847. onDisposeObservable: Observable<{}>;
  110848. private _tmpQuaternion;
  110849. private _tmpVector;
  110850. /**
  110851. * Creates the controller
  110852. * @see https://doc.babylonjs.com/how_to/webxr
  110853. * @param scene the scene which the controller should be associated to
  110854. * @param inputSource the underlying input source for the controller
  110855. * @param parentContainer parent that the controller meshes should be children of
  110856. */
  110857. constructor(scene: Scene,
  110858. /** The underlying input source for the controller */
  110859. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110860. /**
  110861. * Updates the controller pose based on the given XRFrame
  110862. * @param xrFrame xr frame to update the pose with
  110863. * @param referenceSpace reference space to use
  110864. */
  110865. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110866. /**
  110867. * Gets a world space ray coming from the controller
  110868. * @param result the resulting ray
  110869. */
  110870. getWorldPointerRayToRef(result: Ray): void;
  110871. /**
  110872. * Get the scene associated with this controller
  110873. * @returns the scene object
  110874. */
  110875. getScene(): Scene;
  110876. /**
  110877. * Disposes of the object
  110878. */
  110879. dispose(): void;
  110880. }
  110881. }
  110882. declare module BABYLON {
  110883. /**
  110884. * XR input used to track XR inputs such as controllers/rays
  110885. */
  110886. export class WebXRInput implements IDisposable {
  110887. /**
  110888. * Base experience the input listens to
  110889. */
  110890. baseExperience: WebXRExperienceHelper;
  110891. /**
  110892. * XR controllers being tracked
  110893. */
  110894. controllers: Array<WebXRController>;
  110895. private _frameObserver;
  110896. private _stateObserver;
  110897. /**
  110898. * Event when a controller has been connected/added
  110899. */
  110900. onControllerAddedObservable: Observable<WebXRController>;
  110901. /**
  110902. * Event when a controller has been removed/disconnected
  110903. */
  110904. onControllerRemovedObservable: Observable<WebXRController>;
  110905. /**
  110906. * Initializes the WebXRInput
  110907. * @param baseExperience experience helper which the input should be created for
  110908. */
  110909. constructor(
  110910. /**
  110911. * Base experience the input listens to
  110912. */
  110913. baseExperience: WebXRExperienceHelper);
  110914. private _onInputSourcesChange;
  110915. private _addAndRemoveControllers;
  110916. /**
  110917. * Disposes of the object
  110918. */
  110919. dispose(): void;
  110920. }
  110921. }
  110922. declare module BABYLON {
  110923. /**
  110924. * Class used to represent data loading progression
  110925. */
  110926. export class SceneLoaderProgressEvent {
  110927. /** defines if data length to load can be evaluated */
  110928. readonly lengthComputable: boolean;
  110929. /** defines the loaded data length */
  110930. readonly loaded: number;
  110931. /** defines the data length to load */
  110932. readonly total: number;
  110933. /**
  110934. * Create a new progress event
  110935. * @param lengthComputable defines if data length to load can be evaluated
  110936. * @param loaded defines the loaded data length
  110937. * @param total defines the data length to load
  110938. */
  110939. constructor(
  110940. /** defines if data length to load can be evaluated */
  110941. lengthComputable: boolean,
  110942. /** defines the loaded data length */
  110943. loaded: number,
  110944. /** defines the data length to load */
  110945. total: number);
  110946. /**
  110947. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110948. * @param event defines the source event
  110949. * @returns a new SceneLoaderProgressEvent
  110950. */
  110951. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110952. }
  110953. /**
  110954. * Interface used by SceneLoader plugins to define supported file extensions
  110955. */
  110956. export interface ISceneLoaderPluginExtensions {
  110957. /**
  110958. * Defines the list of supported extensions
  110959. */
  110960. [extension: string]: {
  110961. isBinary: boolean;
  110962. };
  110963. }
  110964. /**
  110965. * Interface used by SceneLoader plugin factory
  110966. */
  110967. export interface ISceneLoaderPluginFactory {
  110968. /**
  110969. * Defines the name of the factory
  110970. */
  110971. name: string;
  110972. /**
  110973. * Function called to create a new plugin
  110974. * @return the new plugin
  110975. */
  110976. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110977. /**
  110978. * The callback that returns true if the data can be directly loaded.
  110979. * @param data string containing the file data
  110980. * @returns if the data can be loaded directly
  110981. */
  110982. canDirectLoad?(data: string): boolean;
  110983. }
  110984. /**
  110985. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110986. */
  110987. export interface ISceneLoaderPluginBase {
  110988. /**
  110989. * The friendly name of this plugin.
  110990. */
  110991. name: string;
  110992. /**
  110993. * The file extensions supported by this plugin.
  110994. */
  110995. extensions: string | ISceneLoaderPluginExtensions;
  110996. /**
  110997. * The callback called when loading from a url.
  110998. * @param scene scene loading this url
  110999. * @param url url to load
  111000. * @param onSuccess callback called when the file successfully loads
  111001. * @param onProgress callback called while file is loading (if the server supports this mode)
  111002. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111003. * @param onError callback called when the file fails to load
  111004. * @returns a file request object
  111005. */
  111006. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111007. /**
  111008. * The callback called when loading from a file object.
  111009. * @param scene scene loading this file
  111010. * @param file defines the file to load
  111011. * @param onSuccess defines the callback to call when data is loaded
  111012. * @param onProgress defines the callback to call during loading process
  111013. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  111014. * @param onError defines the callback to call when an error occurs
  111015. * @returns a file request object
  111016. */
  111017. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111018. /**
  111019. * The callback that returns true if the data can be directly loaded.
  111020. * @param data string containing the file data
  111021. * @returns if the data can be loaded directly
  111022. */
  111023. canDirectLoad?(data: string): boolean;
  111024. /**
  111025. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  111026. * @param scene scene loading this data
  111027. * @param data string containing the data
  111028. * @returns data to pass to the plugin
  111029. */
  111030. directLoad?(scene: Scene, data: string): any;
  111031. /**
  111032. * The callback that allows custom handling of the root url based on the response url.
  111033. * @param rootUrl the original root url
  111034. * @param responseURL the response url if available
  111035. * @returns the new root url
  111036. */
  111037. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  111038. }
  111039. /**
  111040. * Interface used to define a SceneLoader plugin
  111041. */
  111042. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  111043. /**
  111044. * Import meshes into a scene.
  111045. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111046. * @param scene The scene to import into
  111047. * @param data The data to import
  111048. * @param rootUrl The root url for scene and resources
  111049. * @param meshes The meshes array to import into
  111050. * @param particleSystems The particle systems array to import into
  111051. * @param skeletons The skeletons array to import into
  111052. * @param onError The callback when import fails
  111053. * @returns True if successful or false otherwise
  111054. */
  111055. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  111056. /**
  111057. * Load into a scene.
  111058. * @param scene The scene to load into
  111059. * @param data The data to import
  111060. * @param rootUrl The root url for scene and resources
  111061. * @param onError The callback when import fails
  111062. * @returns True if successful or false otherwise
  111063. */
  111064. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  111065. /**
  111066. * Load into an asset container.
  111067. * @param scene The scene to load into
  111068. * @param data The data to import
  111069. * @param rootUrl The root url for scene and resources
  111070. * @param onError The callback when import fails
  111071. * @returns The loaded asset container
  111072. */
  111073. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  111074. }
  111075. /**
  111076. * Interface used to define an async SceneLoader plugin
  111077. */
  111078. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  111079. /**
  111080. * Import meshes into a scene.
  111081. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111082. * @param scene The scene to import into
  111083. * @param data The data to import
  111084. * @param rootUrl The root url for scene and resources
  111085. * @param onProgress The callback when the load progresses
  111086. * @param fileName Defines the name of the file to load
  111087. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  111088. */
  111089. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  111090. meshes: AbstractMesh[];
  111091. particleSystems: IParticleSystem[];
  111092. skeletons: Skeleton[];
  111093. animationGroups: AnimationGroup[];
  111094. }>;
  111095. /**
  111096. * Load into a scene.
  111097. * @param scene The scene to load into
  111098. * @param data The data to import
  111099. * @param rootUrl The root url for scene and resources
  111100. * @param onProgress The callback when the load progresses
  111101. * @param fileName Defines the name of the file to load
  111102. * @returns Nothing
  111103. */
  111104. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  111105. /**
  111106. * Load into an asset container.
  111107. * @param scene The scene to load into
  111108. * @param data The data to import
  111109. * @param rootUrl The root url for scene and resources
  111110. * @param onProgress The callback when the load progresses
  111111. * @param fileName Defines the name of the file to load
  111112. * @returns The loaded asset container
  111113. */
  111114. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  111115. }
  111116. /**
  111117. * Class used to load scene from various file formats using registered plugins
  111118. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  111119. */
  111120. export class SceneLoader {
  111121. /**
  111122. * No logging while loading
  111123. */
  111124. static readonly NO_LOGGING: number;
  111125. /**
  111126. * Minimal logging while loading
  111127. */
  111128. static readonly MINIMAL_LOGGING: number;
  111129. /**
  111130. * Summary logging while loading
  111131. */
  111132. static readonly SUMMARY_LOGGING: number;
  111133. /**
  111134. * Detailled logging while loading
  111135. */
  111136. static readonly DETAILED_LOGGING: number;
  111137. /**
  111138. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111139. */
  111140. static ForceFullSceneLoadingForIncremental: boolean;
  111141. /**
  111142. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111143. */
  111144. static ShowLoadingScreen: boolean;
  111145. /**
  111146. * Defines the current logging level (while loading the scene)
  111147. * @ignorenaming
  111148. */
  111149. static loggingLevel: number;
  111150. /**
  111151. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111152. */
  111153. static CleanBoneMatrixWeights: boolean;
  111154. /**
  111155. * Event raised when a plugin is used to load a scene
  111156. */
  111157. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  111158. private static _registeredPlugins;
  111159. private static _getDefaultPlugin;
  111160. private static _getPluginForExtension;
  111161. private static _getPluginForDirectLoad;
  111162. private static _getPluginForFilename;
  111163. private static _getDirectLoad;
  111164. private static _loadData;
  111165. private static _getFileInfo;
  111166. /**
  111167. * Gets a plugin that can load the given extension
  111168. * @param extension defines the extension to load
  111169. * @returns a plugin or null if none works
  111170. */
  111171. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  111172. /**
  111173. * Gets a boolean indicating that the given extension can be loaded
  111174. * @param extension defines the extension to load
  111175. * @returns true if the extension is supported
  111176. */
  111177. static IsPluginForExtensionAvailable(extension: string): boolean;
  111178. /**
  111179. * Adds a new plugin to the list of registered plugins
  111180. * @param plugin defines the plugin to add
  111181. */
  111182. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  111183. /**
  111184. * Import meshes into a scene
  111185. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111186. * @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)
  111187. * @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)
  111188. * @param scene the instance of BABYLON.Scene to append to
  111189. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  111190. * @param onProgress a callback with a progress event for each file being loaded
  111191. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111192. * @param pluginExtension the extension used to determine the plugin
  111193. * @returns The loaded plugin
  111194. */
  111195. 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>;
  111196. /**
  111197. * Import meshes into a scene
  111198. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111199. * @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)
  111200. * @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)
  111201. * @param scene the instance of BABYLON.Scene to append to
  111202. * @param onProgress a callback with a progress event for each file being loaded
  111203. * @param pluginExtension the extension used to determine the plugin
  111204. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  111205. */
  111206. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  111207. meshes: AbstractMesh[];
  111208. particleSystems: IParticleSystem[];
  111209. skeletons: Skeleton[];
  111210. animationGroups: AnimationGroup[];
  111211. }>;
  111212. /**
  111213. * Load a scene
  111214. * @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)
  111215. * @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)
  111216. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111217. * @param onSuccess a callback with the scene when import succeeds
  111218. * @param onProgress a callback with a progress event for each file being loaded
  111219. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111220. * @param pluginExtension the extension used to determine the plugin
  111221. * @returns The loaded plugin
  111222. */
  111223. 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>;
  111224. /**
  111225. * Load a scene
  111226. * @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)
  111227. * @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)
  111228. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111229. * @param onProgress a callback with a progress event for each file being loaded
  111230. * @param pluginExtension the extension used to determine the plugin
  111231. * @returns The loaded scene
  111232. */
  111233. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111234. /**
  111235. * Append a scene
  111236. * @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)
  111237. * @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)
  111238. * @param scene is the instance of BABYLON.Scene to append to
  111239. * @param onSuccess a callback with the scene when import succeeds
  111240. * @param onProgress a callback with a progress event for each file being loaded
  111241. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111242. * @param pluginExtension the extension used to determine the plugin
  111243. * @returns The loaded plugin
  111244. */
  111245. 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>;
  111246. /**
  111247. * Append a scene
  111248. * @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)
  111249. * @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)
  111250. * @param scene is the instance of BABYLON.Scene to append to
  111251. * @param onProgress a callback with a progress event for each file being loaded
  111252. * @param pluginExtension the extension used to determine the plugin
  111253. * @returns The given scene
  111254. */
  111255. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111256. /**
  111257. * Load a scene into an asset container
  111258. * @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)
  111259. * @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)
  111260. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111261. * @param onSuccess a callback with the scene when import succeeds
  111262. * @param onProgress a callback with a progress event for each file being loaded
  111263. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111264. * @param pluginExtension the extension used to determine the plugin
  111265. * @returns The loaded plugin
  111266. */
  111267. 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>;
  111268. /**
  111269. * Load a scene into an asset container
  111270. * @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)
  111271. * @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)
  111272. * @param scene is the instance of Scene to append to
  111273. * @param onProgress a callback with a progress event for each file being loaded
  111274. * @param pluginExtension the extension used to determine the plugin
  111275. * @returns The loaded asset container
  111276. */
  111277. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111278. }
  111279. }
  111280. declare module BABYLON {
  111281. /**
  111282. * Generic Controller
  111283. */
  111284. export class GenericController extends WebVRController {
  111285. /**
  111286. * Base Url for the controller model.
  111287. */
  111288. static readonly MODEL_BASE_URL: string;
  111289. /**
  111290. * File name for the controller model.
  111291. */
  111292. static readonly MODEL_FILENAME: string;
  111293. /**
  111294. * Creates a new GenericController from a gamepad
  111295. * @param vrGamepad the gamepad that the controller should be created from
  111296. */
  111297. constructor(vrGamepad: any);
  111298. /**
  111299. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111300. * @param scene scene in which to add meshes
  111301. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111302. */
  111303. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111304. /**
  111305. * Called once for each button that changed state since the last frame
  111306. * @param buttonIdx Which button index changed
  111307. * @param state New state of the button
  111308. * @param changes Which properties on the state changed since last frame
  111309. */
  111310. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111311. }
  111312. }
  111313. declare module BABYLON {
  111314. /**
  111315. * Defines the WindowsMotionController object that the state of the windows motion controller
  111316. */
  111317. export class WindowsMotionController extends WebVRController {
  111318. /**
  111319. * The base url used to load the left and right controller models
  111320. */
  111321. static MODEL_BASE_URL: string;
  111322. /**
  111323. * The name of the left controller model file
  111324. */
  111325. static MODEL_LEFT_FILENAME: string;
  111326. /**
  111327. * The name of the right controller model file
  111328. */
  111329. static MODEL_RIGHT_FILENAME: string;
  111330. /**
  111331. * The controller name prefix for this controller type
  111332. */
  111333. static readonly GAMEPAD_ID_PREFIX: string;
  111334. /**
  111335. * The controller id pattern for this controller type
  111336. */
  111337. private static readonly GAMEPAD_ID_PATTERN;
  111338. private _loadedMeshInfo;
  111339. protected readonly _mapping: {
  111340. buttons: string[];
  111341. buttonMeshNames: {
  111342. 'trigger': string;
  111343. 'menu': string;
  111344. 'grip': string;
  111345. 'thumbstick': string;
  111346. 'trackpad': string;
  111347. };
  111348. buttonObservableNames: {
  111349. 'trigger': string;
  111350. 'menu': string;
  111351. 'grip': string;
  111352. 'thumbstick': string;
  111353. 'trackpad': string;
  111354. };
  111355. axisMeshNames: string[];
  111356. pointingPoseMeshName: string;
  111357. };
  111358. /**
  111359. * Fired when the trackpad on this controller is clicked
  111360. */
  111361. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111362. /**
  111363. * Fired when the trackpad on this controller is modified
  111364. */
  111365. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111366. /**
  111367. * The current x and y values of this controller's trackpad
  111368. */
  111369. trackpad: StickValues;
  111370. /**
  111371. * Creates a new WindowsMotionController from a gamepad
  111372. * @param vrGamepad the gamepad that the controller should be created from
  111373. */
  111374. constructor(vrGamepad: any);
  111375. /**
  111376. * Fired when the trigger on this controller is modified
  111377. */
  111378. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111379. /**
  111380. * Fired when the menu button on this controller is modified
  111381. */
  111382. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111383. /**
  111384. * Fired when the grip button on this controller is modified
  111385. */
  111386. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111387. /**
  111388. * Fired when the thumbstick button on this controller is modified
  111389. */
  111390. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111391. /**
  111392. * Fired when the touchpad button on this controller is modified
  111393. */
  111394. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111395. /**
  111396. * Fired when the touchpad values on this controller are modified
  111397. */
  111398. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111399. protected _updateTrackpad(): void;
  111400. /**
  111401. * Called once per frame by the engine.
  111402. */
  111403. update(): void;
  111404. /**
  111405. * Called once for each button that changed state since the last frame
  111406. * @param buttonIdx Which button index changed
  111407. * @param state New state of the button
  111408. * @param changes Which properties on the state changed since last frame
  111409. */
  111410. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111411. /**
  111412. * Moves the buttons on the controller mesh based on their current state
  111413. * @param buttonName the name of the button to move
  111414. * @param buttonValue the value of the button which determines the buttons new position
  111415. */
  111416. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111417. /**
  111418. * Moves the axis on the controller mesh based on its current state
  111419. * @param axis the index of the axis
  111420. * @param axisValue the value of the axis which determines the meshes new position
  111421. * @hidden
  111422. */
  111423. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111424. /**
  111425. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111426. * @param scene scene in which to add meshes
  111427. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111428. */
  111429. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111430. /**
  111431. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111432. * can be transformed by button presses and axes values, based on this._mapping.
  111433. *
  111434. * @param scene scene in which the meshes exist
  111435. * @param meshes list of meshes that make up the controller model to process
  111436. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111437. */
  111438. private processModel;
  111439. private createMeshInfo;
  111440. /**
  111441. * Gets the ray of the controller in the direction the controller is pointing
  111442. * @param length the length the resulting ray should be
  111443. * @returns a ray in the direction the controller is pointing
  111444. */
  111445. getForwardRay(length?: number): Ray;
  111446. /**
  111447. * Disposes of the controller
  111448. */
  111449. dispose(): void;
  111450. }
  111451. /**
  111452. * This class represents a new windows motion controller in XR.
  111453. */
  111454. export class XRWindowsMotionController extends WindowsMotionController {
  111455. /**
  111456. * Changing the original WIndowsMotionController mapping to fir the new mapping
  111457. */
  111458. protected readonly _mapping: {
  111459. buttons: string[];
  111460. buttonMeshNames: {
  111461. 'trigger': string;
  111462. 'menu': string;
  111463. 'grip': string;
  111464. 'thumbstick': string;
  111465. 'trackpad': string;
  111466. };
  111467. buttonObservableNames: {
  111468. 'trigger': string;
  111469. 'menu': string;
  111470. 'grip': string;
  111471. 'thumbstick': string;
  111472. 'trackpad': string;
  111473. };
  111474. axisMeshNames: string[];
  111475. pointingPoseMeshName: string;
  111476. };
  111477. /**
  111478. * Construct a new XR-Based windows motion controller
  111479. *
  111480. * @param gamepadInfo the gamepad object from the browser
  111481. */
  111482. constructor(gamepadInfo: any);
  111483. /**
  111484. * holds the thumbstick values (X,Y)
  111485. */
  111486. readonly thumbstickValues: StickValues;
  111487. /**
  111488. * Fired when the thumbstick on this controller is clicked
  111489. */
  111490. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  111491. /**
  111492. * Fired when the thumbstick on this controller is modified
  111493. */
  111494. onThumbstickValuesChangedObservable: Observable<StickValues>;
  111495. /**
  111496. * Fired when the touchpad button on this controller is modified
  111497. */
  111498. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111499. /**
  111500. * Fired when the touchpad values on this controller are modified
  111501. */
  111502. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111503. /**
  111504. * Fired when the thumbstick button on this controller is modified
  111505. * here to prevent breaking changes
  111506. */
  111507. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111508. /**
  111509. * updating the thumbstick(!) and not the trackpad.
  111510. * This is named this way due to the difference between WebVR and XR and to avoid
  111511. * changing the parent class.
  111512. */
  111513. protected _updateTrackpad(): void;
  111514. /**
  111515. * Disposes the class with joy
  111516. */
  111517. dispose(): void;
  111518. }
  111519. }
  111520. declare module BABYLON {
  111521. /**
  111522. * Oculus Touch Controller
  111523. */
  111524. export class OculusTouchController extends WebVRController {
  111525. /**
  111526. * Base Url for the controller model.
  111527. */
  111528. static MODEL_BASE_URL: string;
  111529. /**
  111530. * File name for the left controller model.
  111531. */
  111532. static MODEL_LEFT_FILENAME: string;
  111533. /**
  111534. * File name for the right controller model.
  111535. */
  111536. static MODEL_RIGHT_FILENAME: string;
  111537. /**
  111538. * Base Url for the Quest controller model.
  111539. */
  111540. static QUEST_MODEL_BASE_URL: string;
  111541. /**
  111542. * @hidden
  111543. * If the controllers are running on a device that needs the updated Quest controller models
  111544. */
  111545. static _IsQuest: boolean;
  111546. /**
  111547. * Fired when the secondary trigger on this controller is modified
  111548. */
  111549. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111550. /**
  111551. * Fired when the thumb rest on this controller is modified
  111552. */
  111553. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111554. /**
  111555. * Creates a new OculusTouchController from a gamepad
  111556. * @param vrGamepad the gamepad that the controller should be created from
  111557. */
  111558. constructor(vrGamepad: any);
  111559. /**
  111560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111561. * @param scene scene in which to add meshes
  111562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111563. */
  111564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111565. /**
  111566. * Fired when the A button on this controller is modified
  111567. */
  111568. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111569. /**
  111570. * Fired when the B button on this controller is modified
  111571. */
  111572. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111573. /**
  111574. * Fired when the X button on this controller is modified
  111575. */
  111576. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111577. /**
  111578. * Fired when the Y button on this controller is modified
  111579. */
  111580. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111581. /**
  111582. * Called once for each button that changed state since the last frame
  111583. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111584. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111585. * 2) secondary trigger (same)
  111586. * 3) A (right) X (left), touch, pressed = value
  111587. * 4) B / Y
  111588. * 5) thumb rest
  111589. * @param buttonIdx Which button index changed
  111590. * @param state New state of the button
  111591. * @param changes Which properties on the state changed since last frame
  111592. */
  111593. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111594. }
  111595. }
  111596. declare module BABYLON {
  111597. /**
  111598. * Vive Controller
  111599. */
  111600. export class ViveController extends WebVRController {
  111601. /**
  111602. * Base Url for the controller model.
  111603. */
  111604. static MODEL_BASE_URL: string;
  111605. /**
  111606. * File name for the controller model.
  111607. */
  111608. static MODEL_FILENAME: string;
  111609. /**
  111610. * Creates a new ViveController from a gamepad
  111611. * @param vrGamepad the gamepad that the controller should be created from
  111612. */
  111613. constructor(vrGamepad: any);
  111614. /**
  111615. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111616. * @param scene scene in which to add meshes
  111617. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111618. */
  111619. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111620. /**
  111621. * Fired when the left button on this controller is modified
  111622. */
  111623. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111624. /**
  111625. * Fired when the right button on this controller is modified
  111626. */
  111627. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111628. /**
  111629. * Fired when the menu button on this controller is modified
  111630. */
  111631. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111632. /**
  111633. * Called once for each button that changed state since the last frame
  111634. * Vive mapping:
  111635. * 0: touchpad
  111636. * 1: trigger
  111637. * 2: left AND right buttons
  111638. * 3: menu button
  111639. * @param buttonIdx Which button index changed
  111640. * @param state New state of the button
  111641. * @param changes Which properties on the state changed since last frame
  111642. */
  111643. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111644. }
  111645. }
  111646. declare module BABYLON {
  111647. /**
  111648. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111649. */
  111650. export class WebXRControllerModelLoader {
  111651. /**
  111652. * an observable that triggers when a new model (the mesh itself) was initialized.
  111653. * To know when the mesh was loaded use the controller's own modelLoaded() method
  111654. */
  111655. onControllerModelLoaded: Observable<WebXRController>;
  111656. /**
  111657. * Creates the WebXRControllerModelLoader
  111658. * @param input xr input that creates the controllers
  111659. */
  111660. constructor(input: WebXRInput);
  111661. }
  111662. }
  111663. declare module BABYLON {
  111664. /**
  111665. * Handles pointer input automatically for the pointer of XR controllers
  111666. */
  111667. export class WebXRControllerPointerSelection {
  111668. private static _idCounter;
  111669. private _tmpRay;
  111670. /**
  111671. * Creates a WebXRControllerPointerSelection
  111672. * @param input input manager to setup pointer selection
  111673. */
  111674. constructor(input: WebXRInput);
  111675. private _convertNormalToDirectionOfRay;
  111676. private _updatePointerDistance;
  111677. }
  111678. }
  111679. declare module BABYLON {
  111680. /**
  111681. * Enables teleportation
  111682. */
  111683. export class WebXRControllerTeleportation {
  111684. private _teleportationFillColor;
  111685. private _teleportationBorderColor;
  111686. private _tmpRay;
  111687. private _tmpVector;
  111688. /**
  111689. * Creates a WebXRControllerTeleportation
  111690. * @param input input manager to add teleportation to
  111691. * @param floorMeshes floormeshes which can be teleported to
  111692. */
  111693. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  111694. }
  111695. }
  111696. declare module BABYLON {
  111697. /**
  111698. * Button which can be used to enter a different mode of XR
  111699. */
  111700. export class WebXREnterExitUIButton {
  111701. /** button element */
  111702. element: HTMLElement;
  111703. /** XR initialization options for the button */
  111704. sessionMode: XRSessionMode;
  111705. /** Reference space type */
  111706. referenceSpaceType: XRReferenceSpaceType;
  111707. /**
  111708. * Creates a WebXREnterExitUIButton
  111709. * @param element button element
  111710. * @param sessionMode XR initialization session mode
  111711. * @param referenceSpaceType the type of reference space to be used
  111712. */
  111713. constructor(
  111714. /** button element */
  111715. element: HTMLElement,
  111716. /** XR initialization options for the button */
  111717. sessionMode: XRSessionMode,
  111718. /** Reference space type */
  111719. referenceSpaceType: XRReferenceSpaceType);
  111720. /**
  111721. * Overwritable function which can be used to update the button's visuals when the state changes
  111722. * @param activeButton the current active button in the UI
  111723. */
  111724. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  111725. }
  111726. /**
  111727. * Options to create the webXR UI
  111728. */
  111729. export class WebXREnterExitUIOptions {
  111730. /**
  111731. * Context to enter xr with
  111732. */
  111733. renderTarget?: Nullable<WebXRRenderTarget>;
  111734. /**
  111735. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  111736. */
  111737. customButtons?: Array<WebXREnterExitUIButton>;
  111738. /**
  111739. * A session mode to use when creating the default button.
  111740. * Default is immersive-vr
  111741. */
  111742. sessionMode?: XRSessionMode;
  111743. /**
  111744. * A reference space type to use when creating the default button.
  111745. * Default is local-floor
  111746. */
  111747. referenceSpaceType?: XRReferenceSpaceType;
  111748. }
  111749. /**
  111750. * UI to allow the user to enter/exit XR mode
  111751. */
  111752. export class WebXREnterExitUI implements IDisposable {
  111753. private scene;
  111754. private _overlay;
  111755. private _buttons;
  111756. private _activeButton;
  111757. /**
  111758. * Fired every time the active button is changed.
  111759. *
  111760. * When xr is entered via a button that launches xr that button will be the callback parameter
  111761. *
  111762. * When exiting xr the callback parameter will be null)
  111763. */
  111764. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  111765. /**
  111766. * Creates UI to allow the user to enter/exit XR mode
  111767. * @param scene the scene to add the ui to
  111768. * @param helper the xr experience helper to enter/exit xr with
  111769. * @param options options to configure the UI
  111770. * @returns the created ui
  111771. */
  111772. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  111773. private constructor();
  111774. private _updateButtons;
  111775. /**
  111776. * Disposes of the object
  111777. */
  111778. dispose(): void;
  111779. }
  111780. }
  111781. declare module BABYLON {
  111782. /**
  111783. * Options for the default xr helper
  111784. */
  111785. export class WebXRDefaultExperienceOptions {
  111786. /**
  111787. * Floor meshes that should be used for teleporting
  111788. */
  111789. floorMeshes: Array<AbstractMesh>;
  111790. /**
  111791. * Enable or disable default UI to enter XR
  111792. */
  111793. disableDefaultUI?: boolean;
  111794. /**
  111795. * optional configuration for the output canvas
  111796. */
  111797. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111798. }
  111799. /**
  111800. * Default experience which provides a similar setup to the previous webVRExperience
  111801. */
  111802. export class WebXRDefaultExperience {
  111803. /**
  111804. * Base experience
  111805. */
  111806. baseExperience: WebXRExperienceHelper;
  111807. /**
  111808. * Input experience extension
  111809. */
  111810. input: WebXRInput;
  111811. /**
  111812. * Loads the controller models
  111813. */
  111814. controllerModelLoader: WebXRControllerModelLoader;
  111815. /**
  111816. * Enables laser pointer and selection
  111817. */
  111818. pointerSelection: WebXRControllerPointerSelection;
  111819. /**
  111820. * Enables teleportation
  111821. */
  111822. teleportation: WebXRControllerTeleportation;
  111823. /**
  111824. * Enables ui for enetering/exiting xr
  111825. */
  111826. enterExitUI: WebXREnterExitUI;
  111827. /**
  111828. * Default target xr should render to
  111829. */
  111830. renderTarget: WebXRRenderTarget;
  111831. /**
  111832. * Creates the default xr experience
  111833. * @param scene scene
  111834. * @param options options for basic configuration
  111835. * @returns resulting WebXRDefaultExperience
  111836. */
  111837. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111838. private constructor();
  111839. /**
  111840. * DIsposes of the experience helper
  111841. */
  111842. dispose(): void;
  111843. }
  111844. }
  111845. declare module BABYLON {
  111846. /**
  111847. * Options to modify the vr teleportation behavior.
  111848. */
  111849. export interface VRTeleportationOptions {
  111850. /**
  111851. * The name of the mesh which should be used as the teleportation floor. (default: null)
  111852. */
  111853. floorMeshName?: string;
  111854. /**
  111855. * A list of meshes to be used as the teleportation floor. (default: empty)
  111856. */
  111857. floorMeshes?: Mesh[];
  111858. /**
  111859. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  111860. */
  111861. teleportationMode?: number;
  111862. /**
  111863. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  111864. */
  111865. teleportationTime?: number;
  111866. /**
  111867. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  111868. */
  111869. teleportationSpeed?: number;
  111870. /**
  111871. * The easing function used in the animation or null for Linear. (default CircleEase)
  111872. */
  111873. easingFunction?: EasingFunction;
  111874. }
  111875. /**
  111876. * Options to modify the vr experience helper's behavior.
  111877. */
  111878. export interface VRExperienceHelperOptions extends WebVROptions {
  111879. /**
  111880. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  111881. */
  111882. createDeviceOrientationCamera?: boolean;
  111883. /**
  111884. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  111885. */
  111886. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  111887. /**
  111888. * Uses the main button on the controller to toggle the laser casted. (default: true)
  111889. */
  111890. laserToggle?: boolean;
  111891. /**
  111892. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  111893. */
  111894. floorMeshes?: Mesh[];
  111895. /**
  111896. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  111897. */
  111898. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  111899. /**
  111900. * Defines if WebXR should be used instead of WebVR (if available)
  111901. */
  111902. useXR?: boolean;
  111903. }
  111904. /**
  111905. * Event containing information after VR has been entered
  111906. */
  111907. export class OnAfterEnteringVRObservableEvent {
  111908. /**
  111909. * If entering vr was successful
  111910. */
  111911. success: boolean;
  111912. }
  111913. /**
  111914. * Helps to quickly add VR support to an existing scene.
  111915. * See http://doc.babylonjs.com/how_to/webvr_helper
  111916. */
  111917. export class VRExperienceHelper {
  111918. /** Options to modify the vr experience helper's behavior. */
  111919. webVROptions: VRExperienceHelperOptions;
  111920. private _scene;
  111921. private _position;
  111922. private _btnVR;
  111923. private _btnVRDisplayed;
  111924. private _webVRsupported;
  111925. private _webVRready;
  111926. private _webVRrequesting;
  111927. private _webVRpresenting;
  111928. private _hasEnteredVR;
  111929. private _fullscreenVRpresenting;
  111930. private _inputElement;
  111931. private _webVRCamera;
  111932. private _vrDeviceOrientationCamera;
  111933. private _deviceOrientationCamera;
  111934. private _existingCamera;
  111935. private _onKeyDown;
  111936. private _onVrDisplayPresentChange;
  111937. private _onVRDisplayChanged;
  111938. private _onVRRequestPresentStart;
  111939. private _onVRRequestPresentComplete;
  111940. /**
  111941. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  111942. */
  111943. enableGazeEvenWhenNoPointerLock: boolean;
  111944. /**
  111945. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  111946. */
  111947. exitVROnDoubleTap: boolean;
  111948. /**
  111949. * Observable raised right before entering VR.
  111950. */
  111951. onEnteringVRObservable: Observable<VRExperienceHelper>;
  111952. /**
  111953. * Observable raised when entering VR has completed.
  111954. */
  111955. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  111956. /**
  111957. * Observable raised when exiting VR.
  111958. */
  111959. onExitingVRObservable: Observable<VRExperienceHelper>;
  111960. /**
  111961. * Observable raised when controller mesh is loaded.
  111962. */
  111963. onControllerMeshLoadedObservable: Observable<WebVRController>;
  111964. /** Return this.onEnteringVRObservable
  111965. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  111966. */
  111967. readonly onEnteringVR: Observable<VRExperienceHelper>;
  111968. /** Return this.onExitingVRObservable
  111969. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  111970. */
  111971. readonly onExitingVR: Observable<VRExperienceHelper>;
  111972. /** Return this.onControllerMeshLoadedObservable
  111973. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  111974. */
  111975. readonly onControllerMeshLoaded: Observable<WebVRController>;
  111976. private _rayLength;
  111977. private _useCustomVRButton;
  111978. private _teleportationRequested;
  111979. private _teleportActive;
  111980. private _floorMeshName;
  111981. private _floorMeshesCollection;
  111982. private _teleportationMode;
  111983. private _teleportationTime;
  111984. private _teleportationSpeed;
  111985. private _teleportationEasing;
  111986. private _rotationAllowed;
  111987. private _teleportBackwardsVector;
  111988. private _teleportationTarget;
  111989. private _isDefaultTeleportationTarget;
  111990. private _postProcessMove;
  111991. private _teleportationFillColor;
  111992. private _teleportationBorderColor;
  111993. private _rotationAngle;
  111994. private _haloCenter;
  111995. private _cameraGazer;
  111996. private _padSensibilityUp;
  111997. private _padSensibilityDown;
  111998. private _leftController;
  111999. private _rightController;
  112000. /**
  112001. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  112002. */
  112003. onNewMeshSelected: Observable<AbstractMesh>;
  112004. /**
  112005. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  112006. * This observable will provide the mesh and the controller used to select the mesh
  112007. */
  112008. onMeshSelectedWithController: Observable<{
  112009. mesh: AbstractMesh;
  112010. controller: WebVRController;
  112011. }>;
  112012. /**
  112013. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  112014. */
  112015. onNewMeshPicked: Observable<PickingInfo>;
  112016. private _circleEase;
  112017. /**
  112018. * Observable raised before camera teleportation
  112019. */
  112020. onBeforeCameraTeleport: Observable<Vector3>;
  112021. /**
  112022. * Observable raised after camera teleportation
  112023. */
  112024. onAfterCameraTeleport: Observable<Vector3>;
  112025. /**
  112026. * Observable raised when current selected mesh gets unselected
  112027. */
  112028. onSelectedMeshUnselected: Observable<AbstractMesh>;
  112029. private _raySelectionPredicate;
  112030. /**
  112031. * To be optionaly changed by user to define custom ray selection
  112032. */
  112033. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  112034. /**
  112035. * To be optionaly changed by user to define custom selection logic (after ray selection)
  112036. */
  112037. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112038. /**
  112039. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  112040. */
  112041. teleportationEnabled: boolean;
  112042. private _defaultHeight;
  112043. private _teleportationInitialized;
  112044. private _interactionsEnabled;
  112045. private _interactionsRequested;
  112046. private _displayGaze;
  112047. private _displayLaserPointer;
  112048. /**
  112049. * The mesh used to display where the user is going to teleport.
  112050. */
  112051. /**
  112052. * Sets the mesh to be used to display where the user is going to teleport.
  112053. */
  112054. teleportationTarget: Mesh;
  112055. /**
  112056. * 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
  112057. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  112058. * See http://doc.babylonjs.com/resources/baking_transformations
  112059. */
  112060. gazeTrackerMesh: Mesh;
  112061. /**
  112062. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  112063. */
  112064. updateGazeTrackerScale: boolean;
  112065. /**
  112066. * If the gaze trackers color should be updated when selecting meshes
  112067. */
  112068. updateGazeTrackerColor: boolean;
  112069. /**
  112070. * If the controller laser color should be updated when selecting meshes
  112071. */
  112072. updateControllerLaserColor: boolean;
  112073. /**
  112074. * The gaze tracking mesh corresponding to the left controller
  112075. */
  112076. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  112077. /**
  112078. * The gaze tracking mesh corresponding to the right controller
  112079. */
  112080. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  112081. /**
  112082. * If the ray of the gaze should be displayed.
  112083. */
  112084. /**
  112085. * Sets if the ray of the gaze should be displayed.
  112086. */
  112087. displayGaze: boolean;
  112088. /**
  112089. * If the ray of the LaserPointer should be displayed.
  112090. */
  112091. /**
  112092. * Sets if the ray of the LaserPointer should be displayed.
  112093. */
  112094. displayLaserPointer: boolean;
  112095. /**
  112096. * The deviceOrientationCamera used as the camera when not in VR.
  112097. */
  112098. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  112099. /**
  112100. * Based on the current WebVR support, returns the current VR camera used.
  112101. */
  112102. readonly currentVRCamera: Nullable<Camera>;
  112103. /**
  112104. * The webVRCamera which is used when in VR.
  112105. */
  112106. readonly webVRCamera: WebVRFreeCamera;
  112107. /**
  112108. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  112109. */
  112110. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  112111. /**
  112112. * The html button that is used to trigger entering into VR.
  112113. */
  112114. readonly vrButton: Nullable<HTMLButtonElement>;
  112115. private readonly _teleportationRequestInitiated;
  112116. /**
  112117. * Defines wether or not Pointer lock should be requested when switching to
  112118. * full screen.
  112119. */
  112120. requestPointerLockOnFullScreen: boolean;
  112121. /**
  112122. * If asking to force XR, this will be populated with the default xr experience
  112123. */
  112124. xr: WebXRDefaultExperience;
  112125. /**
  112126. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  112127. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  112128. */
  112129. xrTestDone: boolean;
  112130. /**
  112131. * Instantiates a VRExperienceHelper.
  112132. * Helps to quickly add VR support to an existing scene.
  112133. * @param scene The scene the VRExperienceHelper belongs to.
  112134. * @param webVROptions Options to modify the vr experience helper's behavior.
  112135. */
  112136. constructor(scene: Scene,
  112137. /** Options to modify the vr experience helper's behavior. */
  112138. webVROptions?: VRExperienceHelperOptions);
  112139. private completeVRInit;
  112140. private _onDefaultMeshLoaded;
  112141. private _onResize;
  112142. private _onFullscreenChange;
  112143. /**
  112144. * Gets a value indicating if we are currently in VR mode.
  112145. */
  112146. readonly isInVRMode: boolean;
  112147. private onVrDisplayPresentChange;
  112148. private onVRDisplayChanged;
  112149. private moveButtonToBottomRight;
  112150. private displayVRButton;
  112151. private updateButtonVisibility;
  112152. private _cachedAngularSensibility;
  112153. /**
  112154. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  112155. * Otherwise, will use the fullscreen API.
  112156. */
  112157. enterVR(): void;
  112158. /**
  112159. * Attempt to exit VR, or fullscreen.
  112160. */
  112161. exitVR(): void;
  112162. /**
  112163. * The position of the vr experience helper.
  112164. */
  112165. /**
  112166. * Sets the position of the vr experience helper.
  112167. */
  112168. position: Vector3;
  112169. /**
  112170. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  112171. */
  112172. enableInteractions(): void;
  112173. private readonly _noControllerIsActive;
  112174. private beforeRender;
  112175. private _isTeleportationFloor;
  112176. /**
  112177. * Adds a floor mesh to be used for teleportation.
  112178. * @param floorMesh the mesh to be used for teleportation.
  112179. */
  112180. addFloorMesh(floorMesh: Mesh): void;
  112181. /**
  112182. * Removes a floor mesh from being used for teleportation.
  112183. * @param floorMesh the mesh to be removed.
  112184. */
  112185. removeFloorMesh(floorMesh: Mesh): void;
  112186. /**
  112187. * Enables interactions and teleportation using the VR controllers and gaze.
  112188. * @param vrTeleportationOptions options to modify teleportation behavior.
  112189. */
  112190. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  112191. private _onNewGamepadConnected;
  112192. private _tryEnableInteractionOnController;
  112193. private _onNewGamepadDisconnected;
  112194. private _enableInteractionOnController;
  112195. private _checkTeleportWithRay;
  112196. private _checkRotate;
  112197. private _checkTeleportBackwards;
  112198. private _enableTeleportationOnController;
  112199. private _createTeleportationCircles;
  112200. private _displayTeleportationTarget;
  112201. private _hideTeleportationTarget;
  112202. private _rotateCamera;
  112203. private _moveTeleportationSelectorTo;
  112204. private _workingVector;
  112205. private _workingQuaternion;
  112206. private _workingMatrix;
  112207. /**
  112208. * Time Constant Teleportation Mode
  112209. */
  112210. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  112211. /**
  112212. * Speed Constant Teleportation Mode
  112213. */
  112214. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  112215. /**
  112216. * Teleports the users feet to the desired location
  112217. * @param location The location where the user's feet should be placed
  112218. */
  112219. teleportCamera(location: Vector3): void;
  112220. private _convertNormalToDirectionOfRay;
  112221. private _castRayAndSelectObject;
  112222. private _notifySelectedMeshUnselected;
  112223. /**
  112224. * Sets the color of the laser ray from the vr controllers.
  112225. * @param color new color for the ray.
  112226. */
  112227. changeLaserColor(color: Color3): void;
  112228. /**
  112229. * Sets the color of the ray from the vr headsets gaze.
  112230. * @param color new color for the ray.
  112231. */
  112232. changeGazeColor(color: Color3): void;
  112233. /**
  112234. * Exits VR and disposes of the vr experience helper
  112235. */
  112236. dispose(): void;
  112237. /**
  112238. * Gets the name of the VRExperienceHelper class
  112239. * @returns "VRExperienceHelper"
  112240. */
  112241. getClassName(): string;
  112242. }
  112243. }
  112244. declare module BABYLON {
  112245. /**
  112246. * Contains an array of blocks representing the octree
  112247. */
  112248. export interface IOctreeContainer<T> {
  112249. /**
  112250. * Blocks within the octree
  112251. */
  112252. blocks: Array<OctreeBlock<T>>;
  112253. }
  112254. /**
  112255. * Class used to store a cell in an octree
  112256. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112257. */
  112258. export class OctreeBlock<T> {
  112259. /**
  112260. * Gets the content of the current block
  112261. */
  112262. entries: T[];
  112263. /**
  112264. * Gets the list of block children
  112265. */
  112266. blocks: Array<OctreeBlock<T>>;
  112267. private _depth;
  112268. private _maxDepth;
  112269. private _capacity;
  112270. private _minPoint;
  112271. private _maxPoint;
  112272. private _boundingVectors;
  112273. private _creationFunc;
  112274. /**
  112275. * Creates a new block
  112276. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  112277. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  112278. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112279. * @param depth defines the current depth of this block in the octree
  112280. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  112281. * @param creationFunc defines a callback to call when an element is added to the block
  112282. */
  112283. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  112284. /**
  112285. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112286. */
  112287. readonly capacity: number;
  112288. /**
  112289. * Gets the minimum vector (in world space) of the block's bounding box
  112290. */
  112291. readonly minPoint: Vector3;
  112292. /**
  112293. * Gets the maximum vector (in world space) of the block's bounding box
  112294. */
  112295. readonly maxPoint: Vector3;
  112296. /**
  112297. * Add a new element to this block
  112298. * @param entry defines the element to add
  112299. */
  112300. addEntry(entry: T): void;
  112301. /**
  112302. * Remove an element from this block
  112303. * @param entry defines the element to remove
  112304. */
  112305. removeEntry(entry: T): void;
  112306. /**
  112307. * Add an array of elements to this block
  112308. * @param entries defines the array of elements to add
  112309. */
  112310. addEntries(entries: T[]): void;
  112311. /**
  112312. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  112313. * @param frustumPlanes defines the frustum planes to test
  112314. * @param selection defines the array to store current content if selection is positive
  112315. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112316. */
  112317. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112318. /**
  112319. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  112320. * @param sphereCenter defines the bounding sphere center
  112321. * @param sphereRadius defines the bounding sphere radius
  112322. * @param selection defines the array to store current content if selection is positive
  112323. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112324. */
  112325. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112326. /**
  112327. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  112328. * @param ray defines the ray to test with
  112329. * @param selection defines the array to store current content if selection is positive
  112330. */
  112331. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  112332. /**
  112333. * Subdivide the content into child blocks (this block will then be empty)
  112334. */
  112335. createInnerBlocks(): void;
  112336. /**
  112337. * @hidden
  112338. */
  112339. 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;
  112340. }
  112341. }
  112342. declare module BABYLON {
  112343. /**
  112344. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  112345. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112346. */
  112347. export class Octree<T> {
  112348. /** 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.) */
  112349. maxDepth: number;
  112350. /**
  112351. * Blocks within the octree containing objects
  112352. */
  112353. blocks: Array<OctreeBlock<T>>;
  112354. /**
  112355. * Content stored in the octree
  112356. */
  112357. dynamicContent: T[];
  112358. private _maxBlockCapacity;
  112359. private _selectionContent;
  112360. private _creationFunc;
  112361. /**
  112362. * Creates a octree
  112363. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112364. * @param creationFunc function to be used to instatiate the octree
  112365. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  112366. * @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.)
  112367. */
  112368. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  112369. /** 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.) */
  112370. maxDepth?: number);
  112371. /**
  112372. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  112373. * @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);
  112374. * @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);
  112375. * @param entries meshes to be added to the octree blocks
  112376. */
  112377. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  112378. /**
  112379. * Adds a mesh to the octree
  112380. * @param entry Mesh to add to the octree
  112381. */
  112382. addMesh(entry: T): void;
  112383. /**
  112384. * Remove an element from the octree
  112385. * @param entry defines the element to remove
  112386. */
  112387. removeMesh(entry: T): void;
  112388. /**
  112389. * Selects an array of meshes within the frustum
  112390. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  112391. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  112392. * @returns array of meshes within the frustum
  112393. */
  112394. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  112395. /**
  112396. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  112397. * @param sphereCenter defines the bounding sphere center
  112398. * @param sphereRadius defines the bounding sphere radius
  112399. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112400. * @returns an array of objects that intersect the sphere
  112401. */
  112402. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  112403. /**
  112404. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  112405. * @param ray defines the ray to test with
  112406. * @returns array of intersected objects
  112407. */
  112408. intersectsRay(ray: Ray): SmartArray<T>;
  112409. /**
  112410. * Adds a mesh into the octree block if it intersects the block
  112411. */
  112412. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  112413. /**
  112414. * Adds a submesh into the octree block if it intersects the block
  112415. */
  112416. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  112417. }
  112418. }
  112419. declare module BABYLON {
  112420. interface Scene {
  112421. /**
  112422. * @hidden
  112423. * Backing Filed
  112424. */
  112425. _selectionOctree: Octree<AbstractMesh>;
  112426. /**
  112427. * Gets the octree used to boost mesh selection (picking)
  112428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112429. */
  112430. selectionOctree: Octree<AbstractMesh>;
  112431. /**
  112432. * Creates or updates the octree used to boost selection (picking)
  112433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112434. * @param maxCapacity defines the maximum capacity per leaf
  112435. * @param maxDepth defines the maximum depth of the octree
  112436. * @returns an octree of AbstractMesh
  112437. */
  112438. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  112439. }
  112440. interface AbstractMesh {
  112441. /**
  112442. * @hidden
  112443. * Backing Field
  112444. */
  112445. _submeshesOctree: Octree<SubMesh>;
  112446. /**
  112447. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  112448. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112449. * @param maxCapacity defines the maximum size of each block (64 by default)
  112450. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  112451. * @returns the new octree
  112452. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  112453. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112454. */
  112455. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  112456. }
  112457. /**
  112458. * Defines the octree scene component responsible to manage any octrees
  112459. * in a given scene.
  112460. */
  112461. export class OctreeSceneComponent {
  112462. /**
  112463. * The component name help to identify the component in the list of scene components.
  112464. */
  112465. readonly name: string;
  112466. /**
  112467. * The scene the component belongs to.
  112468. */
  112469. scene: Scene;
  112470. /**
  112471. * Indicates if the meshes have been checked to make sure they are isEnabled()
  112472. */
  112473. readonly checksIsEnabled: boolean;
  112474. /**
  112475. * Creates a new instance of the component for the given scene
  112476. * @param scene Defines the scene to register the component in
  112477. */
  112478. constructor(scene: Scene);
  112479. /**
  112480. * Registers the component in a given scene
  112481. */
  112482. register(): void;
  112483. /**
  112484. * Return the list of active meshes
  112485. * @returns the list of active meshes
  112486. */
  112487. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112488. /**
  112489. * Return the list of active sub meshes
  112490. * @param mesh The mesh to get the candidates sub meshes from
  112491. * @returns the list of active sub meshes
  112492. */
  112493. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112494. private _tempRay;
  112495. /**
  112496. * Return the list of sub meshes intersecting with a given local ray
  112497. * @param mesh defines the mesh to find the submesh for
  112498. * @param localRay defines the ray in local space
  112499. * @returns the list of intersecting sub meshes
  112500. */
  112501. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  112502. /**
  112503. * Return the list of sub meshes colliding with a collider
  112504. * @param mesh defines the mesh to find the submesh for
  112505. * @param collider defines the collider to evaluate the collision against
  112506. * @returns the list of colliding sub meshes
  112507. */
  112508. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  112509. /**
  112510. * Rebuilds the elements related to this component in case of
  112511. * context lost for instance.
  112512. */
  112513. rebuild(): void;
  112514. /**
  112515. * Disposes the component and the associated ressources.
  112516. */
  112517. dispose(): void;
  112518. }
  112519. }
  112520. declare module BABYLON {
  112521. /**
  112522. * Renders a layer on top of an existing scene
  112523. */
  112524. export class UtilityLayerRenderer implements IDisposable {
  112525. /** the original scene that will be rendered on top of */
  112526. originalScene: Scene;
  112527. private _pointerCaptures;
  112528. private _lastPointerEvents;
  112529. private static _DefaultUtilityLayer;
  112530. private static _DefaultKeepDepthUtilityLayer;
  112531. private _sharedGizmoLight;
  112532. private _renderCamera;
  112533. /**
  112534. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  112535. * @returns the camera that is used when rendering the utility layer
  112536. */
  112537. getRenderCamera(): Nullable<Camera>;
  112538. /**
  112539. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  112540. * @param cam the camera that should be used when rendering the utility layer
  112541. */
  112542. setRenderCamera(cam: Nullable<Camera>): void;
  112543. /**
  112544. * @hidden
  112545. * Light which used by gizmos to get light shading
  112546. */
  112547. _getSharedGizmoLight(): HemisphericLight;
  112548. /**
  112549. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  112550. */
  112551. pickUtilitySceneFirst: boolean;
  112552. /**
  112553. * 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)
  112554. */
  112555. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  112556. /**
  112557. * 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)
  112558. */
  112559. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  112560. /**
  112561. * The scene that is rendered on top of the original scene
  112562. */
  112563. utilityLayerScene: Scene;
  112564. /**
  112565. * If the utility layer should automatically be rendered on top of existing scene
  112566. */
  112567. shouldRender: boolean;
  112568. /**
  112569. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  112570. */
  112571. onlyCheckPointerDownEvents: boolean;
  112572. /**
  112573. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  112574. */
  112575. processAllEvents: boolean;
  112576. /**
  112577. * Observable raised when the pointer move from the utility layer scene to the main scene
  112578. */
  112579. onPointerOutObservable: Observable<number>;
  112580. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  112581. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  112582. private _afterRenderObserver;
  112583. private _sceneDisposeObserver;
  112584. private _originalPointerObserver;
  112585. /**
  112586. * Instantiates a UtilityLayerRenderer
  112587. * @param originalScene the original scene that will be rendered on top of
  112588. * @param handleEvents boolean indicating if the utility layer should handle events
  112589. */
  112590. constructor(
  112591. /** the original scene that will be rendered on top of */
  112592. originalScene: Scene, handleEvents?: boolean);
  112593. private _notifyObservers;
  112594. /**
  112595. * Renders the utility layers scene on top of the original scene
  112596. */
  112597. render(): void;
  112598. /**
  112599. * Disposes of the renderer
  112600. */
  112601. dispose(): void;
  112602. private _updateCamera;
  112603. }
  112604. }
  112605. declare module BABYLON {
  112606. /**
  112607. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  112608. */
  112609. export class Gizmo implements IDisposable {
  112610. /** The utility layer the gizmo will be added to */
  112611. gizmoLayer: UtilityLayerRenderer;
  112612. /**
  112613. * The root mesh of the gizmo
  112614. */
  112615. _rootMesh: Mesh;
  112616. private _attachedMesh;
  112617. /**
  112618. * Ratio for the scale of the gizmo (Default: 1)
  112619. */
  112620. scaleRatio: number;
  112621. /**
  112622. * If a custom mesh has been set (Default: false)
  112623. */
  112624. protected _customMeshSet: boolean;
  112625. /**
  112626. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  112627. * * When set, interactions will be enabled
  112628. */
  112629. attachedMesh: Nullable<AbstractMesh>;
  112630. /**
  112631. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112632. * @param mesh The mesh to replace the default mesh of the gizmo
  112633. */
  112634. setCustomMesh(mesh: Mesh): void;
  112635. /**
  112636. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  112637. */
  112638. updateGizmoRotationToMatchAttachedMesh: boolean;
  112639. /**
  112640. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  112641. */
  112642. updateGizmoPositionToMatchAttachedMesh: boolean;
  112643. /**
  112644. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  112645. */
  112646. updateScale: boolean;
  112647. protected _interactionsEnabled: boolean;
  112648. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112649. private _beforeRenderObserver;
  112650. private _tempVector;
  112651. /**
  112652. * Creates a gizmo
  112653. * @param gizmoLayer The utility layer the gizmo will be added to
  112654. */
  112655. constructor(
  112656. /** The utility layer the gizmo will be added to */
  112657. gizmoLayer?: UtilityLayerRenderer);
  112658. /**
  112659. * Updates the gizmo to match the attached mesh's position/rotation
  112660. */
  112661. protected _update(): void;
  112662. /**
  112663. * Disposes of the gizmo
  112664. */
  112665. dispose(): void;
  112666. }
  112667. }
  112668. declare module BABYLON {
  112669. /**
  112670. * Single plane drag gizmo
  112671. */
  112672. export class PlaneDragGizmo extends Gizmo {
  112673. /**
  112674. * Drag behavior responsible for the gizmos dragging interactions
  112675. */
  112676. dragBehavior: PointerDragBehavior;
  112677. private _pointerObserver;
  112678. /**
  112679. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112680. */
  112681. snapDistance: number;
  112682. /**
  112683. * Event that fires each time the gizmo snaps to a new location.
  112684. * * snapDistance is the the change in distance
  112685. */
  112686. onSnapObservable: Observable<{
  112687. snapDistance: number;
  112688. }>;
  112689. private _plane;
  112690. private _coloredMaterial;
  112691. private _hoverMaterial;
  112692. private _isEnabled;
  112693. private _parent;
  112694. /** @hidden */
  112695. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  112696. /** @hidden */
  112697. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112698. /**
  112699. * Creates a PlaneDragGizmo
  112700. * @param gizmoLayer The utility layer the gizmo will be added to
  112701. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  112702. * @param color The color of the gizmo
  112703. */
  112704. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112705. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112706. /**
  112707. * If the gizmo is enabled
  112708. */
  112709. isEnabled: boolean;
  112710. /**
  112711. * Disposes of the gizmo
  112712. */
  112713. dispose(): void;
  112714. }
  112715. }
  112716. declare module BABYLON {
  112717. /**
  112718. * Gizmo that enables dragging a mesh along 3 axis
  112719. */
  112720. export class PositionGizmo extends Gizmo {
  112721. /**
  112722. * Internal gizmo used for interactions on the x axis
  112723. */
  112724. xGizmo: AxisDragGizmo;
  112725. /**
  112726. * Internal gizmo used for interactions on the y axis
  112727. */
  112728. yGizmo: AxisDragGizmo;
  112729. /**
  112730. * Internal gizmo used for interactions on the z axis
  112731. */
  112732. zGizmo: AxisDragGizmo;
  112733. /**
  112734. * Internal gizmo used for interactions on the yz plane
  112735. */
  112736. xPlaneGizmo: PlaneDragGizmo;
  112737. /**
  112738. * Internal gizmo used for interactions on the xz plane
  112739. */
  112740. yPlaneGizmo: PlaneDragGizmo;
  112741. /**
  112742. * Internal gizmo used for interactions on the xy plane
  112743. */
  112744. zPlaneGizmo: PlaneDragGizmo;
  112745. /**
  112746. * private variables
  112747. */
  112748. private _meshAttached;
  112749. private _updateGizmoRotationToMatchAttachedMesh;
  112750. private _snapDistance;
  112751. private _scaleRatio;
  112752. /** Fires an event when any of it's sub gizmos are dragged */
  112753. onDragStartObservable: Observable<unknown>;
  112754. /** Fires an event when any of it's sub gizmos are released from dragging */
  112755. onDragEndObservable: Observable<unknown>;
  112756. /**
  112757. * If set to true, planar drag is enabled
  112758. */
  112759. private _planarGizmoEnabled;
  112760. attachedMesh: Nullable<AbstractMesh>;
  112761. /**
  112762. * Creates a PositionGizmo
  112763. * @param gizmoLayer The utility layer the gizmo will be added to
  112764. */
  112765. constructor(gizmoLayer?: UtilityLayerRenderer);
  112766. /**
  112767. * If the planar drag gizmo is enabled
  112768. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  112769. */
  112770. planarGizmoEnabled: boolean;
  112771. updateGizmoRotationToMatchAttachedMesh: boolean;
  112772. /**
  112773. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112774. */
  112775. snapDistance: number;
  112776. /**
  112777. * Ratio for the scale of the gizmo (Default: 1)
  112778. */
  112779. scaleRatio: number;
  112780. /**
  112781. * Disposes of the gizmo
  112782. */
  112783. dispose(): void;
  112784. /**
  112785. * CustomMeshes are not supported by this gizmo
  112786. * @param mesh The mesh to replace the default mesh of the gizmo
  112787. */
  112788. setCustomMesh(mesh: Mesh): void;
  112789. }
  112790. }
  112791. declare module BABYLON {
  112792. /**
  112793. * Single axis drag gizmo
  112794. */
  112795. export class AxisDragGizmo extends Gizmo {
  112796. /**
  112797. * Drag behavior responsible for the gizmos dragging interactions
  112798. */
  112799. dragBehavior: PointerDragBehavior;
  112800. private _pointerObserver;
  112801. /**
  112802. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112803. */
  112804. snapDistance: number;
  112805. /**
  112806. * Event that fires each time the gizmo snaps to a new location.
  112807. * * snapDistance is the the change in distance
  112808. */
  112809. onSnapObservable: Observable<{
  112810. snapDistance: number;
  112811. }>;
  112812. private _isEnabled;
  112813. private _parent;
  112814. private _arrow;
  112815. private _coloredMaterial;
  112816. private _hoverMaterial;
  112817. /** @hidden */
  112818. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  112819. /** @hidden */
  112820. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112821. /**
  112822. * Creates an AxisDragGizmo
  112823. * @param gizmoLayer The utility layer the gizmo will be added to
  112824. * @param dragAxis The axis which the gizmo will be able to drag on
  112825. * @param color The color of the gizmo
  112826. */
  112827. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112828. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112829. /**
  112830. * If the gizmo is enabled
  112831. */
  112832. isEnabled: boolean;
  112833. /**
  112834. * Disposes of the gizmo
  112835. */
  112836. dispose(): void;
  112837. }
  112838. }
  112839. declare module BABYLON.Debug {
  112840. /**
  112841. * The Axes viewer will show 3 axes in a specific point in space
  112842. */
  112843. export class AxesViewer {
  112844. private _xAxis;
  112845. private _yAxis;
  112846. private _zAxis;
  112847. private _scaleLinesFactor;
  112848. private _instanced;
  112849. /**
  112850. * Gets the hosting scene
  112851. */
  112852. scene: Scene;
  112853. /**
  112854. * Gets or sets a number used to scale line length
  112855. */
  112856. scaleLines: number;
  112857. /** Gets the node hierarchy used to render x-axis */
  112858. readonly xAxis: TransformNode;
  112859. /** Gets the node hierarchy used to render y-axis */
  112860. readonly yAxis: TransformNode;
  112861. /** Gets the node hierarchy used to render z-axis */
  112862. readonly zAxis: TransformNode;
  112863. /**
  112864. * Creates a new AxesViewer
  112865. * @param scene defines the hosting scene
  112866. * @param scaleLines defines a number used to scale line length (1 by default)
  112867. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  112868. * @param xAxis defines the node hierarchy used to render the x-axis
  112869. * @param yAxis defines the node hierarchy used to render the y-axis
  112870. * @param zAxis defines the node hierarchy used to render the z-axis
  112871. */
  112872. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  112873. /**
  112874. * Force the viewer to update
  112875. * @param position defines the position of the viewer
  112876. * @param xaxis defines the x axis of the viewer
  112877. * @param yaxis defines the y axis of the viewer
  112878. * @param zaxis defines the z axis of the viewer
  112879. */
  112880. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  112881. /**
  112882. * Creates an instance of this axes viewer.
  112883. * @returns a new axes viewer with instanced meshes
  112884. */
  112885. createInstance(): AxesViewer;
  112886. /** Releases resources */
  112887. dispose(): void;
  112888. private static _SetRenderingGroupId;
  112889. }
  112890. }
  112891. declare module BABYLON.Debug {
  112892. /**
  112893. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  112894. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  112895. */
  112896. export class BoneAxesViewer extends AxesViewer {
  112897. /**
  112898. * Gets or sets the target mesh where to display the axes viewer
  112899. */
  112900. mesh: Nullable<Mesh>;
  112901. /**
  112902. * Gets or sets the target bone where to display the axes viewer
  112903. */
  112904. bone: Nullable<Bone>;
  112905. /** Gets current position */
  112906. pos: Vector3;
  112907. /** Gets direction of X axis */
  112908. xaxis: Vector3;
  112909. /** Gets direction of Y axis */
  112910. yaxis: Vector3;
  112911. /** Gets direction of Z axis */
  112912. zaxis: Vector3;
  112913. /**
  112914. * Creates a new BoneAxesViewer
  112915. * @param scene defines the hosting scene
  112916. * @param bone defines the target bone
  112917. * @param mesh defines the target mesh
  112918. * @param scaleLines defines a scaling factor for line length (1 by default)
  112919. */
  112920. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  112921. /**
  112922. * Force the viewer to update
  112923. */
  112924. update(): void;
  112925. /** Releases resources */
  112926. dispose(): void;
  112927. }
  112928. }
  112929. declare module BABYLON {
  112930. /**
  112931. * Interface used to define scene explorer extensibility option
  112932. */
  112933. export interface IExplorerExtensibilityOption {
  112934. /**
  112935. * Define the option label
  112936. */
  112937. label: string;
  112938. /**
  112939. * Defines the action to execute on click
  112940. */
  112941. action: (entity: any) => void;
  112942. }
  112943. /**
  112944. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  112945. */
  112946. export interface IExplorerExtensibilityGroup {
  112947. /**
  112948. * Defines a predicate to test if a given type mut be extended
  112949. */
  112950. predicate: (entity: any) => boolean;
  112951. /**
  112952. * Gets the list of options added to a type
  112953. */
  112954. entries: IExplorerExtensibilityOption[];
  112955. }
  112956. /**
  112957. * Interface used to define the options to use to create the Inspector
  112958. */
  112959. export interface IInspectorOptions {
  112960. /**
  112961. * Display in overlay mode (default: false)
  112962. */
  112963. overlay?: boolean;
  112964. /**
  112965. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  112966. */
  112967. globalRoot?: HTMLElement;
  112968. /**
  112969. * Display the Scene explorer
  112970. */
  112971. showExplorer?: boolean;
  112972. /**
  112973. * Display the property inspector
  112974. */
  112975. showInspector?: boolean;
  112976. /**
  112977. * Display in embed mode (both panes on the right)
  112978. */
  112979. embedMode?: boolean;
  112980. /**
  112981. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  112982. */
  112983. handleResize?: boolean;
  112984. /**
  112985. * Allow the panes to popup (default: true)
  112986. */
  112987. enablePopup?: boolean;
  112988. /**
  112989. * Allow the panes to be closed by users (default: true)
  112990. */
  112991. enableClose?: boolean;
  112992. /**
  112993. * Optional list of extensibility entries
  112994. */
  112995. explorerExtensibility?: IExplorerExtensibilityGroup[];
  112996. /**
  112997. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  112998. */
  112999. inspectorURL?: string;
  113000. }
  113001. interface Scene {
  113002. /**
  113003. * @hidden
  113004. * Backing field
  113005. */
  113006. _debugLayer: DebugLayer;
  113007. /**
  113008. * Gets the debug layer (aka Inspector) associated with the scene
  113009. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113010. */
  113011. debugLayer: DebugLayer;
  113012. }
  113013. /**
  113014. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113015. * what is happening in your scene
  113016. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113017. */
  113018. export class DebugLayer {
  113019. /**
  113020. * Define the url to get the inspector script from.
  113021. * By default it uses the babylonjs CDN.
  113022. * @ignoreNaming
  113023. */
  113024. static InspectorURL: string;
  113025. private _scene;
  113026. private BJSINSPECTOR;
  113027. private _onPropertyChangedObservable?;
  113028. /**
  113029. * Observable triggered when a property is changed through the inspector.
  113030. */
  113031. readonly onPropertyChangedObservable: any;
  113032. /**
  113033. * Instantiates a new debug layer.
  113034. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113035. * what is happening in your scene
  113036. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113037. * @param scene Defines the scene to inspect
  113038. */
  113039. constructor(scene: Scene);
  113040. /** Creates the inspector window. */
  113041. private _createInspector;
  113042. /**
  113043. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  113044. * @param entity defines the entity to select
  113045. * @param lineContainerTitle defines the specific block to highlight
  113046. */
  113047. select(entity: any, lineContainerTitle?: string): void;
  113048. /** Get the inspector from bundle or global */
  113049. private _getGlobalInspector;
  113050. /**
  113051. * Get if the inspector is visible or not.
  113052. * @returns true if visible otherwise, false
  113053. */
  113054. isVisible(): boolean;
  113055. /**
  113056. * Hide the inspector and close its window.
  113057. */
  113058. hide(): void;
  113059. /**
  113060. * Launch the debugLayer.
  113061. * @param config Define the configuration of the inspector
  113062. * @return a promise fulfilled when the debug layer is visible
  113063. */
  113064. show(config?: IInspectorOptions): Promise<DebugLayer>;
  113065. }
  113066. }
  113067. declare module BABYLON {
  113068. /**
  113069. * Class containing static functions to help procedurally build meshes
  113070. */
  113071. export class BoxBuilder {
  113072. /**
  113073. * Creates a box mesh
  113074. * * The parameter `size` sets the size (float) of each box side (default 1)
  113075. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  113076. * * 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)
  113077. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113081. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  113082. * @param name defines the name of the mesh
  113083. * @param options defines the options used to create the mesh
  113084. * @param scene defines the hosting scene
  113085. * @returns the box mesh
  113086. */
  113087. static CreateBox(name: string, options: {
  113088. size?: number;
  113089. width?: number;
  113090. height?: number;
  113091. depth?: number;
  113092. faceUV?: Vector4[];
  113093. faceColors?: Color4[];
  113094. sideOrientation?: number;
  113095. frontUVs?: Vector4;
  113096. backUVs?: Vector4;
  113097. wrap?: boolean;
  113098. topBaseAt?: number;
  113099. bottomBaseAt?: number;
  113100. updatable?: boolean;
  113101. }, scene?: Nullable<Scene>): Mesh;
  113102. }
  113103. }
  113104. declare module BABYLON {
  113105. /**
  113106. * Class containing static functions to help procedurally build meshes
  113107. */
  113108. export class SphereBuilder {
  113109. /**
  113110. * Creates a sphere mesh
  113111. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  113112. * * 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`)
  113113. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  113114. * * 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
  113115. * * 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)
  113116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113119. * @param name defines the name of the mesh
  113120. * @param options defines the options used to create the mesh
  113121. * @param scene defines the hosting scene
  113122. * @returns the sphere mesh
  113123. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  113124. */
  113125. static CreateSphere(name: string, options: {
  113126. segments?: number;
  113127. diameter?: number;
  113128. diameterX?: number;
  113129. diameterY?: number;
  113130. diameterZ?: number;
  113131. arc?: number;
  113132. slice?: number;
  113133. sideOrientation?: number;
  113134. frontUVs?: Vector4;
  113135. backUVs?: Vector4;
  113136. updatable?: boolean;
  113137. }, scene?: Nullable<Scene>): Mesh;
  113138. }
  113139. }
  113140. declare module BABYLON.Debug {
  113141. /**
  113142. * Used to show the physics impostor around the specific mesh
  113143. */
  113144. export class PhysicsViewer {
  113145. /** @hidden */
  113146. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  113147. /** @hidden */
  113148. protected _meshes: Array<Nullable<AbstractMesh>>;
  113149. /** @hidden */
  113150. protected _scene: Nullable<Scene>;
  113151. /** @hidden */
  113152. protected _numMeshes: number;
  113153. /** @hidden */
  113154. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  113155. private _renderFunction;
  113156. private _utilityLayer;
  113157. private _debugBoxMesh;
  113158. private _debugSphereMesh;
  113159. private _debugCylinderMesh;
  113160. private _debugMaterial;
  113161. private _debugMeshMeshes;
  113162. /**
  113163. * Creates a new PhysicsViewer
  113164. * @param scene defines the hosting scene
  113165. */
  113166. constructor(scene: Scene);
  113167. /** @hidden */
  113168. protected _updateDebugMeshes(): void;
  113169. /**
  113170. * Renders a specified physic impostor
  113171. * @param impostor defines the impostor to render
  113172. * @param targetMesh defines the mesh represented by the impostor
  113173. * @returns the new debug mesh used to render the impostor
  113174. */
  113175. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  113176. /**
  113177. * Hides a specified physic impostor
  113178. * @param impostor defines the impostor to hide
  113179. */
  113180. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  113181. private _getDebugMaterial;
  113182. private _getDebugBoxMesh;
  113183. private _getDebugSphereMesh;
  113184. private _getDebugCylinderMesh;
  113185. private _getDebugMeshMesh;
  113186. private _getDebugMesh;
  113187. /** Releases all resources */
  113188. dispose(): void;
  113189. }
  113190. }
  113191. declare module BABYLON {
  113192. /**
  113193. * Class containing static functions to help procedurally build meshes
  113194. */
  113195. export class LinesBuilder {
  113196. /**
  113197. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  113198. * * 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
  113199. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  113200. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  113201. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  113202. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  113203. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  113204. * * 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
  113205. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  113206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  113208. * @param name defines the name of the new line system
  113209. * @param options defines the options used to create the line system
  113210. * @param scene defines the hosting scene
  113211. * @returns a new line system mesh
  113212. */
  113213. static CreateLineSystem(name: string, options: {
  113214. lines: Vector3[][];
  113215. updatable?: boolean;
  113216. instance?: Nullable<LinesMesh>;
  113217. colors?: Nullable<Color4[][]>;
  113218. useVertexAlpha?: boolean;
  113219. }, scene: Nullable<Scene>): LinesMesh;
  113220. /**
  113221. * Creates a line mesh
  113222. * 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
  113223. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113224. * * The parameter `points` is an array successive Vector3
  113225. * * 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
  113226. * * The optional parameter `colors` is an array of successive Color4, one per line point
  113227. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  113228. * * When updating an instance, remember that only point positions can change, not the number of points
  113229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  113231. * @param name defines the name of the new line system
  113232. * @param options defines the options used to create the line system
  113233. * @param scene defines the hosting scene
  113234. * @returns a new line mesh
  113235. */
  113236. static CreateLines(name: string, options: {
  113237. points: Vector3[];
  113238. updatable?: boolean;
  113239. instance?: Nullable<LinesMesh>;
  113240. colors?: Color4[];
  113241. useVertexAlpha?: boolean;
  113242. }, scene?: Nullable<Scene>): LinesMesh;
  113243. /**
  113244. * Creates a dashed line mesh
  113245. * * 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
  113246. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113247. * * The parameter `points` is an array successive Vector3
  113248. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  113249. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  113250. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113251. * * 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
  113252. * * When updating an instance, remember that only point positions can change, not the number of points
  113253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113254. * @param name defines the name of the mesh
  113255. * @param options defines the options used to create the mesh
  113256. * @param scene defines the hosting scene
  113257. * @returns the dashed line mesh
  113258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  113259. */
  113260. static CreateDashedLines(name: string, options: {
  113261. points: Vector3[];
  113262. dashSize?: number;
  113263. gapSize?: number;
  113264. dashNb?: number;
  113265. updatable?: boolean;
  113266. instance?: LinesMesh;
  113267. }, scene?: Nullable<Scene>): LinesMesh;
  113268. }
  113269. }
  113270. declare module BABYLON {
  113271. /**
  113272. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113273. * in order to better appreciate the issue one might have.
  113274. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113275. */
  113276. export class RayHelper {
  113277. /**
  113278. * Defines the ray we are currently tryin to visualize.
  113279. */
  113280. ray: Nullable<Ray>;
  113281. private _renderPoints;
  113282. private _renderLine;
  113283. private _renderFunction;
  113284. private _scene;
  113285. private _updateToMeshFunction;
  113286. private _attachedToMesh;
  113287. private _meshSpaceDirection;
  113288. private _meshSpaceOrigin;
  113289. /**
  113290. * Helper function to create a colored helper in a scene in one line.
  113291. * @param ray Defines the ray we are currently tryin to visualize
  113292. * @param scene Defines the scene the ray is used in
  113293. * @param color Defines the color we want to see the ray in
  113294. * @returns The newly created ray helper.
  113295. */
  113296. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  113297. /**
  113298. * Instantiate a new ray helper.
  113299. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113300. * in order to better appreciate the issue one might have.
  113301. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113302. * @param ray Defines the ray we are currently tryin to visualize
  113303. */
  113304. constructor(ray: Ray);
  113305. /**
  113306. * Shows the ray we are willing to debug.
  113307. * @param scene Defines the scene the ray needs to be rendered in
  113308. * @param color Defines the color the ray needs to be rendered in
  113309. */
  113310. show(scene: Scene, color?: Color3): void;
  113311. /**
  113312. * Hides the ray we are debugging.
  113313. */
  113314. hide(): void;
  113315. private _render;
  113316. /**
  113317. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  113318. * @param mesh Defines the mesh we want the helper attached to
  113319. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  113320. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  113321. * @param length Defines the length of the ray
  113322. */
  113323. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  113324. /**
  113325. * Detach the ray helper from the mesh it has previously been attached to.
  113326. */
  113327. detachFromMesh(): void;
  113328. private _updateToMesh;
  113329. /**
  113330. * Dispose the helper and release its associated resources.
  113331. */
  113332. dispose(): void;
  113333. }
  113334. }
  113335. declare module BABYLON.Debug {
  113336. /**
  113337. * Class used to render a debug view of a given skeleton
  113338. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  113339. */
  113340. export class SkeletonViewer {
  113341. /** defines the skeleton to render */
  113342. skeleton: Skeleton;
  113343. /** defines the mesh attached to the skeleton */
  113344. mesh: AbstractMesh;
  113345. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113346. autoUpdateBonesMatrices: boolean;
  113347. /** defines the rendering group id to use with the viewer */
  113348. renderingGroupId: number;
  113349. /** Gets or sets the color used to render the skeleton */
  113350. color: Color3;
  113351. private _scene;
  113352. private _debugLines;
  113353. private _debugMesh;
  113354. private _isEnabled;
  113355. private _renderFunction;
  113356. private _utilityLayer;
  113357. /**
  113358. * Returns the mesh used to render the bones
  113359. */
  113360. readonly debugMesh: Nullable<LinesMesh>;
  113361. /**
  113362. * Creates a new SkeletonViewer
  113363. * @param skeleton defines the skeleton to render
  113364. * @param mesh defines the mesh attached to the skeleton
  113365. * @param scene defines the hosting scene
  113366. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  113367. * @param renderingGroupId defines the rendering group id to use with the viewer
  113368. */
  113369. constructor(
  113370. /** defines the skeleton to render */
  113371. skeleton: Skeleton,
  113372. /** defines the mesh attached to the skeleton */
  113373. mesh: AbstractMesh, scene: Scene,
  113374. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113375. autoUpdateBonesMatrices?: boolean,
  113376. /** defines the rendering group id to use with the viewer */
  113377. renderingGroupId?: number);
  113378. /** Gets or sets a boolean indicating if the viewer is enabled */
  113379. isEnabled: boolean;
  113380. private _getBonePosition;
  113381. private _getLinesForBonesWithLength;
  113382. private _getLinesForBonesNoLength;
  113383. /** Update the viewer to sync with current skeleton state */
  113384. update(): void;
  113385. /** Release associated resources */
  113386. dispose(): void;
  113387. }
  113388. }
  113389. declare module BABYLON {
  113390. /**
  113391. * Options to create the null engine
  113392. */
  113393. export class NullEngineOptions {
  113394. /**
  113395. * Render width (Default: 512)
  113396. */
  113397. renderWidth: number;
  113398. /**
  113399. * Render height (Default: 256)
  113400. */
  113401. renderHeight: number;
  113402. /**
  113403. * Texture size (Default: 512)
  113404. */
  113405. textureSize: number;
  113406. /**
  113407. * If delta time between frames should be constant
  113408. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113409. */
  113410. deterministicLockstep: boolean;
  113411. /**
  113412. * Maximum about of steps between frames (Default: 4)
  113413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113414. */
  113415. lockstepMaxSteps: number;
  113416. }
  113417. /**
  113418. * The null engine class provides support for headless version of babylon.js.
  113419. * This can be used in server side scenario or for testing purposes
  113420. */
  113421. export class NullEngine extends Engine {
  113422. private _options;
  113423. /**
  113424. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113425. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113426. * @returns true if engine is in deterministic lock step mode
  113427. */
  113428. isDeterministicLockStep(): boolean;
  113429. /**
  113430. * Gets the max steps when engine is running in deterministic lock step
  113431. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113432. * @returns the max steps
  113433. */
  113434. getLockstepMaxSteps(): number;
  113435. /**
  113436. * Gets the current hardware scaling level.
  113437. * By default the hardware scaling level is computed from the window device ratio.
  113438. * 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.
  113439. * @returns a number indicating the current hardware scaling level
  113440. */
  113441. getHardwareScalingLevel(): number;
  113442. constructor(options?: NullEngineOptions);
  113443. /**
  113444. * Creates a vertex buffer
  113445. * @param vertices the data for the vertex buffer
  113446. * @returns the new WebGL static buffer
  113447. */
  113448. createVertexBuffer(vertices: FloatArray): DataBuffer;
  113449. /**
  113450. * Creates a new index buffer
  113451. * @param indices defines the content of the index buffer
  113452. * @param updatable defines if the index buffer must be updatable
  113453. * @returns a new webGL buffer
  113454. */
  113455. createIndexBuffer(indices: IndicesArray): DataBuffer;
  113456. /**
  113457. * Clear the current render buffer or the current render target (if any is set up)
  113458. * @param color defines the color to use
  113459. * @param backBuffer defines if the back buffer must be cleared
  113460. * @param depth defines if the depth buffer must be cleared
  113461. * @param stencil defines if the stencil buffer must be cleared
  113462. */
  113463. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113464. /**
  113465. * Gets the current render width
  113466. * @param useScreen defines if screen size must be used (or the current render target if any)
  113467. * @returns a number defining the current render width
  113468. */
  113469. getRenderWidth(useScreen?: boolean): number;
  113470. /**
  113471. * Gets the current render height
  113472. * @param useScreen defines if screen size must be used (or the current render target if any)
  113473. * @returns a number defining the current render height
  113474. */
  113475. getRenderHeight(useScreen?: boolean): number;
  113476. /**
  113477. * Set the WebGL's viewport
  113478. * @param viewport defines the viewport element to be used
  113479. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  113480. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  113481. */
  113482. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  113483. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  113484. /**
  113485. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113486. * @param pipelineContext defines the pipeline context to use
  113487. * @param uniformsNames defines the list of uniform names
  113488. * @returns an array of webGL uniform locations
  113489. */
  113490. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113491. /**
  113492. * Gets the lsit of active attributes for a given webGL program
  113493. * @param pipelineContext defines the pipeline context to use
  113494. * @param attributesNames defines the list of attribute names to get
  113495. * @returns an array of indices indicating the offset of each attribute
  113496. */
  113497. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113498. /**
  113499. * Binds an effect to the webGL context
  113500. * @param effect defines the effect to bind
  113501. */
  113502. bindSamplers(effect: Effect): void;
  113503. /**
  113504. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113505. * @param effect defines the effect to activate
  113506. */
  113507. enableEffect(effect: Effect): void;
  113508. /**
  113509. * Set various states to the webGL context
  113510. * @param culling defines backface culling state
  113511. * @param zOffset defines the value to apply to zOffset (0 by default)
  113512. * @param force defines if states must be applied even if cache is up to date
  113513. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113514. */
  113515. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113516. /**
  113517. * Set the value of an uniform to an array of int32
  113518. * @param uniform defines the webGL uniform location where to store the value
  113519. * @param array defines the array of int32 to store
  113520. */
  113521. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113522. /**
  113523. * Set the value of an uniform to an array of int32 (stored as vec2)
  113524. * @param uniform defines the webGL uniform location where to store the value
  113525. * @param array defines the array of int32 to store
  113526. */
  113527. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113528. /**
  113529. * Set the value of an uniform to an array of int32 (stored as vec3)
  113530. * @param uniform defines the webGL uniform location where to store the value
  113531. * @param array defines the array of int32 to store
  113532. */
  113533. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113534. /**
  113535. * Set the value of an uniform to an array of int32 (stored as vec4)
  113536. * @param uniform defines the webGL uniform location where to store the value
  113537. * @param array defines the array of int32 to store
  113538. */
  113539. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113540. /**
  113541. * Set the value of an uniform to an array of float32
  113542. * @param uniform defines the webGL uniform location where to store the value
  113543. * @param array defines the array of float32 to store
  113544. */
  113545. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113546. /**
  113547. * Set the value of an uniform to an array of float32 (stored as vec2)
  113548. * @param uniform defines the webGL uniform location where to store the value
  113549. * @param array defines the array of float32 to store
  113550. */
  113551. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113552. /**
  113553. * Set the value of an uniform to an array of float32 (stored as vec3)
  113554. * @param uniform defines the webGL uniform location where to store the value
  113555. * @param array defines the array of float32 to store
  113556. */
  113557. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113558. /**
  113559. * Set the value of an uniform to an array of float32 (stored as vec4)
  113560. * @param uniform defines the webGL uniform location where to store the value
  113561. * @param array defines the array of float32 to store
  113562. */
  113563. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113564. /**
  113565. * Set the value of an uniform to an array of number
  113566. * @param uniform defines the webGL uniform location where to store the value
  113567. * @param array defines the array of number to store
  113568. */
  113569. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113570. /**
  113571. * Set the value of an uniform to an array of number (stored as vec2)
  113572. * @param uniform defines the webGL uniform location where to store the value
  113573. * @param array defines the array of number to store
  113574. */
  113575. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113576. /**
  113577. * Set the value of an uniform to an array of number (stored as vec3)
  113578. * @param uniform defines the webGL uniform location where to store the value
  113579. * @param array defines the array of number to store
  113580. */
  113581. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113582. /**
  113583. * Set the value of an uniform to an array of number (stored as vec4)
  113584. * @param uniform defines the webGL uniform location where to store the value
  113585. * @param array defines the array of number to store
  113586. */
  113587. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113588. /**
  113589. * Set the value of an uniform to an array of float32 (stored as matrices)
  113590. * @param uniform defines the webGL uniform location where to store the value
  113591. * @param matrices defines the array of float32 to store
  113592. */
  113593. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113594. /**
  113595. * Set the value of an uniform to a matrix (3x3)
  113596. * @param uniform defines the webGL uniform location where to store the value
  113597. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113598. */
  113599. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113600. /**
  113601. * Set the value of an uniform to a matrix (2x2)
  113602. * @param uniform defines the webGL uniform location where to store the value
  113603. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113604. */
  113605. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113606. /**
  113607. * Set the value of an uniform to a number (float)
  113608. * @param uniform defines the webGL uniform location where to store the value
  113609. * @param value defines the float number to store
  113610. */
  113611. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113612. /**
  113613. * Set the value of an uniform to a vec2
  113614. * @param uniform defines the webGL uniform location where to store the value
  113615. * @param x defines the 1st component of the value
  113616. * @param y defines the 2nd component of the value
  113617. */
  113618. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113619. /**
  113620. * Set the value of an uniform to a vec3
  113621. * @param uniform defines the webGL uniform location where to store the value
  113622. * @param x defines the 1st component of the value
  113623. * @param y defines the 2nd component of the value
  113624. * @param z defines the 3rd component of the value
  113625. */
  113626. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113627. /**
  113628. * Set the value of an uniform to a boolean
  113629. * @param uniform defines the webGL uniform location where to store the value
  113630. * @param bool defines the boolean to store
  113631. */
  113632. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113633. /**
  113634. * Set the value of an uniform to a vec4
  113635. * @param uniform defines the webGL uniform location where to store the value
  113636. * @param x defines the 1st component of the value
  113637. * @param y defines the 2nd component of the value
  113638. * @param z defines the 3rd component of the value
  113639. * @param w defines the 4th component of the value
  113640. */
  113641. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113642. /**
  113643. * Sets the current alpha mode
  113644. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113645. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113646. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113647. */
  113648. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113649. /**
  113650. * Bind webGl buffers directly to the webGL context
  113651. * @param vertexBuffers defines the vertex buffer to bind
  113652. * @param indexBuffer defines the index buffer to bind
  113653. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  113654. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  113655. * @param effect defines the effect associated with the vertex buffer
  113656. */
  113657. bindBuffers(vertexBuffers: {
  113658. [key: string]: VertexBuffer;
  113659. }, indexBuffer: DataBuffer, effect: Effect): void;
  113660. /**
  113661. * Force the entire cache to be cleared
  113662. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113663. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113664. */
  113665. wipeCaches(bruteForce?: boolean): void;
  113666. /**
  113667. * Send a draw order
  113668. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113669. * @param indexStart defines the starting index
  113670. * @param indexCount defines the number of index to draw
  113671. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113672. */
  113673. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113674. /**
  113675. * Draw a list of indexed primitives
  113676. * @param fillMode defines the primitive to use
  113677. * @param indexStart defines the starting index
  113678. * @param indexCount defines the number of index to draw
  113679. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113680. */
  113681. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113682. /**
  113683. * Draw a list of unindexed primitives
  113684. * @param fillMode defines the primitive to use
  113685. * @param verticesStart defines the index of first vertex to draw
  113686. * @param verticesCount defines the count of vertices to draw
  113687. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113688. */
  113689. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113690. /** @hidden */
  113691. _createTexture(): WebGLTexture;
  113692. /** @hidden */
  113693. _releaseTexture(texture: InternalTexture): void;
  113694. /**
  113695. * Usually called from Texture.ts.
  113696. * Passed information to create a WebGLTexture
  113697. * @param urlArg defines a value which contains one of the following:
  113698. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113699. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113700. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113702. * @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)
  113703. * @param scene needed for loading to the correct scene
  113704. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113705. * @param onLoad optional callback to be called upon successful completion
  113706. * @param onError optional callback to be called upon failure
  113707. * @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
  113708. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113709. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113710. * @param forcedExtension defines the extension to use to pick the right loader
  113711. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  113712. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113713. */
  113714. 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;
  113715. /**
  113716. * Creates a new render target texture
  113717. * @param size defines the size of the texture
  113718. * @param options defines the options used to create the texture
  113719. * @returns a new render target texture stored in an InternalTexture
  113720. */
  113721. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  113722. /**
  113723. * Update the sampling mode of a given texture
  113724. * @param samplingMode defines the required sampling mode
  113725. * @param texture defines the texture to update
  113726. */
  113727. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113728. /**
  113729. * Binds the frame buffer to the specified texture.
  113730. * @param texture The texture to render to or null for the default canvas
  113731. * @param faceIndex The face of the texture to render to in case of cube texture
  113732. * @param requiredWidth The width of the target to render to
  113733. * @param requiredHeight The height of the target to render to
  113734. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  113735. * @param depthStencilTexture The depth stencil texture to use to render
  113736. * @param lodLevel defines le lod level to bind to the frame buffer
  113737. */
  113738. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113739. /**
  113740. * Unbind the current render target texture from the webGL context
  113741. * @param texture defines the render target texture to unbind
  113742. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113743. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113744. */
  113745. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113746. /**
  113747. * Creates a dynamic vertex buffer
  113748. * @param vertices the data for the dynamic vertex buffer
  113749. * @returns the new WebGL dynamic buffer
  113750. */
  113751. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  113752. /**
  113753. * Update the content of a dynamic texture
  113754. * @param texture defines the texture to update
  113755. * @param canvas defines the canvas containing the source
  113756. * @param invertY defines if data must be stored with Y axis inverted
  113757. * @param premulAlpha defines if alpha is stored as premultiplied
  113758. * @param format defines the format of the data
  113759. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113760. */
  113761. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  113762. /**
  113763. * Gets a boolean indicating if all created effects are ready
  113764. * @returns true if all effects are ready
  113765. */
  113766. areAllEffectsReady(): boolean;
  113767. /**
  113768. * @hidden
  113769. * Get the current error code of the webGL context
  113770. * @returns the error code
  113771. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113772. */
  113773. getError(): number;
  113774. /** @hidden */
  113775. _getUnpackAlignement(): number;
  113776. /** @hidden */
  113777. _unpackFlipY(value: boolean): void;
  113778. /**
  113779. * Update a dynamic index buffer
  113780. * @param indexBuffer defines the target index buffer
  113781. * @param indices defines the data to update
  113782. * @param offset defines the offset in the target index buffer where update should start
  113783. */
  113784. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  113785. /**
  113786. * Updates a dynamic vertex buffer.
  113787. * @param vertexBuffer the vertex buffer to update
  113788. * @param vertices the data used to update the vertex buffer
  113789. * @param byteOffset the byte offset of the data (optional)
  113790. * @param byteLength the byte length of the data (optional)
  113791. */
  113792. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  113793. /** @hidden */
  113794. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  113795. /** @hidden */
  113796. _bindTexture(channel: number, texture: InternalTexture): void;
  113797. protected _deleteBuffer(buffer: WebGLBuffer): void;
  113798. /**
  113799. * 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
  113800. */
  113801. releaseEffects(): void;
  113802. displayLoadingUI(): void;
  113803. hideLoadingUI(): void;
  113804. /** @hidden */
  113805. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113806. /** @hidden */
  113807. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113808. /** @hidden */
  113809. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113810. /** @hidden */
  113811. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113812. }
  113813. }
  113814. declare module BABYLON {
  113815. /** @hidden */
  113816. export class _OcclusionDataStorage {
  113817. /** @hidden */
  113818. occlusionInternalRetryCounter: number;
  113819. /** @hidden */
  113820. isOcclusionQueryInProgress: boolean;
  113821. /** @hidden */
  113822. isOccluded: boolean;
  113823. /** @hidden */
  113824. occlusionRetryCount: number;
  113825. /** @hidden */
  113826. occlusionType: number;
  113827. /** @hidden */
  113828. occlusionQueryAlgorithmType: number;
  113829. }
  113830. interface Engine {
  113831. /**
  113832. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  113833. * @return the new query
  113834. */
  113835. createQuery(): WebGLQuery;
  113836. /**
  113837. * Delete and release a webGL query
  113838. * @param query defines the query to delete
  113839. * @return the current engine
  113840. */
  113841. deleteQuery(query: WebGLQuery): Engine;
  113842. /**
  113843. * Check if a given query has resolved and got its value
  113844. * @param query defines the query to check
  113845. * @returns true if the query got its value
  113846. */
  113847. isQueryResultAvailable(query: WebGLQuery): boolean;
  113848. /**
  113849. * Gets the value of a given query
  113850. * @param query defines the query to check
  113851. * @returns the value of the query
  113852. */
  113853. getQueryResult(query: WebGLQuery): number;
  113854. /**
  113855. * Initiates an occlusion query
  113856. * @param algorithmType defines the algorithm to use
  113857. * @param query defines the query to use
  113858. * @returns the current engine
  113859. * @see http://doc.babylonjs.com/features/occlusionquery
  113860. */
  113861. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  113862. /**
  113863. * Ends an occlusion query
  113864. * @see http://doc.babylonjs.com/features/occlusionquery
  113865. * @param algorithmType defines the algorithm to use
  113866. * @returns the current engine
  113867. */
  113868. endOcclusionQuery(algorithmType: number): Engine;
  113869. /**
  113870. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  113871. * Please note that only one query can be issued at a time
  113872. * @returns a time token used to track the time span
  113873. */
  113874. startTimeQuery(): Nullable<_TimeToken>;
  113875. /**
  113876. * Ends a time query
  113877. * @param token defines the token used to measure the time span
  113878. * @returns the time spent (in ns)
  113879. */
  113880. endTimeQuery(token: _TimeToken): int;
  113881. /** @hidden */
  113882. _currentNonTimestampToken: Nullable<_TimeToken>;
  113883. /** @hidden */
  113884. _createTimeQuery(): WebGLQuery;
  113885. /** @hidden */
  113886. _deleteTimeQuery(query: WebGLQuery): void;
  113887. /** @hidden */
  113888. _getGlAlgorithmType(algorithmType: number): number;
  113889. /** @hidden */
  113890. _getTimeQueryResult(query: WebGLQuery): any;
  113891. /** @hidden */
  113892. _getTimeQueryAvailability(query: WebGLQuery): any;
  113893. }
  113894. interface AbstractMesh {
  113895. /**
  113896. * Backing filed
  113897. * @hidden
  113898. */
  113899. __occlusionDataStorage: _OcclusionDataStorage;
  113900. /**
  113901. * Access property
  113902. * @hidden
  113903. */
  113904. _occlusionDataStorage: _OcclusionDataStorage;
  113905. /**
  113906. * 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.
  113907. * The default value is -1 which means don't break the query and wait till the result
  113908. * @see http://doc.babylonjs.com/features/occlusionquery
  113909. */
  113910. occlusionRetryCount: number;
  113911. /**
  113912. * 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:
  113913. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  113914. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  113915. * * 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.
  113916. * @see http://doc.babylonjs.com/features/occlusionquery
  113917. */
  113918. occlusionType: number;
  113919. /**
  113920. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  113921. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  113922. * * 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.
  113923. * @see http://doc.babylonjs.com/features/occlusionquery
  113924. */
  113925. occlusionQueryAlgorithmType: number;
  113926. /**
  113927. * 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
  113928. * @see http://doc.babylonjs.com/features/occlusionquery
  113929. */
  113930. isOccluded: boolean;
  113931. /**
  113932. * Flag to check the progress status of the query
  113933. * @see http://doc.babylonjs.com/features/occlusionquery
  113934. */
  113935. isOcclusionQueryInProgress: boolean;
  113936. }
  113937. }
  113938. declare module BABYLON {
  113939. /** @hidden */
  113940. export var _forceTransformFeedbackToBundle: boolean;
  113941. interface Engine {
  113942. /**
  113943. * Creates a webGL transform feedback object
  113944. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  113945. * @returns the webGL transform feedback object
  113946. */
  113947. createTransformFeedback(): WebGLTransformFeedback;
  113948. /**
  113949. * Delete a webGL transform feedback object
  113950. * @param value defines the webGL transform feedback object to delete
  113951. */
  113952. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  113953. /**
  113954. * Bind a webGL transform feedback object to the webgl context
  113955. * @param value defines the webGL transform feedback object to bind
  113956. */
  113957. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  113958. /**
  113959. * Begins a transform feedback operation
  113960. * @param usePoints defines if points or triangles must be used
  113961. */
  113962. beginTransformFeedback(usePoints: boolean): void;
  113963. /**
  113964. * Ends a transform feedback operation
  113965. */
  113966. endTransformFeedback(): void;
  113967. /**
  113968. * Specify the varyings to use with transform feedback
  113969. * @param program defines the associated webGL program
  113970. * @param value defines the list of strings representing the varying names
  113971. */
  113972. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  113973. /**
  113974. * Bind a webGL buffer for a transform feedback operation
  113975. * @param value defines the webGL buffer to bind
  113976. */
  113977. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  113978. }
  113979. }
  113980. declare module BABYLON {
  113981. /**
  113982. * Creation options of the multi render target texture.
  113983. */
  113984. export interface IMultiRenderTargetOptions {
  113985. /**
  113986. * Define if the texture needs to create mip maps after render.
  113987. */
  113988. generateMipMaps?: boolean;
  113989. /**
  113990. * Define the types of all the draw buffers we want to create
  113991. */
  113992. types?: number[];
  113993. /**
  113994. * Define the sampling modes of all the draw buffers we want to create
  113995. */
  113996. samplingModes?: number[];
  113997. /**
  113998. * Define if a depth buffer is required
  113999. */
  114000. generateDepthBuffer?: boolean;
  114001. /**
  114002. * Define if a stencil buffer is required
  114003. */
  114004. generateStencilBuffer?: boolean;
  114005. /**
  114006. * Define if a depth texture is required instead of a depth buffer
  114007. */
  114008. generateDepthTexture?: boolean;
  114009. /**
  114010. * Define the number of desired draw buffers
  114011. */
  114012. textureCount?: number;
  114013. /**
  114014. * Define if aspect ratio should be adapted to the texture or stay the scene one
  114015. */
  114016. doNotChangeAspectRatio?: boolean;
  114017. /**
  114018. * Define the default type of the buffers we are creating
  114019. */
  114020. defaultType?: number;
  114021. }
  114022. /**
  114023. * A multi render target, like a render target provides the ability to render to a texture.
  114024. * Unlike the render target, it can render to several draw buffers in one draw.
  114025. * This is specially interesting in deferred rendering or for any effects requiring more than
  114026. * just one color from a single pass.
  114027. */
  114028. export class MultiRenderTarget extends RenderTargetTexture {
  114029. private _internalTextures;
  114030. private _textures;
  114031. private _multiRenderTargetOptions;
  114032. /**
  114033. * Get if draw buffers are currently supported by the used hardware and browser.
  114034. */
  114035. readonly isSupported: boolean;
  114036. /**
  114037. * Get the list of textures generated by the multi render target.
  114038. */
  114039. readonly textures: Texture[];
  114040. /**
  114041. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  114042. */
  114043. readonly depthTexture: Texture;
  114044. /**
  114045. * Set the wrapping mode on U of all the textures we are rendering to.
  114046. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114047. */
  114048. wrapU: number;
  114049. /**
  114050. * Set the wrapping mode on V of all the textures we are rendering to.
  114051. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114052. */
  114053. wrapV: number;
  114054. /**
  114055. * Instantiate a new multi render target texture.
  114056. * A multi render target, like a render target provides the ability to render to a texture.
  114057. * Unlike the render target, it can render to several draw buffers in one draw.
  114058. * This is specially interesting in deferred rendering or for any effects requiring more than
  114059. * just one color from a single pass.
  114060. * @param name Define the name of the texture
  114061. * @param size Define the size of the buffers to render to
  114062. * @param count Define the number of target we are rendering into
  114063. * @param scene Define the scene the texture belongs to
  114064. * @param options Define the options used to create the multi render target
  114065. */
  114066. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  114067. /** @hidden */
  114068. _rebuild(): void;
  114069. private _createInternalTextures;
  114070. private _createTextures;
  114071. /**
  114072. * Define the number of samples used if MSAA is enabled.
  114073. */
  114074. samples: number;
  114075. /**
  114076. * Resize all the textures in the multi render target.
  114077. * Be carrefull as it will recreate all the data in the new texture.
  114078. * @param size Define the new size
  114079. */
  114080. resize(size: any): void;
  114081. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  114082. /**
  114083. * Dispose the render targets and their associated resources
  114084. */
  114085. dispose(): void;
  114086. /**
  114087. * Release all the underlying texture used as draw buffers.
  114088. */
  114089. releaseInternalTextures(): void;
  114090. }
  114091. }
  114092. declare module BABYLON {
  114093. interface ThinEngine {
  114094. /**
  114095. * Unbind a list of render target textures from the webGL context
  114096. * This is used only when drawBuffer extension or webGL2 are active
  114097. * @param textures defines the render target textures to unbind
  114098. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114099. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114100. */
  114101. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  114102. /**
  114103. * Create a multi render target texture
  114104. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  114105. * @param size defines the size of the texture
  114106. * @param options defines the creation options
  114107. * @returns the cube texture as an InternalTexture
  114108. */
  114109. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  114110. /**
  114111. * Update the sample count for a given multiple render target texture
  114112. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114113. * @param textures defines the textures to update
  114114. * @param samples defines the sample count to set
  114115. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114116. */
  114117. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  114118. }
  114119. }
  114120. declare module BABYLON {
  114121. /**
  114122. * Class used to define an additional view for the engine
  114123. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114124. */
  114125. export class EngineView {
  114126. /** Defines the canvas where to render the view */
  114127. target: HTMLCanvasElement;
  114128. /** Defines an optional camera used to render the view (will use active camera else) */
  114129. camera?: Camera;
  114130. }
  114131. interface Engine {
  114132. /**
  114133. * Gets or sets the HTML element to use for attaching events
  114134. */
  114135. inputElement: Nullable<HTMLElement>;
  114136. /**
  114137. * Gets the current engine view
  114138. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114139. */
  114140. activeView: Nullable<EngineView>;
  114141. /** Gets or sets the list of views */
  114142. views: EngineView[];
  114143. /**
  114144. * Register a new child canvas
  114145. * @param canvas defines the canvas to register
  114146. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  114147. * @returns the associated view
  114148. */
  114149. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  114150. /**
  114151. * Remove a registered child canvas
  114152. * @param canvas defines the canvas to remove
  114153. * @returns the current engine
  114154. */
  114155. unRegisterView(canvas: HTMLCanvasElement): Engine;
  114156. }
  114157. }
  114158. declare module BABYLON {
  114159. /**
  114160. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  114161. */
  114162. export interface CubeMapInfo {
  114163. /**
  114164. * The pixel array for the front face.
  114165. * This is stored in format, left to right, up to down format.
  114166. */
  114167. front: Nullable<ArrayBufferView>;
  114168. /**
  114169. * The pixel array for the back face.
  114170. * This is stored in format, left to right, up to down format.
  114171. */
  114172. back: Nullable<ArrayBufferView>;
  114173. /**
  114174. * The pixel array for the left face.
  114175. * This is stored in format, left to right, up to down format.
  114176. */
  114177. left: Nullable<ArrayBufferView>;
  114178. /**
  114179. * The pixel array for the right face.
  114180. * This is stored in format, left to right, up to down format.
  114181. */
  114182. right: Nullable<ArrayBufferView>;
  114183. /**
  114184. * The pixel array for the up face.
  114185. * This is stored in format, left to right, up to down format.
  114186. */
  114187. up: Nullable<ArrayBufferView>;
  114188. /**
  114189. * The pixel array for the down face.
  114190. * This is stored in format, left to right, up to down format.
  114191. */
  114192. down: Nullable<ArrayBufferView>;
  114193. /**
  114194. * The size of the cubemap stored.
  114195. *
  114196. * Each faces will be size * size pixels.
  114197. */
  114198. size: number;
  114199. /**
  114200. * The format of the texture.
  114201. *
  114202. * RGBA, RGB.
  114203. */
  114204. format: number;
  114205. /**
  114206. * The type of the texture data.
  114207. *
  114208. * UNSIGNED_INT, FLOAT.
  114209. */
  114210. type: number;
  114211. /**
  114212. * Specifies whether the texture is in gamma space.
  114213. */
  114214. gammaSpace: boolean;
  114215. }
  114216. /**
  114217. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  114218. */
  114219. export class PanoramaToCubeMapTools {
  114220. private static FACE_FRONT;
  114221. private static FACE_BACK;
  114222. private static FACE_RIGHT;
  114223. private static FACE_LEFT;
  114224. private static FACE_DOWN;
  114225. private static FACE_UP;
  114226. /**
  114227. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  114228. *
  114229. * @param float32Array The source data.
  114230. * @param inputWidth The width of the input panorama.
  114231. * @param inputHeight The height of the input panorama.
  114232. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  114233. * @return The cubemap data
  114234. */
  114235. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  114236. private static CreateCubemapTexture;
  114237. private static CalcProjectionSpherical;
  114238. }
  114239. }
  114240. declare module BABYLON {
  114241. /**
  114242. * Helper class dealing with the extraction of spherical polynomial dataArray
  114243. * from a cube map.
  114244. */
  114245. export class CubeMapToSphericalPolynomialTools {
  114246. private static FileFaces;
  114247. /**
  114248. * Converts a texture to the according Spherical Polynomial data.
  114249. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114250. *
  114251. * @param texture The texture to extract the information from.
  114252. * @return The Spherical Polynomial data.
  114253. */
  114254. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  114255. /**
  114256. * Converts a cubemap to the according Spherical Polynomial data.
  114257. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114258. *
  114259. * @param cubeInfo The Cube map to extract the information from.
  114260. * @return The Spherical Polynomial data.
  114261. */
  114262. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  114263. }
  114264. }
  114265. declare module BABYLON {
  114266. interface BaseTexture {
  114267. /**
  114268. * Get the polynomial representation of the texture data.
  114269. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  114270. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  114271. */
  114272. sphericalPolynomial: Nullable<SphericalPolynomial>;
  114273. }
  114274. }
  114275. declare module BABYLON {
  114276. /** @hidden */
  114277. export var rgbdEncodePixelShader: {
  114278. name: string;
  114279. shader: string;
  114280. };
  114281. }
  114282. declare module BABYLON {
  114283. /** @hidden */
  114284. export var rgbdDecodePixelShader: {
  114285. name: string;
  114286. shader: string;
  114287. };
  114288. }
  114289. declare module BABYLON {
  114290. /**
  114291. * Raw texture data and descriptor sufficient for WebGL texture upload
  114292. */
  114293. export interface EnvironmentTextureInfo {
  114294. /**
  114295. * Version of the environment map
  114296. */
  114297. version: number;
  114298. /**
  114299. * Width of image
  114300. */
  114301. width: number;
  114302. /**
  114303. * Irradiance information stored in the file.
  114304. */
  114305. irradiance: any;
  114306. /**
  114307. * Specular information stored in the file.
  114308. */
  114309. specular: any;
  114310. }
  114311. /**
  114312. * Defines One Image in the file. It requires only the position in the file
  114313. * as well as the length.
  114314. */
  114315. interface BufferImageData {
  114316. /**
  114317. * Length of the image data.
  114318. */
  114319. length: number;
  114320. /**
  114321. * Position of the data from the null terminator delimiting the end of the JSON.
  114322. */
  114323. position: number;
  114324. }
  114325. /**
  114326. * Defines the specular data enclosed in the file.
  114327. * This corresponds to the version 1 of the data.
  114328. */
  114329. export interface EnvironmentTextureSpecularInfoV1 {
  114330. /**
  114331. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  114332. */
  114333. specularDataPosition?: number;
  114334. /**
  114335. * This contains all the images data needed to reconstruct the cubemap.
  114336. */
  114337. mipmaps: Array<BufferImageData>;
  114338. /**
  114339. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  114340. */
  114341. lodGenerationScale: number;
  114342. }
  114343. /**
  114344. * Sets of helpers addressing the serialization and deserialization of environment texture
  114345. * stored in a BabylonJS env file.
  114346. * Those files are usually stored as .env files.
  114347. */
  114348. export class EnvironmentTextureTools {
  114349. /**
  114350. * Magic number identifying the env file.
  114351. */
  114352. private static _MagicBytes;
  114353. /**
  114354. * Gets the environment info from an env file.
  114355. * @param data The array buffer containing the .env bytes.
  114356. * @returns the environment file info (the json header) if successfully parsed.
  114357. */
  114358. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  114359. /**
  114360. * Creates an environment texture from a loaded cube texture.
  114361. * @param texture defines the cube texture to convert in env file
  114362. * @return a promise containing the environment data if succesfull.
  114363. */
  114364. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  114365. /**
  114366. * Creates a JSON representation of the spherical data.
  114367. * @param texture defines the texture containing the polynomials
  114368. * @return the JSON representation of the spherical info
  114369. */
  114370. private static _CreateEnvTextureIrradiance;
  114371. /**
  114372. * Creates the ArrayBufferViews used for initializing environment texture image data.
  114373. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  114374. * @param info parameters that determine what views will be created for accessing the underlying buffer
  114375. * @return the views described by info providing access to the underlying buffer
  114376. */
  114377. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  114378. /**
  114379. * Uploads the texture info contained in the env file to the GPU.
  114380. * @param texture defines the internal texture to upload to
  114381. * @param arrayBuffer defines the buffer cotaining the data to load
  114382. * @param info defines the texture info retrieved through the GetEnvInfo method
  114383. * @returns a promise
  114384. */
  114385. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  114386. private static _OnImageReadyAsync;
  114387. /**
  114388. * Uploads the levels of image data to the GPU.
  114389. * @param texture defines the internal texture to upload to
  114390. * @param imageData defines the array buffer views of image data [mipmap][face]
  114391. * @returns a promise
  114392. */
  114393. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  114394. /**
  114395. * Uploads spherical polynomials information to the texture.
  114396. * @param texture defines the texture we are trying to upload the information to
  114397. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  114398. */
  114399. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  114400. /** @hidden */
  114401. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114402. }
  114403. }
  114404. declare module BABYLON {
  114405. /**
  114406. * Contains position and normal vectors for a vertex
  114407. */
  114408. export class PositionNormalVertex {
  114409. /** the position of the vertex (defaut: 0,0,0) */
  114410. position: Vector3;
  114411. /** the normal of the vertex (defaut: 0,1,0) */
  114412. normal: Vector3;
  114413. /**
  114414. * Creates a PositionNormalVertex
  114415. * @param position the position of the vertex (defaut: 0,0,0)
  114416. * @param normal the normal of the vertex (defaut: 0,1,0)
  114417. */
  114418. constructor(
  114419. /** the position of the vertex (defaut: 0,0,0) */
  114420. position?: Vector3,
  114421. /** the normal of the vertex (defaut: 0,1,0) */
  114422. normal?: Vector3);
  114423. /**
  114424. * Clones the PositionNormalVertex
  114425. * @returns the cloned PositionNormalVertex
  114426. */
  114427. clone(): PositionNormalVertex;
  114428. }
  114429. /**
  114430. * Contains position, normal and uv vectors for a vertex
  114431. */
  114432. export class PositionNormalTextureVertex {
  114433. /** the position of the vertex (defaut: 0,0,0) */
  114434. position: Vector3;
  114435. /** the normal of the vertex (defaut: 0,1,0) */
  114436. normal: Vector3;
  114437. /** the uv of the vertex (default: 0,0) */
  114438. uv: Vector2;
  114439. /**
  114440. * Creates a PositionNormalTextureVertex
  114441. * @param position the position of the vertex (defaut: 0,0,0)
  114442. * @param normal the normal of the vertex (defaut: 0,1,0)
  114443. * @param uv the uv of the vertex (default: 0,0)
  114444. */
  114445. constructor(
  114446. /** the position of the vertex (defaut: 0,0,0) */
  114447. position?: Vector3,
  114448. /** the normal of the vertex (defaut: 0,1,0) */
  114449. normal?: Vector3,
  114450. /** the uv of the vertex (default: 0,0) */
  114451. uv?: Vector2);
  114452. /**
  114453. * Clones the PositionNormalTextureVertex
  114454. * @returns the cloned PositionNormalTextureVertex
  114455. */
  114456. clone(): PositionNormalTextureVertex;
  114457. }
  114458. }
  114459. declare module BABYLON {
  114460. /** @hidden */
  114461. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  114462. private _genericAttributeLocation;
  114463. private _varyingLocationCount;
  114464. private _varyingLocationMap;
  114465. private _replacements;
  114466. private _textureCount;
  114467. private _uniforms;
  114468. lineProcessor(line: string): string;
  114469. attributeProcessor(attribute: string): string;
  114470. varyingProcessor(varying: string, isFragment: boolean): string;
  114471. uniformProcessor(uniform: string): string;
  114472. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  114473. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114474. }
  114475. }
  114476. declare module BABYLON {
  114477. /**
  114478. * Container for accessors for natively-stored mesh data buffers.
  114479. */
  114480. class NativeDataBuffer extends DataBuffer {
  114481. /**
  114482. * Accessor value used to identify/retrieve a natively-stored index buffer.
  114483. */
  114484. nativeIndexBuffer?: any;
  114485. /**
  114486. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  114487. */
  114488. nativeVertexBuffer?: any;
  114489. }
  114490. /** @hidden */
  114491. class NativeTexture extends InternalTexture {
  114492. getInternalTexture(): InternalTexture;
  114493. getViewCount(): number;
  114494. }
  114495. /** @hidden */
  114496. export class NativeEngine extends Engine {
  114497. private readonly _native;
  114498. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  114499. private readonly INVALID_HANDLE;
  114500. getHardwareScalingLevel(): number;
  114501. constructor();
  114502. /**
  114503. * Can be used to override the current requestAnimationFrame requester.
  114504. * @hidden
  114505. */
  114506. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114507. /**
  114508. * Override default engine behavior.
  114509. * @param color
  114510. * @param backBuffer
  114511. * @param depth
  114512. * @param stencil
  114513. */
  114514. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114515. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114516. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  114517. createVertexBuffer(data: DataArray): NativeDataBuffer;
  114518. recordVertexArrayObject(vertexBuffers: {
  114519. [key: string]: VertexBuffer;
  114520. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114521. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114522. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114523. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114524. /**
  114525. * Draw a list of indexed primitives
  114526. * @param fillMode defines the primitive to use
  114527. * @param indexStart defines the starting index
  114528. * @param indexCount defines the number of index to draw
  114529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114530. */
  114531. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114532. /**
  114533. * Draw a list of unindexed primitives
  114534. * @param fillMode defines the primitive to use
  114535. * @param verticesStart defines the index of first vertex to draw
  114536. * @param verticesCount defines the count of vertices to draw
  114537. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114538. */
  114539. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114540. createPipelineContext(): IPipelineContext;
  114541. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114542. /** @hidden */
  114543. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114544. /** @hidden */
  114545. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114546. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114547. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114548. protected _setProgram(program: WebGLProgram): void;
  114549. _releaseEffect(effect: Effect): void;
  114550. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114551. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  114552. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  114553. bindSamplers(effect: Effect): void;
  114554. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  114555. getRenderWidth(useScreen?: boolean): number;
  114556. getRenderHeight(useScreen?: boolean): number;
  114557. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  114558. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114559. /**
  114560. * Set the z offset to apply to current rendering
  114561. * @param value defines the offset to apply
  114562. */
  114563. setZOffset(value: number): void;
  114564. /**
  114565. * Gets the current value of the zOffset
  114566. * @returns the current zOffset state
  114567. */
  114568. getZOffset(): number;
  114569. /**
  114570. * Enable or disable depth buffering
  114571. * @param enable defines the state to set
  114572. */
  114573. setDepthBuffer(enable: boolean): void;
  114574. /**
  114575. * Gets a boolean indicating if depth writing is enabled
  114576. * @returns the current depth writing state
  114577. */
  114578. getDepthWrite(): boolean;
  114579. /**
  114580. * Enable or disable depth writing
  114581. * @param enable defines the state to set
  114582. */
  114583. setDepthWrite(enable: boolean): void;
  114584. /**
  114585. * Enable or disable color writing
  114586. * @param enable defines the state to set
  114587. */
  114588. setColorWrite(enable: boolean): void;
  114589. /**
  114590. * Gets a boolean indicating if color writing is enabled
  114591. * @returns the current color writing state
  114592. */
  114593. getColorWrite(): boolean;
  114594. /**
  114595. * Sets alpha constants used by some alpha blending modes
  114596. * @param r defines the red component
  114597. * @param g defines the green component
  114598. * @param b defines the blue component
  114599. * @param a defines the alpha component
  114600. */
  114601. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114602. /**
  114603. * Sets the current alpha mode
  114604. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  114605. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114606. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114607. */
  114608. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114609. /**
  114610. * Gets the current alpha mode
  114611. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114612. * @returns the current alpha mode
  114613. */
  114614. getAlphaMode(): number;
  114615. setInt(uniform: WebGLUniformLocation, int: number): void;
  114616. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  114617. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  114618. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  114619. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  114620. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  114621. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  114622. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  114623. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  114624. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  114625. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  114626. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  114627. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  114628. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  114629. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114630. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114631. setFloat(uniform: WebGLUniformLocation, value: number): void;
  114632. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  114633. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  114634. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  114635. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  114636. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  114637. wipeCaches(bruteForce?: boolean): void;
  114638. _createTexture(): WebGLTexture;
  114639. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114640. /**
  114641. * Usually called from BABYLON.Texture.ts.
  114642. * Passed information to create a WebGLTexture
  114643. * @param urlArg defines a value which contains one of the following:
  114644. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114645. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114646. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114647. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114648. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  114649. * @param scene needed for loading to the correct scene
  114650. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  114651. * @param onLoad optional callback to be called upon successful completion
  114652. * @param onError optional callback to be called upon failure
  114653. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  114654. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114655. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114656. * @param forcedExtension defines the extension to use to pick the right loader
  114657. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114658. */
  114659. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  114660. /**
  114661. * Creates a cube texture
  114662. * @param rootUrl defines the url where the files to load is located
  114663. * @param scene defines the current scene
  114664. * @param files defines the list of files to load (1 per face)
  114665. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  114666. * @param onLoad defines an optional callback raised when the texture is loaded
  114667. * @param onError defines an optional callback raised if there is an issue to load the texture
  114668. * @param format defines the format of the data
  114669. * @param forcedExtension defines the extension to use to pick the right loader
  114670. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  114671. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114672. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114673. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  114674. * @returns the cube texture as an InternalTexture
  114675. */
  114676. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  114677. private _getSamplingFilter;
  114678. private static _GetNativeTextureFormat;
  114679. createRenderTargetTexture(size: number | {
  114680. width: number;
  114681. height: number;
  114682. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  114683. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  114684. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  114685. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114686. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114687. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114688. /**
  114689. * Updates a dynamic vertex buffer.
  114690. * @param vertexBuffer the vertex buffer to update
  114691. * @param data the data used to update the vertex buffer
  114692. * @param byteOffset the byte offset of the data (optional)
  114693. * @param byteLength the byte length of the data (optional)
  114694. */
  114695. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114696. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114697. private _updateAnisotropicLevel;
  114698. private _getAddressMode;
  114699. /** @hidden */
  114700. _bindTexture(channel: number, texture: InternalTexture): void;
  114701. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  114702. releaseEffects(): void;
  114703. /** @hidden */
  114704. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114705. /** @hidden */
  114706. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114707. /** @hidden */
  114708. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114709. /** @hidden */
  114710. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  114711. }
  114712. }
  114713. declare module BABYLON {
  114714. /**
  114715. * Gather the list of clipboard event types as constants.
  114716. */
  114717. export class ClipboardEventTypes {
  114718. /**
  114719. * The clipboard event is fired when a copy command is active (pressed).
  114720. */
  114721. static readonly COPY: number;
  114722. /**
  114723. * The clipboard event is fired when a cut command is active (pressed).
  114724. */
  114725. static readonly CUT: number;
  114726. /**
  114727. * The clipboard event is fired when a paste command is active (pressed).
  114728. */
  114729. static readonly PASTE: number;
  114730. }
  114731. /**
  114732. * This class is used to store clipboard related info for the onClipboardObservable event.
  114733. */
  114734. export class ClipboardInfo {
  114735. /**
  114736. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114737. */
  114738. type: number;
  114739. /**
  114740. * Defines the related dom event
  114741. */
  114742. event: ClipboardEvent;
  114743. /**
  114744. *Creates an instance of ClipboardInfo.
  114745. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  114746. * @param event Defines the related dom event
  114747. */
  114748. constructor(
  114749. /**
  114750. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114751. */
  114752. type: number,
  114753. /**
  114754. * Defines the related dom event
  114755. */
  114756. event: ClipboardEvent);
  114757. /**
  114758. * Get the clipboard event's type from the keycode.
  114759. * @param keyCode Defines the keyCode for the current keyboard event.
  114760. * @return {number}
  114761. */
  114762. static GetTypeFromCharacter(keyCode: number): number;
  114763. }
  114764. }
  114765. declare module BABYLON {
  114766. /**
  114767. * Google Daydream controller
  114768. */
  114769. export class DaydreamController extends WebVRController {
  114770. /**
  114771. * Base Url for the controller model.
  114772. */
  114773. static MODEL_BASE_URL: string;
  114774. /**
  114775. * File name for the controller model.
  114776. */
  114777. static MODEL_FILENAME: string;
  114778. /**
  114779. * Gamepad Id prefix used to identify Daydream Controller.
  114780. */
  114781. static readonly GAMEPAD_ID_PREFIX: string;
  114782. /**
  114783. * Creates a new DaydreamController from a gamepad
  114784. * @param vrGamepad the gamepad that the controller should be created from
  114785. */
  114786. constructor(vrGamepad: any);
  114787. /**
  114788. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114789. * @param scene scene in which to add meshes
  114790. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114791. */
  114792. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114793. /**
  114794. * Called once for each button that changed state since the last frame
  114795. * @param buttonIdx Which button index changed
  114796. * @param state New state of the button
  114797. * @param changes Which properties on the state changed since last frame
  114798. */
  114799. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114800. }
  114801. }
  114802. declare module BABYLON {
  114803. /**
  114804. * Gear VR Controller
  114805. */
  114806. export class GearVRController extends WebVRController {
  114807. /**
  114808. * Base Url for the controller model.
  114809. */
  114810. static MODEL_BASE_URL: string;
  114811. /**
  114812. * File name for the controller model.
  114813. */
  114814. static MODEL_FILENAME: string;
  114815. /**
  114816. * Gamepad Id prefix used to identify this controller.
  114817. */
  114818. static readonly GAMEPAD_ID_PREFIX: string;
  114819. private readonly _buttonIndexToObservableNameMap;
  114820. /**
  114821. * Creates a new GearVRController from a gamepad
  114822. * @param vrGamepad the gamepad that the controller should be created from
  114823. */
  114824. constructor(vrGamepad: any);
  114825. /**
  114826. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114827. * @param scene scene in which to add meshes
  114828. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114829. */
  114830. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114831. /**
  114832. * Called once for each button that changed state since the last frame
  114833. * @param buttonIdx Which button index changed
  114834. * @param state New state of the button
  114835. * @param changes Which properties on the state changed since last frame
  114836. */
  114837. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114838. }
  114839. }
  114840. declare module BABYLON {
  114841. /**
  114842. * Class containing static functions to help procedurally build meshes
  114843. */
  114844. export class PolyhedronBuilder {
  114845. /**
  114846. * Creates a polyhedron mesh
  114847. * * 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
  114848. * * The parameter `size` (positive float, default 1) sets the polygon size
  114849. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114850. * * 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`
  114851. * * 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
  114852. * * 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)`)
  114853. * * 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
  114854. * * 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
  114855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114858. * @param name defines the name of the mesh
  114859. * @param options defines the options used to create the mesh
  114860. * @param scene defines the hosting scene
  114861. * @returns the polyhedron mesh
  114862. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  114863. */
  114864. static CreatePolyhedron(name: string, options: {
  114865. type?: number;
  114866. size?: number;
  114867. sizeX?: number;
  114868. sizeY?: number;
  114869. sizeZ?: number;
  114870. custom?: any;
  114871. faceUV?: Vector4[];
  114872. faceColors?: Color4[];
  114873. flat?: boolean;
  114874. updatable?: boolean;
  114875. sideOrientation?: number;
  114876. frontUVs?: Vector4;
  114877. backUVs?: Vector4;
  114878. }, scene?: Nullable<Scene>): Mesh;
  114879. }
  114880. }
  114881. declare module BABYLON {
  114882. /**
  114883. * Gizmo that enables scaling a mesh along 3 axis
  114884. */
  114885. export class ScaleGizmo extends Gizmo {
  114886. /**
  114887. * Internal gizmo used for interactions on the x axis
  114888. */
  114889. xGizmo: AxisScaleGizmo;
  114890. /**
  114891. * Internal gizmo used for interactions on the y axis
  114892. */
  114893. yGizmo: AxisScaleGizmo;
  114894. /**
  114895. * Internal gizmo used for interactions on the z axis
  114896. */
  114897. zGizmo: AxisScaleGizmo;
  114898. /**
  114899. * Internal gizmo used to scale all axis equally
  114900. */
  114901. uniformScaleGizmo: AxisScaleGizmo;
  114902. private _meshAttached;
  114903. private _updateGizmoRotationToMatchAttachedMesh;
  114904. private _snapDistance;
  114905. private _scaleRatio;
  114906. private _uniformScalingMesh;
  114907. private _octahedron;
  114908. private _sensitivity;
  114909. /** Fires an event when any of it's sub gizmos are dragged */
  114910. onDragStartObservable: Observable<unknown>;
  114911. /** Fires an event when any of it's sub gizmos are released from dragging */
  114912. onDragEndObservable: Observable<unknown>;
  114913. attachedMesh: Nullable<AbstractMesh>;
  114914. /**
  114915. * Creates a ScaleGizmo
  114916. * @param gizmoLayer The utility layer the gizmo will be added to
  114917. */
  114918. constructor(gizmoLayer?: UtilityLayerRenderer);
  114919. updateGizmoRotationToMatchAttachedMesh: boolean;
  114920. /**
  114921. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114922. */
  114923. snapDistance: number;
  114924. /**
  114925. * Ratio for the scale of the gizmo (Default: 1)
  114926. */
  114927. scaleRatio: number;
  114928. /**
  114929. * Sensitivity factor for dragging (Default: 1)
  114930. */
  114931. sensitivity: number;
  114932. /**
  114933. * Disposes of the gizmo
  114934. */
  114935. dispose(): void;
  114936. }
  114937. }
  114938. declare module BABYLON {
  114939. /**
  114940. * Single axis scale gizmo
  114941. */
  114942. export class AxisScaleGizmo extends Gizmo {
  114943. /**
  114944. * Drag behavior responsible for the gizmos dragging interactions
  114945. */
  114946. dragBehavior: PointerDragBehavior;
  114947. private _pointerObserver;
  114948. /**
  114949. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114950. */
  114951. snapDistance: number;
  114952. /**
  114953. * Event that fires each time the gizmo snaps to a new location.
  114954. * * snapDistance is the the change in distance
  114955. */
  114956. onSnapObservable: Observable<{
  114957. snapDistance: number;
  114958. }>;
  114959. /**
  114960. * If the scaling operation should be done on all axis (default: false)
  114961. */
  114962. uniformScaling: boolean;
  114963. /**
  114964. * Custom sensitivity value for the drag strength
  114965. */
  114966. sensitivity: number;
  114967. private _isEnabled;
  114968. private _parent;
  114969. private _arrow;
  114970. private _coloredMaterial;
  114971. private _hoverMaterial;
  114972. /**
  114973. * Creates an AxisScaleGizmo
  114974. * @param gizmoLayer The utility layer the gizmo will be added to
  114975. * @param dragAxis The axis which the gizmo will be able to scale on
  114976. * @param color The color of the gizmo
  114977. */
  114978. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  114979. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114980. /**
  114981. * If the gizmo is enabled
  114982. */
  114983. isEnabled: boolean;
  114984. /**
  114985. * Disposes of the gizmo
  114986. */
  114987. dispose(): void;
  114988. /**
  114989. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  114990. * @param mesh The mesh to replace the default mesh of the gizmo
  114991. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  114992. */
  114993. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  114994. }
  114995. }
  114996. declare module BABYLON {
  114997. /**
  114998. * Bounding box gizmo
  114999. */
  115000. export class BoundingBoxGizmo extends Gizmo {
  115001. private _lineBoundingBox;
  115002. private _rotateSpheresParent;
  115003. private _scaleBoxesParent;
  115004. private _boundingDimensions;
  115005. private _renderObserver;
  115006. private _pointerObserver;
  115007. private _scaleDragSpeed;
  115008. private _tmpQuaternion;
  115009. private _tmpVector;
  115010. private _tmpRotationMatrix;
  115011. /**
  115012. * 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)
  115013. */
  115014. ignoreChildren: boolean;
  115015. /**
  115016. * 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)
  115017. */
  115018. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  115019. /**
  115020. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  115021. */
  115022. rotationSphereSize: number;
  115023. /**
  115024. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  115025. */
  115026. scaleBoxSize: number;
  115027. /**
  115028. * 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)
  115029. */
  115030. fixedDragMeshScreenSize: boolean;
  115031. /**
  115032. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  115033. */
  115034. fixedDragMeshScreenSizeDistanceFactor: number;
  115035. /**
  115036. * Fired when a rotation sphere or scale box is dragged
  115037. */
  115038. onDragStartObservable: Observable<{}>;
  115039. /**
  115040. * Fired when a scale box is dragged
  115041. */
  115042. onScaleBoxDragObservable: Observable<{}>;
  115043. /**
  115044. * Fired when a scale box drag is ended
  115045. */
  115046. onScaleBoxDragEndObservable: Observable<{}>;
  115047. /**
  115048. * Fired when a rotation sphere is dragged
  115049. */
  115050. onRotationSphereDragObservable: Observable<{}>;
  115051. /**
  115052. * Fired when a rotation sphere drag is ended
  115053. */
  115054. onRotationSphereDragEndObservable: Observable<{}>;
  115055. /**
  115056. * 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)
  115057. */
  115058. scalePivot: Nullable<Vector3>;
  115059. /**
  115060. * Mesh used as a pivot to rotate the attached mesh
  115061. */
  115062. private _anchorMesh;
  115063. private _existingMeshScale;
  115064. private _dragMesh;
  115065. private pointerDragBehavior;
  115066. private coloredMaterial;
  115067. private hoverColoredMaterial;
  115068. /**
  115069. * Sets the color of the bounding box gizmo
  115070. * @param color the color to set
  115071. */
  115072. setColor(color: Color3): void;
  115073. /**
  115074. * Creates an BoundingBoxGizmo
  115075. * @param gizmoLayer The utility layer the gizmo will be added to
  115076. * @param color The color of the gizmo
  115077. */
  115078. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  115079. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115080. private _selectNode;
  115081. /**
  115082. * Updates the bounding box information for the Gizmo
  115083. */
  115084. updateBoundingBox(): void;
  115085. private _updateRotationSpheres;
  115086. private _updateScaleBoxes;
  115087. /**
  115088. * Enables rotation on the specified axis and disables rotation on the others
  115089. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  115090. */
  115091. setEnabledRotationAxis(axis: string): void;
  115092. /**
  115093. * Enables/disables scaling
  115094. * @param enable if scaling should be enabled
  115095. */
  115096. setEnabledScaling(enable: boolean): void;
  115097. private _updateDummy;
  115098. /**
  115099. * Enables a pointer drag behavior on the bounding box of the gizmo
  115100. */
  115101. enableDragBehavior(): void;
  115102. /**
  115103. * Disposes of the gizmo
  115104. */
  115105. dispose(): void;
  115106. /**
  115107. * 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)
  115108. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  115109. * @returns the bounding box mesh with the passed in mesh as a child
  115110. */
  115111. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  115112. /**
  115113. * CustomMeshes are not supported by this gizmo
  115114. * @param mesh The mesh to replace the default mesh of the gizmo
  115115. */
  115116. setCustomMesh(mesh: Mesh): void;
  115117. }
  115118. }
  115119. declare module BABYLON {
  115120. /**
  115121. * Single plane rotation gizmo
  115122. */
  115123. export class PlaneRotationGizmo extends Gizmo {
  115124. /**
  115125. * Drag behavior responsible for the gizmos dragging interactions
  115126. */
  115127. dragBehavior: PointerDragBehavior;
  115128. private _pointerObserver;
  115129. /**
  115130. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  115131. */
  115132. snapDistance: number;
  115133. /**
  115134. * Event that fires each time the gizmo snaps to a new location.
  115135. * * snapDistance is the the change in distance
  115136. */
  115137. onSnapObservable: Observable<{
  115138. snapDistance: number;
  115139. }>;
  115140. private _isEnabled;
  115141. private _parent;
  115142. /**
  115143. * Creates a PlaneRotationGizmo
  115144. * @param gizmoLayer The utility layer the gizmo will be added to
  115145. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  115146. * @param color The color of the gizmo
  115147. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115148. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115149. */
  115150. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  115151. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115152. /**
  115153. * If the gizmo is enabled
  115154. */
  115155. isEnabled: boolean;
  115156. /**
  115157. * Disposes of the gizmo
  115158. */
  115159. dispose(): void;
  115160. }
  115161. }
  115162. declare module BABYLON {
  115163. /**
  115164. * Gizmo that enables rotating a mesh along 3 axis
  115165. */
  115166. export class RotationGizmo extends Gizmo {
  115167. /**
  115168. * Internal gizmo used for interactions on the x axis
  115169. */
  115170. xGizmo: PlaneRotationGizmo;
  115171. /**
  115172. * Internal gizmo used for interactions on the y axis
  115173. */
  115174. yGizmo: PlaneRotationGizmo;
  115175. /**
  115176. * Internal gizmo used for interactions on the z axis
  115177. */
  115178. zGizmo: PlaneRotationGizmo;
  115179. /** Fires an event when any of it's sub gizmos are dragged */
  115180. onDragStartObservable: Observable<unknown>;
  115181. /** Fires an event when any of it's sub gizmos are released from dragging */
  115182. onDragEndObservable: Observable<unknown>;
  115183. private _meshAttached;
  115184. attachedMesh: Nullable<AbstractMesh>;
  115185. /**
  115186. * Creates a RotationGizmo
  115187. * @param gizmoLayer The utility layer the gizmo will be added to
  115188. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115189. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115190. */
  115191. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  115192. updateGizmoRotationToMatchAttachedMesh: boolean;
  115193. /**
  115194. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115195. */
  115196. snapDistance: number;
  115197. /**
  115198. * Ratio for the scale of the gizmo (Default: 1)
  115199. */
  115200. scaleRatio: number;
  115201. /**
  115202. * Disposes of the gizmo
  115203. */
  115204. dispose(): void;
  115205. /**
  115206. * CustomMeshes are not supported by this gizmo
  115207. * @param mesh The mesh to replace the default mesh of the gizmo
  115208. */
  115209. setCustomMesh(mesh: Mesh): void;
  115210. }
  115211. }
  115212. declare module BABYLON {
  115213. /**
  115214. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  115215. */
  115216. export class GizmoManager implements IDisposable {
  115217. private scene;
  115218. /**
  115219. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  115220. */
  115221. gizmos: {
  115222. positionGizmo: Nullable<PositionGizmo>;
  115223. rotationGizmo: Nullable<RotationGizmo>;
  115224. scaleGizmo: Nullable<ScaleGizmo>;
  115225. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  115226. };
  115227. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  115228. clearGizmoOnEmptyPointerEvent: boolean;
  115229. /** Fires an event when the manager is attached to a mesh */
  115230. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  115231. private _gizmosEnabled;
  115232. private _pointerObserver;
  115233. private _attachedMesh;
  115234. private _boundingBoxColor;
  115235. private _defaultUtilityLayer;
  115236. private _defaultKeepDepthUtilityLayer;
  115237. /**
  115238. * When bounding box gizmo is enabled, this can be used to track drag/end events
  115239. */
  115240. boundingBoxDragBehavior: SixDofDragBehavior;
  115241. /**
  115242. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  115243. */
  115244. attachableMeshes: Nullable<Array<AbstractMesh>>;
  115245. /**
  115246. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  115247. */
  115248. usePointerToAttachGizmos: boolean;
  115249. /**
  115250. * Utility layer that the bounding box gizmo belongs to
  115251. */
  115252. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  115253. /**
  115254. * Utility layer that all gizmos besides bounding box belong to
  115255. */
  115256. readonly utilityLayer: UtilityLayerRenderer;
  115257. /**
  115258. * Instatiates a gizmo manager
  115259. * @param scene the scene to overlay the gizmos on top of
  115260. */
  115261. constructor(scene: Scene);
  115262. /**
  115263. * Attaches a set of gizmos to the specified mesh
  115264. * @param mesh The mesh the gizmo's should be attached to
  115265. */
  115266. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115267. /**
  115268. * If the position gizmo is enabled
  115269. */
  115270. positionGizmoEnabled: boolean;
  115271. /**
  115272. * If the rotation gizmo is enabled
  115273. */
  115274. rotationGizmoEnabled: boolean;
  115275. /**
  115276. * If the scale gizmo is enabled
  115277. */
  115278. scaleGizmoEnabled: boolean;
  115279. /**
  115280. * If the boundingBox gizmo is enabled
  115281. */
  115282. boundingBoxGizmoEnabled: boolean;
  115283. /**
  115284. * Disposes of the gizmo manager
  115285. */
  115286. dispose(): void;
  115287. }
  115288. }
  115289. declare module BABYLON {
  115290. /**
  115291. * A directional light is defined by a direction (what a surprise!).
  115292. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  115293. * 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.
  115294. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115295. */
  115296. export class DirectionalLight extends ShadowLight {
  115297. private _shadowFrustumSize;
  115298. /**
  115299. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  115300. */
  115301. /**
  115302. * Specifies a fix frustum size for the shadow generation.
  115303. */
  115304. shadowFrustumSize: number;
  115305. private _shadowOrthoScale;
  115306. /**
  115307. * Gets the shadow projection scale against the optimal computed one.
  115308. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115309. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115310. */
  115311. /**
  115312. * Sets the shadow projection scale against the optimal computed one.
  115313. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115314. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115315. */
  115316. shadowOrthoScale: number;
  115317. /**
  115318. * Automatically compute the projection matrix to best fit (including all the casters)
  115319. * on each frame.
  115320. */
  115321. autoUpdateExtends: boolean;
  115322. private _orthoLeft;
  115323. private _orthoRight;
  115324. private _orthoTop;
  115325. private _orthoBottom;
  115326. /**
  115327. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  115328. * The directional light is emitted from everywhere in the given direction.
  115329. * It can cast shadows.
  115330. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115331. * @param name The friendly name of the light
  115332. * @param direction The direction of the light
  115333. * @param scene The scene the light belongs to
  115334. */
  115335. constructor(name: string, direction: Vector3, scene: Scene);
  115336. /**
  115337. * Returns the string "DirectionalLight".
  115338. * @return The class name
  115339. */
  115340. getClassName(): string;
  115341. /**
  115342. * Returns the integer 1.
  115343. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115344. */
  115345. getTypeID(): number;
  115346. /**
  115347. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  115348. * Returns the DirectionalLight Shadow projection matrix.
  115349. */
  115350. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115351. /**
  115352. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  115353. * Returns the DirectionalLight Shadow projection matrix.
  115354. */
  115355. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  115356. /**
  115357. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  115358. * Returns the DirectionalLight Shadow projection matrix.
  115359. */
  115360. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115361. protected _buildUniformLayout(): void;
  115362. /**
  115363. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  115364. * @param effect The effect to update
  115365. * @param lightIndex The index of the light in the effect to update
  115366. * @returns The directional light
  115367. */
  115368. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  115369. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  115370. /**
  115371. * Gets the minZ used for shadow according to both the scene and the light.
  115372. *
  115373. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115374. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115375. * @param activeCamera The camera we are returning the min for
  115376. * @returns the depth min z
  115377. */
  115378. getDepthMinZ(activeCamera: Camera): number;
  115379. /**
  115380. * Gets the maxZ used for shadow according to both the scene and the light.
  115381. *
  115382. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115383. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115384. * @param activeCamera The camera we are returning the max for
  115385. * @returns the depth max z
  115386. */
  115387. getDepthMaxZ(activeCamera: Camera): number;
  115388. /**
  115389. * Prepares the list of defines specific to the light type.
  115390. * @param defines the list of defines
  115391. * @param lightIndex defines the index of the light for the effect
  115392. */
  115393. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115394. }
  115395. }
  115396. declare module BABYLON {
  115397. /**
  115398. * Class containing static functions to help procedurally build meshes
  115399. */
  115400. export class HemisphereBuilder {
  115401. /**
  115402. * Creates a hemisphere mesh
  115403. * @param name defines the name of the mesh
  115404. * @param options defines the options used to create the mesh
  115405. * @param scene defines the hosting scene
  115406. * @returns the hemisphere mesh
  115407. */
  115408. static CreateHemisphere(name: string, options: {
  115409. segments?: number;
  115410. diameter?: number;
  115411. sideOrientation?: number;
  115412. }, scene: any): Mesh;
  115413. }
  115414. }
  115415. declare module BABYLON {
  115416. /**
  115417. * A spot light is defined by a position, a direction, an angle, and an exponent.
  115418. * These values define a cone of light starting from the position, emitting toward the direction.
  115419. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  115420. * and the exponent defines the speed of the decay of the light with distance (reach).
  115421. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115422. */
  115423. export class SpotLight extends ShadowLight {
  115424. private _angle;
  115425. private _innerAngle;
  115426. private _cosHalfAngle;
  115427. private _lightAngleScale;
  115428. private _lightAngleOffset;
  115429. /**
  115430. * Gets the cone angle of the spot light in Radians.
  115431. */
  115432. /**
  115433. * Sets the cone angle of the spot light in Radians.
  115434. */
  115435. angle: number;
  115436. /**
  115437. * Only used in gltf falloff mode, this defines the angle where
  115438. * the directional falloff will start before cutting at angle which could be seen
  115439. * as outer angle.
  115440. */
  115441. /**
  115442. * Only used in gltf falloff mode, this defines the angle where
  115443. * the directional falloff will start before cutting at angle which could be seen
  115444. * as outer angle.
  115445. */
  115446. innerAngle: number;
  115447. private _shadowAngleScale;
  115448. /**
  115449. * Allows scaling the angle of the light for shadow generation only.
  115450. */
  115451. /**
  115452. * Allows scaling the angle of the light for shadow generation only.
  115453. */
  115454. shadowAngleScale: number;
  115455. /**
  115456. * The light decay speed with the distance from the emission spot.
  115457. */
  115458. exponent: number;
  115459. private _projectionTextureMatrix;
  115460. /**
  115461. * Allows reading the projecton texture
  115462. */
  115463. readonly projectionTextureMatrix: Matrix;
  115464. protected _projectionTextureLightNear: number;
  115465. /**
  115466. * Gets the near clip of the Spotlight for texture projection.
  115467. */
  115468. /**
  115469. * Sets the near clip of the Spotlight for texture projection.
  115470. */
  115471. projectionTextureLightNear: number;
  115472. protected _projectionTextureLightFar: number;
  115473. /**
  115474. * Gets the far clip of the Spotlight for texture projection.
  115475. */
  115476. /**
  115477. * Sets the far clip of the Spotlight for texture projection.
  115478. */
  115479. projectionTextureLightFar: number;
  115480. protected _projectionTextureUpDirection: Vector3;
  115481. /**
  115482. * Gets the Up vector of the Spotlight for texture projection.
  115483. */
  115484. /**
  115485. * Sets the Up vector of the Spotlight for texture projection.
  115486. */
  115487. projectionTextureUpDirection: Vector3;
  115488. private _projectionTexture;
  115489. /**
  115490. * Gets the projection texture of the light.
  115491. */
  115492. /**
  115493. * Sets the projection texture of the light.
  115494. */
  115495. projectionTexture: Nullable<BaseTexture>;
  115496. private _projectionTextureViewLightDirty;
  115497. private _projectionTextureProjectionLightDirty;
  115498. private _projectionTextureDirty;
  115499. private _projectionTextureViewTargetVector;
  115500. private _projectionTextureViewLightMatrix;
  115501. private _projectionTextureProjectionLightMatrix;
  115502. private _projectionTextureScalingMatrix;
  115503. /**
  115504. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  115505. * It can cast shadows.
  115506. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115507. * @param name The light friendly name
  115508. * @param position The position of the spot light in the scene
  115509. * @param direction The direction of the light in the scene
  115510. * @param angle The cone angle of the light in Radians
  115511. * @param exponent The light decay speed with the distance from the emission spot
  115512. * @param scene The scene the lights belongs to
  115513. */
  115514. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  115515. /**
  115516. * Returns the string "SpotLight".
  115517. * @returns the class name
  115518. */
  115519. getClassName(): string;
  115520. /**
  115521. * Returns the integer 2.
  115522. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115523. */
  115524. getTypeID(): number;
  115525. /**
  115526. * Overrides the direction setter to recompute the projection texture view light Matrix.
  115527. */
  115528. protected _setDirection(value: Vector3): void;
  115529. /**
  115530. * Overrides the position setter to recompute the projection texture view light Matrix.
  115531. */
  115532. protected _setPosition(value: Vector3): void;
  115533. /**
  115534. * 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.
  115535. * Returns the SpotLight.
  115536. */
  115537. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115538. protected _computeProjectionTextureViewLightMatrix(): void;
  115539. protected _computeProjectionTextureProjectionLightMatrix(): void;
  115540. /**
  115541. * Main function for light texture projection matrix computing.
  115542. */
  115543. protected _computeProjectionTextureMatrix(): void;
  115544. protected _buildUniformLayout(): void;
  115545. private _computeAngleValues;
  115546. /**
  115547. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  115548. * @param effect The effect to update
  115549. * @param lightIndex The index of the light in the effect to update
  115550. * @returns The spot light
  115551. */
  115552. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  115553. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115554. /**
  115555. * Disposes the light and the associated resources.
  115556. */
  115557. dispose(): void;
  115558. /**
  115559. * Prepares the list of defines specific to the light type.
  115560. * @param defines the list of defines
  115561. * @param lightIndex defines the index of the light for the effect
  115562. */
  115563. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115564. }
  115565. }
  115566. declare module BABYLON {
  115567. /**
  115568. * Gizmo that enables viewing a light
  115569. */
  115570. export class LightGizmo extends Gizmo {
  115571. private _lightMesh;
  115572. private _material;
  115573. private _cachedPosition;
  115574. private _cachedForward;
  115575. private _attachedMeshParent;
  115576. /**
  115577. * Creates a LightGizmo
  115578. * @param gizmoLayer The utility layer the gizmo will be added to
  115579. */
  115580. constructor(gizmoLayer?: UtilityLayerRenderer);
  115581. private _light;
  115582. /**
  115583. * The light that the gizmo is attached to
  115584. */
  115585. light: Nullable<Light>;
  115586. /**
  115587. * Gets the material used to render the light gizmo
  115588. */
  115589. readonly material: StandardMaterial;
  115590. /**
  115591. * @hidden
  115592. * Updates the gizmo to match the attached mesh's position/rotation
  115593. */
  115594. protected _update(): void;
  115595. private static _Scale;
  115596. /**
  115597. * Creates the lines for a light mesh
  115598. */
  115599. private static _CreateLightLines;
  115600. /**
  115601. * Disposes of the light gizmo
  115602. */
  115603. dispose(): void;
  115604. private static _CreateHemisphericLightMesh;
  115605. private static _CreatePointLightMesh;
  115606. private static _CreateSpotLightMesh;
  115607. private static _CreateDirectionalLightMesh;
  115608. }
  115609. }
  115610. declare module BABYLON {
  115611. /** @hidden */
  115612. export var backgroundFragmentDeclaration: {
  115613. name: string;
  115614. shader: string;
  115615. };
  115616. }
  115617. declare module BABYLON {
  115618. /** @hidden */
  115619. export var backgroundUboDeclaration: {
  115620. name: string;
  115621. shader: string;
  115622. };
  115623. }
  115624. declare module BABYLON {
  115625. /** @hidden */
  115626. export var backgroundPixelShader: {
  115627. name: string;
  115628. shader: string;
  115629. };
  115630. }
  115631. declare module BABYLON {
  115632. /** @hidden */
  115633. export var backgroundVertexDeclaration: {
  115634. name: string;
  115635. shader: string;
  115636. };
  115637. }
  115638. declare module BABYLON {
  115639. /** @hidden */
  115640. export var backgroundVertexShader: {
  115641. name: string;
  115642. shader: string;
  115643. };
  115644. }
  115645. declare module BABYLON {
  115646. /**
  115647. * Background material used to create an efficient environement around your scene.
  115648. */
  115649. export class BackgroundMaterial extends PushMaterial {
  115650. /**
  115651. * Standard reflectance value at parallel view angle.
  115652. */
  115653. static StandardReflectance0: number;
  115654. /**
  115655. * Standard reflectance value at grazing angle.
  115656. */
  115657. static StandardReflectance90: number;
  115658. protected _primaryColor: Color3;
  115659. /**
  115660. * Key light Color (multiply against the environement texture)
  115661. */
  115662. primaryColor: Color3;
  115663. protected __perceptualColor: Nullable<Color3>;
  115664. /**
  115665. * Experimental Internal Use Only.
  115666. *
  115667. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  115668. * This acts as a helper to set the primary color to a more "human friendly" value.
  115669. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  115670. * output color as close as possible from the chosen value.
  115671. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  115672. * part of lighting setup.)
  115673. */
  115674. _perceptualColor: Nullable<Color3>;
  115675. protected _primaryColorShadowLevel: float;
  115676. /**
  115677. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  115678. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  115679. */
  115680. primaryColorShadowLevel: float;
  115681. protected _primaryColorHighlightLevel: float;
  115682. /**
  115683. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  115684. * The primary color is used at the level chosen to define what the white area would look.
  115685. */
  115686. primaryColorHighlightLevel: float;
  115687. protected _reflectionTexture: Nullable<BaseTexture>;
  115688. /**
  115689. * Reflection Texture used in the material.
  115690. * Should be author in a specific way for the best result (refer to the documentation).
  115691. */
  115692. reflectionTexture: Nullable<BaseTexture>;
  115693. protected _reflectionBlur: float;
  115694. /**
  115695. * Reflection Texture level of blur.
  115696. *
  115697. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  115698. * texture twice.
  115699. */
  115700. reflectionBlur: float;
  115701. protected _diffuseTexture: Nullable<BaseTexture>;
  115702. /**
  115703. * Diffuse Texture used in the material.
  115704. * Should be author in a specific way for the best result (refer to the documentation).
  115705. */
  115706. diffuseTexture: Nullable<BaseTexture>;
  115707. protected _shadowLights: Nullable<IShadowLight[]>;
  115708. /**
  115709. * Specify the list of lights casting shadow on the material.
  115710. * All scene shadow lights will be included if null.
  115711. */
  115712. shadowLights: Nullable<IShadowLight[]>;
  115713. protected _shadowLevel: float;
  115714. /**
  115715. * Helps adjusting the shadow to a softer level if required.
  115716. * 0 means black shadows and 1 means no shadows.
  115717. */
  115718. shadowLevel: float;
  115719. protected _sceneCenter: Vector3;
  115720. /**
  115721. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  115722. * It is usually zero but might be interesting to modify according to your setup.
  115723. */
  115724. sceneCenter: Vector3;
  115725. protected _opacityFresnel: boolean;
  115726. /**
  115727. * This helps specifying that the material is falling off to the sky box at grazing angle.
  115728. * This helps ensuring a nice transition when the camera goes under the ground.
  115729. */
  115730. opacityFresnel: boolean;
  115731. protected _reflectionFresnel: boolean;
  115732. /**
  115733. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  115734. * This helps adding a mirror texture on the ground.
  115735. */
  115736. reflectionFresnel: boolean;
  115737. protected _reflectionFalloffDistance: number;
  115738. /**
  115739. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  115740. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  115741. */
  115742. reflectionFalloffDistance: number;
  115743. protected _reflectionAmount: number;
  115744. /**
  115745. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  115746. */
  115747. reflectionAmount: number;
  115748. protected _reflectionReflectance0: number;
  115749. /**
  115750. * This specifies the weight of the reflection at grazing angle.
  115751. */
  115752. reflectionReflectance0: number;
  115753. protected _reflectionReflectance90: number;
  115754. /**
  115755. * This specifies the weight of the reflection at a perpendicular point of view.
  115756. */
  115757. reflectionReflectance90: number;
  115758. /**
  115759. * Sets the reflection reflectance fresnel values according to the default standard
  115760. * empirically know to work well :-)
  115761. */
  115762. reflectionStandardFresnelWeight: number;
  115763. protected _useRGBColor: boolean;
  115764. /**
  115765. * Helps to directly use the maps channels instead of their level.
  115766. */
  115767. useRGBColor: boolean;
  115768. protected _enableNoise: boolean;
  115769. /**
  115770. * This helps reducing the banding effect that could occur on the background.
  115771. */
  115772. enableNoise: boolean;
  115773. /**
  115774. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115775. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  115776. * Recommended to be keep at 1.0 except for special cases.
  115777. */
  115778. fovMultiplier: number;
  115779. private _fovMultiplier;
  115780. /**
  115781. * Enable the FOV adjustment feature controlled by fovMultiplier.
  115782. */
  115783. useEquirectangularFOV: boolean;
  115784. private _maxSimultaneousLights;
  115785. /**
  115786. * Number of Simultaneous lights allowed on the material.
  115787. */
  115788. maxSimultaneousLights: int;
  115789. /**
  115790. * Default configuration related to image processing available in the Background Material.
  115791. */
  115792. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115793. /**
  115794. * Keep track of the image processing observer to allow dispose and replace.
  115795. */
  115796. private _imageProcessingObserver;
  115797. /**
  115798. * Attaches a new image processing configuration to the PBR Material.
  115799. * @param configuration (if null the scene configuration will be use)
  115800. */
  115801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115802. /**
  115803. * Gets the image processing configuration used either in this material.
  115804. */
  115805. /**
  115806. * Sets the Default image processing configuration used either in the this material.
  115807. *
  115808. * If sets to null, the scene one is in use.
  115809. */
  115810. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  115811. /**
  115812. * Gets wether the color curves effect is enabled.
  115813. */
  115814. /**
  115815. * Sets wether the color curves effect is enabled.
  115816. */
  115817. cameraColorCurvesEnabled: boolean;
  115818. /**
  115819. * Gets wether the color grading effect is enabled.
  115820. */
  115821. /**
  115822. * Gets wether the color grading effect is enabled.
  115823. */
  115824. cameraColorGradingEnabled: boolean;
  115825. /**
  115826. * Gets wether tonemapping is enabled or not.
  115827. */
  115828. /**
  115829. * Sets wether tonemapping is enabled or not
  115830. */
  115831. cameraToneMappingEnabled: boolean;
  115832. /**
  115833. * The camera exposure used on this material.
  115834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115835. * This corresponds to a photographic exposure.
  115836. */
  115837. /**
  115838. * The camera exposure used on this material.
  115839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115840. * This corresponds to a photographic exposure.
  115841. */
  115842. cameraExposure: float;
  115843. /**
  115844. * Gets The camera contrast used on this material.
  115845. */
  115846. /**
  115847. * Sets The camera contrast used on this material.
  115848. */
  115849. cameraContrast: float;
  115850. /**
  115851. * Gets the Color Grading 2D Lookup Texture.
  115852. */
  115853. /**
  115854. * Sets the Color Grading 2D Lookup Texture.
  115855. */
  115856. cameraColorGradingTexture: Nullable<BaseTexture>;
  115857. /**
  115858. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115859. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115860. * 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;
  115861. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115862. */
  115863. /**
  115864. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115865. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115866. * 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;
  115867. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115868. */
  115869. cameraColorCurves: Nullable<ColorCurves>;
  115870. /**
  115871. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  115872. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  115873. */
  115874. switchToBGR: boolean;
  115875. private _renderTargets;
  115876. private _reflectionControls;
  115877. private _white;
  115878. private _primaryShadowColor;
  115879. private _primaryHighlightColor;
  115880. /**
  115881. * Instantiates a Background Material in the given scene
  115882. * @param name The friendly name of the material
  115883. * @param scene The scene to add the material to
  115884. */
  115885. constructor(name: string, scene: Scene);
  115886. /**
  115887. * Gets a boolean indicating that current material needs to register RTT
  115888. */
  115889. readonly hasRenderTargetTextures: boolean;
  115890. /**
  115891. * The entire material has been created in order to prevent overdraw.
  115892. * @returns false
  115893. */
  115894. needAlphaTesting(): boolean;
  115895. /**
  115896. * The entire material has been created in order to prevent overdraw.
  115897. * @returns true if blending is enable
  115898. */
  115899. needAlphaBlending(): boolean;
  115900. /**
  115901. * Checks wether the material is ready to be rendered for a given mesh.
  115902. * @param mesh The mesh to render
  115903. * @param subMesh The submesh to check against
  115904. * @param useInstances Specify wether or not the material is used with instances
  115905. * @returns true if all the dependencies are ready (Textures, Effects...)
  115906. */
  115907. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115908. /**
  115909. * Compute the primary color according to the chosen perceptual color.
  115910. */
  115911. private _computePrimaryColorFromPerceptualColor;
  115912. /**
  115913. * Compute the highlights and shadow colors according to their chosen levels.
  115914. */
  115915. private _computePrimaryColors;
  115916. /**
  115917. * Build the uniform buffer used in the material.
  115918. */
  115919. buildUniformLayout(): void;
  115920. /**
  115921. * Unbind the material.
  115922. */
  115923. unbind(): void;
  115924. /**
  115925. * Bind only the world matrix to the material.
  115926. * @param world The world matrix to bind.
  115927. */
  115928. bindOnlyWorldMatrix(world: Matrix): void;
  115929. /**
  115930. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  115931. * @param world The world matrix to bind.
  115932. * @param subMesh The submesh to bind for.
  115933. */
  115934. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115935. /**
  115936. * Checks to see if a texture is used in the material.
  115937. * @param texture - Base texture to use.
  115938. * @returns - Boolean specifying if a texture is used in the material.
  115939. */
  115940. hasTexture(texture: BaseTexture): boolean;
  115941. /**
  115942. * Dispose the material.
  115943. * @param forceDisposeEffect Force disposal of the associated effect.
  115944. * @param forceDisposeTextures Force disposal of the associated textures.
  115945. */
  115946. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115947. /**
  115948. * Clones the material.
  115949. * @param name The cloned name.
  115950. * @returns The cloned material.
  115951. */
  115952. clone(name: string): BackgroundMaterial;
  115953. /**
  115954. * Serializes the current material to its JSON representation.
  115955. * @returns The JSON representation.
  115956. */
  115957. serialize(): any;
  115958. /**
  115959. * Gets the class name of the material
  115960. * @returns "BackgroundMaterial"
  115961. */
  115962. getClassName(): string;
  115963. /**
  115964. * Parse a JSON input to create back a background material.
  115965. * @param source The JSON data to parse
  115966. * @param scene The scene to create the parsed material in
  115967. * @param rootUrl The root url of the assets the material depends upon
  115968. * @returns the instantiated BackgroundMaterial.
  115969. */
  115970. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  115971. }
  115972. }
  115973. declare module BABYLON {
  115974. /**
  115975. * Represents the different options available during the creation of
  115976. * a Environment helper.
  115977. *
  115978. * This can control the default ground, skybox and image processing setup of your scene.
  115979. */
  115980. export interface IEnvironmentHelperOptions {
  115981. /**
  115982. * Specifies wether or not to create a ground.
  115983. * True by default.
  115984. */
  115985. createGround: boolean;
  115986. /**
  115987. * Specifies the ground size.
  115988. * 15 by default.
  115989. */
  115990. groundSize: number;
  115991. /**
  115992. * The texture used on the ground for the main color.
  115993. * Comes from the BabylonJS CDN by default.
  115994. *
  115995. * Remarks: Can be either a texture or a url.
  115996. */
  115997. groundTexture: string | BaseTexture;
  115998. /**
  115999. * The color mixed in the ground texture by default.
  116000. * BabylonJS clearColor by default.
  116001. */
  116002. groundColor: Color3;
  116003. /**
  116004. * Specifies the ground opacity.
  116005. * 1 by default.
  116006. */
  116007. groundOpacity: number;
  116008. /**
  116009. * Enables the ground to receive shadows.
  116010. * True by default.
  116011. */
  116012. enableGroundShadow: boolean;
  116013. /**
  116014. * Helps preventing the shadow to be fully black on the ground.
  116015. * 0.5 by default.
  116016. */
  116017. groundShadowLevel: number;
  116018. /**
  116019. * Creates a mirror texture attach to the ground.
  116020. * false by default.
  116021. */
  116022. enableGroundMirror: boolean;
  116023. /**
  116024. * Specifies the ground mirror size ratio.
  116025. * 0.3 by default as the default kernel is 64.
  116026. */
  116027. groundMirrorSizeRatio: number;
  116028. /**
  116029. * Specifies the ground mirror blur kernel size.
  116030. * 64 by default.
  116031. */
  116032. groundMirrorBlurKernel: number;
  116033. /**
  116034. * Specifies the ground mirror visibility amount.
  116035. * 1 by default
  116036. */
  116037. groundMirrorAmount: number;
  116038. /**
  116039. * Specifies the ground mirror reflectance weight.
  116040. * This uses the standard weight of the background material to setup the fresnel effect
  116041. * of the mirror.
  116042. * 1 by default.
  116043. */
  116044. groundMirrorFresnelWeight: number;
  116045. /**
  116046. * Specifies the ground mirror Falloff distance.
  116047. * This can helps reducing the size of the reflection.
  116048. * 0 by Default.
  116049. */
  116050. groundMirrorFallOffDistance: number;
  116051. /**
  116052. * Specifies the ground mirror texture type.
  116053. * Unsigned Int by Default.
  116054. */
  116055. groundMirrorTextureType: number;
  116056. /**
  116057. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  116058. * the shown objects.
  116059. */
  116060. groundYBias: number;
  116061. /**
  116062. * Specifies wether or not to create a skybox.
  116063. * True by default.
  116064. */
  116065. createSkybox: boolean;
  116066. /**
  116067. * Specifies the skybox size.
  116068. * 20 by default.
  116069. */
  116070. skyboxSize: number;
  116071. /**
  116072. * The texture used on the skybox for the main color.
  116073. * Comes from the BabylonJS CDN by default.
  116074. *
  116075. * Remarks: Can be either a texture or a url.
  116076. */
  116077. skyboxTexture: string | BaseTexture;
  116078. /**
  116079. * The color mixed in the skybox texture by default.
  116080. * BabylonJS clearColor by default.
  116081. */
  116082. skyboxColor: Color3;
  116083. /**
  116084. * The background rotation around the Y axis of the scene.
  116085. * This helps aligning the key lights of your scene with the background.
  116086. * 0 by default.
  116087. */
  116088. backgroundYRotation: number;
  116089. /**
  116090. * Compute automatically the size of the elements to best fit with the scene.
  116091. */
  116092. sizeAuto: boolean;
  116093. /**
  116094. * Default position of the rootMesh if autoSize is not true.
  116095. */
  116096. rootPosition: Vector3;
  116097. /**
  116098. * Sets up the image processing in the scene.
  116099. * true by default.
  116100. */
  116101. setupImageProcessing: boolean;
  116102. /**
  116103. * The texture used as your environment texture in the scene.
  116104. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  116105. *
  116106. * Remarks: Can be either a texture or a url.
  116107. */
  116108. environmentTexture: string | BaseTexture;
  116109. /**
  116110. * The value of the exposure to apply to the scene.
  116111. * 0.6 by default if setupImageProcessing is true.
  116112. */
  116113. cameraExposure: number;
  116114. /**
  116115. * The value of the contrast to apply to the scene.
  116116. * 1.6 by default if setupImageProcessing is true.
  116117. */
  116118. cameraContrast: number;
  116119. /**
  116120. * Specifies wether or not tonemapping should be enabled in the scene.
  116121. * true by default if setupImageProcessing is true.
  116122. */
  116123. toneMappingEnabled: boolean;
  116124. }
  116125. /**
  116126. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  116127. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  116128. * It also helps with the default setup of your imageProcessing configuration.
  116129. */
  116130. export class EnvironmentHelper {
  116131. /**
  116132. * Default ground texture URL.
  116133. */
  116134. private static _groundTextureCDNUrl;
  116135. /**
  116136. * Default skybox texture URL.
  116137. */
  116138. private static _skyboxTextureCDNUrl;
  116139. /**
  116140. * Default environment texture URL.
  116141. */
  116142. private static _environmentTextureCDNUrl;
  116143. /**
  116144. * Creates the default options for the helper.
  116145. */
  116146. private static _getDefaultOptions;
  116147. private _rootMesh;
  116148. /**
  116149. * Gets the root mesh created by the helper.
  116150. */
  116151. readonly rootMesh: Mesh;
  116152. private _skybox;
  116153. /**
  116154. * Gets the skybox created by the helper.
  116155. */
  116156. readonly skybox: Nullable<Mesh>;
  116157. private _skyboxTexture;
  116158. /**
  116159. * Gets the skybox texture created by the helper.
  116160. */
  116161. readonly skyboxTexture: Nullable<BaseTexture>;
  116162. private _skyboxMaterial;
  116163. /**
  116164. * Gets the skybox material created by the helper.
  116165. */
  116166. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  116167. private _ground;
  116168. /**
  116169. * Gets the ground mesh created by the helper.
  116170. */
  116171. readonly ground: Nullable<Mesh>;
  116172. private _groundTexture;
  116173. /**
  116174. * Gets the ground texture created by the helper.
  116175. */
  116176. readonly groundTexture: Nullable<BaseTexture>;
  116177. private _groundMirror;
  116178. /**
  116179. * Gets the ground mirror created by the helper.
  116180. */
  116181. readonly groundMirror: Nullable<MirrorTexture>;
  116182. /**
  116183. * Gets the ground mirror render list to helps pushing the meshes
  116184. * you wish in the ground reflection.
  116185. */
  116186. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  116187. private _groundMaterial;
  116188. /**
  116189. * Gets the ground material created by the helper.
  116190. */
  116191. readonly groundMaterial: Nullable<BackgroundMaterial>;
  116192. /**
  116193. * Stores the creation options.
  116194. */
  116195. private readonly _scene;
  116196. private _options;
  116197. /**
  116198. * This observable will be notified with any error during the creation of the environment,
  116199. * mainly texture creation errors.
  116200. */
  116201. onErrorObservable: Observable<{
  116202. message?: string;
  116203. exception?: any;
  116204. }>;
  116205. /**
  116206. * constructor
  116207. * @param options Defines the options we want to customize the helper
  116208. * @param scene The scene to add the material to
  116209. */
  116210. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  116211. /**
  116212. * Updates the background according to the new options
  116213. * @param options
  116214. */
  116215. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  116216. /**
  116217. * Sets the primary color of all the available elements.
  116218. * @param color the main color to affect to the ground and the background
  116219. */
  116220. setMainColor(color: Color3): void;
  116221. /**
  116222. * Setup the image processing according to the specified options.
  116223. */
  116224. private _setupImageProcessing;
  116225. /**
  116226. * Setup the environment texture according to the specified options.
  116227. */
  116228. private _setupEnvironmentTexture;
  116229. /**
  116230. * Setup the background according to the specified options.
  116231. */
  116232. private _setupBackground;
  116233. /**
  116234. * Get the scene sizes according to the setup.
  116235. */
  116236. private _getSceneSize;
  116237. /**
  116238. * Setup the ground according to the specified options.
  116239. */
  116240. private _setupGround;
  116241. /**
  116242. * Setup the ground material according to the specified options.
  116243. */
  116244. private _setupGroundMaterial;
  116245. /**
  116246. * Setup the ground diffuse texture according to the specified options.
  116247. */
  116248. private _setupGroundDiffuseTexture;
  116249. /**
  116250. * Setup the ground mirror texture according to the specified options.
  116251. */
  116252. private _setupGroundMirrorTexture;
  116253. /**
  116254. * Setup the ground to receive the mirror texture.
  116255. */
  116256. private _setupMirrorInGroundMaterial;
  116257. /**
  116258. * Setup the skybox according to the specified options.
  116259. */
  116260. private _setupSkybox;
  116261. /**
  116262. * Setup the skybox material according to the specified options.
  116263. */
  116264. private _setupSkyboxMaterial;
  116265. /**
  116266. * Setup the skybox reflection texture according to the specified options.
  116267. */
  116268. private _setupSkyboxReflectionTexture;
  116269. private _errorHandler;
  116270. /**
  116271. * Dispose all the elements created by the Helper.
  116272. */
  116273. dispose(): void;
  116274. }
  116275. }
  116276. declare module BABYLON {
  116277. /**
  116278. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  116279. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  116280. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  116281. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116282. */
  116283. export class PhotoDome extends TransformNode {
  116284. /**
  116285. * Define the image as a Monoscopic panoramic 360 image.
  116286. */
  116287. static readonly MODE_MONOSCOPIC: number;
  116288. /**
  116289. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116290. */
  116291. static readonly MODE_TOPBOTTOM: number;
  116292. /**
  116293. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116294. */
  116295. static readonly MODE_SIDEBYSIDE: number;
  116296. private _useDirectMapping;
  116297. /**
  116298. * The texture being displayed on the sphere
  116299. */
  116300. protected _photoTexture: Texture;
  116301. /**
  116302. * Gets or sets the texture being displayed on the sphere
  116303. */
  116304. photoTexture: Texture;
  116305. /**
  116306. * Observable raised when an error occured while loading the 360 image
  116307. */
  116308. onLoadErrorObservable: Observable<string>;
  116309. /**
  116310. * The skybox material
  116311. */
  116312. protected _material: BackgroundMaterial;
  116313. /**
  116314. * The surface used for the skybox
  116315. */
  116316. protected _mesh: Mesh;
  116317. /**
  116318. * Gets the mesh used for the skybox.
  116319. */
  116320. readonly mesh: Mesh;
  116321. /**
  116322. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116323. * Also see the options.resolution property.
  116324. */
  116325. fovMultiplier: number;
  116326. private _imageMode;
  116327. /**
  116328. * Gets or set the current video mode for the video. It can be:
  116329. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  116330. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116331. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116332. */
  116333. imageMode: number;
  116334. /**
  116335. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  116336. * @param name Element's name, child elements will append suffixes for their own names.
  116337. * @param urlsOfPhoto defines the url of the photo to display
  116338. * @param options defines an object containing optional or exposed sub element properties
  116339. * @param onError defines a callback called when an error occured while loading the texture
  116340. */
  116341. constructor(name: string, urlOfPhoto: string, options: {
  116342. resolution?: number;
  116343. size?: number;
  116344. useDirectMapping?: boolean;
  116345. faceForward?: boolean;
  116346. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  116347. private _onBeforeCameraRenderObserver;
  116348. private _changeImageMode;
  116349. /**
  116350. * Releases resources associated with this node.
  116351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116353. */
  116354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116355. }
  116356. }
  116357. declare module BABYLON {
  116358. /**
  116359. * Class used to host RGBD texture specific utilities
  116360. */
  116361. export class RGBDTextureTools {
  116362. /**
  116363. * Expand the RGBD Texture from RGBD to Half Float if possible.
  116364. * @param texture the texture to expand.
  116365. */
  116366. static ExpandRGBDTexture(texture: Texture): void;
  116367. }
  116368. }
  116369. declare module BABYLON {
  116370. /**
  116371. * Class used to host texture specific utilities
  116372. */
  116373. export class BRDFTextureTools {
  116374. /**
  116375. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  116376. * @param scene defines the hosting scene
  116377. * @returns the environment BRDF texture
  116378. */
  116379. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  116380. private static _environmentBRDFBase64Texture;
  116381. }
  116382. }
  116383. declare module BABYLON {
  116384. /**
  116385. * @hidden
  116386. */
  116387. export interface IMaterialClearCoatDefines {
  116388. CLEARCOAT: boolean;
  116389. CLEARCOAT_DEFAULTIOR: boolean;
  116390. CLEARCOAT_TEXTURE: boolean;
  116391. CLEARCOAT_TEXTUREDIRECTUV: number;
  116392. CLEARCOAT_BUMP: boolean;
  116393. CLEARCOAT_BUMPDIRECTUV: number;
  116394. CLEARCOAT_TINT: boolean;
  116395. CLEARCOAT_TINT_TEXTURE: boolean;
  116396. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116397. /** @hidden */
  116398. _areTexturesDirty: boolean;
  116399. }
  116400. /**
  116401. * Define the code related to the clear coat parameters of the pbr material.
  116402. */
  116403. export class PBRClearCoatConfiguration {
  116404. /**
  116405. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116406. * The default fits with a polyurethane material.
  116407. */
  116408. private static readonly _DefaultIndexOfRefraction;
  116409. private _isEnabled;
  116410. /**
  116411. * Defines if the clear coat is enabled in the material.
  116412. */
  116413. isEnabled: boolean;
  116414. /**
  116415. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  116416. */
  116417. intensity: number;
  116418. /**
  116419. * Defines the clear coat layer roughness.
  116420. */
  116421. roughness: number;
  116422. private _indexOfRefraction;
  116423. /**
  116424. * Defines the index of refraction of the clear coat.
  116425. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116426. * The default fits with a polyurethane material.
  116427. * Changing the default value is more performance intensive.
  116428. */
  116429. indexOfRefraction: number;
  116430. private _texture;
  116431. /**
  116432. * Stores the clear coat values in a texture.
  116433. */
  116434. texture: Nullable<BaseTexture>;
  116435. private _bumpTexture;
  116436. /**
  116437. * Define the clear coat specific bump texture.
  116438. */
  116439. bumpTexture: Nullable<BaseTexture>;
  116440. private _isTintEnabled;
  116441. /**
  116442. * Defines if the clear coat tint is enabled in the material.
  116443. */
  116444. isTintEnabled: boolean;
  116445. /**
  116446. * Defines the clear coat tint of the material.
  116447. * This is only use if tint is enabled
  116448. */
  116449. tintColor: Color3;
  116450. /**
  116451. * Defines the distance at which the tint color should be found in the
  116452. * clear coat media.
  116453. * This is only use if tint is enabled
  116454. */
  116455. tintColorAtDistance: number;
  116456. /**
  116457. * Defines the clear coat layer thickness.
  116458. * This is only use if tint is enabled
  116459. */
  116460. tintThickness: number;
  116461. private _tintTexture;
  116462. /**
  116463. * Stores the clear tint values in a texture.
  116464. * rgb is tint
  116465. * a is a thickness factor
  116466. */
  116467. tintTexture: Nullable<BaseTexture>;
  116468. /** @hidden */
  116469. private _internalMarkAllSubMeshesAsTexturesDirty;
  116470. /** @hidden */
  116471. _markAllSubMeshesAsTexturesDirty(): void;
  116472. /**
  116473. * Instantiate a new istance of clear coat configuration.
  116474. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116475. */
  116476. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116477. /**
  116478. * Gets wehter the submesh is ready to be used or not.
  116479. * @param defines the list of "defines" to update.
  116480. * @param scene defines the scene the material belongs to.
  116481. * @param engine defines the engine the material belongs to.
  116482. * @param disableBumpMap defines wether the material disables bump or not.
  116483. * @returns - boolean indicating that the submesh is ready or not.
  116484. */
  116485. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  116486. /**
  116487. * Checks to see if a texture is used in the material.
  116488. * @param defines the list of "defines" to update.
  116489. * @param scene defines the scene to the material belongs to.
  116490. */
  116491. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  116492. /**
  116493. * Binds the material data.
  116494. * @param uniformBuffer defines the Uniform buffer to fill in.
  116495. * @param scene defines the scene the material belongs to.
  116496. * @param engine defines the engine the material belongs to.
  116497. * @param disableBumpMap defines wether the material disables bump or not.
  116498. * @param isFrozen defines wether the material is frozen or not.
  116499. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116500. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116501. */
  116502. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  116503. /**
  116504. * Checks to see if a texture is used in the material.
  116505. * @param texture - Base texture to use.
  116506. * @returns - Boolean specifying if a texture is used in the material.
  116507. */
  116508. hasTexture(texture: BaseTexture): boolean;
  116509. /**
  116510. * Returns an array of the actively used textures.
  116511. * @param activeTextures Array of BaseTextures
  116512. */
  116513. getActiveTextures(activeTextures: BaseTexture[]): void;
  116514. /**
  116515. * Returns the animatable textures.
  116516. * @param animatables Array of animatable textures.
  116517. */
  116518. getAnimatables(animatables: IAnimatable[]): void;
  116519. /**
  116520. * Disposes the resources of the material.
  116521. * @param forceDisposeTextures - Forces the disposal of all textures.
  116522. */
  116523. dispose(forceDisposeTextures?: boolean): void;
  116524. /**
  116525. * Get the current class name of the texture useful for serialization or dynamic coding.
  116526. * @returns "PBRClearCoatConfiguration"
  116527. */
  116528. getClassName(): string;
  116529. /**
  116530. * Add fallbacks to the effect fallbacks list.
  116531. * @param defines defines the Base texture to use.
  116532. * @param fallbacks defines the current fallback list.
  116533. * @param currentRank defines the current fallback rank.
  116534. * @returns the new fallback rank.
  116535. */
  116536. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116537. /**
  116538. * Add the required uniforms to the current list.
  116539. * @param uniforms defines the current uniform list.
  116540. */
  116541. static AddUniforms(uniforms: string[]): void;
  116542. /**
  116543. * Add the required samplers to the current list.
  116544. * @param samplers defines the current sampler list.
  116545. */
  116546. static AddSamplers(samplers: string[]): void;
  116547. /**
  116548. * Add the required uniforms to the current buffer.
  116549. * @param uniformBuffer defines the current uniform buffer.
  116550. */
  116551. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116552. /**
  116553. * Makes a duplicate of the current configuration into another one.
  116554. * @param clearCoatConfiguration define the config where to copy the info
  116555. */
  116556. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  116557. /**
  116558. * Serializes this clear coat configuration.
  116559. * @returns - An object with the serialized config.
  116560. */
  116561. serialize(): any;
  116562. /**
  116563. * Parses a anisotropy Configuration from a serialized object.
  116564. * @param source - Serialized object.
  116565. * @param scene Defines the scene we are parsing for
  116566. * @param rootUrl Defines the rootUrl to load from
  116567. */
  116568. parse(source: any, scene: Scene, rootUrl: string): void;
  116569. }
  116570. }
  116571. declare module BABYLON {
  116572. /**
  116573. * @hidden
  116574. */
  116575. export interface IMaterialAnisotropicDefines {
  116576. ANISOTROPIC: boolean;
  116577. ANISOTROPIC_TEXTURE: boolean;
  116578. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116579. MAINUV1: boolean;
  116580. _areTexturesDirty: boolean;
  116581. _needUVs: boolean;
  116582. }
  116583. /**
  116584. * Define the code related to the anisotropic parameters of the pbr material.
  116585. */
  116586. export class PBRAnisotropicConfiguration {
  116587. private _isEnabled;
  116588. /**
  116589. * Defines if the anisotropy is enabled in the material.
  116590. */
  116591. isEnabled: boolean;
  116592. /**
  116593. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  116594. */
  116595. intensity: number;
  116596. /**
  116597. * Defines if the effect is along the tangents, bitangents or in between.
  116598. * By default, the effect is "strectching" the highlights along the tangents.
  116599. */
  116600. direction: Vector2;
  116601. private _texture;
  116602. /**
  116603. * Stores the anisotropy values in a texture.
  116604. * rg is direction (like normal from -1 to 1)
  116605. * b is a intensity
  116606. */
  116607. texture: Nullable<BaseTexture>;
  116608. /** @hidden */
  116609. private _internalMarkAllSubMeshesAsTexturesDirty;
  116610. /** @hidden */
  116611. _markAllSubMeshesAsTexturesDirty(): void;
  116612. /**
  116613. * Instantiate a new istance of anisotropy configuration.
  116614. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116615. */
  116616. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116617. /**
  116618. * Specifies that the submesh is ready to be used.
  116619. * @param defines the list of "defines" to update.
  116620. * @param scene defines the scene the material belongs to.
  116621. * @returns - boolean indicating that the submesh is ready or not.
  116622. */
  116623. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  116624. /**
  116625. * Checks to see if a texture is used in the material.
  116626. * @param defines the list of "defines" to update.
  116627. * @param mesh the mesh we are preparing the defines for.
  116628. * @param scene defines the scene the material belongs to.
  116629. */
  116630. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  116631. /**
  116632. * Binds the material data.
  116633. * @param uniformBuffer defines the Uniform buffer to fill in.
  116634. * @param scene defines the scene the material belongs to.
  116635. * @param isFrozen defines wether the material is frozen or not.
  116636. */
  116637. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116638. /**
  116639. * Checks to see if a texture is used in the material.
  116640. * @param texture - Base texture to use.
  116641. * @returns - Boolean specifying if a texture is used in the material.
  116642. */
  116643. hasTexture(texture: BaseTexture): boolean;
  116644. /**
  116645. * Returns an array of the actively used textures.
  116646. * @param activeTextures Array of BaseTextures
  116647. */
  116648. getActiveTextures(activeTextures: BaseTexture[]): void;
  116649. /**
  116650. * Returns the animatable textures.
  116651. * @param animatables Array of animatable textures.
  116652. */
  116653. getAnimatables(animatables: IAnimatable[]): void;
  116654. /**
  116655. * Disposes the resources of the material.
  116656. * @param forceDisposeTextures - Forces the disposal of all textures.
  116657. */
  116658. dispose(forceDisposeTextures?: boolean): void;
  116659. /**
  116660. * Get the current class name of the texture useful for serialization or dynamic coding.
  116661. * @returns "PBRAnisotropicConfiguration"
  116662. */
  116663. getClassName(): string;
  116664. /**
  116665. * Add fallbacks to the effect fallbacks list.
  116666. * @param defines defines the Base texture to use.
  116667. * @param fallbacks defines the current fallback list.
  116668. * @param currentRank defines the current fallback rank.
  116669. * @returns the new fallback rank.
  116670. */
  116671. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116672. /**
  116673. * Add the required uniforms to the current list.
  116674. * @param uniforms defines the current uniform list.
  116675. */
  116676. static AddUniforms(uniforms: string[]): void;
  116677. /**
  116678. * Add the required uniforms to the current buffer.
  116679. * @param uniformBuffer defines the current uniform buffer.
  116680. */
  116681. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116682. /**
  116683. * Add the required samplers to the current list.
  116684. * @param samplers defines the current sampler list.
  116685. */
  116686. static AddSamplers(samplers: string[]): void;
  116687. /**
  116688. * Makes a duplicate of the current configuration into another one.
  116689. * @param anisotropicConfiguration define the config where to copy the info
  116690. */
  116691. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  116692. /**
  116693. * Serializes this anisotropy configuration.
  116694. * @returns - An object with the serialized config.
  116695. */
  116696. serialize(): any;
  116697. /**
  116698. * Parses a anisotropy Configuration from a serialized object.
  116699. * @param source - Serialized object.
  116700. * @param scene Defines the scene we are parsing for
  116701. * @param rootUrl Defines the rootUrl to load from
  116702. */
  116703. parse(source: any, scene: Scene, rootUrl: string): void;
  116704. }
  116705. }
  116706. declare module BABYLON {
  116707. /**
  116708. * @hidden
  116709. */
  116710. export interface IMaterialBRDFDefines {
  116711. BRDF_V_HEIGHT_CORRELATED: boolean;
  116712. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116713. SPHERICAL_HARMONICS: boolean;
  116714. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116715. /** @hidden */
  116716. _areMiscDirty: boolean;
  116717. }
  116718. /**
  116719. * Define the code related to the BRDF parameters of the pbr material.
  116720. */
  116721. export class PBRBRDFConfiguration {
  116722. /**
  116723. * Default value used for the energy conservation.
  116724. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116725. */
  116726. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  116727. /**
  116728. * Default value used for the Smith Visibility Height Correlated mode.
  116729. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116730. */
  116731. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  116732. /**
  116733. * Default value used for the IBL diffuse part.
  116734. * This can help switching back to the polynomials mode globally which is a tiny bit
  116735. * less GPU intensive at the drawback of a lower quality.
  116736. */
  116737. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  116738. /**
  116739. * Default value used for activating energy conservation for the specular workflow.
  116740. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116741. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116742. */
  116743. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  116744. private _useEnergyConservation;
  116745. /**
  116746. * Defines if the material uses energy conservation.
  116747. */
  116748. useEnergyConservation: boolean;
  116749. private _useSmithVisibilityHeightCorrelated;
  116750. /**
  116751. * LEGACY Mode set to false
  116752. * Defines if the material uses height smith correlated visibility term.
  116753. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  116754. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  116755. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  116756. * Not relying on height correlated will also disable energy conservation.
  116757. */
  116758. useSmithVisibilityHeightCorrelated: boolean;
  116759. private _useSphericalHarmonics;
  116760. /**
  116761. * LEGACY Mode set to false
  116762. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  116763. * diffuse part of the IBL.
  116764. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  116765. * to the ground truth.
  116766. */
  116767. useSphericalHarmonics: boolean;
  116768. private _useSpecularGlossinessInputEnergyConservation;
  116769. /**
  116770. * Defines if the material uses energy conservation, when the specular workflow is active.
  116771. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116772. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116773. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  116774. */
  116775. useSpecularGlossinessInputEnergyConservation: boolean;
  116776. /** @hidden */
  116777. private _internalMarkAllSubMeshesAsMiscDirty;
  116778. /** @hidden */
  116779. _markAllSubMeshesAsMiscDirty(): void;
  116780. /**
  116781. * Instantiate a new istance of clear coat configuration.
  116782. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  116783. */
  116784. constructor(markAllSubMeshesAsMiscDirty: () => void);
  116785. /**
  116786. * Checks to see if a texture is used in the material.
  116787. * @param defines the list of "defines" to update.
  116788. */
  116789. prepareDefines(defines: IMaterialBRDFDefines): void;
  116790. /**
  116791. * Get the current class name of the texture useful for serialization or dynamic coding.
  116792. * @returns "PBRClearCoatConfiguration"
  116793. */
  116794. getClassName(): string;
  116795. /**
  116796. * Makes a duplicate of the current configuration into another one.
  116797. * @param brdfConfiguration define the config where to copy the info
  116798. */
  116799. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  116800. /**
  116801. * Serializes this BRDF configuration.
  116802. * @returns - An object with the serialized config.
  116803. */
  116804. serialize(): any;
  116805. /**
  116806. * Parses a anisotropy Configuration from a serialized object.
  116807. * @param source - Serialized object.
  116808. * @param scene Defines the scene we are parsing for
  116809. * @param rootUrl Defines the rootUrl to load from
  116810. */
  116811. parse(source: any, scene: Scene, rootUrl: string): void;
  116812. }
  116813. }
  116814. declare module BABYLON {
  116815. /**
  116816. * @hidden
  116817. */
  116818. export interface IMaterialSheenDefines {
  116819. SHEEN: boolean;
  116820. SHEEN_TEXTURE: boolean;
  116821. SHEEN_TEXTUREDIRECTUV: number;
  116822. SHEEN_LINKWITHALBEDO: boolean;
  116823. /** @hidden */
  116824. _areTexturesDirty: boolean;
  116825. }
  116826. /**
  116827. * Define the code related to the Sheen parameters of the pbr material.
  116828. */
  116829. export class PBRSheenConfiguration {
  116830. private _isEnabled;
  116831. /**
  116832. * Defines if the material uses sheen.
  116833. */
  116834. isEnabled: boolean;
  116835. private _linkSheenWithAlbedo;
  116836. /**
  116837. * Defines if the sheen is linked to the sheen color.
  116838. */
  116839. linkSheenWithAlbedo: boolean;
  116840. /**
  116841. * Defines the sheen intensity.
  116842. */
  116843. intensity: number;
  116844. /**
  116845. * Defines the sheen color.
  116846. */
  116847. color: Color3;
  116848. private _texture;
  116849. /**
  116850. * Stores the sheen tint values in a texture.
  116851. * rgb is tint
  116852. * a is a intensity
  116853. */
  116854. texture: Nullable<BaseTexture>;
  116855. /** @hidden */
  116856. private _internalMarkAllSubMeshesAsTexturesDirty;
  116857. /** @hidden */
  116858. _markAllSubMeshesAsTexturesDirty(): void;
  116859. /**
  116860. * Instantiate a new istance of clear coat configuration.
  116861. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116862. */
  116863. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116864. /**
  116865. * Specifies that the submesh is ready to be used.
  116866. * @param defines the list of "defines" to update.
  116867. * @param scene defines the scene the material belongs to.
  116868. * @returns - boolean indicating that the submesh is ready or not.
  116869. */
  116870. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  116871. /**
  116872. * Checks to see if a texture is used in the material.
  116873. * @param defines the list of "defines" to update.
  116874. * @param scene defines the scene the material belongs to.
  116875. */
  116876. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  116877. /**
  116878. * Binds the material data.
  116879. * @param uniformBuffer defines the Uniform buffer to fill in.
  116880. * @param scene defines the scene the material belongs to.
  116881. * @param isFrozen defines wether the material is frozen or not.
  116882. */
  116883. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116884. /**
  116885. * Checks to see if a texture is used in the material.
  116886. * @param texture - Base texture to use.
  116887. * @returns - Boolean specifying if a texture is used in the material.
  116888. */
  116889. hasTexture(texture: BaseTexture): boolean;
  116890. /**
  116891. * Returns an array of the actively used textures.
  116892. * @param activeTextures Array of BaseTextures
  116893. */
  116894. getActiveTextures(activeTextures: BaseTexture[]): void;
  116895. /**
  116896. * Returns the animatable textures.
  116897. * @param animatables Array of animatable textures.
  116898. */
  116899. getAnimatables(animatables: IAnimatable[]): void;
  116900. /**
  116901. * Disposes the resources of the material.
  116902. * @param forceDisposeTextures - Forces the disposal of all textures.
  116903. */
  116904. dispose(forceDisposeTextures?: boolean): void;
  116905. /**
  116906. * Get the current class name of the texture useful for serialization or dynamic coding.
  116907. * @returns "PBRSheenConfiguration"
  116908. */
  116909. getClassName(): string;
  116910. /**
  116911. * Add fallbacks to the effect fallbacks list.
  116912. * @param defines defines the Base texture to use.
  116913. * @param fallbacks defines the current fallback list.
  116914. * @param currentRank defines the current fallback rank.
  116915. * @returns the new fallback rank.
  116916. */
  116917. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116918. /**
  116919. * Add the required uniforms to the current list.
  116920. * @param uniforms defines the current uniform list.
  116921. */
  116922. static AddUniforms(uniforms: string[]): void;
  116923. /**
  116924. * Add the required uniforms to the current buffer.
  116925. * @param uniformBuffer defines the current uniform buffer.
  116926. */
  116927. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116928. /**
  116929. * Add the required samplers to the current list.
  116930. * @param samplers defines the current sampler list.
  116931. */
  116932. static AddSamplers(samplers: string[]): void;
  116933. /**
  116934. * Makes a duplicate of the current configuration into another one.
  116935. * @param sheenConfiguration define the config where to copy the info
  116936. */
  116937. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  116938. /**
  116939. * Serializes this BRDF configuration.
  116940. * @returns - An object with the serialized config.
  116941. */
  116942. serialize(): any;
  116943. /**
  116944. * Parses a anisotropy Configuration from a serialized object.
  116945. * @param source - Serialized object.
  116946. * @param scene Defines the scene we are parsing for
  116947. * @param rootUrl Defines the rootUrl to load from
  116948. */
  116949. parse(source: any, scene: Scene, rootUrl: string): void;
  116950. }
  116951. }
  116952. declare module BABYLON {
  116953. /**
  116954. * @hidden
  116955. */
  116956. export interface IMaterialSubSurfaceDefines {
  116957. SUBSURFACE: boolean;
  116958. SS_REFRACTION: boolean;
  116959. SS_TRANSLUCENCY: boolean;
  116960. SS_SCATERRING: boolean;
  116961. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116962. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116963. SS_REFRACTIONMAP_3D: boolean;
  116964. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116965. SS_LODINREFRACTIONALPHA: boolean;
  116966. SS_GAMMAREFRACTION: boolean;
  116967. SS_RGBDREFRACTION: boolean;
  116968. SS_LINEARSPECULARREFRACTION: boolean;
  116969. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116970. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116971. /** @hidden */
  116972. _areTexturesDirty: boolean;
  116973. }
  116974. /**
  116975. * Define the code related to the sub surface parameters of the pbr material.
  116976. */
  116977. export class PBRSubSurfaceConfiguration {
  116978. private _isRefractionEnabled;
  116979. /**
  116980. * Defines if the refraction is enabled in the material.
  116981. */
  116982. isRefractionEnabled: boolean;
  116983. private _isTranslucencyEnabled;
  116984. /**
  116985. * Defines if the translucency is enabled in the material.
  116986. */
  116987. isTranslucencyEnabled: boolean;
  116988. private _isScatteringEnabled;
  116989. /**
  116990. * Defines the refraction intensity of the material.
  116991. * The refraction when enabled replaces the Diffuse part of the material.
  116992. * The intensity helps transitionning between diffuse and refraction.
  116993. */
  116994. refractionIntensity: number;
  116995. /**
  116996. * Defines the translucency intensity of the material.
  116997. * When translucency has been enabled, this defines how much of the "translucency"
  116998. * is addded to the diffuse part of the material.
  116999. */
  117000. translucencyIntensity: number;
  117001. /**
  117002. * Defines the scattering intensity of the material.
  117003. * When scattering has been enabled, this defines how much of the "scattered light"
  117004. * is addded to the diffuse part of the material.
  117005. */
  117006. scatteringIntensity: number;
  117007. private _thicknessTexture;
  117008. /**
  117009. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  117010. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  117011. * 0 would mean minimumThickness
  117012. * 1 would mean maximumThickness
  117013. * The other channels might be use as a mask to vary the different effects intensity.
  117014. */
  117015. thicknessTexture: Nullable<BaseTexture>;
  117016. private _refractionTexture;
  117017. /**
  117018. * Defines the texture to use for refraction.
  117019. */
  117020. refractionTexture: Nullable<BaseTexture>;
  117021. private _indexOfRefraction;
  117022. /**
  117023. * Defines the index of refraction used in the material.
  117024. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  117025. */
  117026. indexOfRefraction: number;
  117027. private _invertRefractionY;
  117028. /**
  117029. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117030. */
  117031. invertRefractionY: boolean;
  117032. private _linkRefractionWithTransparency;
  117033. /**
  117034. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117035. * Materials half opaque for instance using refraction could benefit from this control.
  117036. */
  117037. linkRefractionWithTransparency: boolean;
  117038. /**
  117039. * Defines the minimum thickness stored in the thickness map.
  117040. * If no thickness map is defined, this value will be used to simulate thickness.
  117041. */
  117042. minimumThickness: number;
  117043. /**
  117044. * Defines the maximum thickness stored in the thickness map.
  117045. */
  117046. maximumThickness: number;
  117047. /**
  117048. * Defines the volume tint of the material.
  117049. * This is used for both translucency and scattering.
  117050. */
  117051. tintColor: Color3;
  117052. /**
  117053. * Defines the distance at which the tint color should be found in the media.
  117054. * This is used for refraction only.
  117055. */
  117056. tintColorAtDistance: number;
  117057. /**
  117058. * Defines how far each channel transmit through the media.
  117059. * It is defined as a color to simplify it selection.
  117060. */
  117061. diffusionDistance: Color3;
  117062. private _useMaskFromThicknessTexture;
  117063. /**
  117064. * Stores the intensity of the different subsurface effects in the thickness texture.
  117065. * * the green channel is the translucency intensity.
  117066. * * the blue channel is the scattering intensity.
  117067. * * the alpha channel is the refraction intensity.
  117068. */
  117069. useMaskFromThicknessTexture: boolean;
  117070. /** @hidden */
  117071. private _internalMarkAllSubMeshesAsTexturesDirty;
  117072. /** @hidden */
  117073. _markAllSubMeshesAsTexturesDirty(): void;
  117074. /**
  117075. * Instantiate a new istance of sub surface configuration.
  117076. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117077. */
  117078. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117079. /**
  117080. * Gets wehter the submesh is ready to be used or not.
  117081. * @param defines the list of "defines" to update.
  117082. * @param scene defines the scene the material belongs to.
  117083. * @returns - boolean indicating that the submesh is ready or not.
  117084. */
  117085. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  117086. /**
  117087. * Checks to see if a texture is used in the material.
  117088. * @param defines the list of "defines" to update.
  117089. * @param scene defines the scene to the material belongs to.
  117090. */
  117091. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  117092. /**
  117093. * Binds the material data.
  117094. * @param uniformBuffer defines the Uniform buffer to fill in.
  117095. * @param scene defines the scene the material belongs to.
  117096. * @param engine defines the engine the material belongs to.
  117097. * @param isFrozen defines wether the material is frozen or not.
  117098. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  117099. */
  117100. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  117101. /**
  117102. * Unbinds the material from the mesh.
  117103. * @param activeEffect defines the effect that should be unbound from.
  117104. * @returns true if unbound, otherwise false
  117105. */
  117106. unbind(activeEffect: Effect): boolean;
  117107. /**
  117108. * Returns the texture used for refraction or null if none is used.
  117109. * @param scene defines the scene the material belongs to.
  117110. * @returns - Refraction texture if present. If no refraction texture and refraction
  117111. * is linked with transparency, returns environment texture. Otherwise, returns null.
  117112. */
  117113. private _getRefractionTexture;
  117114. /**
  117115. * Returns true if alpha blending should be disabled.
  117116. */
  117117. readonly disableAlphaBlending: boolean;
  117118. /**
  117119. * Fills the list of render target textures.
  117120. * @param renderTargets the list of render targets to update
  117121. */
  117122. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  117123. /**
  117124. * Checks to see if a texture is used in the material.
  117125. * @param texture - Base texture to use.
  117126. * @returns - Boolean specifying if a texture is used in the material.
  117127. */
  117128. hasTexture(texture: BaseTexture): boolean;
  117129. /**
  117130. * Gets a boolean indicating that current material needs to register RTT
  117131. * @returns true if this uses a render target otherwise false.
  117132. */
  117133. hasRenderTargetTextures(): boolean;
  117134. /**
  117135. * Returns an array of the actively used textures.
  117136. * @param activeTextures Array of BaseTextures
  117137. */
  117138. getActiveTextures(activeTextures: BaseTexture[]): void;
  117139. /**
  117140. * Returns the animatable textures.
  117141. * @param animatables Array of animatable textures.
  117142. */
  117143. getAnimatables(animatables: IAnimatable[]): void;
  117144. /**
  117145. * Disposes the resources of the material.
  117146. * @param forceDisposeTextures - Forces the disposal of all textures.
  117147. */
  117148. dispose(forceDisposeTextures?: boolean): void;
  117149. /**
  117150. * Get the current class name of the texture useful for serialization or dynamic coding.
  117151. * @returns "PBRSubSurfaceConfiguration"
  117152. */
  117153. getClassName(): string;
  117154. /**
  117155. * Add fallbacks to the effect fallbacks list.
  117156. * @param defines defines the Base texture to use.
  117157. * @param fallbacks defines the current fallback list.
  117158. * @param currentRank defines the current fallback rank.
  117159. * @returns the new fallback rank.
  117160. */
  117161. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117162. /**
  117163. * Add the required uniforms to the current list.
  117164. * @param uniforms defines the current uniform list.
  117165. */
  117166. static AddUniforms(uniforms: string[]): void;
  117167. /**
  117168. * Add the required samplers to the current list.
  117169. * @param samplers defines the current sampler list.
  117170. */
  117171. static AddSamplers(samplers: string[]): void;
  117172. /**
  117173. * Add the required uniforms to the current buffer.
  117174. * @param uniformBuffer defines the current uniform buffer.
  117175. */
  117176. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117177. /**
  117178. * Makes a duplicate of the current configuration into another one.
  117179. * @param configuration define the config where to copy the info
  117180. */
  117181. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  117182. /**
  117183. * Serializes this Sub Surface configuration.
  117184. * @returns - An object with the serialized config.
  117185. */
  117186. serialize(): any;
  117187. /**
  117188. * Parses a anisotropy Configuration from a serialized object.
  117189. * @param source - Serialized object.
  117190. * @param scene Defines the scene we are parsing for
  117191. * @param rootUrl Defines the rootUrl to load from
  117192. */
  117193. parse(source: any, scene: Scene, rootUrl: string): void;
  117194. }
  117195. }
  117196. declare module BABYLON {
  117197. /** @hidden */
  117198. export var pbrFragmentDeclaration: {
  117199. name: string;
  117200. shader: string;
  117201. };
  117202. }
  117203. declare module BABYLON {
  117204. /** @hidden */
  117205. export var pbrUboDeclaration: {
  117206. name: string;
  117207. shader: string;
  117208. };
  117209. }
  117210. declare module BABYLON {
  117211. /** @hidden */
  117212. export var pbrFragmentExtraDeclaration: {
  117213. name: string;
  117214. shader: string;
  117215. };
  117216. }
  117217. declare module BABYLON {
  117218. /** @hidden */
  117219. export var pbrFragmentSamplersDeclaration: {
  117220. name: string;
  117221. shader: string;
  117222. };
  117223. }
  117224. declare module BABYLON {
  117225. /** @hidden */
  117226. export var pbrHelperFunctions: {
  117227. name: string;
  117228. shader: string;
  117229. };
  117230. }
  117231. declare module BABYLON {
  117232. /** @hidden */
  117233. export var harmonicsFunctions: {
  117234. name: string;
  117235. shader: string;
  117236. };
  117237. }
  117238. declare module BABYLON {
  117239. /** @hidden */
  117240. export var pbrDirectLightingSetupFunctions: {
  117241. name: string;
  117242. shader: string;
  117243. };
  117244. }
  117245. declare module BABYLON {
  117246. /** @hidden */
  117247. export var pbrDirectLightingFalloffFunctions: {
  117248. name: string;
  117249. shader: string;
  117250. };
  117251. }
  117252. declare module BABYLON {
  117253. /** @hidden */
  117254. export var pbrBRDFFunctions: {
  117255. name: string;
  117256. shader: string;
  117257. };
  117258. }
  117259. declare module BABYLON {
  117260. /** @hidden */
  117261. export var pbrDirectLightingFunctions: {
  117262. name: string;
  117263. shader: string;
  117264. };
  117265. }
  117266. declare module BABYLON {
  117267. /** @hidden */
  117268. export var pbrIBLFunctions: {
  117269. name: string;
  117270. shader: string;
  117271. };
  117272. }
  117273. declare module BABYLON {
  117274. /** @hidden */
  117275. export var pbrDebug: {
  117276. name: string;
  117277. shader: string;
  117278. };
  117279. }
  117280. declare module BABYLON {
  117281. /** @hidden */
  117282. export var pbrPixelShader: {
  117283. name: string;
  117284. shader: string;
  117285. };
  117286. }
  117287. declare module BABYLON {
  117288. /** @hidden */
  117289. export var pbrVertexDeclaration: {
  117290. name: string;
  117291. shader: string;
  117292. };
  117293. }
  117294. declare module BABYLON {
  117295. /** @hidden */
  117296. export var pbrVertexShader: {
  117297. name: string;
  117298. shader: string;
  117299. };
  117300. }
  117301. declare module BABYLON {
  117302. /**
  117303. * Manages the defines for the PBR Material.
  117304. * @hidden
  117305. */
  117306. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  117307. PBR: boolean;
  117308. MAINUV1: boolean;
  117309. MAINUV2: boolean;
  117310. UV1: boolean;
  117311. UV2: boolean;
  117312. ALBEDO: boolean;
  117313. ALBEDODIRECTUV: number;
  117314. VERTEXCOLOR: boolean;
  117315. AMBIENT: boolean;
  117316. AMBIENTDIRECTUV: number;
  117317. AMBIENTINGRAYSCALE: boolean;
  117318. OPACITY: boolean;
  117319. VERTEXALPHA: boolean;
  117320. OPACITYDIRECTUV: number;
  117321. OPACITYRGB: boolean;
  117322. ALPHATEST: boolean;
  117323. DEPTHPREPASS: boolean;
  117324. ALPHABLEND: boolean;
  117325. ALPHAFROMALBEDO: boolean;
  117326. ALPHATESTVALUE: string;
  117327. SPECULAROVERALPHA: boolean;
  117328. RADIANCEOVERALPHA: boolean;
  117329. ALPHAFRESNEL: boolean;
  117330. LINEARALPHAFRESNEL: boolean;
  117331. PREMULTIPLYALPHA: boolean;
  117332. EMISSIVE: boolean;
  117333. EMISSIVEDIRECTUV: number;
  117334. REFLECTIVITY: boolean;
  117335. REFLECTIVITYDIRECTUV: number;
  117336. SPECULARTERM: boolean;
  117337. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  117338. MICROSURFACEAUTOMATIC: boolean;
  117339. LODBASEDMICROSFURACE: boolean;
  117340. MICROSURFACEMAP: boolean;
  117341. MICROSURFACEMAPDIRECTUV: number;
  117342. METALLICWORKFLOW: boolean;
  117343. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  117344. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  117345. METALLNESSSTOREINMETALMAPBLUE: boolean;
  117346. AOSTOREINMETALMAPRED: boolean;
  117347. METALLICF0FACTORFROMMETALLICMAP: boolean;
  117348. ENVIRONMENTBRDF: boolean;
  117349. ENVIRONMENTBRDF_RGBD: boolean;
  117350. NORMAL: boolean;
  117351. TANGENT: boolean;
  117352. BUMP: boolean;
  117353. BUMPDIRECTUV: number;
  117354. OBJECTSPACE_NORMALMAP: boolean;
  117355. PARALLAX: boolean;
  117356. PARALLAXOCCLUSION: boolean;
  117357. NORMALXYSCALE: boolean;
  117358. LIGHTMAP: boolean;
  117359. LIGHTMAPDIRECTUV: number;
  117360. USELIGHTMAPASSHADOWMAP: boolean;
  117361. GAMMALIGHTMAP: boolean;
  117362. RGBDLIGHTMAP: boolean;
  117363. REFLECTION: boolean;
  117364. REFLECTIONMAP_3D: boolean;
  117365. REFLECTIONMAP_SPHERICAL: boolean;
  117366. REFLECTIONMAP_PLANAR: boolean;
  117367. REFLECTIONMAP_CUBIC: boolean;
  117368. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  117369. REFLECTIONMAP_PROJECTION: boolean;
  117370. REFLECTIONMAP_SKYBOX: boolean;
  117371. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  117372. REFLECTIONMAP_EXPLICIT: boolean;
  117373. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  117374. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  117375. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  117376. INVERTCUBICMAP: boolean;
  117377. USESPHERICALFROMREFLECTIONMAP: boolean;
  117378. USEIRRADIANCEMAP: boolean;
  117379. SPHERICAL_HARMONICS: boolean;
  117380. USESPHERICALINVERTEX: boolean;
  117381. REFLECTIONMAP_OPPOSITEZ: boolean;
  117382. LODINREFLECTIONALPHA: boolean;
  117383. GAMMAREFLECTION: boolean;
  117384. RGBDREFLECTION: boolean;
  117385. LINEARSPECULARREFLECTION: boolean;
  117386. RADIANCEOCCLUSION: boolean;
  117387. HORIZONOCCLUSION: boolean;
  117388. INSTANCES: boolean;
  117389. NUM_BONE_INFLUENCERS: number;
  117390. BonesPerMesh: number;
  117391. BONETEXTURE: boolean;
  117392. NONUNIFORMSCALING: boolean;
  117393. MORPHTARGETS: boolean;
  117394. MORPHTARGETS_NORMAL: boolean;
  117395. MORPHTARGETS_TANGENT: boolean;
  117396. MORPHTARGETS_UV: boolean;
  117397. NUM_MORPH_INFLUENCERS: number;
  117398. IMAGEPROCESSING: boolean;
  117399. VIGNETTE: boolean;
  117400. VIGNETTEBLENDMODEMULTIPLY: boolean;
  117401. VIGNETTEBLENDMODEOPAQUE: boolean;
  117402. TONEMAPPING: boolean;
  117403. TONEMAPPING_ACES: boolean;
  117404. CONTRAST: boolean;
  117405. COLORCURVES: boolean;
  117406. COLORGRADING: boolean;
  117407. COLORGRADING3D: boolean;
  117408. SAMPLER3DGREENDEPTH: boolean;
  117409. SAMPLER3DBGRMAP: boolean;
  117410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117411. EXPOSURE: boolean;
  117412. MULTIVIEW: boolean;
  117413. USEPHYSICALLIGHTFALLOFF: boolean;
  117414. USEGLTFLIGHTFALLOFF: boolean;
  117415. TWOSIDEDLIGHTING: boolean;
  117416. SHADOWFLOAT: boolean;
  117417. CLIPPLANE: boolean;
  117418. CLIPPLANE2: boolean;
  117419. CLIPPLANE3: boolean;
  117420. CLIPPLANE4: boolean;
  117421. POINTSIZE: boolean;
  117422. FOG: boolean;
  117423. LOGARITHMICDEPTH: boolean;
  117424. FORCENORMALFORWARD: boolean;
  117425. SPECULARAA: boolean;
  117426. CLEARCOAT: boolean;
  117427. CLEARCOAT_DEFAULTIOR: boolean;
  117428. CLEARCOAT_TEXTURE: boolean;
  117429. CLEARCOAT_TEXTUREDIRECTUV: number;
  117430. CLEARCOAT_BUMP: boolean;
  117431. CLEARCOAT_BUMPDIRECTUV: number;
  117432. CLEARCOAT_TINT: boolean;
  117433. CLEARCOAT_TINT_TEXTURE: boolean;
  117434. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  117435. ANISOTROPIC: boolean;
  117436. ANISOTROPIC_TEXTURE: boolean;
  117437. ANISOTROPIC_TEXTUREDIRECTUV: number;
  117438. BRDF_V_HEIGHT_CORRELATED: boolean;
  117439. MS_BRDF_ENERGY_CONSERVATION: boolean;
  117440. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  117441. SHEEN: boolean;
  117442. SHEEN_TEXTURE: boolean;
  117443. SHEEN_TEXTUREDIRECTUV: number;
  117444. SHEEN_LINKWITHALBEDO: boolean;
  117445. SUBSURFACE: boolean;
  117446. SS_REFRACTION: boolean;
  117447. SS_TRANSLUCENCY: boolean;
  117448. SS_SCATERRING: boolean;
  117449. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117450. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117451. SS_REFRACTIONMAP_3D: boolean;
  117452. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117453. SS_LODINREFRACTIONALPHA: boolean;
  117454. SS_GAMMAREFRACTION: boolean;
  117455. SS_RGBDREFRACTION: boolean;
  117456. SS_LINEARSPECULARREFRACTION: boolean;
  117457. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117458. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117459. UNLIT: boolean;
  117460. DEBUGMODE: number;
  117461. /**
  117462. * Initializes the PBR Material defines.
  117463. */
  117464. constructor();
  117465. /**
  117466. * Resets the PBR Material defines.
  117467. */
  117468. reset(): void;
  117469. }
  117470. /**
  117471. * The Physically based material base class of BJS.
  117472. *
  117473. * This offers the main features of a standard PBR material.
  117474. * For more information, please refer to the documentation :
  117475. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117476. */
  117477. export abstract class PBRBaseMaterial extends PushMaterial {
  117478. /**
  117479. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117480. */
  117481. static readonly PBRMATERIAL_OPAQUE: number;
  117482. /**
  117483. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117484. */
  117485. static readonly PBRMATERIAL_ALPHATEST: number;
  117486. /**
  117487. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117488. */
  117489. static readonly PBRMATERIAL_ALPHABLEND: number;
  117490. /**
  117491. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117492. * They are also discarded below the alpha cutoff threshold to improve performances.
  117493. */
  117494. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117495. /**
  117496. * Defines the default value of how much AO map is occluding the analytical lights
  117497. * (point spot...).
  117498. */
  117499. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117500. /**
  117501. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  117502. */
  117503. static readonly LIGHTFALLOFF_PHYSICAL: number;
  117504. /**
  117505. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  117506. * to enhance interoperability with other engines.
  117507. */
  117508. static readonly LIGHTFALLOFF_GLTF: number;
  117509. /**
  117510. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  117511. * to enhance interoperability with other materials.
  117512. */
  117513. static readonly LIGHTFALLOFF_STANDARD: number;
  117514. /**
  117515. * Intensity of the direct lights e.g. the four lights available in your scene.
  117516. * This impacts both the direct diffuse and specular highlights.
  117517. */
  117518. protected _directIntensity: number;
  117519. /**
  117520. * Intensity of the emissive part of the material.
  117521. * This helps controlling the emissive effect without modifying the emissive color.
  117522. */
  117523. protected _emissiveIntensity: number;
  117524. /**
  117525. * Intensity of the environment e.g. how much the environment will light the object
  117526. * either through harmonics for rough material or through the refelction for shiny ones.
  117527. */
  117528. protected _environmentIntensity: number;
  117529. /**
  117530. * This is a special control allowing the reduction of the specular highlights coming from the
  117531. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117532. */
  117533. protected _specularIntensity: number;
  117534. /**
  117535. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  117536. */
  117537. private _lightingInfos;
  117538. /**
  117539. * Debug Control allowing disabling the bump map on this material.
  117540. */
  117541. protected _disableBumpMap: boolean;
  117542. /**
  117543. * AKA Diffuse Texture in standard nomenclature.
  117544. */
  117545. protected _albedoTexture: Nullable<BaseTexture>;
  117546. /**
  117547. * AKA Occlusion Texture in other nomenclature.
  117548. */
  117549. protected _ambientTexture: Nullable<BaseTexture>;
  117550. /**
  117551. * AKA Occlusion Texture Intensity in other nomenclature.
  117552. */
  117553. protected _ambientTextureStrength: number;
  117554. /**
  117555. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117556. * 1 means it completely occludes it
  117557. * 0 mean it has no impact
  117558. */
  117559. protected _ambientTextureImpactOnAnalyticalLights: number;
  117560. /**
  117561. * Stores the alpha values in a texture.
  117562. */
  117563. protected _opacityTexture: Nullable<BaseTexture>;
  117564. /**
  117565. * Stores the reflection values in a texture.
  117566. */
  117567. protected _reflectionTexture: Nullable<BaseTexture>;
  117568. /**
  117569. * Stores the emissive values in a texture.
  117570. */
  117571. protected _emissiveTexture: Nullable<BaseTexture>;
  117572. /**
  117573. * AKA Specular texture in other nomenclature.
  117574. */
  117575. protected _reflectivityTexture: Nullable<BaseTexture>;
  117576. /**
  117577. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117578. */
  117579. protected _metallicTexture: Nullable<BaseTexture>;
  117580. /**
  117581. * Specifies the metallic scalar of the metallic/roughness workflow.
  117582. * Can also be used to scale the metalness values of the metallic texture.
  117583. */
  117584. protected _metallic: Nullable<number>;
  117585. /**
  117586. * Specifies the roughness scalar of the metallic/roughness workflow.
  117587. * Can also be used to scale the roughness values of the metallic texture.
  117588. */
  117589. protected _roughness: Nullable<number>;
  117590. /**
  117591. * Specifies the an F0 factor to help configuring the material F0.
  117592. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117593. * to 0.5 the previously hard coded value stays the same.
  117594. * Can also be used to scale the F0 values of the metallic texture.
  117595. */
  117596. protected _metallicF0Factor: number;
  117597. /**
  117598. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117599. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117600. * your expectation as it multiplies with the texture data.
  117601. */
  117602. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  117603. /**
  117604. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117605. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117606. */
  117607. protected _microSurfaceTexture: Nullable<BaseTexture>;
  117608. /**
  117609. * Stores surface normal data used to displace a mesh in a texture.
  117610. */
  117611. protected _bumpTexture: Nullable<BaseTexture>;
  117612. /**
  117613. * Stores the pre-calculated light information of a mesh in a texture.
  117614. */
  117615. protected _lightmapTexture: Nullable<BaseTexture>;
  117616. /**
  117617. * The color of a material in ambient lighting.
  117618. */
  117619. protected _ambientColor: Color3;
  117620. /**
  117621. * AKA Diffuse Color in other nomenclature.
  117622. */
  117623. protected _albedoColor: Color3;
  117624. /**
  117625. * AKA Specular Color in other nomenclature.
  117626. */
  117627. protected _reflectivityColor: Color3;
  117628. /**
  117629. * The color applied when light is reflected from a material.
  117630. */
  117631. protected _reflectionColor: Color3;
  117632. /**
  117633. * The color applied when light is emitted from a material.
  117634. */
  117635. protected _emissiveColor: Color3;
  117636. /**
  117637. * AKA Glossiness in other nomenclature.
  117638. */
  117639. protected _microSurface: number;
  117640. /**
  117641. * Specifies that the material will use the light map as a show map.
  117642. */
  117643. protected _useLightmapAsShadowmap: boolean;
  117644. /**
  117645. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117646. * makes the reflect vector face the model (under horizon).
  117647. */
  117648. protected _useHorizonOcclusion: boolean;
  117649. /**
  117650. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117651. * too much the area relying on ambient texture to define their ambient occlusion.
  117652. */
  117653. protected _useRadianceOcclusion: boolean;
  117654. /**
  117655. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117656. */
  117657. protected _useAlphaFromAlbedoTexture: boolean;
  117658. /**
  117659. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  117660. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117661. */
  117662. protected _useSpecularOverAlpha: boolean;
  117663. /**
  117664. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117665. */
  117666. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117667. /**
  117668. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117669. */
  117670. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  117671. /**
  117672. * Specifies if the metallic texture contains the roughness information in its green channel.
  117673. */
  117674. protected _useRoughnessFromMetallicTextureGreen: boolean;
  117675. /**
  117676. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117677. */
  117678. protected _useMetallnessFromMetallicTextureBlue: boolean;
  117679. /**
  117680. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117681. */
  117682. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  117683. /**
  117684. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117685. */
  117686. protected _useAmbientInGrayScale: boolean;
  117687. /**
  117688. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117689. * The material will try to infer what glossiness each pixel should be.
  117690. */
  117691. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  117692. /**
  117693. * Defines the falloff type used in this material.
  117694. * It by default is Physical.
  117695. */
  117696. protected _lightFalloff: number;
  117697. /**
  117698. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117699. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117700. */
  117701. protected _useRadianceOverAlpha: boolean;
  117702. /**
  117703. * Allows using an object space normal map (instead of tangent space).
  117704. */
  117705. protected _useObjectSpaceNormalMap: boolean;
  117706. /**
  117707. * Allows using the bump map in parallax mode.
  117708. */
  117709. protected _useParallax: boolean;
  117710. /**
  117711. * Allows using the bump map in parallax occlusion mode.
  117712. */
  117713. protected _useParallaxOcclusion: boolean;
  117714. /**
  117715. * Controls the scale bias of the parallax mode.
  117716. */
  117717. protected _parallaxScaleBias: number;
  117718. /**
  117719. * If sets to true, disables all the lights affecting the material.
  117720. */
  117721. protected _disableLighting: boolean;
  117722. /**
  117723. * Number of Simultaneous lights allowed on the material.
  117724. */
  117725. protected _maxSimultaneousLights: number;
  117726. /**
  117727. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  117728. */
  117729. protected _invertNormalMapX: boolean;
  117730. /**
  117731. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  117732. */
  117733. protected _invertNormalMapY: boolean;
  117734. /**
  117735. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117736. */
  117737. protected _twoSidedLighting: boolean;
  117738. /**
  117739. * Defines the alpha limits in alpha test mode.
  117740. */
  117741. protected _alphaCutOff: number;
  117742. /**
  117743. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117744. */
  117745. protected _forceAlphaTest: boolean;
  117746. /**
  117747. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117748. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117749. */
  117750. protected _useAlphaFresnel: boolean;
  117751. /**
  117752. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117753. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117754. */
  117755. protected _useLinearAlphaFresnel: boolean;
  117756. /**
  117757. * The transparency mode of the material.
  117758. */
  117759. protected _transparencyMode: Nullable<number>;
  117760. /**
  117761. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  117762. * from cos thetav and roughness:
  117763. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  117764. */
  117765. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  117766. /**
  117767. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117768. */
  117769. protected _forceIrradianceInFragment: boolean;
  117770. /**
  117771. * Force normal to face away from face.
  117772. */
  117773. protected _forceNormalForward: boolean;
  117774. /**
  117775. * Enables specular anti aliasing in the PBR shader.
  117776. * It will both interacts on the Geometry for analytical and IBL lighting.
  117777. * It also prefilter the roughness map based on the bump values.
  117778. */
  117779. protected _enableSpecularAntiAliasing: boolean;
  117780. /**
  117781. * Default configuration related to image processing available in the PBR Material.
  117782. */
  117783. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117784. /**
  117785. * Keep track of the image processing observer to allow dispose and replace.
  117786. */
  117787. private _imageProcessingObserver;
  117788. /**
  117789. * Attaches a new image processing configuration to the PBR Material.
  117790. * @param configuration
  117791. */
  117792. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117793. /**
  117794. * Stores the available render targets.
  117795. */
  117796. private _renderTargets;
  117797. /**
  117798. * Sets the global ambient color for the material used in lighting calculations.
  117799. */
  117800. private _globalAmbientColor;
  117801. /**
  117802. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  117803. */
  117804. private _useLogarithmicDepth;
  117805. /**
  117806. * If set to true, no lighting calculations will be applied.
  117807. */
  117808. private _unlit;
  117809. private _debugMode;
  117810. /**
  117811. * @hidden
  117812. * This is reserved for the inspector.
  117813. * Defines the material debug mode.
  117814. * It helps seeing only some components of the material while troubleshooting.
  117815. */
  117816. debugMode: number;
  117817. /**
  117818. * @hidden
  117819. * This is reserved for the inspector.
  117820. * Specify from where on screen the debug mode should start.
  117821. * The value goes from -1 (full screen) to 1 (not visible)
  117822. * It helps with side by side comparison against the final render
  117823. * This defaults to -1
  117824. */
  117825. private debugLimit;
  117826. /**
  117827. * @hidden
  117828. * This is reserved for the inspector.
  117829. * As the default viewing range might not be enough (if the ambient is really small for instance)
  117830. * You can use the factor to better multiply the final value.
  117831. */
  117832. private debugFactor;
  117833. /**
  117834. * Defines the clear coat layer parameters for the material.
  117835. */
  117836. readonly clearCoat: PBRClearCoatConfiguration;
  117837. /**
  117838. * Defines the anisotropic parameters for the material.
  117839. */
  117840. readonly anisotropy: PBRAnisotropicConfiguration;
  117841. /**
  117842. * Defines the BRDF parameters for the material.
  117843. */
  117844. readonly brdf: PBRBRDFConfiguration;
  117845. /**
  117846. * Defines the Sheen parameters for the material.
  117847. */
  117848. readonly sheen: PBRSheenConfiguration;
  117849. /**
  117850. * Defines the SubSurface parameters for the material.
  117851. */
  117852. readonly subSurface: PBRSubSurfaceConfiguration;
  117853. /**
  117854. * Custom callback helping to override the default shader used in the material.
  117855. */
  117856. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  117857. protected _rebuildInParallel: boolean;
  117858. /**
  117859. * Instantiates a new PBRMaterial instance.
  117860. *
  117861. * @param name The material name
  117862. * @param scene The scene the material will be use in.
  117863. */
  117864. constructor(name: string, scene: Scene);
  117865. /**
  117866. * Gets a boolean indicating that current material needs to register RTT
  117867. */
  117868. readonly hasRenderTargetTextures: boolean;
  117869. /**
  117870. * Gets the name of the material class.
  117871. */
  117872. getClassName(): string;
  117873. /**
  117874. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117875. */
  117876. /**
  117877. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117878. */
  117879. useLogarithmicDepth: boolean;
  117880. /**
  117881. * Gets the current transparency mode.
  117882. */
  117883. /**
  117884. * Sets the transparency mode of the material.
  117885. *
  117886. * | Value | Type | Description |
  117887. * | ----- | ----------------------------------- | ----------- |
  117888. * | 0 | OPAQUE | |
  117889. * | 1 | ALPHATEST | |
  117890. * | 2 | ALPHABLEND | |
  117891. * | 3 | ALPHATESTANDBLEND | |
  117892. *
  117893. */
  117894. transparencyMode: Nullable<number>;
  117895. /**
  117896. * Returns true if alpha blending should be disabled.
  117897. */
  117898. private readonly _disableAlphaBlending;
  117899. /**
  117900. * Specifies whether or not this material should be rendered in alpha blend mode.
  117901. */
  117902. needAlphaBlending(): boolean;
  117903. /**
  117904. * Specifies if the mesh will require alpha blending.
  117905. * @param mesh - BJS mesh.
  117906. */
  117907. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  117908. /**
  117909. * Specifies whether or not this material should be rendered in alpha test mode.
  117910. */
  117911. needAlphaTesting(): boolean;
  117912. /**
  117913. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  117914. */
  117915. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  117916. /**
  117917. * Gets the texture used for the alpha test.
  117918. */
  117919. getAlphaTestTexture(): Nullable<BaseTexture>;
  117920. /**
  117921. * Specifies that the submesh is ready to be used.
  117922. * @param mesh - BJS mesh.
  117923. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  117924. * @param useInstances - Specifies that instances should be used.
  117925. * @returns - boolean indicating that the submesh is ready or not.
  117926. */
  117927. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117928. /**
  117929. * Specifies if the material uses metallic roughness workflow.
  117930. * @returns boolean specifiying if the material uses metallic roughness workflow.
  117931. */
  117932. isMetallicWorkflow(): boolean;
  117933. private _prepareEffect;
  117934. private _prepareDefines;
  117935. /**
  117936. * Force shader compilation
  117937. */
  117938. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  117939. /**
  117940. * Initializes the uniform buffer layout for the shader.
  117941. */
  117942. buildUniformLayout(): void;
  117943. /**
  117944. * Unbinds the material from the mesh
  117945. */
  117946. unbind(): void;
  117947. /**
  117948. * Binds the submesh data.
  117949. * @param world - The world matrix.
  117950. * @param mesh - The BJS mesh.
  117951. * @param subMesh - A submesh of the BJS mesh.
  117952. */
  117953. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117954. /**
  117955. * Returns the animatable textures.
  117956. * @returns - Array of animatable textures.
  117957. */
  117958. getAnimatables(): IAnimatable[];
  117959. /**
  117960. * Returns the texture used for reflections.
  117961. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  117962. */
  117963. private _getReflectionTexture;
  117964. /**
  117965. * Returns an array of the actively used textures.
  117966. * @returns - Array of BaseTextures
  117967. */
  117968. getActiveTextures(): BaseTexture[];
  117969. /**
  117970. * Checks to see if a texture is used in the material.
  117971. * @param texture - Base texture to use.
  117972. * @returns - Boolean specifying if a texture is used in the material.
  117973. */
  117974. hasTexture(texture: BaseTexture): boolean;
  117975. /**
  117976. * Disposes the resources of the material.
  117977. * @param forceDisposeEffect - Forces the disposal of effects.
  117978. * @param forceDisposeTextures - Forces the disposal of all textures.
  117979. */
  117980. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  117981. }
  117982. }
  117983. declare module BABYLON {
  117984. /**
  117985. * The Physically based material of BJS.
  117986. *
  117987. * This offers the main features of a standard PBR material.
  117988. * For more information, please refer to the documentation :
  117989. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117990. */
  117991. export class PBRMaterial extends PBRBaseMaterial {
  117992. /**
  117993. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117994. */
  117995. static readonly PBRMATERIAL_OPAQUE: number;
  117996. /**
  117997. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117998. */
  117999. static readonly PBRMATERIAL_ALPHATEST: number;
  118000. /**
  118001. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118002. */
  118003. static readonly PBRMATERIAL_ALPHABLEND: number;
  118004. /**
  118005. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118006. * They are also discarded below the alpha cutoff threshold to improve performances.
  118007. */
  118008. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  118009. /**
  118010. * Defines the default value of how much AO map is occluding the analytical lights
  118011. * (point spot...).
  118012. */
  118013. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  118014. /**
  118015. * Intensity of the direct lights e.g. the four lights available in your scene.
  118016. * This impacts both the direct diffuse and specular highlights.
  118017. */
  118018. directIntensity: number;
  118019. /**
  118020. * Intensity of the emissive part of the material.
  118021. * This helps controlling the emissive effect without modifying the emissive color.
  118022. */
  118023. emissiveIntensity: number;
  118024. /**
  118025. * Intensity of the environment e.g. how much the environment will light the object
  118026. * either through harmonics for rough material or through the refelction for shiny ones.
  118027. */
  118028. environmentIntensity: number;
  118029. /**
  118030. * This is a special control allowing the reduction of the specular highlights coming from the
  118031. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118032. */
  118033. specularIntensity: number;
  118034. /**
  118035. * Debug Control allowing disabling the bump map on this material.
  118036. */
  118037. disableBumpMap: boolean;
  118038. /**
  118039. * AKA Diffuse Texture in standard nomenclature.
  118040. */
  118041. albedoTexture: BaseTexture;
  118042. /**
  118043. * AKA Occlusion Texture in other nomenclature.
  118044. */
  118045. ambientTexture: BaseTexture;
  118046. /**
  118047. * AKA Occlusion Texture Intensity in other nomenclature.
  118048. */
  118049. ambientTextureStrength: number;
  118050. /**
  118051. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118052. * 1 means it completely occludes it
  118053. * 0 mean it has no impact
  118054. */
  118055. ambientTextureImpactOnAnalyticalLights: number;
  118056. /**
  118057. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  118058. */
  118059. opacityTexture: BaseTexture;
  118060. /**
  118061. * Stores the reflection values in a texture.
  118062. */
  118063. reflectionTexture: Nullable<BaseTexture>;
  118064. /**
  118065. * Stores the emissive values in a texture.
  118066. */
  118067. emissiveTexture: BaseTexture;
  118068. /**
  118069. * AKA Specular texture in other nomenclature.
  118070. */
  118071. reflectivityTexture: BaseTexture;
  118072. /**
  118073. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118074. */
  118075. metallicTexture: BaseTexture;
  118076. /**
  118077. * Specifies the metallic scalar of the metallic/roughness workflow.
  118078. * Can also be used to scale the metalness values of the metallic texture.
  118079. */
  118080. metallic: Nullable<number>;
  118081. /**
  118082. * Specifies the roughness scalar of the metallic/roughness workflow.
  118083. * Can also be used to scale the roughness values of the metallic texture.
  118084. */
  118085. roughness: Nullable<number>;
  118086. /**
  118087. * Specifies the an F0 factor to help configuring the material F0.
  118088. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118089. * to 0.5 the previously hard coded value stays the same.
  118090. * Can also be used to scale the F0 values of the metallic texture.
  118091. */
  118092. metallicF0Factor: number;
  118093. /**
  118094. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118095. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118096. * your expectation as it multiplies with the texture data.
  118097. */
  118098. useMetallicF0FactorFromMetallicTexture: boolean;
  118099. /**
  118100. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118101. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118102. */
  118103. microSurfaceTexture: BaseTexture;
  118104. /**
  118105. * Stores surface normal data used to displace a mesh in a texture.
  118106. */
  118107. bumpTexture: BaseTexture;
  118108. /**
  118109. * Stores the pre-calculated light information of a mesh in a texture.
  118110. */
  118111. lightmapTexture: BaseTexture;
  118112. /**
  118113. * Stores the refracted light information in a texture.
  118114. */
  118115. refractionTexture: Nullable<BaseTexture>;
  118116. /**
  118117. * The color of a material in ambient lighting.
  118118. */
  118119. ambientColor: Color3;
  118120. /**
  118121. * AKA Diffuse Color in other nomenclature.
  118122. */
  118123. albedoColor: Color3;
  118124. /**
  118125. * AKA Specular Color in other nomenclature.
  118126. */
  118127. reflectivityColor: Color3;
  118128. /**
  118129. * The color reflected from the material.
  118130. */
  118131. reflectionColor: Color3;
  118132. /**
  118133. * The color emitted from the material.
  118134. */
  118135. emissiveColor: Color3;
  118136. /**
  118137. * AKA Glossiness in other nomenclature.
  118138. */
  118139. microSurface: number;
  118140. /**
  118141. * source material index of refraction (IOR)' / 'destination material IOR.
  118142. */
  118143. indexOfRefraction: number;
  118144. /**
  118145. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  118146. */
  118147. invertRefractionY: boolean;
  118148. /**
  118149. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  118150. * Materials half opaque for instance using refraction could benefit from this control.
  118151. */
  118152. linkRefractionWithTransparency: boolean;
  118153. /**
  118154. * If true, the light map contains occlusion information instead of lighting info.
  118155. */
  118156. useLightmapAsShadowmap: boolean;
  118157. /**
  118158. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118159. */
  118160. useAlphaFromAlbedoTexture: boolean;
  118161. /**
  118162. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118163. */
  118164. forceAlphaTest: boolean;
  118165. /**
  118166. * Defines the alpha limits in alpha test mode.
  118167. */
  118168. alphaCutOff: number;
  118169. /**
  118170. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  118171. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118172. */
  118173. useSpecularOverAlpha: boolean;
  118174. /**
  118175. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118176. */
  118177. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118178. /**
  118179. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118180. */
  118181. useRoughnessFromMetallicTextureAlpha: boolean;
  118182. /**
  118183. * Specifies if the metallic texture contains the roughness information in its green channel.
  118184. */
  118185. useRoughnessFromMetallicTextureGreen: boolean;
  118186. /**
  118187. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118188. */
  118189. useMetallnessFromMetallicTextureBlue: boolean;
  118190. /**
  118191. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118192. */
  118193. useAmbientOcclusionFromMetallicTextureRed: boolean;
  118194. /**
  118195. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118196. */
  118197. useAmbientInGrayScale: boolean;
  118198. /**
  118199. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118200. * The material will try to infer what glossiness each pixel should be.
  118201. */
  118202. useAutoMicroSurfaceFromReflectivityMap: boolean;
  118203. /**
  118204. * BJS is using an harcoded light falloff based on a manually sets up range.
  118205. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118206. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118207. */
  118208. /**
  118209. * BJS is using an harcoded light falloff based on a manually sets up range.
  118210. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118211. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118212. */
  118213. usePhysicalLightFalloff: boolean;
  118214. /**
  118215. * In order to support the falloff compatibility with gltf, a special mode has been added
  118216. * to reproduce the gltf light falloff.
  118217. */
  118218. /**
  118219. * In order to support the falloff compatibility with gltf, a special mode has been added
  118220. * to reproduce the gltf light falloff.
  118221. */
  118222. useGLTFLightFalloff: boolean;
  118223. /**
  118224. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118225. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118226. */
  118227. useRadianceOverAlpha: boolean;
  118228. /**
  118229. * Allows using an object space normal map (instead of tangent space).
  118230. */
  118231. useObjectSpaceNormalMap: boolean;
  118232. /**
  118233. * Allows using the bump map in parallax mode.
  118234. */
  118235. useParallax: boolean;
  118236. /**
  118237. * Allows using the bump map in parallax occlusion mode.
  118238. */
  118239. useParallaxOcclusion: boolean;
  118240. /**
  118241. * Controls the scale bias of the parallax mode.
  118242. */
  118243. parallaxScaleBias: number;
  118244. /**
  118245. * If sets to true, disables all the lights affecting the material.
  118246. */
  118247. disableLighting: boolean;
  118248. /**
  118249. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118250. */
  118251. forceIrradianceInFragment: boolean;
  118252. /**
  118253. * Number of Simultaneous lights allowed on the material.
  118254. */
  118255. maxSimultaneousLights: number;
  118256. /**
  118257. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118258. */
  118259. invertNormalMapX: boolean;
  118260. /**
  118261. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118262. */
  118263. invertNormalMapY: boolean;
  118264. /**
  118265. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118266. */
  118267. twoSidedLighting: boolean;
  118268. /**
  118269. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118270. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  118271. */
  118272. useAlphaFresnel: boolean;
  118273. /**
  118274. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118275. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  118276. */
  118277. useLinearAlphaFresnel: boolean;
  118278. /**
  118279. * Let user defines the brdf lookup texture used for IBL.
  118280. * A default 8bit version is embedded but you could point at :
  118281. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  118282. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118283. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  118284. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118285. */
  118286. environmentBRDFTexture: Nullable<BaseTexture>;
  118287. /**
  118288. * Force normal to face away from face.
  118289. */
  118290. forceNormalForward: boolean;
  118291. /**
  118292. * Enables specular anti aliasing in the PBR shader.
  118293. * It will both interacts on the Geometry for analytical and IBL lighting.
  118294. * It also prefilter the roughness map based on the bump values.
  118295. */
  118296. enableSpecularAntiAliasing: boolean;
  118297. /**
  118298. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  118299. * makes the reflect vector face the model (under horizon).
  118300. */
  118301. useHorizonOcclusion: boolean;
  118302. /**
  118303. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  118304. * too much the area relying on ambient texture to define their ambient occlusion.
  118305. */
  118306. useRadianceOcclusion: boolean;
  118307. /**
  118308. * If set to true, no lighting calculations will be applied.
  118309. */
  118310. unlit: boolean;
  118311. /**
  118312. * Gets the image processing configuration used either in this material.
  118313. */
  118314. /**
  118315. * Sets the Default image processing configuration used either in the this material.
  118316. *
  118317. * If sets to null, the scene one is in use.
  118318. */
  118319. imageProcessingConfiguration: ImageProcessingConfiguration;
  118320. /**
  118321. * Gets wether the color curves effect is enabled.
  118322. */
  118323. /**
  118324. * Sets wether the color curves effect is enabled.
  118325. */
  118326. cameraColorCurvesEnabled: boolean;
  118327. /**
  118328. * Gets wether the color grading effect is enabled.
  118329. */
  118330. /**
  118331. * Gets wether the color grading effect is enabled.
  118332. */
  118333. cameraColorGradingEnabled: boolean;
  118334. /**
  118335. * Gets wether tonemapping is enabled or not.
  118336. */
  118337. /**
  118338. * Sets wether tonemapping is enabled or not
  118339. */
  118340. cameraToneMappingEnabled: boolean;
  118341. /**
  118342. * The camera exposure used on this material.
  118343. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118344. * This corresponds to a photographic exposure.
  118345. */
  118346. /**
  118347. * The camera exposure used on this material.
  118348. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118349. * This corresponds to a photographic exposure.
  118350. */
  118351. cameraExposure: number;
  118352. /**
  118353. * Gets The camera contrast used on this material.
  118354. */
  118355. /**
  118356. * Sets The camera contrast used on this material.
  118357. */
  118358. cameraContrast: number;
  118359. /**
  118360. * Gets the Color Grading 2D Lookup Texture.
  118361. */
  118362. /**
  118363. * Sets the Color Grading 2D Lookup Texture.
  118364. */
  118365. cameraColorGradingTexture: Nullable<BaseTexture>;
  118366. /**
  118367. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118368. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118369. * 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;
  118370. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118371. */
  118372. /**
  118373. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118374. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118375. * 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;
  118376. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118377. */
  118378. cameraColorCurves: Nullable<ColorCurves>;
  118379. /**
  118380. * Instantiates a new PBRMaterial instance.
  118381. *
  118382. * @param name The material name
  118383. * @param scene The scene the material will be use in.
  118384. */
  118385. constructor(name: string, scene: Scene);
  118386. /**
  118387. * Returns the name of this material class.
  118388. */
  118389. getClassName(): string;
  118390. /**
  118391. * Makes a duplicate of the current material.
  118392. * @param name - name to use for the new material.
  118393. */
  118394. clone(name: string): PBRMaterial;
  118395. /**
  118396. * Serializes this PBR Material.
  118397. * @returns - An object with the serialized material.
  118398. */
  118399. serialize(): any;
  118400. /**
  118401. * Parses a PBR Material from a serialized object.
  118402. * @param source - Serialized object.
  118403. * @param scene - BJS scene instance.
  118404. * @param rootUrl - url for the scene object
  118405. * @returns - PBRMaterial
  118406. */
  118407. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  118408. }
  118409. }
  118410. declare module BABYLON {
  118411. /**
  118412. * Direct draw surface info
  118413. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  118414. */
  118415. export interface DDSInfo {
  118416. /**
  118417. * Width of the texture
  118418. */
  118419. width: number;
  118420. /**
  118421. * Width of the texture
  118422. */
  118423. height: number;
  118424. /**
  118425. * Number of Mipmaps for the texture
  118426. * @see https://en.wikipedia.org/wiki/Mipmap
  118427. */
  118428. mipmapCount: number;
  118429. /**
  118430. * If the textures format is a known fourCC format
  118431. * @see https://www.fourcc.org/
  118432. */
  118433. isFourCC: boolean;
  118434. /**
  118435. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  118436. */
  118437. isRGB: boolean;
  118438. /**
  118439. * If the texture is a lumincance format
  118440. */
  118441. isLuminance: boolean;
  118442. /**
  118443. * If this is a cube texture
  118444. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  118445. */
  118446. isCube: boolean;
  118447. /**
  118448. * If the texture is a compressed format eg. FOURCC_DXT1
  118449. */
  118450. isCompressed: boolean;
  118451. /**
  118452. * The dxgiFormat of the texture
  118453. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  118454. */
  118455. dxgiFormat: number;
  118456. /**
  118457. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  118458. */
  118459. textureType: number;
  118460. /**
  118461. * Sphericle polynomial created for the dds texture
  118462. */
  118463. sphericalPolynomial?: SphericalPolynomial;
  118464. }
  118465. /**
  118466. * Class used to provide DDS decompression tools
  118467. */
  118468. export class DDSTools {
  118469. /**
  118470. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  118471. */
  118472. static StoreLODInAlphaChannel: boolean;
  118473. /**
  118474. * Gets DDS information from an array buffer
  118475. * @param arrayBuffer defines the array buffer to read data from
  118476. * @returns the DDS information
  118477. */
  118478. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  118479. private static _FloatView;
  118480. private static _Int32View;
  118481. private static _ToHalfFloat;
  118482. private static _FromHalfFloat;
  118483. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  118484. private static _GetHalfFloatRGBAArrayBuffer;
  118485. private static _GetFloatRGBAArrayBuffer;
  118486. private static _GetFloatAsUIntRGBAArrayBuffer;
  118487. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  118488. private static _GetRGBAArrayBuffer;
  118489. private static _ExtractLongWordOrder;
  118490. private static _GetRGBArrayBuffer;
  118491. private static _GetLuminanceArrayBuffer;
  118492. /**
  118493. * Uploads DDS Levels to a Babylon Texture
  118494. * @hidden
  118495. */
  118496. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  118497. }
  118498. interface ThinEngine {
  118499. /**
  118500. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  118501. * @param rootUrl defines the url where the file to load is located
  118502. * @param scene defines the current scene
  118503. * @param lodScale defines scale to apply to the mip map selection
  118504. * @param lodOffset defines offset to apply to the mip map selection
  118505. * @param onLoad defines an optional callback raised when the texture is loaded
  118506. * @param onError defines an optional callback raised if there is an issue to load the texture
  118507. * @param format defines the format of the data
  118508. * @param forcedExtension defines the extension to use to pick the right loader
  118509. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  118510. * @returns the cube texture as an InternalTexture
  118511. */
  118512. 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;
  118513. }
  118514. }
  118515. declare module BABYLON {
  118516. /**
  118517. * Implementation of the DDS Texture Loader.
  118518. * @hidden
  118519. */
  118520. export class _DDSTextureLoader implements IInternalTextureLoader {
  118521. /**
  118522. * Defines wether the loader supports cascade loading the different faces.
  118523. */
  118524. readonly supportCascades: boolean;
  118525. /**
  118526. * This returns if the loader support the current file information.
  118527. * @param extension defines the file extension of the file being loaded
  118528. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118529. * @param fallback defines the fallback internal texture if any
  118530. * @param isBase64 defines whether the texture is encoded as a base64
  118531. * @param isBuffer defines whether the texture data are stored as a buffer
  118532. * @returns true if the loader can load the specified file
  118533. */
  118534. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118535. /**
  118536. * Transform the url before loading if required.
  118537. * @param rootUrl the url of the texture
  118538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118539. * @returns the transformed texture
  118540. */
  118541. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118542. /**
  118543. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118544. * @param rootUrl the url of the texture
  118545. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118546. * @returns the fallback texture
  118547. */
  118548. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118549. /**
  118550. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118551. * @param data contains the texture data
  118552. * @param texture defines the BabylonJS internal texture
  118553. * @param createPolynomials will be true if polynomials have been requested
  118554. * @param onLoad defines the callback to trigger once the texture is ready
  118555. * @param onError defines the callback to trigger in case of error
  118556. */
  118557. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118558. /**
  118559. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118560. * @param data contains the texture data
  118561. * @param texture defines the BabylonJS internal texture
  118562. * @param callback defines the method to call once ready to upload
  118563. */
  118564. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118565. }
  118566. }
  118567. declare module BABYLON {
  118568. /**
  118569. * Implementation of the ENV Texture Loader.
  118570. * @hidden
  118571. */
  118572. export class _ENVTextureLoader implements IInternalTextureLoader {
  118573. /**
  118574. * Defines wether the loader supports cascade loading the different faces.
  118575. */
  118576. readonly supportCascades: boolean;
  118577. /**
  118578. * This returns if the loader support the current file information.
  118579. * @param extension defines the file extension of the file being loaded
  118580. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118581. * @param fallback defines the fallback internal texture if any
  118582. * @param isBase64 defines whether the texture is encoded as a base64
  118583. * @param isBuffer defines whether the texture data are stored as a buffer
  118584. * @returns true if the loader can load the specified file
  118585. */
  118586. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118587. /**
  118588. * Transform the url before loading if required.
  118589. * @param rootUrl the url of the texture
  118590. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118591. * @returns the transformed texture
  118592. */
  118593. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118594. /**
  118595. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118596. * @param rootUrl the url of the texture
  118597. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118598. * @returns the fallback texture
  118599. */
  118600. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118601. /**
  118602. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118603. * @param data contains the texture data
  118604. * @param texture defines the BabylonJS internal texture
  118605. * @param createPolynomials will be true if polynomials have been requested
  118606. * @param onLoad defines the callback to trigger once the texture is ready
  118607. * @param onError defines the callback to trigger in case of error
  118608. */
  118609. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118610. /**
  118611. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118612. * @param data contains the texture data
  118613. * @param texture defines the BabylonJS internal texture
  118614. * @param callback defines the method to call once ready to upload
  118615. */
  118616. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118617. }
  118618. }
  118619. declare module BABYLON {
  118620. /**
  118621. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  118622. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  118623. */
  118624. export class KhronosTextureContainer {
  118625. /** contents of the KTX container file */
  118626. arrayBuffer: any;
  118627. private static HEADER_LEN;
  118628. private static COMPRESSED_2D;
  118629. private static COMPRESSED_3D;
  118630. private static TEX_2D;
  118631. private static TEX_3D;
  118632. /**
  118633. * Gets the openGL type
  118634. */
  118635. glType: number;
  118636. /**
  118637. * Gets the openGL type size
  118638. */
  118639. glTypeSize: number;
  118640. /**
  118641. * Gets the openGL format
  118642. */
  118643. glFormat: number;
  118644. /**
  118645. * Gets the openGL internal format
  118646. */
  118647. glInternalFormat: number;
  118648. /**
  118649. * Gets the base internal format
  118650. */
  118651. glBaseInternalFormat: number;
  118652. /**
  118653. * Gets image width in pixel
  118654. */
  118655. pixelWidth: number;
  118656. /**
  118657. * Gets image height in pixel
  118658. */
  118659. pixelHeight: number;
  118660. /**
  118661. * Gets image depth in pixels
  118662. */
  118663. pixelDepth: number;
  118664. /**
  118665. * Gets the number of array elements
  118666. */
  118667. numberOfArrayElements: number;
  118668. /**
  118669. * Gets the number of faces
  118670. */
  118671. numberOfFaces: number;
  118672. /**
  118673. * Gets the number of mipmap levels
  118674. */
  118675. numberOfMipmapLevels: number;
  118676. /**
  118677. * Gets the bytes of key value data
  118678. */
  118679. bytesOfKeyValueData: number;
  118680. /**
  118681. * Gets the load type
  118682. */
  118683. loadType: number;
  118684. /**
  118685. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  118686. */
  118687. isInvalid: boolean;
  118688. /**
  118689. * Creates a new KhronosTextureContainer
  118690. * @param arrayBuffer contents of the KTX container file
  118691. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  118692. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  118693. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  118694. */
  118695. constructor(
  118696. /** contents of the KTX container file */
  118697. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  118698. /**
  118699. * Uploads KTX content to a Babylon Texture.
  118700. * It is assumed that the texture has already been created & is currently bound
  118701. * @hidden
  118702. */
  118703. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  118704. private _upload2DCompressedLevels;
  118705. }
  118706. }
  118707. declare module BABYLON {
  118708. /**
  118709. * Implementation of the KTX Texture Loader.
  118710. * @hidden
  118711. */
  118712. export class _KTXTextureLoader implements IInternalTextureLoader {
  118713. /**
  118714. * Defines wether the loader supports cascade loading the different faces.
  118715. */
  118716. readonly supportCascades: boolean;
  118717. /**
  118718. * This returns if the loader support the current file information.
  118719. * @param extension defines the file extension of the file being loaded
  118720. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118721. * @param fallback defines the fallback internal texture if any
  118722. * @param isBase64 defines whether the texture is encoded as a base64
  118723. * @param isBuffer defines whether the texture data are stored as a buffer
  118724. * @returns true if the loader can load the specified file
  118725. */
  118726. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118727. /**
  118728. * Transform the url before loading if required.
  118729. * @param rootUrl the url of the texture
  118730. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118731. * @returns the transformed texture
  118732. */
  118733. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118734. /**
  118735. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118736. * @param rootUrl the url of the texture
  118737. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118738. * @returns the fallback texture
  118739. */
  118740. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118741. /**
  118742. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118743. * @param data contains the texture data
  118744. * @param texture defines the BabylonJS internal texture
  118745. * @param createPolynomials will be true if polynomials have been requested
  118746. * @param onLoad defines the callback to trigger once the texture is ready
  118747. * @param onError defines the callback to trigger in case of error
  118748. */
  118749. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118750. /**
  118751. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118752. * @param data contains the texture data
  118753. * @param texture defines the BabylonJS internal texture
  118754. * @param callback defines the method to call once ready to upload
  118755. */
  118756. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  118757. }
  118758. }
  118759. declare module BABYLON {
  118760. /** @hidden */
  118761. export var _forceSceneHelpersToBundle: boolean;
  118762. interface Scene {
  118763. /**
  118764. * Creates a default light for the scene.
  118765. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  118766. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  118767. */
  118768. createDefaultLight(replace?: boolean): void;
  118769. /**
  118770. * Creates a default camera for the scene.
  118771. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  118772. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118773. * @param replace has default false, when true replaces the active camera in the scene
  118774. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  118775. */
  118776. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118777. /**
  118778. * Creates a default camera and a default light.
  118779. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  118780. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118781. * @param replace has the default false, when true replaces the active camera/light in the scene
  118782. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  118783. */
  118784. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118785. /**
  118786. * Creates a new sky box
  118787. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  118788. * @param environmentTexture defines the texture to use as environment texture
  118789. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  118790. * @param scale defines the overall scale of the skybox
  118791. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  118792. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  118793. * @returns a new mesh holding the sky box
  118794. */
  118795. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  118796. /**
  118797. * Creates a new environment
  118798. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  118799. * @param options defines the options you can use to configure the environment
  118800. * @returns the new EnvironmentHelper
  118801. */
  118802. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  118803. /**
  118804. * Creates a new VREXperienceHelper
  118805. * @see http://doc.babylonjs.com/how_to/webvr_helper
  118806. * @param webVROptions defines the options used to create the new VREXperienceHelper
  118807. * @returns a new VREXperienceHelper
  118808. */
  118809. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  118810. /**
  118811. * Creates a new WebXRDefaultExperience
  118812. * @see http://doc.babylonjs.com/how_to/webxr
  118813. * @param options experience options
  118814. * @returns a promise for a new WebXRDefaultExperience
  118815. */
  118816. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118817. }
  118818. }
  118819. declare module BABYLON {
  118820. /**
  118821. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  118822. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  118823. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  118824. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  118825. */
  118826. export class VideoDome extends TransformNode {
  118827. /**
  118828. * Define the video source as a Monoscopic panoramic 360 video.
  118829. */
  118830. static readonly MODE_MONOSCOPIC: number;
  118831. /**
  118832. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118833. */
  118834. static readonly MODE_TOPBOTTOM: number;
  118835. /**
  118836. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118837. */
  118838. static readonly MODE_SIDEBYSIDE: number;
  118839. private _halfDome;
  118840. private _useDirectMapping;
  118841. /**
  118842. * The video texture being displayed on the sphere
  118843. */
  118844. protected _videoTexture: VideoTexture;
  118845. /**
  118846. * Gets the video texture being displayed on the sphere
  118847. */
  118848. readonly videoTexture: VideoTexture;
  118849. /**
  118850. * The skybox material
  118851. */
  118852. protected _material: BackgroundMaterial;
  118853. /**
  118854. * The surface used for the skybox
  118855. */
  118856. protected _mesh: Mesh;
  118857. /**
  118858. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  118859. */
  118860. private _halfDomeMask;
  118861. /**
  118862. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118863. * Also see the options.resolution property.
  118864. */
  118865. fovMultiplier: number;
  118866. private _videoMode;
  118867. /**
  118868. * Gets or set the current video mode for the video. It can be:
  118869. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  118870. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118871. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118872. */
  118873. videoMode: number;
  118874. /**
  118875. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  118876. *
  118877. */
  118878. /**
  118879. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  118880. */
  118881. halfDome: boolean;
  118882. /**
  118883. * Oberserver used in Stereoscopic VR Mode.
  118884. */
  118885. private _onBeforeCameraRenderObserver;
  118886. /**
  118887. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  118888. * @param name Element's name, child elements will append suffixes for their own names.
  118889. * @param urlsOrVideo defines the url(s) or the video element to use
  118890. * @param options An object containing optional or exposed sub element properties
  118891. */
  118892. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  118893. resolution?: number;
  118894. clickToPlay?: boolean;
  118895. autoPlay?: boolean;
  118896. loop?: boolean;
  118897. size?: number;
  118898. poster?: string;
  118899. faceForward?: boolean;
  118900. useDirectMapping?: boolean;
  118901. halfDomeMode?: boolean;
  118902. }, scene: Scene);
  118903. private _changeVideoMode;
  118904. /**
  118905. * Releases resources associated with this node.
  118906. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118907. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118908. */
  118909. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118910. }
  118911. }
  118912. declare module BABYLON {
  118913. /**
  118914. * This class can be used to get instrumentation data from a Babylon engine
  118915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118916. */
  118917. export class EngineInstrumentation implements IDisposable {
  118918. /**
  118919. * Define the instrumented engine.
  118920. */
  118921. engine: Engine;
  118922. private _captureGPUFrameTime;
  118923. private _gpuFrameTimeToken;
  118924. private _gpuFrameTime;
  118925. private _captureShaderCompilationTime;
  118926. private _shaderCompilationTime;
  118927. private _onBeginFrameObserver;
  118928. private _onEndFrameObserver;
  118929. private _onBeforeShaderCompilationObserver;
  118930. private _onAfterShaderCompilationObserver;
  118931. /**
  118932. * Gets the perf counter used for GPU frame time
  118933. */
  118934. readonly gpuFrameTimeCounter: PerfCounter;
  118935. /**
  118936. * Gets the GPU frame time capture status
  118937. */
  118938. /**
  118939. * Enable or disable the GPU frame time capture
  118940. */
  118941. captureGPUFrameTime: boolean;
  118942. /**
  118943. * Gets the perf counter used for shader compilation time
  118944. */
  118945. readonly shaderCompilationTimeCounter: PerfCounter;
  118946. /**
  118947. * Gets the shader compilation time capture status
  118948. */
  118949. /**
  118950. * Enable or disable the shader compilation time capture
  118951. */
  118952. captureShaderCompilationTime: boolean;
  118953. /**
  118954. * Instantiates a new engine instrumentation.
  118955. * This class can be used to get instrumentation data from a Babylon engine
  118956. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118957. * @param engine Defines the engine to instrument
  118958. */
  118959. constructor(
  118960. /**
  118961. * Define the instrumented engine.
  118962. */
  118963. engine: Engine);
  118964. /**
  118965. * Dispose and release associated resources.
  118966. */
  118967. dispose(): void;
  118968. }
  118969. }
  118970. declare module BABYLON {
  118971. /**
  118972. * This class can be used to get instrumentation data from a Babylon engine
  118973. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118974. */
  118975. export class SceneInstrumentation implements IDisposable {
  118976. /**
  118977. * Defines the scene to instrument
  118978. */
  118979. scene: Scene;
  118980. private _captureActiveMeshesEvaluationTime;
  118981. private _activeMeshesEvaluationTime;
  118982. private _captureRenderTargetsRenderTime;
  118983. private _renderTargetsRenderTime;
  118984. private _captureFrameTime;
  118985. private _frameTime;
  118986. private _captureRenderTime;
  118987. private _renderTime;
  118988. private _captureInterFrameTime;
  118989. private _interFrameTime;
  118990. private _captureParticlesRenderTime;
  118991. private _particlesRenderTime;
  118992. private _captureSpritesRenderTime;
  118993. private _spritesRenderTime;
  118994. private _capturePhysicsTime;
  118995. private _physicsTime;
  118996. private _captureAnimationsTime;
  118997. private _animationsTime;
  118998. private _captureCameraRenderTime;
  118999. private _cameraRenderTime;
  119000. private _onBeforeActiveMeshesEvaluationObserver;
  119001. private _onAfterActiveMeshesEvaluationObserver;
  119002. private _onBeforeRenderTargetsRenderObserver;
  119003. private _onAfterRenderTargetsRenderObserver;
  119004. private _onAfterRenderObserver;
  119005. private _onBeforeDrawPhaseObserver;
  119006. private _onAfterDrawPhaseObserver;
  119007. private _onBeforeAnimationsObserver;
  119008. private _onBeforeParticlesRenderingObserver;
  119009. private _onAfterParticlesRenderingObserver;
  119010. private _onBeforeSpritesRenderingObserver;
  119011. private _onAfterSpritesRenderingObserver;
  119012. private _onBeforePhysicsObserver;
  119013. private _onAfterPhysicsObserver;
  119014. private _onAfterAnimationsObserver;
  119015. private _onBeforeCameraRenderObserver;
  119016. private _onAfterCameraRenderObserver;
  119017. /**
  119018. * Gets the perf counter used for active meshes evaluation time
  119019. */
  119020. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  119021. /**
  119022. * Gets the active meshes evaluation time capture status
  119023. */
  119024. /**
  119025. * Enable or disable the active meshes evaluation time capture
  119026. */
  119027. captureActiveMeshesEvaluationTime: boolean;
  119028. /**
  119029. * Gets the perf counter used for render targets render time
  119030. */
  119031. readonly renderTargetsRenderTimeCounter: PerfCounter;
  119032. /**
  119033. * Gets the render targets render time capture status
  119034. */
  119035. /**
  119036. * Enable or disable the render targets render time capture
  119037. */
  119038. captureRenderTargetsRenderTime: boolean;
  119039. /**
  119040. * Gets the perf counter used for particles render time
  119041. */
  119042. readonly particlesRenderTimeCounter: PerfCounter;
  119043. /**
  119044. * Gets the particles render time capture status
  119045. */
  119046. /**
  119047. * Enable or disable the particles render time capture
  119048. */
  119049. captureParticlesRenderTime: boolean;
  119050. /**
  119051. * Gets the perf counter used for sprites render time
  119052. */
  119053. readonly spritesRenderTimeCounter: PerfCounter;
  119054. /**
  119055. * Gets the sprites render time capture status
  119056. */
  119057. /**
  119058. * Enable or disable the sprites render time capture
  119059. */
  119060. captureSpritesRenderTime: boolean;
  119061. /**
  119062. * Gets the perf counter used for physics time
  119063. */
  119064. readonly physicsTimeCounter: PerfCounter;
  119065. /**
  119066. * Gets the physics time capture status
  119067. */
  119068. /**
  119069. * Enable or disable the physics time capture
  119070. */
  119071. capturePhysicsTime: boolean;
  119072. /**
  119073. * Gets the perf counter used for animations time
  119074. */
  119075. readonly animationsTimeCounter: PerfCounter;
  119076. /**
  119077. * Gets the animations time capture status
  119078. */
  119079. /**
  119080. * Enable or disable the animations time capture
  119081. */
  119082. captureAnimationsTime: boolean;
  119083. /**
  119084. * Gets the perf counter used for frame time capture
  119085. */
  119086. readonly frameTimeCounter: PerfCounter;
  119087. /**
  119088. * Gets the frame time capture status
  119089. */
  119090. /**
  119091. * Enable or disable the frame time capture
  119092. */
  119093. captureFrameTime: boolean;
  119094. /**
  119095. * Gets the perf counter used for inter-frames time capture
  119096. */
  119097. readonly interFrameTimeCounter: PerfCounter;
  119098. /**
  119099. * Gets the inter-frames time capture status
  119100. */
  119101. /**
  119102. * Enable or disable the inter-frames time capture
  119103. */
  119104. captureInterFrameTime: boolean;
  119105. /**
  119106. * Gets the perf counter used for render time capture
  119107. */
  119108. readonly renderTimeCounter: PerfCounter;
  119109. /**
  119110. * Gets the render time capture status
  119111. */
  119112. /**
  119113. * Enable or disable the render time capture
  119114. */
  119115. captureRenderTime: boolean;
  119116. /**
  119117. * Gets the perf counter used for camera render time capture
  119118. */
  119119. readonly cameraRenderTimeCounter: PerfCounter;
  119120. /**
  119121. * Gets the camera render time capture status
  119122. */
  119123. /**
  119124. * Enable or disable the camera render time capture
  119125. */
  119126. captureCameraRenderTime: boolean;
  119127. /**
  119128. * Gets the perf counter used for draw calls
  119129. */
  119130. readonly drawCallsCounter: PerfCounter;
  119131. /**
  119132. * Instantiates a new scene instrumentation.
  119133. * This class can be used to get instrumentation data from a Babylon engine
  119134. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119135. * @param scene Defines the scene to instrument
  119136. */
  119137. constructor(
  119138. /**
  119139. * Defines the scene to instrument
  119140. */
  119141. scene: Scene);
  119142. /**
  119143. * Dispose and release associated resources.
  119144. */
  119145. dispose(): void;
  119146. }
  119147. }
  119148. declare module BABYLON {
  119149. /** @hidden */
  119150. export var glowMapGenerationPixelShader: {
  119151. name: string;
  119152. shader: string;
  119153. };
  119154. }
  119155. declare module BABYLON {
  119156. /** @hidden */
  119157. export var glowMapGenerationVertexShader: {
  119158. name: string;
  119159. shader: string;
  119160. };
  119161. }
  119162. declare module BABYLON {
  119163. /**
  119164. * Effect layer options. This helps customizing the behaviour
  119165. * of the effect layer.
  119166. */
  119167. export interface IEffectLayerOptions {
  119168. /**
  119169. * Multiplication factor apply to the canvas size to compute the render target size
  119170. * used to generated the objects (the smaller the faster).
  119171. */
  119172. mainTextureRatio: number;
  119173. /**
  119174. * Enforces a fixed size texture to ensure effect stability across devices.
  119175. */
  119176. mainTextureFixedSize?: number;
  119177. /**
  119178. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  119179. */
  119180. alphaBlendingMode: number;
  119181. /**
  119182. * The camera attached to the layer.
  119183. */
  119184. camera: Nullable<Camera>;
  119185. /**
  119186. * The rendering group to draw the layer in.
  119187. */
  119188. renderingGroupId: number;
  119189. }
  119190. /**
  119191. * The effect layer Helps adding post process effect blended with the main pass.
  119192. *
  119193. * This can be for instance use to generate glow or higlight effects on the scene.
  119194. *
  119195. * The effect layer class can not be used directly and is intented to inherited from to be
  119196. * customized per effects.
  119197. */
  119198. export abstract class EffectLayer {
  119199. private _vertexBuffers;
  119200. private _indexBuffer;
  119201. private _cachedDefines;
  119202. private _effectLayerMapGenerationEffect;
  119203. private _effectLayerOptions;
  119204. private _mergeEffect;
  119205. protected _scene: Scene;
  119206. protected _engine: Engine;
  119207. protected _maxSize: number;
  119208. protected _mainTextureDesiredSize: ISize;
  119209. protected _mainTexture: RenderTargetTexture;
  119210. protected _shouldRender: boolean;
  119211. protected _postProcesses: PostProcess[];
  119212. protected _textures: BaseTexture[];
  119213. protected _emissiveTextureAndColor: {
  119214. texture: Nullable<BaseTexture>;
  119215. color: Color4;
  119216. };
  119217. /**
  119218. * The name of the layer
  119219. */
  119220. name: string;
  119221. /**
  119222. * The clear color of the texture used to generate the glow map.
  119223. */
  119224. neutralColor: Color4;
  119225. /**
  119226. * Specifies wether the highlight layer is enabled or not.
  119227. */
  119228. isEnabled: boolean;
  119229. /**
  119230. * Gets the camera attached to the layer.
  119231. */
  119232. readonly camera: Nullable<Camera>;
  119233. /**
  119234. * Gets the rendering group id the layer should render in.
  119235. */
  119236. renderingGroupId: number;
  119237. /**
  119238. * An event triggered when the effect layer has been disposed.
  119239. */
  119240. onDisposeObservable: Observable<EffectLayer>;
  119241. /**
  119242. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  119243. */
  119244. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  119245. /**
  119246. * An event triggered when the generated texture is being merged in the scene.
  119247. */
  119248. onBeforeComposeObservable: Observable<EffectLayer>;
  119249. /**
  119250. * An event triggered when the mesh is rendered into the effect render target.
  119251. */
  119252. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  119253. /**
  119254. * An event triggered after the mesh has been rendered into the effect render target.
  119255. */
  119256. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  119257. /**
  119258. * An event triggered when the generated texture has been merged in the scene.
  119259. */
  119260. onAfterComposeObservable: Observable<EffectLayer>;
  119261. /**
  119262. * An event triggered when the efffect layer changes its size.
  119263. */
  119264. onSizeChangedObservable: Observable<EffectLayer>;
  119265. /** @hidden */
  119266. static _SceneComponentInitialization: (scene: Scene) => void;
  119267. /**
  119268. * Instantiates a new effect Layer and references it in the scene.
  119269. * @param name The name of the layer
  119270. * @param scene The scene to use the layer in
  119271. */
  119272. constructor(
  119273. /** The Friendly of the effect in the scene */
  119274. name: string, scene: Scene);
  119275. /**
  119276. * Get the effect name of the layer.
  119277. * @return The effect name
  119278. */
  119279. abstract getEffectName(): string;
  119280. /**
  119281. * Checks for the readiness of the element composing the layer.
  119282. * @param subMesh the mesh to check for
  119283. * @param useInstances specify wether or not to use instances to render the mesh
  119284. * @return true if ready otherwise, false
  119285. */
  119286. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119287. /**
  119288. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119289. * @returns true if the effect requires stencil during the main canvas render pass.
  119290. */
  119291. abstract needStencil(): boolean;
  119292. /**
  119293. * Create the merge effect. This is the shader use to blit the information back
  119294. * to the main canvas at the end of the scene rendering.
  119295. * @returns The effect containing the shader used to merge the effect on the main canvas
  119296. */
  119297. protected abstract _createMergeEffect(): Effect;
  119298. /**
  119299. * Creates the render target textures and post processes used in the effect layer.
  119300. */
  119301. protected abstract _createTextureAndPostProcesses(): void;
  119302. /**
  119303. * Implementation specific of rendering the generating effect on the main canvas.
  119304. * @param effect The effect used to render through
  119305. */
  119306. protected abstract _internalRender(effect: Effect): void;
  119307. /**
  119308. * Sets the required values for both the emissive texture and and the main color.
  119309. */
  119310. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119311. /**
  119312. * Free any resources and references associated to a mesh.
  119313. * Internal use
  119314. * @param mesh The mesh to free.
  119315. */
  119316. abstract _disposeMesh(mesh: Mesh): void;
  119317. /**
  119318. * Serializes this layer (Glow or Highlight for example)
  119319. * @returns a serialized layer object
  119320. */
  119321. abstract serialize?(): any;
  119322. /**
  119323. * Initializes the effect layer with the required options.
  119324. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  119325. */
  119326. protected _init(options: Partial<IEffectLayerOptions>): void;
  119327. /**
  119328. * Generates the index buffer of the full screen quad blending to the main canvas.
  119329. */
  119330. private _generateIndexBuffer;
  119331. /**
  119332. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  119333. */
  119334. private _generateVertexBuffer;
  119335. /**
  119336. * Sets the main texture desired size which is the closest power of two
  119337. * of the engine canvas size.
  119338. */
  119339. private _setMainTextureSize;
  119340. /**
  119341. * Creates the main texture for the effect layer.
  119342. */
  119343. protected _createMainTexture(): void;
  119344. /**
  119345. * Adds specific effects defines.
  119346. * @param defines The defines to add specifics to.
  119347. */
  119348. protected _addCustomEffectDefines(defines: string[]): void;
  119349. /**
  119350. * Checks for the readiness of the element composing the layer.
  119351. * @param subMesh the mesh to check for
  119352. * @param useInstances specify wether or not to use instances to render the mesh
  119353. * @param emissiveTexture the associated emissive texture used to generate the glow
  119354. * @return true if ready otherwise, false
  119355. */
  119356. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  119357. /**
  119358. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  119359. */
  119360. render(): void;
  119361. /**
  119362. * Determine if a given mesh will be used in the current effect.
  119363. * @param mesh mesh to test
  119364. * @returns true if the mesh will be used
  119365. */
  119366. hasMesh(mesh: AbstractMesh): boolean;
  119367. /**
  119368. * Returns true if the layer contains information to display, otherwise false.
  119369. * @returns true if the glow layer should be rendered
  119370. */
  119371. shouldRender(): boolean;
  119372. /**
  119373. * Returns true if the mesh should render, otherwise false.
  119374. * @param mesh The mesh to render
  119375. * @returns true if it should render otherwise false
  119376. */
  119377. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  119378. /**
  119379. * Returns true if the mesh can be rendered, otherwise false.
  119380. * @param mesh The mesh to render
  119381. * @param material The material used on the mesh
  119382. * @returns true if it can be rendered otherwise false
  119383. */
  119384. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119385. /**
  119386. * Returns true if the mesh should render, otherwise false.
  119387. * @param mesh The mesh to render
  119388. * @returns true if it should render otherwise false
  119389. */
  119390. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  119391. /**
  119392. * Renders the submesh passed in parameter to the generation map.
  119393. */
  119394. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  119395. /**
  119396. * Defines wether the current material of the mesh should be use to render the effect.
  119397. * @param mesh defines the current mesh to render
  119398. */
  119399. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119400. /**
  119401. * Rebuild the required buffers.
  119402. * @hidden Internal use only.
  119403. */
  119404. _rebuild(): void;
  119405. /**
  119406. * Dispose only the render target textures and post process.
  119407. */
  119408. private _disposeTextureAndPostProcesses;
  119409. /**
  119410. * Dispose the highlight layer and free resources.
  119411. */
  119412. dispose(): void;
  119413. /**
  119414. * Gets the class name of the effect layer
  119415. * @returns the string with the class name of the effect layer
  119416. */
  119417. getClassName(): string;
  119418. /**
  119419. * Creates an effect layer from parsed effect layer data
  119420. * @param parsedEffectLayer defines effect layer data
  119421. * @param scene defines the current scene
  119422. * @param rootUrl defines the root URL containing the effect layer information
  119423. * @returns a parsed effect Layer
  119424. */
  119425. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  119426. }
  119427. }
  119428. declare module BABYLON {
  119429. interface AbstractScene {
  119430. /**
  119431. * The list of effect layers (highlights/glow) added to the scene
  119432. * @see http://doc.babylonjs.com/how_to/highlight_layer
  119433. * @see http://doc.babylonjs.com/how_to/glow_layer
  119434. */
  119435. effectLayers: Array<EffectLayer>;
  119436. /**
  119437. * Removes the given effect layer from this scene.
  119438. * @param toRemove defines the effect layer to remove
  119439. * @returns the index of the removed effect layer
  119440. */
  119441. removeEffectLayer(toRemove: EffectLayer): number;
  119442. /**
  119443. * Adds the given effect layer to this scene
  119444. * @param newEffectLayer defines the effect layer to add
  119445. */
  119446. addEffectLayer(newEffectLayer: EffectLayer): void;
  119447. }
  119448. /**
  119449. * Defines the layer scene component responsible to manage any effect layers
  119450. * in a given scene.
  119451. */
  119452. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  119453. /**
  119454. * The component name helpfull to identify the component in the list of scene components.
  119455. */
  119456. readonly name: string;
  119457. /**
  119458. * The scene the component belongs to.
  119459. */
  119460. scene: Scene;
  119461. private _engine;
  119462. private _renderEffects;
  119463. private _needStencil;
  119464. private _previousStencilState;
  119465. /**
  119466. * Creates a new instance of the component for the given scene
  119467. * @param scene Defines the scene to register the component in
  119468. */
  119469. constructor(scene: Scene);
  119470. /**
  119471. * Registers the component in a given scene
  119472. */
  119473. register(): void;
  119474. /**
  119475. * Rebuilds the elements related to this component in case of
  119476. * context lost for instance.
  119477. */
  119478. rebuild(): void;
  119479. /**
  119480. * Serializes the component data to the specified json object
  119481. * @param serializationObject The object to serialize to
  119482. */
  119483. serialize(serializationObject: any): void;
  119484. /**
  119485. * Adds all the elements from the container to the scene
  119486. * @param container the container holding the elements
  119487. */
  119488. addFromContainer(container: AbstractScene): void;
  119489. /**
  119490. * Removes all the elements in the container from the scene
  119491. * @param container contains the elements to remove
  119492. * @param dispose if the removed element should be disposed (default: false)
  119493. */
  119494. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119495. /**
  119496. * Disposes the component and the associated ressources.
  119497. */
  119498. dispose(): void;
  119499. private _isReadyForMesh;
  119500. private _renderMainTexture;
  119501. private _setStencil;
  119502. private _setStencilBack;
  119503. private _draw;
  119504. private _drawCamera;
  119505. private _drawRenderingGroup;
  119506. }
  119507. }
  119508. declare module BABYLON {
  119509. /** @hidden */
  119510. export var glowMapMergePixelShader: {
  119511. name: string;
  119512. shader: string;
  119513. };
  119514. }
  119515. declare module BABYLON {
  119516. /** @hidden */
  119517. export var glowMapMergeVertexShader: {
  119518. name: string;
  119519. shader: string;
  119520. };
  119521. }
  119522. declare module BABYLON {
  119523. interface AbstractScene {
  119524. /**
  119525. * Return a the first highlight layer of the scene with a given name.
  119526. * @param name The name of the highlight layer to look for.
  119527. * @return The highlight layer if found otherwise null.
  119528. */
  119529. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  119530. }
  119531. /**
  119532. * Glow layer options. This helps customizing the behaviour
  119533. * of the glow layer.
  119534. */
  119535. export interface IGlowLayerOptions {
  119536. /**
  119537. * Multiplication factor apply to the canvas size to compute the render target size
  119538. * used to generated the glowing objects (the smaller the faster).
  119539. */
  119540. mainTextureRatio: number;
  119541. /**
  119542. * Enforces a fixed size texture to ensure resize independant blur.
  119543. */
  119544. mainTextureFixedSize?: number;
  119545. /**
  119546. * How big is the kernel of the blur texture.
  119547. */
  119548. blurKernelSize: number;
  119549. /**
  119550. * The camera attached to the layer.
  119551. */
  119552. camera: Nullable<Camera>;
  119553. /**
  119554. * Enable MSAA by chosing the number of samples.
  119555. */
  119556. mainTextureSamples?: number;
  119557. /**
  119558. * The rendering group to draw the layer in.
  119559. */
  119560. renderingGroupId: number;
  119561. }
  119562. /**
  119563. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  119564. *
  119565. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  119566. *
  119567. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  119568. */
  119569. export class GlowLayer extends EffectLayer {
  119570. /**
  119571. * Effect Name of the layer.
  119572. */
  119573. static readonly EffectName: string;
  119574. /**
  119575. * The default blur kernel size used for the glow.
  119576. */
  119577. static DefaultBlurKernelSize: number;
  119578. /**
  119579. * The default texture size ratio used for the glow.
  119580. */
  119581. static DefaultTextureRatio: number;
  119582. /**
  119583. * Sets the kernel size of the blur.
  119584. */
  119585. /**
  119586. * Gets the kernel size of the blur.
  119587. */
  119588. blurKernelSize: number;
  119589. /**
  119590. * Sets the glow intensity.
  119591. */
  119592. /**
  119593. * Gets the glow intensity.
  119594. */
  119595. intensity: number;
  119596. private _options;
  119597. private _intensity;
  119598. private _horizontalBlurPostprocess1;
  119599. private _verticalBlurPostprocess1;
  119600. private _horizontalBlurPostprocess2;
  119601. private _verticalBlurPostprocess2;
  119602. private _blurTexture1;
  119603. private _blurTexture2;
  119604. private _postProcesses1;
  119605. private _postProcesses2;
  119606. private _includedOnlyMeshes;
  119607. private _excludedMeshes;
  119608. private _meshesUsingTheirOwnMaterials;
  119609. /**
  119610. * Callback used to let the user override the color selection on a per mesh basis
  119611. */
  119612. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  119613. /**
  119614. * Callback used to let the user override the texture selection on a per mesh basis
  119615. */
  119616. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  119617. /**
  119618. * Instantiates a new glow Layer and references it to the scene.
  119619. * @param name The name of the layer
  119620. * @param scene The scene to use the layer in
  119621. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  119622. */
  119623. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  119624. /**
  119625. * Get the effect name of the layer.
  119626. * @return The effect name
  119627. */
  119628. getEffectName(): string;
  119629. /**
  119630. * Create the merge effect. This is the shader use to blit the information back
  119631. * to the main canvas at the end of the scene rendering.
  119632. */
  119633. protected _createMergeEffect(): Effect;
  119634. /**
  119635. * Creates the render target textures and post processes used in the glow layer.
  119636. */
  119637. protected _createTextureAndPostProcesses(): void;
  119638. /**
  119639. * Checks for the readiness of the element composing the layer.
  119640. * @param subMesh the mesh to check for
  119641. * @param useInstances specify wether or not to use instances to render the mesh
  119642. * @param emissiveTexture the associated emissive texture used to generate the glow
  119643. * @return true if ready otherwise, false
  119644. */
  119645. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119646. /**
  119647. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119648. */
  119649. needStencil(): boolean;
  119650. /**
  119651. * Returns true if the mesh can be rendered, otherwise false.
  119652. * @param mesh The mesh to render
  119653. * @param material The material used on the mesh
  119654. * @returns true if it can be rendered otherwise false
  119655. */
  119656. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119657. /**
  119658. * Implementation specific of rendering the generating effect on the main canvas.
  119659. * @param effect The effect used to render through
  119660. */
  119661. protected _internalRender(effect: Effect): void;
  119662. /**
  119663. * Sets the required values for both the emissive texture and and the main color.
  119664. */
  119665. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119666. /**
  119667. * Returns true if the mesh should render, otherwise false.
  119668. * @param mesh The mesh to render
  119669. * @returns true if it should render otherwise false
  119670. */
  119671. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119672. /**
  119673. * Adds specific effects defines.
  119674. * @param defines The defines to add specifics to.
  119675. */
  119676. protected _addCustomEffectDefines(defines: string[]): void;
  119677. /**
  119678. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  119679. * @param mesh The mesh to exclude from the glow layer
  119680. */
  119681. addExcludedMesh(mesh: Mesh): void;
  119682. /**
  119683. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  119684. * @param mesh The mesh to remove
  119685. */
  119686. removeExcludedMesh(mesh: Mesh): void;
  119687. /**
  119688. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  119689. * @param mesh The mesh to include in the glow layer
  119690. */
  119691. addIncludedOnlyMesh(mesh: Mesh): void;
  119692. /**
  119693. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  119694. * @param mesh The mesh to remove
  119695. */
  119696. removeIncludedOnlyMesh(mesh: Mesh): void;
  119697. /**
  119698. * Determine if a given mesh will be used in the glow layer
  119699. * @param mesh The mesh to test
  119700. * @returns true if the mesh will be highlighted by the current glow layer
  119701. */
  119702. hasMesh(mesh: AbstractMesh): boolean;
  119703. /**
  119704. * Defines wether the current material of the mesh should be use to render the effect.
  119705. * @param mesh defines the current mesh to render
  119706. */
  119707. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119708. /**
  119709. * Add a mesh to be rendered through its own material and not with emissive only.
  119710. * @param mesh The mesh for which we need to use its material
  119711. */
  119712. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  119713. /**
  119714. * Remove a mesh from being rendered through its own material and not with emissive only.
  119715. * @param mesh The mesh for which we need to not use its material
  119716. */
  119717. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  119718. /**
  119719. * Free any resources and references associated to a mesh.
  119720. * Internal use
  119721. * @param mesh The mesh to free.
  119722. * @hidden
  119723. */
  119724. _disposeMesh(mesh: Mesh): void;
  119725. /**
  119726. * Gets the class name of the effect layer
  119727. * @returns the string with the class name of the effect layer
  119728. */
  119729. getClassName(): string;
  119730. /**
  119731. * Serializes this glow layer
  119732. * @returns a serialized glow layer object
  119733. */
  119734. serialize(): any;
  119735. /**
  119736. * Creates a Glow Layer from parsed glow layer data
  119737. * @param parsedGlowLayer defines glow layer data
  119738. * @param scene defines the current scene
  119739. * @param rootUrl defines the root URL containing the glow layer information
  119740. * @returns a parsed Glow Layer
  119741. */
  119742. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  119743. }
  119744. }
  119745. declare module BABYLON {
  119746. /** @hidden */
  119747. export var glowBlurPostProcessPixelShader: {
  119748. name: string;
  119749. shader: string;
  119750. };
  119751. }
  119752. declare module BABYLON {
  119753. interface AbstractScene {
  119754. /**
  119755. * Return a the first highlight layer of the scene with a given name.
  119756. * @param name The name of the highlight layer to look for.
  119757. * @return The highlight layer if found otherwise null.
  119758. */
  119759. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  119760. }
  119761. /**
  119762. * Highlight layer options. This helps customizing the behaviour
  119763. * of the highlight layer.
  119764. */
  119765. export interface IHighlightLayerOptions {
  119766. /**
  119767. * Multiplication factor apply to the canvas size to compute the render target size
  119768. * used to generated the glowing objects (the smaller the faster).
  119769. */
  119770. mainTextureRatio: number;
  119771. /**
  119772. * Enforces a fixed size texture to ensure resize independant blur.
  119773. */
  119774. mainTextureFixedSize?: number;
  119775. /**
  119776. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  119777. * of the picture to blur (the smaller the faster).
  119778. */
  119779. blurTextureSizeRatio: number;
  119780. /**
  119781. * How big in texel of the blur texture is the vertical blur.
  119782. */
  119783. blurVerticalSize: number;
  119784. /**
  119785. * How big in texel of the blur texture is the horizontal blur.
  119786. */
  119787. blurHorizontalSize: number;
  119788. /**
  119789. * Alpha blending mode used to apply the blur. Default is combine.
  119790. */
  119791. alphaBlendingMode: number;
  119792. /**
  119793. * The camera attached to the layer.
  119794. */
  119795. camera: Nullable<Camera>;
  119796. /**
  119797. * Should we display highlight as a solid stroke?
  119798. */
  119799. isStroke?: boolean;
  119800. /**
  119801. * The rendering group to draw the layer in.
  119802. */
  119803. renderingGroupId: number;
  119804. }
  119805. /**
  119806. * The highlight layer Helps adding a glow effect around a mesh.
  119807. *
  119808. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  119809. * glowy meshes to your scene.
  119810. *
  119811. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  119812. */
  119813. export class HighlightLayer extends EffectLayer {
  119814. name: string;
  119815. /**
  119816. * Effect Name of the highlight layer.
  119817. */
  119818. static readonly EffectName: string;
  119819. /**
  119820. * The neutral color used during the preparation of the glow effect.
  119821. * This is black by default as the blend operation is a blend operation.
  119822. */
  119823. static NeutralColor: Color4;
  119824. /**
  119825. * Stencil value used for glowing meshes.
  119826. */
  119827. static GlowingMeshStencilReference: number;
  119828. /**
  119829. * Stencil value used for the other meshes in the scene.
  119830. */
  119831. static NormalMeshStencilReference: number;
  119832. /**
  119833. * Specifies whether or not the inner glow is ACTIVE in the layer.
  119834. */
  119835. innerGlow: boolean;
  119836. /**
  119837. * Specifies whether or not the outer glow is ACTIVE in the layer.
  119838. */
  119839. outerGlow: boolean;
  119840. /**
  119841. * Specifies the horizontal size of the blur.
  119842. */
  119843. /**
  119844. * Gets the horizontal size of the blur.
  119845. */
  119846. blurHorizontalSize: number;
  119847. /**
  119848. * Specifies the vertical size of the blur.
  119849. */
  119850. /**
  119851. * Gets the vertical size of the blur.
  119852. */
  119853. blurVerticalSize: number;
  119854. /**
  119855. * An event triggered when the highlight layer is being blurred.
  119856. */
  119857. onBeforeBlurObservable: Observable<HighlightLayer>;
  119858. /**
  119859. * An event triggered when the highlight layer has been blurred.
  119860. */
  119861. onAfterBlurObservable: Observable<HighlightLayer>;
  119862. private _instanceGlowingMeshStencilReference;
  119863. private _options;
  119864. private _downSamplePostprocess;
  119865. private _horizontalBlurPostprocess;
  119866. private _verticalBlurPostprocess;
  119867. private _blurTexture;
  119868. private _meshes;
  119869. private _excludedMeshes;
  119870. /**
  119871. * Instantiates a new highlight Layer and references it to the scene..
  119872. * @param name The name of the layer
  119873. * @param scene The scene to use the layer in
  119874. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  119875. */
  119876. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  119877. /**
  119878. * Get the effect name of the layer.
  119879. * @return The effect name
  119880. */
  119881. getEffectName(): string;
  119882. /**
  119883. * Create the merge effect. This is the shader use to blit the information back
  119884. * to the main canvas at the end of the scene rendering.
  119885. */
  119886. protected _createMergeEffect(): Effect;
  119887. /**
  119888. * Creates the render target textures and post processes used in the highlight layer.
  119889. */
  119890. protected _createTextureAndPostProcesses(): void;
  119891. /**
  119892. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119893. */
  119894. needStencil(): boolean;
  119895. /**
  119896. * Checks for the readiness of the element composing the layer.
  119897. * @param subMesh the mesh to check for
  119898. * @param useInstances specify wether or not to use instances to render the mesh
  119899. * @param emissiveTexture the associated emissive texture used to generate the glow
  119900. * @return true if ready otherwise, false
  119901. */
  119902. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119903. /**
  119904. * Implementation specific of rendering the generating effect on the main canvas.
  119905. * @param effect The effect used to render through
  119906. */
  119907. protected _internalRender(effect: Effect): void;
  119908. /**
  119909. * Returns true if the layer contains information to display, otherwise false.
  119910. */
  119911. shouldRender(): boolean;
  119912. /**
  119913. * Returns true if the mesh should render, otherwise false.
  119914. * @param mesh The mesh to render
  119915. * @returns true if it should render otherwise false
  119916. */
  119917. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119918. /**
  119919. * Sets the required values for both the emissive texture and and the main color.
  119920. */
  119921. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119922. /**
  119923. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  119924. * @param mesh The mesh to exclude from the highlight layer
  119925. */
  119926. addExcludedMesh(mesh: Mesh): void;
  119927. /**
  119928. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  119929. * @param mesh The mesh to highlight
  119930. */
  119931. removeExcludedMesh(mesh: Mesh): void;
  119932. /**
  119933. * Determine if a given mesh will be highlighted by the current HighlightLayer
  119934. * @param mesh mesh to test
  119935. * @returns true if the mesh will be highlighted by the current HighlightLayer
  119936. */
  119937. hasMesh(mesh: AbstractMesh): boolean;
  119938. /**
  119939. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  119940. * @param mesh The mesh to highlight
  119941. * @param color The color of the highlight
  119942. * @param glowEmissiveOnly Extract the glow from the emissive texture
  119943. */
  119944. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  119945. /**
  119946. * Remove a mesh from the highlight layer in order to make it stop glowing.
  119947. * @param mesh The mesh to highlight
  119948. */
  119949. removeMesh(mesh: Mesh): void;
  119950. /**
  119951. * Force the stencil to the normal expected value for none glowing parts
  119952. */
  119953. private _defaultStencilReference;
  119954. /**
  119955. * Free any resources and references associated to a mesh.
  119956. * Internal use
  119957. * @param mesh The mesh to free.
  119958. * @hidden
  119959. */
  119960. _disposeMesh(mesh: Mesh): void;
  119961. /**
  119962. * Dispose the highlight layer and free resources.
  119963. */
  119964. dispose(): void;
  119965. /**
  119966. * Gets the class name of the effect layer
  119967. * @returns the string with the class name of the effect layer
  119968. */
  119969. getClassName(): string;
  119970. /**
  119971. * Serializes this Highlight layer
  119972. * @returns a serialized Highlight layer object
  119973. */
  119974. serialize(): any;
  119975. /**
  119976. * Creates a Highlight layer from parsed Highlight layer data
  119977. * @param parsedHightlightLayer defines the Highlight layer data
  119978. * @param scene defines the current scene
  119979. * @param rootUrl defines the root URL containing the Highlight layer information
  119980. * @returns a parsed Highlight layer
  119981. */
  119982. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  119983. }
  119984. }
  119985. declare module BABYLON {
  119986. interface AbstractScene {
  119987. /**
  119988. * The list of layers (background and foreground) of the scene
  119989. */
  119990. layers: Array<Layer>;
  119991. }
  119992. /**
  119993. * Defines the layer scene component responsible to manage any layers
  119994. * in a given scene.
  119995. */
  119996. export class LayerSceneComponent implements ISceneComponent {
  119997. /**
  119998. * The component name helpfull to identify the component in the list of scene components.
  119999. */
  120000. readonly name: string;
  120001. /**
  120002. * The scene the component belongs to.
  120003. */
  120004. scene: Scene;
  120005. private _engine;
  120006. /**
  120007. * Creates a new instance of the component for the given scene
  120008. * @param scene Defines the scene to register the component in
  120009. */
  120010. constructor(scene: Scene);
  120011. /**
  120012. * Registers the component in a given scene
  120013. */
  120014. register(): void;
  120015. /**
  120016. * Rebuilds the elements related to this component in case of
  120017. * context lost for instance.
  120018. */
  120019. rebuild(): void;
  120020. /**
  120021. * Disposes the component and the associated ressources.
  120022. */
  120023. dispose(): void;
  120024. private _draw;
  120025. private _drawCameraPredicate;
  120026. private _drawCameraBackground;
  120027. private _drawCameraForeground;
  120028. private _drawRenderTargetPredicate;
  120029. private _drawRenderTargetBackground;
  120030. private _drawRenderTargetForeground;
  120031. /**
  120032. * Adds all the elements from the container to the scene
  120033. * @param container the container holding the elements
  120034. */
  120035. addFromContainer(container: AbstractScene): void;
  120036. /**
  120037. * Removes all the elements in the container from the scene
  120038. * @param container contains the elements to remove
  120039. * @param dispose if the removed element should be disposed (default: false)
  120040. */
  120041. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120042. }
  120043. }
  120044. declare module BABYLON {
  120045. /** @hidden */
  120046. export var layerPixelShader: {
  120047. name: string;
  120048. shader: string;
  120049. };
  120050. }
  120051. declare module BABYLON {
  120052. /** @hidden */
  120053. export var layerVertexShader: {
  120054. name: string;
  120055. shader: string;
  120056. };
  120057. }
  120058. declare module BABYLON {
  120059. /**
  120060. * This represents a full screen 2d layer.
  120061. * This can be useful to display a picture in the background of your scene for instance.
  120062. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120063. */
  120064. export class Layer {
  120065. /**
  120066. * Define the name of the layer.
  120067. */
  120068. name: string;
  120069. /**
  120070. * Define the texture the layer should display.
  120071. */
  120072. texture: Nullable<Texture>;
  120073. /**
  120074. * Is the layer in background or foreground.
  120075. */
  120076. isBackground: boolean;
  120077. /**
  120078. * Define the color of the layer (instead of texture).
  120079. */
  120080. color: Color4;
  120081. /**
  120082. * Define the scale of the layer in order to zoom in out of the texture.
  120083. */
  120084. scale: Vector2;
  120085. /**
  120086. * Define an offset for the layer in order to shift the texture.
  120087. */
  120088. offset: Vector2;
  120089. /**
  120090. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  120091. */
  120092. alphaBlendingMode: number;
  120093. /**
  120094. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  120095. * Alpha test will not mix with the background color in case of transparency.
  120096. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  120097. */
  120098. alphaTest: boolean;
  120099. /**
  120100. * Define a mask to restrict the layer to only some of the scene cameras.
  120101. */
  120102. layerMask: number;
  120103. /**
  120104. * Define the list of render target the layer is visible into.
  120105. */
  120106. renderTargetTextures: RenderTargetTexture[];
  120107. /**
  120108. * Define if the layer is only used in renderTarget or if it also
  120109. * renders in the main frame buffer of the canvas.
  120110. */
  120111. renderOnlyInRenderTargetTextures: boolean;
  120112. private _scene;
  120113. private _vertexBuffers;
  120114. private _indexBuffer;
  120115. private _effect;
  120116. private _alphaTestEffect;
  120117. /**
  120118. * An event triggered when the layer is disposed.
  120119. */
  120120. onDisposeObservable: Observable<Layer>;
  120121. private _onDisposeObserver;
  120122. /**
  120123. * Back compatibility with callback before the onDisposeObservable existed.
  120124. * The set callback will be triggered when the layer has been disposed.
  120125. */
  120126. onDispose: () => void;
  120127. /**
  120128. * An event triggered before rendering the scene
  120129. */
  120130. onBeforeRenderObservable: Observable<Layer>;
  120131. private _onBeforeRenderObserver;
  120132. /**
  120133. * Back compatibility with callback before the onBeforeRenderObservable existed.
  120134. * The set callback will be triggered just before rendering the layer.
  120135. */
  120136. onBeforeRender: () => void;
  120137. /**
  120138. * An event triggered after rendering the scene
  120139. */
  120140. onAfterRenderObservable: Observable<Layer>;
  120141. private _onAfterRenderObserver;
  120142. /**
  120143. * Back compatibility with callback before the onAfterRenderObservable existed.
  120144. * The set callback will be triggered just after rendering the layer.
  120145. */
  120146. onAfterRender: () => void;
  120147. /**
  120148. * Instantiates a new layer.
  120149. * This represents a full screen 2d layer.
  120150. * This can be useful to display a picture in the background of your scene for instance.
  120151. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120152. * @param name Define the name of the layer in the scene
  120153. * @param imgUrl Define the url of the texture to display in the layer
  120154. * @param scene Define the scene the layer belongs to
  120155. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  120156. * @param color Defines a color for the layer
  120157. */
  120158. constructor(
  120159. /**
  120160. * Define the name of the layer.
  120161. */
  120162. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  120163. private _createIndexBuffer;
  120164. /** @hidden */
  120165. _rebuild(): void;
  120166. /**
  120167. * Renders the layer in the scene.
  120168. */
  120169. render(): void;
  120170. /**
  120171. * Disposes and releases the associated ressources.
  120172. */
  120173. dispose(): void;
  120174. }
  120175. }
  120176. declare module BABYLON {
  120177. /** @hidden */
  120178. export var lensFlarePixelShader: {
  120179. name: string;
  120180. shader: string;
  120181. };
  120182. }
  120183. declare module BABYLON {
  120184. /** @hidden */
  120185. export var lensFlareVertexShader: {
  120186. name: string;
  120187. shader: string;
  120188. };
  120189. }
  120190. declare module BABYLON {
  120191. /**
  120192. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120193. * It is usually composed of several `lensFlare`.
  120194. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120195. */
  120196. export class LensFlareSystem {
  120197. /**
  120198. * Define the name of the lens flare system
  120199. */
  120200. name: string;
  120201. /**
  120202. * List of lens flares used in this system.
  120203. */
  120204. lensFlares: LensFlare[];
  120205. /**
  120206. * Define a limit from the border the lens flare can be visible.
  120207. */
  120208. borderLimit: number;
  120209. /**
  120210. * Define a viewport border we do not want to see the lens flare in.
  120211. */
  120212. viewportBorder: number;
  120213. /**
  120214. * Define a predicate which could limit the list of meshes able to occlude the effect.
  120215. */
  120216. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  120217. /**
  120218. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  120219. */
  120220. layerMask: number;
  120221. /**
  120222. * Define the id of the lens flare system in the scene.
  120223. * (equal to name by default)
  120224. */
  120225. id: string;
  120226. private _scene;
  120227. private _emitter;
  120228. private _vertexBuffers;
  120229. private _indexBuffer;
  120230. private _effect;
  120231. private _positionX;
  120232. private _positionY;
  120233. private _isEnabled;
  120234. /** @hidden */
  120235. static _SceneComponentInitialization: (scene: Scene) => void;
  120236. /**
  120237. * Instantiates a lens flare system.
  120238. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120239. * It is usually composed of several `lensFlare`.
  120240. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120241. * @param name Define the name of the lens flare system in the scene
  120242. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  120243. * @param scene Define the scene the lens flare system belongs to
  120244. */
  120245. constructor(
  120246. /**
  120247. * Define the name of the lens flare system
  120248. */
  120249. name: string, emitter: any, scene: Scene);
  120250. /**
  120251. * Define if the lens flare system is enabled.
  120252. */
  120253. isEnabled: boolean;
  120254. /**
  120255. * Get the scene the effects belongs to.
  120256. * @returns the scene holding the lens flare system
  120257. */
  120258. getScene(): Scene;
  120259. /**
  120260. * Get the emitter of the lens flare system.
  120261. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120262. * @returns the emitter of the lens flare system
  120263. */
  120264. getEmitter(): any;
  120265. /**
  120266. * Set the emitter of the lens flare system.
  120267. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120268. * @param newEmitter Define the new emitter of the system
  120269. */
  120270. setEmitter(newEmitter: any): void;
  120271. /**
  120272. * Get the lens flare system emitter position.
  120273. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  120274. * @returns the position
  120275. */
  120276. getEmitterPosition(): Vector3;
  120277. /**
  120278. * @hidden
  120279. */
  120280. computeEffectivePosition(globalViewport: Viewport): boolean;
  120281. /** @hidden */
  120282. _isVisible(): boolean;
  120283. /**
  120284. * @hidden
  120285. */
  120286. render(): boolean;
  120287. /**
  120288. * Dispose and release the lens flare with its associated resources.
  120289. */
  120290. dispose(): void;
  120291. /**
  120292. * Parse a lens flare system from a JSON repressentation
  120293. * @param parsedLensFlareSystem Define the JSON to parse
  120294. * @param scene Define the scene the parsed system should be instantiated in
  120295. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  120296. * @returns the parsed system
  120297. */
  120298. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  120299. /**
  120300. * Serialize the current Lens Flare System into a JSON representation.
  120301. * @returns the serialized JSON
  120302. */
  120303. serialize(): any;
  120304. }
  120305. }
  120306. declare module BABYLON {
  120307. /**
  120308. * This represents one of the lens effect in a `lensFlareSystem`.
  120309. * It controls one of the indiviual texture used in the effect.
  120310. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120311. */
  120312. export class LensFlare {
  120313. /**
  120314. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120315. */
  120316. size: number;
  120317. /**
  120318. * 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.
  120319. */
  120320. position: number;
  120321. /**
  120322. * Define the lens color.
  120323. */
  120324. color: Color3;
  120325. /**
  120326. * Define the lens texture.
  120327. */
  120328. texture: Nullable<Texture>;
  120329. /**
  120330. * Define the alpha mode to render this particular lens.
  120331. */
  120332. alphaMode: number;
  120333. private _system;
  120334. /**
  120335. * Creates a new Lens Flare.
  120336. * This represents one of the lens effect in a `lensFlareSystem`.
  120337. * It controls one of the indiviual texture used in the effect.
  120338. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120339. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  120340. * @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.
  120341. * @param color Define the lens color
  120342. * @param imgUrl Define the lens texture url
  120343. * @param system Define the `lensFlareSystem` this flare is part of
  120344. * @returns The newly created Lens Flare
  120345. */
  120346. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  120347. /**
  120348. * Instantiates a new Lens Flare.
  120349. * This represents one of the lens effect in a `lensFlareSystem`.
  120350. * It controls one of the indiviual texture used in the effect.
  120351. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120352. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  120353. * @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.
  120354. * @param color Define the lens color
  120355. * @param imgUrl Define the lens texture url
  120356. * @param system Define the `lensFlareSystem` this flare is part of
  120357. */
  120358. constructor(
  120359. /**
  120360. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120361. */
  120362. size: number,
  120363. /**
  120364. * 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.
  120365. */
  120366. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  120367. /**
  120368. * Dispose and release the lens flare with its associated resources.
  120369. */
  120370. dispose(): void;
  120371. }
  120372. }
  120373. declare module BABYLON {
  120374. interface AbstractScene {
  120375. /**
  120376. * The list of lens flare system added to the scene
  120377. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120378. */
  120379. lensFlareSystems: Array<LensFlareSystem>;
  120380. /**
  120381. * Removes the given lens flare system from this scene.
  120382. * @param toRemove The lens flare system to remove
  120383. * @returns The index of the removed lens flare system
  120384. */
  120385. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  120386. /**
  120387. * Adds the given lens flare system to this scene
  120388. * @param newLensFlareSystem The lens flare system to add
  120389. */
  120390. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  120391. /**
  120392. * Gets a lens flare system using its name
  120393. * @param name defines the name to look for
  120394. * @returns the lens flare system or null if not found
  120395. */
  120396. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  120397. /**
  120398. * Gets a lens flare system using its id
  120399. * @param id defines the id to look for
  120400. * @returns the lens flare system or null if not found
  120401. */
  120402. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  120403. }
  120404. /**
  120405. * Defines the lens flare scene component responsible to manage any lens flares
  120406. * in a given scene.
  120407. */
  120408. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  120409. /**
  120410. * The component name helpfull to identify the component in the list of scene components.
  120411. */
  120412. readonly name: string;
  120413. /**
  120414. * The scene the component belongs to.
  120415. */
  120416. scene: Scene;
  120417. /**
  120418. * Creates a new instance of the component for the given scene
  120419. * @param scene Defines the scene to register the component in
  120420. */
  120421. constructor(scene: Scene);
  120422. /**
  120423. * Registers the component in a given scene
  120424. */
  120425. register(): void;
  120426. /**
  120427. * Rebuilds the elements related to this component in case of
  120428. * context lost for instance.
  120429. */
  120430. rebuild(): void;
  120431. /**
  120432. * Adds all the elements from the container to the scene
  120433. * @param container the container holding the elements
  120434. */
  120435. addFromContainer(container: AbstractScene): void;
  120436. /**
  120437. * Removes all the elements in the container from the scene
  120438. * @param container contains the elements to remove
  120439. * @param dispose if the removed element should be disposed (default: false)
  120440. */
  120441. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120442. /**
  120443. * Serializes the component data to the specified json object
  120444. * @param serializationObject The object to serialize to
  120445. */
  120446. serialize(serializationObject: any): void;
  120447. /**
  120448. * Disposes the component and the associated ressources.
  120449. */
  120450. dispose(): void;
  120451. private _draw;
  120452. }
  120453. }
  120454. declare module BABYLON {
  120455. /**
  120456. * Defines the shadow generator component responsible to manage any shadow generators
  120457. * in a given scene.
  120458. */
  120459. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  120460. /**
  120461. * The component name helpfull to identify the component in the list of scene components.
  120462. */
  120463. readonly name: string;
  120464. /**
  120465. * The scene the component belongs to.
  120466. */
  120467. scene: Scene;
  120468. /**
  120469. * Creates a new instance of the component for the given scene
  120470. * @param scene Defines the scene to register the component in
  120471. */
  120472. constructor(scene: Scene);
  120473. /**
  120474. * Registers the component in a given scene
  120475. */
  120476. register(): void;
  120477. /**
  120478. * Rebuilds the elements related to this component in case of
  120479. * context lost for instance.
  120480. */
  120481. rebuild(): void;
  120482. /**
  120483. * Serializes the component data to the specified json object
  120484. * @param serializationObject The object to serialize to
  120485. */
  120486. serialize(serializationObject: any): void;
  120487. /**
  120488. * Adds all the elements from the container to the scene
  120489. * @param container the container holding the elements
  120490. */
  120491. addFromContainer(container: AbstractScene): void;
  120492. /**
  120493. * Removes all the elements in the container from the scene
  120494. * @param container contains the elements to remove
  120495. * @param dispose if the removed element should be disposed (default: false)
  120496. */
  120497. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120498. /**
  120499. * Rebuilds the elements related to this component in case of
  120500. * context lost for instance.
  120501. */
  120502. dispose(): void;
  120503. private _gatherRenderTargets;
  120504. }
  120505. }
  120506. declare module BABYLON {
  120507. /**
  120508. * A point light is a light defined by an unique point in world space.
  120509. * The light is emitted in every direction from this point.
  120510. * A good example of a point light is a standard light bulb.
  120511. * Documentation: https://doc.babylonjs.com/babylon101/lights
  120512. */
  120513. export class PointLight extends ShadowLight {
  120514. private _shadowAngle;
  120515. /**
  120516. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120517. * This specifies what angle the shadow will use to be created.
  120518. *
  120519. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120520. */
  120521. /**
  120522. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120523. * This specifies what angle the shadow will use to be created.
  120524. *
  120525. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120526. */
  120527. shadowAngle: number;
  120528. /**
  120529. * Gets the direction if it has been set.
  120530. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120531. */
  120532. /**
  120533. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120534. */
  120535. direction: Vector3;
  120536. /**
  120537. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  120538. * A PointLight emits the light in every direction.
  120539. * It can cast shadows.
  120540. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  120541. * ```javascript
  120542. * var pointLight = new PointLight("pl", camera.position, scene);
  120543. * ```
  120544. * Documentation : https://doc.babylonjs.com/babylon101/lights
  120545. * @param name The light friendly name
  120546. * @param position The position of the point light in the scene
  120547. * @param scene The scene the lights belongs to
  120548. */
  120549. constructor(name: string, position: Vector3, scene: Scene);
  120550. /**
  120551. * Returns the string "PointLight"
  120552. * @returns the class name
  120553. */
  120554. getClassName(): string;
  120555. /**
  120556. * Returns the integer 0.
  120557. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  120558. */
  120559. getTypeID(): number;
  120560. /**
  120561. * Specifies wether or not the shadowmap should be a cube texture.
  120562. * @returns true if the shadowmap needs to be a cube texture.
  120563. */
  120564. needCube(): boolean;
  120565. /**
  120566. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  120567. * @param faceIndex The index of the face we are computed the direction to generate shadow
  120568. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  120569. */
  120570. getShadowDirection(faceIndex?: number): Vector3;
  120571. /**
  120572. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  120573. * - fov = PI / 2
  120574. * - aspect ratio : 1.0
  120575. * - z-near and far equal to the active camera minZ and maxZ.
  120576. * Returns the PointLight.
  120577. */
  120578. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  120579. protected _buildUniformLayout(): void;
  120580. /**
  120581. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  120582. * @param effect The effect to update
  120583. * @param lightIndex The index of the light in the effect to update
  120584. * @returns The point light
  120585. */
  120586. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  120587. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  120588. /**
  120589. * Prepares the list of defines specific to the light type.
  120590. * @param defines the list of defines
  120591. * @param lightIndex defines the index of the light for the effect
  120592. */
  120593. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  120594. }
  120595. }
  120596. declare module BABYLON {
  120597. /**
  120598. * Header information of HDR texture files.
  120599. */
  120600. export interface HDRInfo {
  120601. /**
  120602. * The height of the texture in pixels.
  120603. */
  120604. height: number;
  120605. /**
  120606. * The width of the texture in pixels.
  120607. */
  120608. width: number;
  120609. /**
  120610. * The index of the beginning of the data in the binary file.
  120611. */
  120612. dataPosition: number;
  120613. }
  120614. /**
  120615. * This groups tools to convert HDR texture to native colors array.
  120616. */
  120617. export class HDRTools {
  120618. private static Ldexp;
  120619. private static Rgbe2float;
  120620. private static readStringLine;
  120621. /**
  120622. * Reads header information from an RGBE texture stored in a native array.
  120623. * More information on this format are available here:
  120624. * https://en.wikipedia.org/wiki/RGBE_image_format
  120625. *
  120626. * @param uint8array The binary file stored in native array.
  120627. * @return The header information.
  120628. */
  120629. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  120630. /**
  120631. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  120632. * This RGBE texture needs to store the information as a panorama.
  120633. *
  120634. * More information on this format are available here:
  120635. * https://en.wikipedia.org/wiki/RGBE_image_format
  120636. *
  120637. * @param buffer The binary file stored in an array buffer.
  120638. * @param size The expected size of the extracted cubemap.
  120639. * @return The Cube Map information.
  120640. */
  120641. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  120642. /**
  120643. * Returns the pixels data extracted from an RGBE texture.
  120644. * This pixels will be stored left to right up to down in the R G B order in one array.
  120645. *
  120646. * More information on this format are available here:
  120647. * https://en.wikipedia.org/wiki/RGBE_image_format
  120648. *
  120649. * @param uint8array The binary file stored in an array buffer.
  120650. * @param hdrInfo The header information of the file.
  120651. * @return The pixels data in RGB right to left up to down order.
  120652. */
  120653. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  120654. private static RGBE_ReadPixels_RLE;
  120655. }
  120656. }
  120657. declare module BABYLON {
  120658. /**
  120659. * This represents a texture coming from an HDR input.
  120660. *
  120661. * The only supported format is currently panorama picture stored in RGBE format.
  120662. * Example of such files can be found on HDRLib: http://hdrlib.com/
  120663. */
  120664. export class HDRCubeTexture extends BaseTexture {
  120665. private static _facesMapping;
  120666. private _generateHarmonics;
  120667. private _noMipmap;
  120668. private _textureMatrix;
  120669. private _size;
  120670. private _onLoad;
  120671. private _onError;
  120672. /**
  120673. * The texture URL.
  120674. */
  120675. url: string;
  120676. /**
  120677. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  120678. */
  120679. coordinatesMode: number;
  120680. protected _isBlocking: boolean;
  120681. /**
  120682. * Sets wether or not the texture is blocking during loading.
  120683. */
  120684. /**
  120685. * Gets wether or not the texture is blocking during loading.
  120686. */
  120687. isBlocking: boolean;
  120688. protected _rotationY: number;
  120689. /**
  120690. * Sets texture matrix rotation angle around Y axis in radians.
  120691. */
  120692. /**
  120693. * Gets texture matrix rotation angle around Y axis radians.
  120694. */
  120695. rotationY: number;
  120696. /**
  120697. * Gets or sets the center of the bounding box associated with the cube texture
  120698. * It must define where the camera used to render the texture was set
  120699. */
  120700. boundingBoxPosition: Vector3;
  120701. private _boundingBoxSize;
  120702. /**
  120703. * Gets or sets the size of the bounding box associated with the cube texture
  120704. * When defined, the cubemap will switch to local mode
  120705. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  120706. * @example https://www.babylonjs-playground.com/#RNASML
  120707. */
  120708. boundingBoxSize: Vector3;
  120709. /**
  120710. * Instantiates an HDRTexture from the following parameters.
  120711. *
  120712. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  120713. * @param scene The scene the texture will be used in
  120714. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120715. * @param noMipmap Forces to not generate the mipmap if true
  120716. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  120717. * @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)
  120718. * @param reserved Reserved flag for internal use.
  120719. */
  120720. 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>);
  120721. /**
  120722. * Get the current class name of the texture useful for serialization or dynamic coding.
  120723. * @returns "HDRCubeTexture"
  120724. */
  120725. getClassName(): string;
  120726. /**
  120727. * Occurs when the file is raw .hdr file.
  120728. */
  120729. private loadTexture;
  120730. clone(): HDRCubeTexture;
  120731. delayLoad(): void;
  120732. /**
  120733. * Get the texture reflection matrix used to rotate/transform the reflection.
  120734. * @returns the reflection matrix
  120735. */
  120736. getReflectionTextureMatrix(): Matrix;
  120737. /**
  120738. * Set the texture reflection matrix used to rotate/transform the reflection.
  120739. * @param value Define the reflection matrix to set
  120740. */
  120741. setReflectionTextureMatrix(value: Matrix): void;
  120742. /**
  120743. * Parses a JSON representation of an HDR Texture in order to create the texture
  120744. * @param parsedTexture Define the JSON representation
  120745. * @param scene Define the scene the texture should be created in
  120746. * @param rootUrl Define the root url in case we need to load relative dependencies
  120747. * @returns the newly created texture after parsing
  120748. */
  120749. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  120750. serialize(): any;
  120751. }
  120752. }
  120753. declare module BABYLON {
  120754. /**
  120755. * Class used to control physics engine
  120756. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120757. */
  120758. export class PhysicsEngine implements IPhysicsEngine {
  120759. private _physicsPlugin;
  120760. /**
  120761. * Global value used to control the smallest number supported by the simulation
  120762. */
  120763. static Epsilon: number;
  120764. private _impostors;
  120765. private _joints;
  120766. private _subTimeStep;
  120767. /**
  120768. * Gets the gravity vector used by the simulation
  120769. */
  120770. gravity: Vector3;
  120771. /**
  120772. * Factory used to create the default physics plugin.
  120773. * @returns The default physics plugin
  120774. */
  120775. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  120776. /**
  120777. * Creates a new Physics Engine
  120778. * @param gravity defines the gravity vector used by the simulation
  120779. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  120780. */
  120781. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  120782. /**
  120783. * Sets the gravity vector used by the simulation
  120784. * @param gravity defines the gravity vector to use
  120785. */
  120786. setGravity(gravity: Vector3): void;
  120787. /**
  120788. * Set the time step of the physics engine.
  120789. * Default is 1/60.
  120790. * To slow it down, enter 1/600 for example.
  120791. * To speed it up, 1/30
  120792. * @param newTimeStep defines the new timestep to apply to this world.
  120793. */
  120794. setTimeStep(newTimeStep?: number): void;
  120795. /**
  120796. * Get the time step of the physics engine.
  120797. * @returns the current time step
  120798. */
  120799. getTimeStep(): number;
  120800. /**
  120801. * Set the sub time step of the physics engine.
  120802. * Default is 0 meaning there is no sub steps
  120803. * To increase physics resolution precision, set a small value (like 1 ms)
  120804. * @param subTimeStep defines the new sub timestep used for physics resolution.
  120805. */
  120806. setSubTimeStep(subTimeStep?: number): void;
  120807. /**
  120808. * Get the sub time step of the physics engine.
  120809. * @returns the current sub time step
  120810. */
  120811. getSubTimeStep(): number;
  120812. /**
  120813. * Release all resources
  120814. */
  120815. dispose(): void;
  120816. /**
  120817. * Gets the name of the current physics plugin
  120818. * @returns the name of the plugin
  120819. */
  120820. getPhysicsPluginName(): string;
  120821. /**
  120822. * Adding a new impostor for the impostor tracking.
  120823. * This will be done by the impostor itself.
  120824. * @param impostor the impostor to add
  120825. */
  120826. addImpostor(impostor: PhysicsImpostor): void;
  120827. /**
  120828. * Remove an impostor from the engine.
  120829. * This impostor and its mesh will not longer be updated by the physics engine.
  120830. * @param impostor the impostor to remove
  120831. */
  120832. removeImpostor(impostor: PhysicsImpostor): void;
  120833. /**
  120834. * Add a joint to the physics engine
  120835. * @param mainImpostor defines the main impostor to which the joint is added.
  120836. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  120837. * @param joint defines the joint that will connect both impostors.
  120838. */
  120839. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120840. /**
  120841. * Removes a joint from the simulation
  120842. * @param mainImpostor defines the impostor used with the joint
  120843. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  120844. * @param joint defines the joint to remove
  120845. */
  120846. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120847. /**
  120848. * Called by the scene. No need to call it.
  120849. * @param delta defines the timespam between frames
  120850. */
  120851. _step(delta: number): void;
  120852. /**
  120853. * Gets the current plugin used to run the simulation
  120854. * @returns current plugin
  120855. */
  120856. getPhysicsPlugin(): IPhysicsEnginePlugin;
  120857. /**
  120858. * Gets the list of physic impostors
  120859. * @returns an array of PhysicsImpostor
  120860. */
  120861. getImpostors(): Array<PhysicsImpostor>;
  120862. /**
  120863. * Gets the impostor for a physics enabled object
  120864. * @param object defines the object impersonated by the impostor
  120865. * @returns the PhysicsImpostor or null if not found
  120866. */
  120867. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  120868. /**
  120869. * Gets the impostor for a physics body object
  120870. * @param body defines physics body used by the impostor
  120871. * @returns the PhysicsImpostor or null if not found
  120872. */
  120873. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  120874. /**
  120875. * Does a raycast in the physics world
  120876. * @param from when should the ray start?
  120877. * @param to when should the ray end?
  120878. * @returns PhysicsRaycastResult
  120879. */
  120880. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120881. }
  120882. }
  120883. declare module BABYLON {
  120884. /** @hidden */
  120885. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  120886. private _useDeltaForWorldStep;
  120887. world: any;
  120888. name: string;
  120889. private _physicsMaterials;
  120890. private _fixedTimeStep;
  120891. private _cannonRaycastResult;
  120892. private _raycastResult;
  120893. private _physicsBodysToRemoveAfterStep;
  120894. BJSCANNON: any;
  120895. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  120896. setGravity(gravity: Vector3): void;
  120897. setTimeStep(timeStep: number): void;
  120898. getTimeStep(): number;
  120899. executeStep(delta: number): void;
  120900. private _removeMarkedPhysicsBodiesFromWorld;
  120901. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120902. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120903. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120904. private _processChildMeshes;
  120905. removePhysicsBody(impostor: PhysicsImpostor): void;
  120906. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120907. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120908. private _addMaterial;
  120909. private _checkWithEpsilon;
  120910. private _createShape;
  120911. private _createHeightmap;
  120912. private _minus90X;
  120913. private _plus90X;
  120914. private _tmpPosition;
  120915. private _tmpDeltaPosition;
  120916. private _tmpUnityRotation;
  120917. private _updatePhysicsBodyTransformation;
  120918. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120919. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120920. isSupported(): boolean;
  120921. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120922. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120923. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120924. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120925. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120926. getBodyMass(impostor: PhysicsImpostor): number;
  120927. getBodyFriction(impostor: PhysicsImpostor): number;
  120928. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120929. getBodyRestitution(impostor: PhysicsImpostor): number;
  120930. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120931. sleepBody(impostor: PhysicsImpostor): void;
  120932. wakeUpBody(impostor: PhysicsImpostor): void;
  120933. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  120934. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120935. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120936. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120937. getRadius(impostor: PhysicsImpostor): number;
  120938. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120939. dispose(): void;
  120940. private _extendNamespace;
  120941. /**
  120942. * Does a raycast in the physics world
  120943. * @param from when should the ray start?
  120944. * @param to when should the ray end?
  120945. * @returns PhysicsRaycastResult
  120946. */
  120947. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120948. }
  120949. }
  120950. declare module BABYLON {
  120951. /** @hidden */
  120952. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  120953. world: any;
  120954. name: string;
  120955. BJSOIMO: any;
  120956. private _raycastResult;
  120957. constructor(iterations?: number, oimoInjection?: any);
  120958. setGravity(gravity: Vector3): void;
  120959. setTimeStep(timeStep: number): void;
  120960. getTimeStep(): number;
  120961. private _tmpImpostorsArray;
  120962. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120963. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120964. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120965. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120966. private _tmpPositionVector;
  120967. removePhysicsBody(impostor: PhysicsImpostor): void;
  120968. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120969. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120970. isSupported(): boolean;
  120971. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120972. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120973. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120974. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120975. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120976. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120977. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120978. getBodyMass(impostor: PhysicsImpostor): number;
  120979. getBodyFriction(impostor: PhysicsImpostor): number;
  120980. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120981. getBodyRestitution(impostor: PhysicsImpostor): number;
  120982. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120983. sleepBody(impostor: PhysicsImpostor): void;
  120984. wakeUpBody(impostor: PhysicsImpostor): void;
  120985. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120986. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  120987. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  120988. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120989. getRadius(impostor: PhysicsImpostor): number;
  120990. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120991. dispose(): void;
  120992. /**
  120993. * Does a raycast in the physics world
  120994. * @param from when should the ray start?
  120995. * @param to when should the ray end?
  120996. * @returns PhysicsRaycastResult
  120997. */
  120998. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120999. }
  121000. }
  121001. declare module BABYLON {
  121002. /**
  121003. * Class containing static functions to help procedurally build meshes
  121004. */
  121005. export class RibbonBuilder {
  121006. /**
  121007. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121008. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121009. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121010. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121011. * * 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
  121012. * * 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
  121013. * * 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
  121014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121016. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121017. * * 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
  121018. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121019. * * 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
  121020. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121022. * @param name defines the name of the mesh
  121023. * @param options defines the options used to create the mesh
  121024. * @param scene defines the hosting scene
  121025. * @returns the ribbon mesh
  121026. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121027. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121028. */
  121029. static CreateRibbon(name: string, options: {
  121030. pathArray: Vector3[][];
  121031. closeArray?: boolean;
  121032. closePath?: boolean;
  121033. offset?: number;
  121034. updatable?: boolean;
  121035. sideOrientation?: number;
  121036. frontUVs?: Vector4;
  121037. backUVs?: Vector4;
  121038. instance?: Mesh;
  121039. invertUV?: boolean;
  121040. uvs?: Vector2[];
  121041. colors?: Color4[];
  121042. }, scene?: Nullable<Scene>): Mesh;
  121043. }
  121044. }
  121045. declare module BABYLON {
  121046. /**
  121047. * Class containing static functions to help procedurally build meshes
  121048. */
  121049. export class ShapeBuilder {
  121050. /**
  121051. * 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.
  121052. * * 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.
  121053. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121054. * * 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.
  121055. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121056. * * 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
  121057. * * 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
  121058. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121061. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121063. * @param name defines the name of the mesh
  121064. * @param options defines the options used to create the mesh
  121065. * @param scene defines the hosting scene
  121066. * @returns the extruded shape mesh
  121067. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121069. */
  121070. static ExtrudeShape(name: string, options: {
  121071. shape: Vector3[];
  121072. path: Vector3[];
  121073. scale?: number;
  121074. rotation?: number;
  121075. cap?: number;
  121076. updatable?: boolean;
  121077. sideOrientation?: number;
  121078. frontUVs?: Vector4;
  121079. backUVs?: Vector4;
  121080. instance?: Mesh;
  121081. invertUV?: boolean;
  121082. }, scene?: Nullable<Scene>): Mesh;
  121083. /**
  121084. * Creates an custom extruded shape mesh.
  121085. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121086. * * 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.
  121087. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121088. * * 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
  121089. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121090. * * 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
  121091. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121092. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121093. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121094. * * 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
  121095. * * 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
  121096. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121101. * @param name defines the name of the mesh
  121102. * @param options defines the options used to create the mesh
  121103. * @param scene defines the hosting scene
  121104. * @returns the custom extruded shape mesh
  121105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121108. */
  121109. static ExtrudeShapeCustom(name: string, options: {
  121110. shape: Vector3[];
  121111. path: Vector3[];
  121112. scaleFunction?: any;
  121113. rotationFunction?: any;
  121114. ribbonCloseArray?: boolean;
  121115. ribbonClosePath?: boolean;
  121116. cap?: number;
  121117. updatable?: boolean;
  121118. sideOrientation?: number;
  121119. frontUVs?: Vector4;
  121120. backUVs?: Vector4;
  121121. instance?: Mesh;
  121122. invertUV?: boolean;
  121123. }, scene?: Nullable<Scene>): Mesh;
  121124. private static _ExtrudeShapeGeneric;
  121125. }
  121126. }
  121127. declare module BABYLON {
  121128. /**
  121129. * AmmoJS Physics plugin
  121130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  121131. * @see https://github.com/kripken/ammo.js/
  121132. */
  121133. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  121134. private _useDeltaForWorldStep;
  121135. /**
  121136. * Reference to the Ammo library
  121137. */
  121138. bjsAMMO: any;
  121139. /**
  121140. * Created ammoJS world which physics bodies are added to
  121141. */
  121142. world: any;
  121143. /**
  121144. * Name of the plugin
  121145. */
  121146. name: string;
  121147. private _timeStep;
  121148. private _fixedTimeStep;
  121149. private _maxSteps;
  121150. private _tmpQuaternion;
  121151. private _tmpAmmoTransform;
  121152. private _tmpAmmoQuaternion;
  121153. private _tmpAmmoConcreteContactResultCallback;
  121154. private _collisionConfiguration;
  121155. private _dispatcher;
  121156. private _overlappingPairCache;
  121157. private _solver;
  121158. private _softBodySolver;
  121159. private _tmpAmmoVectorA;
  121160. private _tmpAmmoVectorB;
  121161. private _tmpAmmoVectorC;
  121162. private _tmpAmmoVectorD;
  121163. private _tmpContactCallbackResult;
  121164. private _tmpAmmoVectorRCA;
  121165. private _tmpAmmoVectorRCB;
  121166. private _raycastResult;
  121167. private static readonly DISABLE_COLLISION_FLAG;
  121168. private static readonly KINEMATIC_FLAG;
  121169. private static readonly DISABLE_DEACTIVATION_FLAG;
  121170. /**
  121171. * Initializes the ammoJS plugin
  121172. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  121173. * @param ammoInjection can be used to inject your own ammo reference
  121174. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  121175. */
  121176. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  121177. /**
  121178. * Sets the gravity of the physics world (m/(s^2))
  121179. * @param gravity Gravity to set
  121180. */
  121181. setGravity(gravity: Vector3): void;
  121182. /**
  121183. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  121184. * @param timeStep timestep to use in seconds
  121185. */
  121186. setTimeStep(timeStep: number): void;
  121187. /**
  121188. * 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)
  121189. * @param fixedTimeStep fixedTimeStep to use in seconds
  121190. */
  121191. setFixedTimeStep(fixedTimeStep: number): void;
  121192. /**
  121193. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  121194. * @param maxSteps the maximum number of steps by the physics engine per frame
  121195. */
  121196. setMaxSteps(maxSteps: number): void;
  121197. /**
  121198. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  121199. * @returns the current timestep in seconds
  121200. */
  121201. getTimeStep(): number;
  121202. /**
  121203. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  121204. */
  121205. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  121206. private _isImpostorInContact;
  121207. private _isImpostorPairInContact;
  121208. private _stepSimulation;
  121209. /**
  121210. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  121211. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  121212. * After the step the babylon meshes are set to the position of the physics imposters
  121213. * @param delta amount of time to step forward
  121214. * @param impostors array of imposters to update before/after the step
  121215. */
  121216. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121217. /**
  121218. * Update babylon mesh to match physics world object
  121219. * @param impostor imposter to match
  121220. */
  121221. private _afterSoftStep;
  121222. /**
  121223. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121224. * @param impostor imposter to match
  121225. */
  121226. private _ropeStep;
  121227. /**
  121228. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121229. * @param impostor imposter to match
  121230. */
  121231. private _softbodyOrClothStep;
  121232. private _tmpVector;
  121233. private _tmpMatrix;
  121234. /**
  121235. * Applies an impulse on the imposter
  121236. * @param impostor imposter to apply impulse to
  121237. * @param force amount of force to be applied to the imposter
  121238. * @param contactPoint the location to apply the impulse on the imposter
  121239. */
  121240. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121241. /**
  121242. * Applies a force on the imposter
  121243. * @param impostor imposter to apply force
  121244. * @param force amount of force to be applied to the imposter
  121245. * @param contactPoint the location to apply the force on the imposter
  121246. */
  121247. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121248. /**
  121249. * Creates a physics body using the plugin
  121250. * @param impostor the imposter to create the physics body on
  121251. */
  121252. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121253. /**
  121254. * Removes the physics body from the imposter and disposes of the body's memory
  121255. * @param impostor imposter to remove the physics body from
  121256. */
  121257. removePhysicsBody(impostor: PhysicsImpostor): void;
  121258. /**
  121259. * Generates a joint
  121260. * @param impostorJoint the imposter joint to create the joint with
  121261. */
  121262. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121263. /**
  121264. * Removes a joint
  121265. * @param impostorJoint the imposter joint to remove the joint from
  121266. */
  121267. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121268. private _addMeshVerts;
  121269. /**
  121270. * Initialise the soft body vertices to match its object's (mesh) vertices
  121271. * Softbody vertices (nodes) are in world space and to match this
  121272. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  121273. * @param impostor to create the softbody for
  121274. */
  121275. private _softVertexData;
  121276. /**
  121277. * Create an impostor's soft body
  121278. * @param impostor to create the softbody for
  121279. */
  121280. private _createSoftbody;
  121281. /**
  121282. * Create cloth for an impostor
  121283. * @param impostor to create the softbody for
  121284. */
  121285. private _createCloth;
  121286. /**
  121287. * Create rope for an impostor
  121288. * @param impostor to create the softbody for
  121289. */
  121290. private _createRope;
  121291. /**
  121292. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  121293. * @param impostor to create the custom physics shape for
  121294. */
  121295. private _createCustom;
  121296. private _addHullVerts;
  121297. private _createShape;
  121298. /**
  121299. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  121300. * @param impostor imposter containing the physics body and babylon object
  121301. */
  121302. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121303. /**
  121304. * Sets the babylon object's position/rotation from the physics body's position/rotation
  121305. * @param impostor imposter containing the physics body and babylon object
  121306. * @param newPosition new position
  121307. * @param newRotation new rotation
  121308. */
  121309. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121310. /**
  121311. * If this plugin is supported
  121312. * @returns true if its supported
  121313. */
  121314. isSupported(): boolean;
  121315. /**
  121316. * Sets the linear velocity of the physics body
  121317. * @param impostor imposter to set the velocity on
  121318. * @param velocity velocity to set
  121319. */
  121320. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121321. /**
  121322. * Sets the angular velocity of the physics body
  121323. * @param impostor imposter to set the velocity on
  121324. * @param velocity velocity to set
  121325. */
  121326. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121327. /**
  121328. * gets the linear velocity
  121329. * @param impostor imposter to get linear velocity from
  121330. * @returns linear velocity
  121331. */
  121332. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121333. /**
  121334. * gets the angular velocity
  121335. * @param impostor imposter to get angular velocity from
  121336. * @returns angular velocity
  121337. */
  121338. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121339. /**
  121340. * Sets the mass of physics body
  121341. * @param impostor imposter to set the mass on
  121342. * @param mass mass to set
  121343. */
  121344. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121345. /**
  121346. * Gets the mass of the physics body
  121347. * @param impostor imposter to get the mass from
  121348. * @returns mass
  121349. */
  121350. getBodyMass(impostor: PhysicsImpostor): number;
  121351. /**
  121352. * Gets friction of the impostor
  121353. * @param impostor impostor to get friction from
  121354. * @returns friction value
  121355. */
  121356. getBodyFriction(impostor: PhysicsImpostor): number;
  121357. /**
  121358. * Sets friction of the impostor
  121359. * @param impostor impostor to set friction on
  121360. * @param friction friction value
  121361. */
  121362. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121363. /**
  121364. * Gets restitution of the impostor
  121365. * @param impostor impostor to get restitution from
  121366. * @returns restitution value
  121367. */
  121368. getBodyRestitution(impostor: PhysicsImpostor): number;
  121369. /**
  121370. * Sets resitution of the impostor
  121371. * @param impostor impostor to set resitution on
  121372. * @param restitution resitution value
  121373. */
  121374. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121375. /**
  121376. * Gets pressure inside the impostor
  121377. * @param impostor impostor to get pressure from
  121378. * @returns pressure value
  121379. */
  121380. getBodyPressure(impostor: PhysicsImpostor): number;
  121381. /**
  121382. * Sets pressure inside a soft body impostor
  121383. * Cloth and rope must remain 0 pressure
  121384. * @param impostor impostor to set pressure on
  121385. * @param pressure pressure value
  121386. */
  121387. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  121388. /**
  121389. * Gets stiffness of the impostor
  121390. * @param impostor impostor to get stiffness from
  121391. * @returns pressure value
  121392. */
  121393. getBodyStiffness(impostor: PhysicsImpostor): number;
  121394. /**
  121395. * Sets stiffness of the impostor
  121396. * @param impostor impostor to set stiffness on
  121397. * @param stiffness stiffness value from 0 to 1
  121398. */
  121399. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  121400. /**
  121401. * Gets velocityIterations of the impostor
  121402. * @param impostor impostor to get velocity iterations from
  121403. * @returns velocityIterations value
  121404. */
  121405. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  121406. /**
  121407. * Sets velocityIterations of the impostor
  121408. * @param impostor impostor to set velocity iterations on
  121409. * @param velocityIterations velocityIterations value
  121410. */
  121411. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  121412. /**
  121413. * Gets positionIterations of the impostor
  121414. * @param impostor impostor to get position iterations from
  121415. * @returns positionIterations value
  121416. */
  121417. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  121418. /**
  121419. * Sets positionIterations of the impostor
  121420. * @param impostor impostor to set position on
  121421. * @param positionIterations positionIterations value
  121422. */
  121423. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  121424. /**
  121425. * Append an anchor to a cloth object
  121426. * @param impostor is the cloth impostor to add anchor to
  121427. * @param otherImpostor is the rigid impostor to anchor to
  121428. * @param width ratio across width from 0 to 1
  121429. * @param height ratio up height from 0 to 1
  121430. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  121431. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121432. */
  121433. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121434. /**
  121435. * Append an hook to a rope object
  121436. * @param impostor is the rope impostor to add hook to
  121437. * @param otherImpostor is the rigid impostor to hook to
  121438. * @param length ratio along the rope from 0 to 1
  121439. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  121440. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121441. */
  121442. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121443. /**
  121444. * Sleeps the physics body and stops it from being active
  121445. * @param impostor impostor to sleep
  121446. */
  121447. sleepBody(impostor: PhysicsImpostor): void;
  121448. /**
  121449. * Activates the physics body
  121450. * @param impostor impostor to activate
  121451. */
  121452. wakeUpBody(impostor: PhysicsImpostor): void;
  121453. /**
  121454. * Updates the distance parameters of the joint
  121455. * @param joint joint to update
  121456. * @param maxDistance maximum distance of the joint
  121457. * @param minDistance minimum distance of the joint
  121458. */
  121459. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121460. /**
  121461. * Sets a motor on the joint
  121462. * @param joint joint to set motor on
  121463. * @param speed speed of the motor
  121464. * @param maxForce maximum force of the motor
  121465. * @param motorIndex index of the motor
  121466. */
  121467. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121468. /**
  121469. * Sets the motors limit
  121470. * @param joint joint to set limit on
  121471. * @param upperLimit upper limit
  121472. * @param lowerLimit lower limit
  121473. */
  121474. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121475. /**
  121476. * Syncs the position and rotation of a mesh with the impostor
  121477. * @param mesh mesh to sync
  121478. * @param impostor impostor to update the mesh with
  121479. */
  121480. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121481. /**
  121482. * Gets the radius of the impostor
  121483. * @param impostor impostor to get radius from
  121484. * @returns the radius
  121485. */
  121486. getRadius(impostor: PhysicsImpostor): number;
  121487. /**
  121488. * Gets the box size of the impostor
  121489. * @param impostor impostor to get box size from
  121490. * @param result the resulting box size
  121491. */
  121492. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121493. /**
  121494. * Disposes of the impostor
  121495. */
  121496. dispose(): void;
  121497. /**
  121498. * Does a raycast in the physics world
  121499. * @param from when should the ray start?
  121500. * @param to when should the ray end?
  121501. * @returns PhysicsRaycastResult
  121502. */
  121503. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121504. }
  121505. }
  121506. declare module BABYLON {
  121507. interface AbstractScene {
  121508. /**
  121509. * The list of reflection probes added to the scene
  121510. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121511. */
  121512. reflectionProbes: Array<ReflectionProbe>;
  121513. /**
  121514. * Removes the given reflection probe from this scene.
  121515. * @param toRemove The reflection probe to remove
  121516. * @returns The index of the removed reflection probe
  121517. */
  121518. removeReflectionProbe(toRemove: ReflectionProbe): number;
  121519. /**
  121520. * Adds the given reflection probe to this scene.
  121521. * @param newReflectionProbe The reflection probe to add
  121522. */
  121523. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  121524. }
  121525. /**
  121526. * Class used to generate realtime reflection / refraction cube textures
  121527. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121528. */
  121529. export class ReflectionProbe {
  121530. /** defines the name of the probe */
  121531. name: string;
  121532. private _scene;
  121533. private _renderTargetTexture;
  121534. private _projectionMatrix;
  121535. private _viewMatrix;
  121536. private _target;
  121537. private _add;
  121538. private _attachedMesh;
  121539. private _invertYAxis;
  121540. /** Gets or sets probe position (center of the cube map) */
  121541. position: Vector3;
  121542. /**
  121543. * Creates a new reflection probe
  121544. * @param name defines the name of the probe
  121545. * @param size defines the texture resolution (for each face)
  121546. * @param scene defines the hosting scene
  121547. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  121548. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  121549. */
  121550. constructor(
  121551. /** defines the name of the probe */
  121552. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  121553. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  121554. samples: number;
  121555. /** Gets or sets the refresh rate to use (on every frame by default) */
  121556. refreshRate: number;
  121557. /**
  121558. * Gets the hosting scene
  121559. * @returns a Scene
  121560. */
  121561. getScene(): Scene;
  121562. /** Gets the internal CubeTexture used to render to */
  121563. readonly cubeTexture: RenderTargetTexture;
  121564. /** Gets the list of meshes to render */
  121565. readonly renderList: Nullable<AbstractMesh[]>;
  121566. /**
  121567. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  121568. * @param mesh defines the mesh to attach to
  121569. */
  121570. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121571. /**
  121572. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  121573. * @param renderingGroupId The rendering group id corresponding to its index
  121574. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121575. */
  121576. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  121577. /**
  121578. * Clean all associated resources
  121579. */
  121580. dispose(): void;
  121581. /**
  121582. * Converts the reflection probe information to a readable string for debug purpose.
  121583. * @param fullDetails Supports for multiple levels of logging within scene loading
  121584. * @returns the human readable reflection probe info
  121585. */
  121586. toString(fullDetails?: boolean): string;
  121587. /**
  121588. * Get the class name of the relfection probe.
  121589. * @returns "ReflectionProbe"
  121590. */
  121591. getClassName(): string;
  121592. /**
  121593. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  121594. * @returns The JSON representation of the texture
  121595. */
  121596. serialize(): any;
  121597. /**
  121598. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  121599. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  121600. * @param scene Define the scene the parsed reflection probe should be instantiated in
  121601. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  121602. * @returns The parsed reflection probe if successful
  121603. */
  121604. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  121605. }
  121606. }
  121607. declare module BABYLON {
  121608. /** @hidden */
  121609. export var _BabylonLoaderRegistered: boolean;
  121610. /**
  121611. * Helps setting up some configuration for the babylon file loader.
  121612. */
  121613. export class BabylonFileLoaderConfiguration {
  121614. /**
  121615. * The loader does not allow injecting custom physix engine into the plugins.
  121616. * Unfortunately in ES6, we need to manually inject them into the plugin.
  121617. * So you could set this variable to your engine import to make it work.
  121618. */
  121619. static LoaderInjectedPhysicsEngine: any;
  121620. }
  121621. }
  121622. declare module BABYLON {
  121623. /**
  121624. * The Physically based simple base material of BJS.
  121625. *
  121626. * This enables better naming and convention enforcements on top of the pbrMaterial.
  121627. * It is used as the base class for both the specGloss and metalRough conventions.
  121628. */
  121629. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  121630. /**
  121631. * Number of Simultaneous lights allowed on the material.
  121632. */
  121633. maxSimultaneousLights: number;
  121634. /**
  121635. * If sets to true, disables all the lights affecting the material.
  121636. */
  121637. disableLighting: boolean;
  121638. /**
  121639. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  121640. */
  121641. environmentTexture: BaseTexture;
  121642. /**
  121643. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121644. */
  121645. invertNormalMapX: boolean;
  121646. /**
  121647. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121648. */
  121649. invertNormalMapY: boolean;
  121650. /**
  121651. * Normal map used in the model.
  121652. */
  121653. normalTexture: BaseTexture;
  121654. /**
  121655. * Emissivie color used to self-illuminate the model.
  121656. */
  121657. emissiveColor: Color3;
  121658. /**
  121659. * Emissivie texture used to self-illuminate the model.
  121660. */
  121661. emissiveTexture: BaseTexture;
  121662. /**
  121663. * Occlusion Channel Strenght.
  121664. */
  121665. occlusionStrength: number;
  121666. /**
  121667. * Occlusion Texture of the material (adding extra occlusion effects).
  121668. */
  121669. occlusionTexture: BaseTexture;
  121670. /**
  121671. * Defines the alpha limits in alpha test mode.
  121672. */
  121673. alphaCutOff: number;
  121674. /**
  121675. * Gets the current double sided mode.
  121676. */
  121677. /**
  121678. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121679. */
  121680. doubleSided: boolean;
  121681. /**
  121682. * Stores the pre-calculated light information of a mesh in a texture.
  121683. */
  121684. lightmapTexture: BaseTexture;
  121685. /**
  121686. * If true, the light map contains occlusion information instead of lighting info.
  121687. */
  121688. useLightmapAsShadowmap: boolean;
  121689. /**
  121690. * Instantiates a new PBRMaterial instance.
  121691. *
  121692. * @param name The material name
  121693. * @param scene The scene the material will be use in.
  121694. */
  121695. constructor(name: string, scene: Scene);
  121696. getClassName(): string;
  121697. }
  121698. }
  121699. declare module BABYLON {
  121700. /**
  121701. * The PBR material of BJS following the metal roughness convention.
  121702. *
  121703. * This fits to the PBR convention in the GLTF definition:
  121704. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  121705. */
  121706. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  121707. /**
  121708. * The base color has two different interpretations depending on the value of metalness.
  121709. * When the material is a metal, the base color is the specific measured reflectance value
  121710. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  121711. * of the material.
  121712. */
  121713. baseColor: Color3;
  121714. /**
  121715. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  121716. * well as opacity information in the alpha channel.
  121717. */
  121718. baseTexture: BaseTexture;
  121719. /**
  121720. * Specifies the metallic scalar value of the material.
  121721. * Can also be used to scale the metalness values of the metallic texture.
  121722. */
  121723. metallic: number;
  121724. /**
  121725. * Specifies the roughness scalar value of the material.
  121726. * Can also be used to scale the roughness values of the metallic texture.
  121727. */
  121728. roughness: number;
  121729. /**
  121730. * Texture containing both the metallic value in the B channel and the
  121731. * roughness value in the G channel to keep better precision.
  121732. */
  121733. metallicRoughnessTexture: BaseTexture;
  121734. /**
  121735. * Instantiates a new PBRMetalRoughnessMaterial instance.
  121736. *
  121737. * @param name The material name
  121738. * @param scene The scene the material will be use in.
  121739. */
  121740. constructor(name: string, scene: Scene);
  121741. /**
  121742. * Return the currrent class name of the material.
  121743. */
  121744. getClassName(): string;
  121745. /**
  121746. * Makes a duplicate of the current material.
  121747. * @param name - name to use for the new material.
  121748. */
  121749. clone(name: string): PBRMetallicRoughnessMaterial;
  121750. /**
  121751. * Serialize the material to a parsable JSON object.
  121752. */
  121753. serialize(): any;
  121754. /**
  121755. * Parses a JSON object correponding to the serialize function.
  121756. */
  121757. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  121758. }
  121759. }
  121760. declare module BABYLON {
  121761. /**
  121762. * The PBR material of BJS following the specular glossiness convention.
  121763. *
  121764. * This fits to the PBR convention in the GLTF definition:
  121765. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  121766. */
  121767. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  121768. /**
  121769. * Specifies the diffuse color of the material.
  121770. */
  121771. diffuseColor: Color3;
  121772. /**
  121773. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  121774. * channel.
  121775. */
  121776. diffuseTexture: BaseTexture;
  121777. /**
  121778. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  121779. */
  121780. specularColor: Color3;
  121781. /**
  121782. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  121783. */
  121784. glossiness: number;
  121785. /**
  121786. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  121787. */
  121788. specularGlossinessTexture: BaseTexture;
  121789. /**
  121790. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  121791. *
  121792. * @param name The material name
  121793. * @param scene The scene the material will be use in.
  121794. */
  121795. constructor(name: string, scene: Scene);
  121796. /**
  121797. * Return the currrent class name of the material.
  121798. */
  121799. getClassName(): string;
  121800. /**
  121801. * Makes a duplicate of the current material.
  121802. * @param name - name to use for the new material.
  121803. */
  121804. clone(name: string): PBRSpecularGlossinessMaterial;
  121805. /**
  121806. * Serialize the material to a parsable JSON object.
  121807. */
  121808. serialize(): any;
  121809. /**
  121810. * Parses a JSON object correponding to the serialize function.
  121811. */
  121812. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  121813. }
  121814. }
  121815. declare module BABYLON {
  121816. /**
  121817. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  121818. * It can help converting any input color in a desired output one. This can then be used to create effects
  121819. * from sepia, black and white to sixties or futuristic rendering...
  121820. *
  121821. * The only supported format is currently 3dl.
  121822. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  121823. */
  121824. export class ColorGradingTexture extends BaseTexture {
  121825. /**
  121826. * The current texture matrix. (will always be identity in color grading texture)
  121827. */
  121828. private _textureMatrix;
  121829. /**
  121830. * The texture URL.
  121831. */
  121832. url: string;
  121833. /**
  121834. * Empty line regex stored for GC.
  121835. */
  121836. private static _noneEmptyLineRegex;
  121837. private _engine;
  121838. /**
  121839. * Instantiates a ColorGradingTexture from the following parameters.
  121840. *
  121841. * @param url The location of the color gradind data (currently only supporting 3dl)
  121842. * @param scene The scene the texture will be used in
  121843. */
  121844. constructor(url: string, scene: Scene);
  121845. /**
  121846. * Returns the texture matrix used in most of the material.
  121847. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  121848. */
  121849. getTextureMatrix(): Matrix;
  121850. /**
  121851. * Occurs when the file being loaded is a .3dl LUT file.
  121852. */
  121853. private load3dlTexture;
  121854. /**
  121855. * Starts the loading process of the texture.
  121856. */
  121857. private loadTexture;
  121858. /**
  121859. * Clones the color gradind texture.
  121860. */
  121861. clone(): ColorGradingTexture;
  121862. /**
  121863. * Called during delayed load for textures.
  121864. */
  121865. delayLoad(): void;
  121866. /**
  121867. * Parses a color grading texture serialized by Babylon.
  121868. * @param parsedTexture The texture information being parsedTexture
  121869. * @param scene The scene to load the texture in
  121870. * @param rootUrl The root url of the data assets to load
  121871. * @return A color gradind texture
  121872. */
  121873. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  121874. /**
  121875. * Serializes the LUT texture to json format.
  121876. */
  121877. serialize(): any;
  121878. }
  121879. }
  121880. declare module BABYLON {
  121881. /**
  121882. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  121883. */
  121884. export class EquiRectangularCubeTexture extends BaseTexture {
  121885. /** The six faces of the cube. */
  121886. private static _FacesMapping;
  121887. private _noMipmap;
  121888. private _onLoad;
  121889. private _onError;
  121890. /** The size of the cubemap. */
  121891. private _size;
  121892. /** The buffer of the image. */
  121893. private _buffer;
  121894. /** The width of the input image. */
  121895. private _width;
  121896. /** The height of the input image. */
  121897. private _height;
  121898. /** The URL to the image. */
  121899. url: string;
  121900. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  121901. coordinatesMode: number;
  121902. /**
  121903. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  121904. * @param url The location of the image
  121905. * @param scene The scene the texture will be used in
  121906. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  121907. * @param noMipmap Forces to not generate the mipmap if true
  121908. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121909. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121910. * @param onLoad — defines a callback called when texture is loaded
  121911. * @param onError — defines a callback called if there is an error
  121912. */
  121913. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  121914. /**
  121915. * Load the image data, by putting the image on a canvas and extracting its buffer.
  121916. */
  121917. private loadImage;
  121918. /**
  121919. * Convert the image buffer into a cubemap and create a CubeTexture.
  121920. */
  121921. private loadTexture;
  121922. /**
  121923. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  121924. * @param buffer The ArrayBuffer that should be converted.
  121925. * @returns The buffer as Float32Array.
  121926. */
  121927. private getFloat32ArrayFromArrayBuffer;
  121928. /**
  121929. * Get the current class name of the texture useful for serialization or dynamic coding.
  121930. * @returns "EquiRectangularCubeTexture"
  121931. */
  121932. getClassName(): string;
  121933. /**
  121934. * Create a clone of the current EquiRectangularCubeTexture and return it.
  121935. * @returns A clone of the current EquiRectangularCubeTexture.
  121936. */
  121937. clone(): EquiRectangularCubeTexture;
  121938. }
  121939. }
  121940. declare module BABYLON {
  121941. /**
  121942. * Based on jsTGALoader - Javascript loader for TGA file
  121943. * By Vincent Thibault
  121944. * @see http://blog.robrowser.com/javascript-tga-loader.html
  121945. */
  121946. export class TGATools {
  121947. private static _TYPE_INDEXED;
  121948. private static _TYPE_RGB;
  121949. private static _TYPE_GREY;
  121950. private static _TYPE_RLE_INDEXED;
  121951. private static _TYPE_RLE_RGB;
  121952. private static _TYPE_RLE_GREY;
  121953. private static _ORIGIN_MASK;
  121954. private static _ORIGIN_SHIFT;
  121955. private static _ORIGIN_BL;
  121956. private static _ORIGIN_BR;
  121957. private static _ORIGIN_UL;
  121958. private static _ORIGIN_UR;
  121959. /**
  121960. * Gets the header of a TGA file
  121961. * @param data defines the TGA data
  121962. * @returns the header
  121963. */
  121964. static GetTGAHeader(data: Uint8Array): any;
  121965. /**
  121966. * Uploads TGA content to a Babylon Texture
  121967. * @hidden
  121968. */
  121969. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  121970. /** @hidden */
  121971. 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;
  121972. /** @hidden */
  121973. 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;
  121974. /** @hidden */
  121975. 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;
  121976. /** @hidden */
  121977. 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;
  121978. /** @hidden */
  121979. 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;
  121980. /** @hidden */
  121981. 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;
  121982. }
  121983. }
  121984. declare module BABYLON {
  121985. /**
  121986. * Implementation of the TGA Texture Loader.
  121987. * @hidden
  121988. */
  121989. export class _TGATextureLoader implements IInternalTextureLoader {
  121990. /**
  121991. * Defines wether the loader supports cascade loading the different faces.
  121992. */
  121993. readonly supportCascades: boolean;
  121994. /**
  121995. * This returns if the loader support the current file information.
  121996. * @param extension defines the file extension of the file being loaded
  121997. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121998. * @param fallback defines the fallback internal texture if any
  121999. * @param isBase64 defines whether the texture is encoded as a base64
  122000. * @param isBuffer defines whether the texture data are stored as a buffer
  122001. * @returns true if the loader can load the specified file
  122002. */
  122003. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122004. /**
  122005. * Transform the url before loading if required.
  122006. * @param rootUrl the url of the texture
  122007. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122008. * @returns the transformed texture
  122009. */
  122010. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122011. /**
  122012. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122013. * @param rootUrl the url of the texture
  122014. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122015. * @returns the fallback texture
  122016. */
  122017. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122018. /**
  122019. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  122020. * @param data contains the texture data
  122021. * @param texture defines the BabylonJS internal texture
  122022. * @param createPolynomials will be true if polynomials have been requested
  122023. * @param onLoad defines the callback to trigger once the texture is ready
  122024. * @param onError defines the callback to trigger in case of error
  122025. */
  122026. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122027. /**
  122028. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122029. * @param data contains the texture data
  122030. * @param texture defines the BabylonJS internal texture
  122031. * @param callback defines the method to call once ready to upload
  122032. */
  122033. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122034. }
  122035. }
  122036. declare module BABYLON {
  122037. /**
  122038. * Info about the .basis files
  122039. */
  122040. class BasisFileInfo {
  122041. /**
  122042. * If the file has alpha
  122043. */
  122044. hasAlpha: boolean;
  122045. /**
  122046. * Info about each image of the basis file
  122047. */
  122048. images: Array<{
  122049. levels: Array<{
  122050. width: number;
  122051. height: number;
  122052. transcodedPixels: ArrayBufferView;
  122053. }>;
  122054. }>;
  122055. }
  122056. /**
  122057. * Result of transcoding a basis file
  122058. */
  122059. class TranscodeResult {
  122060. /**
  122061. * Info about the .basis file
  122062. */
  122063. fileInfo: BasisFileInfo;
  122064. /**
  122065. * Format to use when loading the file
  122066. */
  122067. format: number;
  122068. }
  122069. /**
  122070. * Configuration options for the Basis transcoder
  122071. */
  122072. export class BasisTranscodeConfiguration {
  122073. /**
  122074. * Supported compression formats used to determine the supported output format of the transcoder
  122075. */
  122076. supportedCompressionFormats?: {
  122077. /**
  122078. * etc1 compression format
  122079. */
  122080. etc1?: boolean;
  122081. /**
  122082. * s3tc compression format
  122083. */
  122084. s3tc?: boolean;
  122085. /**
  122086. * pvrtc compression format
  122087. */
  122088. pvrtc?: boolean;
  122089. /**
  122090. * etc2 compression format
  122091. */
  122092. etc2?: boolean;
  122093. };
  122094. /**
  122095. * If mipmap levels should be loaded for transcoded images (Default: true)
  122096. */
  122097. loadMipmapLevels?: boolean;
  122098. /**
  122099. * Index of a single image to load (Default: all images)
  122100. */
  122101. loadSingleImage?: number;
  122102. }
  122103. /**
  122104. * Used to load .Basis files
  122105. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  122106. */
  122107. export class BasisTools {
  122108. private static _IgnoreSupportedFormats;
  122109. /**
  122110. * URL to use when loading the basis transcoder
  122111. */
  122112. static JSModuleURL: string;
  122113. /**
  122114. * URL to use when loading the wasm module for the transcoder
  122115. */
  122116. static WasmModuleURL: string;
  122117. /**
  122118. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  122119. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  122120. * @returns internal format corresponding to the Basis format
  122121. */
  122122. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  122123. private static _WorkerPromise;
  122124. private static _Worker;
  122125. private static _actionId;
  122126. private static _CreateWorkerAsync;
  122127. /**
  122128. * Transcodes a loaded image file to compressed pixel data
  122129. * @param imageData image data to transcode
  122130. * @param config configuration options for the transcoding
  122131. * @returns a promise resulting in the transcoded image
  122132. */
  122133. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  122134. /**
  122135. * Loads a texture from the transcode result
  122136. * @param texture texture load to
  122137. * @param transcodeResult the result of transcoding the basis file to load from
  122138. */
  122139. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  122140. }
  122141. }
  122142. declare module BABYLON {
  122143. /**
  122144. * Loader for .basis file format
  122145. */
  122146. export class _BasisTextureLoader implements IInternalTextureLoader {
  122147. /**
  122148. * Defines whether the loader supports cascade loading the different faces.
  122149. */
  122150. readonly supportCascades: boolean;
  122151. /**
  122152. * This returns if the loader support the current file information.
  122153. * @param extension defines the file extension of the file being loaded
  122154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122155. * @param fallback defines the fallback internal texture if any
  122156. * @param isBase64 defines whether the texture is encoded as a base64
  122157. * @param isBuffer defines whether the texture data are stored as a buffer
  122158. * @returns true if the loader can load the specified file
  122159. */
  122160. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122161. /**
  122162. * Transform the url before loading if required.
  122163. * @param rootUrl the url of the texture
  122164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122165. * @returns the transformed texture
  122166. */
  122167. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122168. /**
  122169. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122170. * @param rootUrl the url of the texture
  122171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122172. * @returns the fallback texture
  122173. */
  122174. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122175. /**
  122176. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  122177. * @param data contains the texture data
  122178. * @param texture defines the BabylonJS internal texture
  122179. * @param createPolynomials will be true if polynomials have been requested
  122180. * @param onLoad defines the callback to trigger once the texture is ready
  122181. * @param onError defines the callback to trigger in case of error
  122182. */
  122183. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122184. /**
  122185. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122186. * @param data contains the texture data
  122187. * @param texture defines the BabylonJS internal texture
  122188. * @param callback defines the method to call once ready to upload
  122189. */
  122190. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122191. }
  122192. }
  122193. declare module BABYLON {
  122194. /**
  122195. * 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.
  122196. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122197. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122198. */
  122199. export class CustomProceduralTexture extends ProceduralTexture {
  122200. private _animate;
  122201. private _time;
  122202. private _config;
  122203. private _texturePath;
  122204. /**
  122205. * Instantiates a new Custom Procedural Texture.
  122206. * 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.
  122207. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122208. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122209. * @param name Define the name of the texture
  122210. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  122211. * @param size Define the size of the texture to create
  122212. * @param scene Define the scene the texture belongs to
  122213. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  122214. * @param generateMipMaps Define if the texture should creates mip maps or not
  122215. */
  122216. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122217. private _loadJson;
  122218. /**
  122219. * Is the texture ready to be used ? (rendered at least once)
  122220. * @returns true if ready, otherwise, false.
  122221. */
  122222. isReady(): boolean;
  122223. /**
  122224. * Render the texture to its associated render target.
  122225. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  122226. */
  122227. render(useCameraPostProcess?: boolean): void;
  122228. /**
  122229. * Update the list of dependant textures samplers in the shader.
  122230. */
  122231. updateTextures(): void;
  122232. /**
  122233. * Update the uniform values of the procedural texture in the shader.
  122234. */
  122235. updateShaderUniforms(): void;
  122236. /**
  122237. * Define if the texture animates or not.
  122238. */
  122239. animate: boolean;
  122240. }
  122241. }
  122242. declare module BABYLON {
  122243. /** @hidden */
  122244. export var noisePixelShader: {
  122245. name: string;
  122246. shader: string;
  122247. };
  122248. }
  122249. declare module BABYLON {
  122250. /**
  122251. * Class used to generate noise procedural textures
  122252. */
  122253. export class NoiseProceduralTexture extends ProceduralTexture {
  122254. private _time;
  122255. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  122256. brightness: number;
  122257. /** Defines the number of octaves to process */
  122258. octaves: number;
  122259. /** Defines the level of persistence (0.8 by default) */
  122260. persistence: number;
  122261. /** Gets or sets animation speed factor (default is 1) */
  122262. animationSpeedFactor: number;
  122263. /**
  122264. * Creates a new NoiseProceduralTexture
  122265. * @param name defines the name fo the texture
  122266. * @param size defines the size of the texture (default is 256)
  122267. * @param scene defines the hosting scene
  122268. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  122269. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  122270. */
  122271. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122272. private _updateShaderUniforms;
  122273. protected _getDefines(): string;
  122274. /** Generate the current state of the procedural texture */
  122275. render(useCameraPostProcess?: boolean): void;
  122276. /**
  122277. * Serializes this noise procedural texture
  122278. * @returns a serialized noise procedural texture object
  122279. */
  122280. serialize(): any;
  122281. /**
  122282. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  122283. * @param parsedTexture defines parsed texture data
  122284. * @param scene defines the current scene
  122285. * @param rootUrl defines the root URL containing noise procedural texture information
  122286. * @returns a parsed NoiseProceduralTexture
  122287. */
  122288. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  122289. }
  122290. }
  122291. declare module BABYLON {
  122292. /**
  122293. * Raw cube texture where the raw buffers are passed in
  122294. */
  122295. export class RawCubeTexture extends CubeTexture {
  122296. /**
  122297. * Creates a cube texture where the raw buffers are passed in.
  122298. * @param scene defines the scene the texture is attached to
  122299. * @param data defines the array of data to use to create each face
  122300. * @param size defines the size of the textures
  122301. * @param format defines the format of the data
  122302. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  122303. * @param generateMipMaps defines if the engine should generate the mip levels
  122304. * @param invertY defines if data must be stored with Y axis inverted
  122305. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  122306. * @param compression defines the compression used (null by default)
  122307. */
  122308. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  122309. /**
  122310. * Updates the raw cube texture.
  122311. * @param data defines the data to store
  122312. * @param format defines the data format
  122313. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122314. * @param invertY defines if data must be stored with Y axis inverted
  122315. * @param compression defines the compression used (null by default)
  122316. * @param level defines which level of the texture to update
  122317. */
  122318. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  122319. /**
  122320. * Updates a raw cube texture with RGBD encoded data.
  122321. * @param data defines the array of data [mipmap][face] to use to create each face
  122322. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  122323. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122324. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122325. * @returns a promsie that resolves when the operation is complete
  122326. */
  122327. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  122328. /**
  122329. * Clones the raw cube texture.
  122330. * @return a new cube texture
  122331. */
  122332. clone(): CubeTexture;
  122333. /** @hidden */
  122334. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122335. }
  122336. }
  122337. declare module BABYLON {
  122338. /**
  122339. * Class used to store 3D textures containing user data
  122340. */
  122341. export class RawTexture3D extends Texture {
  122342. /** Gets or sets the texture format to use */
  122343. format: number;
  122344. private _engine;
  122345. /**
  122346. * Create a new RawTexture3D
  122347. * @param data defines the data of the texture
  122348. * @param width defines the width of the texture
  122349. * @param height defines the height of the texture
  122350. * @param depth defines the depth of the texture
  122351. * @param format defines the texture format to use
  122352. * @param scene defines the hosting scene
  122353. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122354. * @param invertY defines if texture must be stored with Y axis inverted
  122355. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122356. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122357. */
  122358. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122359. /** Gets or sets the texture format to use */
  122360. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122361. /**
  122362. * Update the texture with new data
  122363. * @param data defines the data to store in the texture
  122364. */
  122365. update(data: ArrayBufferView): void;
  122366. }
  122367. }
  122368. declare module BABYLON {
  122369. /**
  122370. * Class used to store 2D array textures containing user data
  122371. */
  122372. export class RawTexture2DArray extends Texture {
  122373. /** Gets or sets the texture format to use */
  122374. format: number;
  122375. private _engine;
  122376. /**
  122377. * Create a new RawTexture2DArray
  122378. * @param data defines the data of the texture
  122379. * @param width defines the width of the texture
  122380. * @param height defines the height of the texture
  122381. * @param depth defines the number of layers of the texture
  122382. * @param format defines the texture format to use
  122383. * @param scene defines the hosting scene
  122384. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122385. * @param invertY defines if texture must be stored with Y axis inverted
  122386. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122387. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122388. */
  122389. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122390. /** Gets or sets the texture format to use */
  122391. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122392. /**
  122393. * Update the texture with new data
  122394. * @param data defines the data to store in the texture
  122395. */
  122396. update(data: ArrayBufferView): void;
  122397. }
  122398. }
  122399. declare module BABYLON {
  122400. /**
  122401. * Creates a refraction texture used by refraction channel of the standard material.
  122402. * It is like a mirror but to see through a material.
  122403. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122404. */
  122405. export class RefractionTexture extends RenderTargetTexture {
  122406. /**
  122407. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  122408. * 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.
  122409. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122410. */
  122411. refractionPlane: Plane;
  122412. /**
  122413. * Define how deep under the surface we should see.
  122414. */
  122415. depth: number;
  122416. /**
  122417. * Creates a refraction texture used by refraction channel of the standard material.
  122418. * It is like a mirror but to see through a material.
  122419. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122420. * @param name Define the texture name
  122421. * @param size Define the size of the underlying texture
  122422. * @param scene Define the scene the refraction belongs to
  122423. * @param generateMipMaps Define if we need to generate mips level for the refraction
  122424. */
  122425. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  122426. /**
  122427. * Clone the refraction texture.
  122428. * @returns the cloned texture
  122429. */
  122430. clone(): RefractionTexture;
  122431. /**
  122432. * Serialize the texture to a JSON representation you could use in Parse later on
  122433. * @returns the serialized JSON representation
  122434. */
  122435. serialize(): any;
  122436. }
  122437. }
  122438. declare module BABYLON {
  122439. /**
  122440. * Defines the options related to the creation of an HtmlElementTexture
  122441. */
  122442. export interface IHtmlElementTextureOptions {
  122443. /**
  122444. * Defines wether mip maps should be created or not.
  122445. */
  122446. generateMipMaps?: boolean;
  122447. /**
  122448. * Defines the sampling mode of the texture.
  122449. */
  122450. samplingMode?: number;
  122451. /**
  122452. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  122453. */
  122454. engine: Nullable<ThinEngine>;
  122455. /**
  122456. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  122457. */
  122458. scene: Nullable<Scene>;
  122459. }
  122460. /**
  122461. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  122462. * To be as efficient as possible depending on your constraints nothing aside the first upload
  122463. * is automatically managed.
  122464. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  122465. * in your application.
  122466. *
  122467. * As the update is not automatic, you need to call them manually.
  122468. */
  122469. export class HtmlElementTexture extends BaseTexture {
  122470. /**
  122471. * The texture URL.
  122472. */
  122473. element: HTMLVideoElement | HTMLCanvasElement;
  122474. private static readonly DefaultOptions;
  122475. private _textureMatrix;
  122476. private _engine;
  122477. private _isVideo;
  122478. private _generateMipMaps;
  122479. private _samplingMode;
  122480. /**
  122481. * Instantiates a HtmlElementTexture from the following parameters.
  122482. *
  122483. * @param name Defines the name of the texture
  122484. * @param element Defines the video or canvas the texture is filled with
  122485. * @param options Defines the other none mandatory texture creation options
  122486. */
  122487. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  122488. private _createInternalTexture;
  122489. /**
  122490. * Returns the texture matrix used in most of the material.
  122491. */
  122492. getTextureMatrix(): Matrix;
  122493. /**
  122494. * Updates the content of the texture.
  122495. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  122496. */
  122497. update(invertY?: Nullable<boolean>): void;
  122498. }
  122499. }
  122500. declare module BABYLON {
  122501. /**
  122502. * Enum used to define the target of a block
  122503. */
  122504. export enum NodeMaterialBlockTargets {
  122505. /** Vertex shader */
  122506. Vertex = 1,
  122507. /** Fragment shader */
  122508. Fragment = 2,
  122509. /** Neutral */
  122510. Neutral = 4,
  122511. /** Vertex and Fragment */
  122512. VertexAndFragment = 3
  122513. }
  122514. }
  122515. declare module BABYLON {
  122516. /**
  122517. * Defines the kind of connection point for node based material
  122518. */
  122519. export enum NodeMaterialBlockConnectionPointTypes {
  122520. /** Float */
  122521. Float = 1,
  122522. /** Int */
  122523. Int = 2,
  122524. /** Vector2 */
  122525. Vector2 = 4,
  122526. /** Vector3 */
  122527. Vector3 = 8,
  122528. /** Vector4 */
  122529. Vector4 = 16,
  122530. /** Color3 */
  122531. Color3 = 32,
  122532. /** Color4 */
  122533. Color4 = 64,
  122534. /** Matrix */
  122535. Matrix = 128,
  122536. /** Detect type based on connection */
  122537. AutoDetect = 1024,
  122538. /** Output type that will be defined by input type */
  122539. BasedOnInput = 2048
  122540. }
  122541. }
  122542. declare module BABYLON {
  122543. /**
  122544. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  122545. */
  122546. export enum NodeMaterialBlockConnectionPointMode {
  122547. /** Value is an uniform */
  122548. Uniform = 0,
  122549. /** Value is a mesh attribute */
  122550. Attribute = 1,
  122551. /** Value is a varying between vertex and fragment shaders */
  122552. Varying = 2,
  122553. /** Mode is undefined */
  122554. Undefined = 3
  122555. }
  122556. }
  122557. declare module BABYLON {
  122558. /**
  122559. * Enum used to define system values e.g. values automatically provided by the system
  122560. */
  122561. export enum NodeMaterialSystemValues {
  122562. /** World */
  122563. World = 1,
  122564. /** View */
  122565. View = 2,
  122566. /** Projection */
  122567. Projection = 3,
  122568. /** ViewProjection */
  122569. ViewProjection = 4,
  122570. /** WorldView */
  122571. WorldView = 5,
  122572. /** WorldViewProjection */
  122573. WorldViewProjection = 6,
  122574. /** CameraPosition */
  122575. CameraPosition = 7,
  122576. /** Fog Color */
  122577. FogColor = 8,
  122578. /** Delta time */
  122579. DeltaTime = 9
  122580. }
  122581. }
  122582. declare module BABYLON {
  122583. /**
  122584. * Root class for all node material optimizers
  122585. */
  122586. export class NodeMaterialOptimizer {
  122587. /**
  122588. * Function used to optimize a NodeMaterial graph
  122589. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  122590. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  122591. */
  122592. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  122593. }
  122594. }
  122595. declare module BABYLON {
  122596. /**
  122597. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  122598. */
  122599. export class TransformBlock extends NodeMaterialBlock {
  122600. /**
  122601. * Defines the value to use to complement W value to transform it to a Vector4
  122602. */
  122603. complementW: number;
  122604. /**
  122605. * Defines the value to use to complement z value to transform it to a Vector4
  122606. */
  122607. complementZ: number;
  122608. /**
  122609. * Creates a new TransformBlock
  122610. * @param name defines the block name
  122611. */
  122612. constructor(name: string);
  122613. /**
  122614. * Gets the current class name
  122615. * @returns the class name
  122616. */
  122617. getClassName(): string;
  122618. /**
  122619. * Gets the vector input
  122620. */
  122621. readonly vector: NodeMaterialConnectionPoint;
  122622. /**
  122623. * Gets the output component
  122624. */
  122625. readonly output: NodeMaterialConnectionPoint;
  122626. /**
  122627. * Gets the matrix transform input
  122628. */
  122629. readonly transform: NodeMaterialConnectionPoint;
  122630. protected _buildBlock(state: NodeMaterialBuildState): this;
  122631. serialize(): any;
  122632. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122633. protected _dumpPropertiesCode(): string;
  122634. }
  122635. }
  122636. declare module BABYLON {
  122637. /**
  122638. * Block used to output the vertex position
  122639. */
  122640. export class VertexOutputBlock extends NodeMaterialBlock {
  122641. /**
  122642. * Creates a new VertexOutputBlock
  122643. * @param name defines the block name
  122644. */
  122645. constructor(name: string);
  122646. /**
  122647. * Gets the current class name
  122648. * @returns the class name
  122649. */
  122650. getClassName(): string;
  122651. /**
  122652. * Gets the vector input component
  122653. */
  122654. readonly vector: NodeMaterialConnectionPoint;
  122655. protected _buildBlock(state: NodeMaterialBuildState): this;
  122656. }
  122657. }
  122658. declare module BABYLON {
  122659. /**
  122660. * Block used to output the final color
  122661. */
  122662. export class FragmentOutputBlock extends NodeMaterialBlock {
  122663. /**
  122664. * Create a new FragmentOutputBlock
  122665. * @param name defines the block name
  122666. */
  122667. constructor(name: string);
  122668. /**
  122669. * Gets the current class name
  122670. * @returns the class name
  122671. */
  122672. getClassName(): string;
  122673. /**
  122674. * Gets the rgba input component
  122675. */
  122676. readonly rgba: NodeMaterialConnectionPoint;
  122677. /**
  122678. * Gets the rgb input component
  122679. */
  122680. readonly rgb: NodeMaterialConnectionPoint;
  122681. /**
  122682. * Gets the a input component
  122683. */
  122684. readonly a: NodeMaterialConnectionPoint;
  122685. protected _buildBlock(state: NodeMaterialBuildState): this;
  122686. }
  122687. }
  122688. declare module BABYLON {
  122689. /**
  122690. * Block used to read a reflection texture from a sampler
  122691. */
  122692. export class ReflectionTextureBlock extends NodeMaterialBlock {
  122693. private _define3DName;
  122694. private _defineCubicName;
  122695. private _defineExplicitName;
  122696. private _defineProjectionName;
  122697. private _defineLocalCubicName;
  122698. private _defineSphericalName;
  122699. private _definePlanarName;
  122700. private _defineEquirectangularName;
  122701. private _defineMirroredEquirectangularFixedName;
  122702. private _defineEquirectangularFixedName;
  122703. private _defineSkyboxName;
  122704. private _cubeSamplerName;
  122705. private _2DSamplerName;
  122706. private _positionUVWName;
  122707. private _directionWName;
  122708. private _reflectionCoordsName;
  122709. private _reflection2DCoordsName;
  122710. private _reflectionColorName;
  122711. private _reflectionMatrixName;
  122712. /**
  122713. * Gets or sets the texture associated with the node
  122714. */
  122715. texture: Nullable<BaseTexture>;
  122716. /**
  122717. * Create a new TextureBlock
  122718. * @param name defines the block name
  122719. */
  122720. constructor(name: string);
  122721. /**
  122722. * Gets the current class name
  122723. * @returns the class name
  122724. */
  122725. getClassName(): string;
  122726. /**
  122727. * Gets the world position input component
  122728. */
  122729. readonly position: NodeMaterialConnectionPoint;
  122730. /**
  122731. * Gets the world position input component
  122732. */
  122733. readonly worldPosition: NodeMaterialConnectionPoint;
  122734. /**
  122735. * Gets the world normal input component
  122736. */
  122737. readonly worldNormal: NodeMaterialConnectionPoint;
  122738. /**
  122739. * Gets the world input component
  122740. */
  122741. readonly world: NodeMaterialConnectionPoint;
  122742. /**
  122743. * Gets the camera (or eye) position component
  122744. */
  122745. readonly cameraPosition: NodeMaterialConnectionPoint;
  122746. /**
  122747. * Gets the view input component
  122748. */
  122749. readonly view: NodeMaterialConnectionPoint;
  122750. /**
  122751. * Gets the rgb output component
  122752. */
  122753. readonly rgb: NodeMaterialConnectionPoint;
  122754. /**
  122755. * Gets the r output component
  122756. */
  122757. readonly r: NodeMaterialConnectionPoint;
  122758. /**
  122759. * Gets the g output component
  122760. */
  122761. readonly g: NodeMaterialConnectionPoint;
  122762. /**
  122763. * Gets the b output component
  122764. */
  122765. readonly b: NodeMaterialConnectionPoint;
  122766. autoConfigure(material: NodeMaterial): void;
  122767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122768. isReady(): boolean;
  122769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122770. private _injectVertexCode;
  122771. private _writeOutput;
  122772. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122773. protected _dumpPropertiesCode(): string;
  122774. serialize(): any;
  122775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122776. }
  122777. }
  122778. declare module BABYLON {
  122779. /**
  122780. * Interface used to configure the node material editor
  122781. */
  122782. export interface INodeMaterialEditorOptions {
  122783. /** Define the URl to load node editor script */
  122784. editorURL?: string;
  122785. }
  122786. /** @hidden */
  122787. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  122788. /** BONES */
  122789. NUM_BONE_INFLUENCERS: number;
  122790. BonesPerMesh: number;
  122791. BONETEXTURE: boolean;
  122792. /** MORPH TARGETS */
  122793. MORPHTARGETS: boolean;
  122794. MORPHTARGETS_NORMAL: boolean;
  122795. MORPHTARGETS_TANGENT: boolean;
  122796. MORPHTARGETS_UV: boolean;
  122797. NUM_MORPH_INFLUENCERS: number;
  122798. /** IMAGE PROCESSING */
  122799. IMAGEPROCESSING: boolean;
  122800. VIGNETTE: boolean;
  122801. VIGNETTEBLENDMODEMULTIPLY: boolean;
  122802. VIGNETTEBLENDMODEOPAQUE: boolean;
  122803. TONEMAPPING: boolean;
  122804. TONEMAPPING_ACES: boolean;
  122805. CONTRAST: boolean;
  122806. EXPOSURE: boolean;
  122807. COLORCURVES: boolean;
  122808. COLORGRADING: boolean;
  122809. COLORGRADING3D: boolean;
  122810. SAMPLER3DGREENDEPTH: boolean;
  122811. SAMPLER3DBGRMAP: boolean;
  122812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  122813. /** MISC. */
  122814. BUMPDIRECTUV: number;
  122815. constructor();
  122816. setValue(name: string, value: boolean): void;
  122817. }
  122818. /**
  122819. * Class used to configure NodeMaterial
  122820. */
  122821. export interface INodeMaterialOptions {
  122822. /**
  122823. * Defines if blocks should emit comments
  122824. */
  122825. emitComments: boolean;
  122826. }
  122827. /**
  122828. * Class used to create a node based material built by assembling shader blocks
  122829. */
  122830. export class NodeMaterial extends PushMaterial {
  122831. private static _BuildIdGenerator;
  122832. private _options;
  122833. private _vertexCompilationState;
  122834. private _fragmentCompilationState;
  122835. private _sharedData;
  122836. private _buildId;
  122837. private _buildWasSuccessful;
  122838. private _cachedWorldViewMatrix;
  122839. private _cachedWorldViewProjectionMatrix;
  122840. private _optimizers;
  122841. private _animationFrame;
  122842. /** Define the URl to load node editor script */
  122843. static EditorURL: string;
  122844. private BJSNODEMATERIALEDITOR;
  122845. /** Get the inspector from bundle or global */
  122846. private _getGlobalNodeMaterialEditor;
  122847. /**
  122848. * Gets or sets data used by visual editor
  122849. * @see https://nme.babylonjs.com
  122850. */
  122851. editorData: any;
  122852. /**
  122853. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  122854. */
  122855. ignoreAlpha: boolean;
  122856. /**
  122857. * Defines the maximum number of lights that can be used in the material
  122858. */
  122859. maxSimultaneousLights: number;
  122860. /**
  122861. * Observable raised when the material is built
  122862. */
  122863. onBuildObservable: Observable<NodeMaterial>;
  122864. /**
  122865. * Gets or sets the root nodes of the material vertex shader
  122866. */
  122867. _vertexOutputNodes: NodeMaterialBlock[];
  122868. /**
  122869. * Gets or sets the root nodes of the material fragment (pixel) shader
  122870. */
  122871. _fragmentOutputNodes: NodeMaterialBlock[];
  122872. /** Gets or sets options to control the node material overall behavior */
  122873. options: INodeMaterialOptions;
  122874. /**
  122875. * Default configuration related to image processing available in the standard Material.
  122876. */
  122877. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122878. /**
  122879. * Gets the image processing configuration used either in this material.
  122880. */
  122881. /**
  122882. * Sets the Default image processing configuration used either in the this material.
  122883. *
  122884. * If sets to null, the scene one is in use.
  122885. */
  122886. imageProcessingConfiguration: ImageProcessingConfiguration;
  122887. /**
  122888. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  122889. */
  122890. attachedBlocks: NodeMaterialBlock[];
  122891. /**
  122892. * Create a new node based material
  122893. * @param name defines the material name
  122894. * @param scene defines the hosting scene
  122895. * @param options defines creation option
  122896. */
  122897. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  122898. /**
  122899. * Gets the current class name of the material e.g. "NodeMaterial"
  122900. * @returns the class name
  122901. */
  122902. getClassName(): string;
  122903. /**
  122904. * Keep track of the image processing observer to allow dispose and replace.
  122905. */
  122906. private _imageProcessingObserver;
  122907. /**
  122908. * Attaches a new image processing configuration to the Standard Material.
  122909. * @param configuration
  122910. */
  122911. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122912. /**
  122913. * Get a block by its name
  122914. * @param name defines the name of the block to retrieve
  122915. * @returns the required block or null if not found
  122916. */
  122917. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  122918. /**
  122919. * Get a block by its name
  122920. * @param predicate defines the predicate used to find the good candidate
  122921. * @returns the required block or null if not found
  122922. */
  122923. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  122924. /**
  122925. * Get an input block by its name
  122926. * @param predicate defines the predicate used to find the good candidate
  122927. * @returns the required input block or null if not found
  122928. */
  122929. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  122930. /**
  122931. * Gets the list of input blocks attached to this material
  122932. * @returns an array of InputBlocks
  122933. */
  122934. getInputBlocks(): InputBlock[];
  122935. /**
  122936. * Adds a new optimizer to the list of optimizers
  122937. * @param optimizer defines the optimizers to add
  122938. * @returns the current material
  122939. */
  122940. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  122941. /**
  122942. * Remove an optimizer from the list of optimizers
  122943. * @param optimizer defines the optimizers to remove
  122944. * @returns the current material
  122945. */
  122946. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  122947. /**
  122948. * Add a new block to the list of output nodes
  122949. * @param node defines the node to add
  122950. * @returns the current material
  122951. */
  122952. addOutputNode(node: NodeMaterialBlock): this;
  122953. /**
  122954. * Remove a block from the list of root nodes
  122955. * @param node defines the node to remove
  122956. * @returns the current material
  122957. */
  122958. removeOutputNode(node: NodeMaterialBlock): this;
  122959. private _addVertexOutputNode;
  122960. private _removeVertexOutputNode;
  122961. private _addFragmentOutputNode;
  122962. private _removeFragmentOutputNode;
  122963. /**
  122964. * Specifies if the material will require alpha blending
  122965. * @returns a boolean specifying if alpha blending is needed
  122966. */
  122967. needAlphaBlending(): boolean;
  122968. /**
  122969. * Specifies if this material should be rendered in alpha test mode
  122970. * @returns a boolean specifying if an alpha test is needed.
  122971. */
  122972. needAlphaTesting(): boolean;
  122973. private _initializeBlock;
  122974. private _resetDualBlocks;
  122975. /**
  122976. * Remove a block from the current node material
  122977. * @param block defines the block to remove
  122978. */
  122979. removeBlock(block: NodeMaterialBlock): void;
  122980. /**
  122981. * Build the material and generates the inner effect
  122982. * @param verbose defines if the build should log activity
  122983. */
  122984. build(verbose?: boolean): void;
  122985. /**
  122986. * Runs an otpimization phase to try to improve the shader code
  122987. */
  122988. optimize(): void;
  122989. private _prepareDefinesForAttributes;
  122990. /**
  122991. * Get if the submesh is ready to be used and all its information available.
  122992. * Child classes can use it to update shaders
  122993. * @param mesh defines the mesh to check
  122994. * @param subMesh defines which submesh to check
  122995. * @param useInstances specifies that instances should be used
  122996. * @returns a boolean indicating that the submesh is ready or not
  122997. */
  122998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122999. /**
  123000. * Get a string representing the shaders built by the current node graph
  123001. */
  123002. readonly compiledShaders: string;
  123003. /**
  123004. * Binds the world matrix to the material
  123005. * @param world defines the world transformation matrix
  123006. */
  123007. bindOnlyWorldMatrix(world: Matrix): void;
  123008. /**
  123009. * Binds the submesh to this material by preparing the effect and shader to draw
  123010. * @param world defines the world transformation matrix
  123011. * @param mesh defines the mesh containing the submesh
  123012. * @param subMesh defines the submesh to bind the material to
  123013. */
  123014. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123015. /**
  123016. * Gets the active textures from the material
  123017. * @returns an array of textures
  123018. */
  123019. getActiveTextures(): BaseTexture[];
  123020. /**
  123021. * Gets the list of texture blocks
  123022. * @returns an array of texture blocks
  123023. */
  123024. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  123025. /**
  123026. * Specifies if the material uses a texture
  123027. * @param texture defines the texture to check against the material
  123028. * @returns a boolean specifying if the material uses the texture
  123029. */
  123030. hasTexture(texture: BaseTexture): boolean;
  123031. /**
  123032. * Disposes the material
  123033. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  123034. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  123035. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  123036. */
  123037. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  123038. /** Creates the node editor window. */
  123039. private _createNodeEditor;
  123040. /**
  123041. * Launch the node material editor
  123042. * @param config Define the configuration of the editor
  123043. * @return a promise fulfilled when the node editor is visible
  123044. */
  123045. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  123046. /**
  123047. * Clear the current material
  123048. */
  123049. clear(): void;
  123050. /**
  123051. * Clear the current material and set it to a default state
  123052. */
  123053. setToDefault(): void;
  123054. /**
  123055. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  123056. * @param url defines the url to load from
  123057. * @returns a promise that will fullfil when the material is fully loaded
  123058. */
  123059. loadAsync(url: string): Promise<void>;
  123060. private _gatherBlocks;
  123061. /**
  123062. * Generate a string containing the code declaration required to create an equivalent of this material
  123063. * @returns a string
  123064. */
  123065. generateCode(): string;
  123066. /**
  123067. * Serializes this material in a JSON representation
  123068. * @returns the serialized material object
  123069. */
  123070. serialize(): any;
  123071. private _restoreConnections;
  123072. /**
  123073. * Clear the current graph and load a new one from a serialization object
  123074. * @param source defines the JSON representation of the material
  123075. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123076. */
  123077. loadFromSerialization(source: any, rootUrl?: string): void;
  123078. /**
  123079. * Creates a node material from parsed material data
  123080. * @param source defines the JSON representation of the material
  123081. * @param scene defines the hosting scene
  123082. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123083. * @returns a new node material
  123084. */
  123085. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  123086. /**
  123087. * Creates a new node material set to default basic configuration
  123088. * @param name defines the name of the material
  123089. * @param scene defines the hosting scene
  123090. * @returns a new NodeMaterial
  123091. */
  123092. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  123093. }
  123094. }
  123095. declare module BABYLON {
  123096. /**
  123097. * Block used to read a texture from a sampler
  123098. */
  123099. export class TextureBlock extends NodeMaterialBlock {
  123100. private _defineName;
  123101. private _linearDefineName;
  123102. private _tempTextureRead;
  123103. private _samplerName;
  123104. private _transformedUVName;
  123105. private _textureTransformName;
  123106. private _textureInfoName;
  123107. private _mainUVName;
  123108. private _mainUVDefineName;
  123109. /**
  123110. * Gets or sets the texture associated with the node
  123111. */
  123112. texture: Nullable<Texture>;
  123113. /**
  123114. * Create a new TextureBlock
  123115. * @param name defines the block name
  123116. */
  123117. constructor(name: string);
  123118. /**
  123119. * Gets the current class name
  123120. * @returns the class name
  123121. */
  123122. getClassName(): string;
  123123. /**
  123124. * Gets the uv input component
  123125. */
  123126. readonly uv: NodeMaterialConnectionPoint;
  123127. /**
  123128. * Gets the rgba output component
  123129. */
  123130. readonly rgba: NodeMaterialConnectionPoint;
  123131. /**
  123132. * Gets the rgb output component
  123133. */
  123134. readonly rgb: NodeMaterialConnectionPoint;
  123135. /**
  123136. * Gets the r output component
  123137. */
  123138. readonly r: NodeMaterialConnectionPoint;
  123139. /**
  123140. * Gets the g output component
  123141. */
  123142. readonly g: NodeMaterialConnectionPoint;
  123143. /**
  123144. * Gets the b output component
  123145. */
  123146. readonly b: NodeMaterialConnectionPoint;
  123147. /**
  123148. * Gets the a output component
  123149. */
  123150. readonly a: NodeMaterialConnectionPoint;
  123151. readonly target: NodeMaterialBlockTargets;
  123152. autoConfigure(material: NodeMaterial): void;
  123153. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123154. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123155. private _getTextureBase;
  123156. isReady(): boolean;
  123157. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123158. private readonly _isMixed;
  123159. private _injectVertexCode;
  123160. private _writeTextureRead;
  123161. private _writeOutput;
  123162. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123163. protected _dumpPropertiesCode(): string;
  123164. serialize(): any;
  123165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123166. }
  123167. }
  123168. declare module BABYLON {
  123169. /**
  123170. * Class used to store shared data between 2 NodeMaterialBuildState
  123171. */
  123172. export class NodeMaterialBuildStateSharedData {
  123173. /**
  123174. * Gets the list of emitted varyings
  123175. */
  123176. temps: string[];
  123177. /**
  123178. * Gets the list of emitted varyings
  123179. */
  123180. varyings: string[];
  123181. /**
  123182. * Gets the varying declaration string
  123183. */
  123184. varyingDeclaration: string;
  123185. /**
  123186. * Input blocks
  123187. */
  123188. inputBlocks: InputBlock[];
  123189. /**
  123190. * Input blocks
  123191. */
  123192. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  123193. /**
  123194. * Bindable blocks (Blocks that need to set data to the effect)
  123195. */
  123196. bindableBlocks: NodeMaterialBlock[];
  123197. /**
  123198. * List of blocks that can provide a compilation fallback
  123199. */
  123200. blocksWithFallbacks: NodeMaterialBlock[];
  123201. /**
  123202. * List of blocks that can provide a define update
  123203. */
  123204. blocksWithDefines: NodeMaterialBlock[];
  123205. /**
  123206. * List of blocks that can provide a repeatable content
  123207. */
  123208. repeatableContentBlocks: NodeMaterialBlock[];
  123209. /**
  123210. * List of blocks that can provide a dynamic list of uniforms
  123211. */
  123212. dynamicUniformBlocks: NodeMaterialBlock[];
  123213. /**
  123214. * List of blocks that can block the isReady function for the material
  123215. */
  123216. blockingBlocks: NodeMaterialBlock[];
  123217. /**
  123218. * Gets the list of animated inputs
  123219. */
  123220. animatedInputs: InputBlock[];
  123221. /**
  123222. * Build Id used to avoid multiple recompilations
  123223. */
  123224. buildId: number;
  123225. /** List of emitted variables */
  123226. variableNames: {
  123227. [key: string]: number;
  123228. };
  123229. /** List of emitted defines */
  123230. defineNames: {
  123231. [key: string]: number;
  123232. };
  123233. /** Should emit comments? */
  123234. emitComments: boolean;
  123235. /** Emit build activity */
  123236. verbose: boolean;
  123237. /** Gets or sets the hosting scene */
  123238. scene: Scene;
  123239. /**
  123240. * Gets the compilation hints emitted at compilation time
  123241. */
  123242. hints: {
  123243. needWorldViewMatrix: boolean;
  123244. needWorldViewProjectionMatrix: boolean;
  123245. needAlphaBlending: boolean;
  123246. needAlphaTesting: boolean;
  123247. };
  123248. /**
  123249. * List of compilation checks
  123250. */
  123251. checks: {
  123252. emitVertex: boolean;
  123253. emitFragment: boolean;
  123254. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  123255. };
  123256. /** Creates a new shared data */
  123257. constructor();
  123258. /**
  123259. * Emits console errors and exceptions if there is a failing check
  123260. */
  123261. emitErrors(): void;
  123262. }
  123263. }
  123264. declare module BABYLON {
  123265. /**
  123266. * Class used to store node based material build state
  123267. */
  123268. export class NodeMaterialBuildState {
  123269. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  123270. supportUniformBuffers: boolean;
  123271. /**
  123272. * Gets the list of emitted attributes
  123273. */
  123274. attributes: string[];
  123275. /**
  123276. * Gets the list of emitted uniforms
  123277. */
  123278. uniforms: string[];
  123279. /**
  123280. * Gets the list of emitted constants
  123281. */
  123282. constants: string[];
  123283. /**
  123284. * Gets the list of emitted samplers
  123285. */
  123286. samplers: string[];
  123287. /**
  123288. * Gets the list of emitted functions
  123289. */
  123290. functions: {
  123291. [key: string]: string;
  123292. };
  123293. /**
  123294. * Gets the list of emitted extensions
  123295. */
  123296. extensions: {
  123297. [key: string]: string;
  123298. };
  123299. /**
  123300. * Gets the target of the compilation state
  123301. */
  123302. target: NodeMaterialBlockTargets;
  123303. /**
  123304. * Gets the list of emitted counters
  123305. */
  123306. counters: {
  123307. [key: string]: number;
  123308. };
  123309. /**
  123310. * Shared data between multiple NodeMaterialBuildState instances
  123311. */
  123312. sharedData: NodeMaterialBuildStateSharedData;
  123313. /** @hidden */
  123314. _vertexState: NodeMaterialBuildState;
  123315. /** @hidden */
  123316. _attributeDeclaration: string;
  123317. /** @hidden */
  123318. _uniformDeclaration: string;
  123319. /** @hidden */
  123320. _constantDeclaration: string;
  123321. /** @hidden */
  123322. _samplerDeclaration: string;
  123323. /** @hidden */
  123324. _varyingTransfer: string;
  123325. private _repeatableContentAnchorIndex;
  123326. /** @hidden */
  123327. _builtCompilationString: string;
  123328. /**
  123329. * Gets the emitted compilation strings
  123330. */
  123331. compilationString: string;
  123332. /**
  123333. * Finalize the compilation strings
  123334. * @param state defines the current compilation state
  123335. */
  123336. finalize(state: NodeMaterialBuildState): void;
  123337. /** @hidden */
  123338. readonly _repeatableContentAnchor: string;
  123339. /** @hidden */
  123340. _getFreeVariableName(prefix: string): string;
  123341. /** @hidden */
  123342. _getFreeDefineName(prefix: string): string;
  123343. /** @hidden */
  123344. _excludeVariableName(name: string): void;
  123345. /** @hidden */
  123346. _emit2DSampler(name: string): void;
  123347. /** @hidden */
  123348. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  123349. /** @hidden */
  123350. _emitExtension(name: string, extension: string): void;
  123351. /** @hidden */
  123352. _emitFunction(name: string, code: string, comments: string): void;
  123353. /** @hidden */
  123354. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  123355. replaceStrings?: {
  123356. search: RegExp;
  123357. replace: string;
  123358. }[];
  123359. repeatKey?: string;
  123360. }): string;
  123361. /** @hidden */
  123362. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  123363. repeatKey?: string;
  123364. removeAttributes?: boolean;
  123365. removeUniforms?: boolean;
  123366. removeVaryings?: boolean;
  123367. removeIfDef?: boolean;
  123368. replaceStrings?: {
  123369. search: RegExp;
  123370. replace: string;
  123371. }[];
  123372. }, storeKey?: string): void;
  123373. /** @hidden */
  123374. _registerTempVariable(name: string): boolean;
  123375. /** @hidden */
  123376. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  123377. /** @hidden */
  123378. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  123379. /** @hidden */
  123380. _emitFloat(value: number): string;
  123381. }
  123382. }
  123383. declare module BABYLON {
  123384. /**
  123385. * Defines a block that can be used inside a node based material
  123386. */
  123387. export class NodeMaterialBlock {
  123388. private _buildId;
  123389. private _buildTarget;
  123390. private _target;
  123391. private _isFinalMerger;
  123392. private _isInput;
  123393. protected _isUnique: boolean;
  123394. /** @hidden */
  123395. _codeVariableName: string;
  123396. /** @hidden */
  123397. _inputs: NodeMaterialConnectionPoint[];
  123398. /** @hidden */
  123399. _outputs: NodeMaterialConnectionPoint[];
  123400. /** @hidden */
  123401. _preparationId: number;
  123402. /**
  123403. * Gets or sets the name of the block
  123404. */
  123405. name: string;
  123406. /**
  123407. * Gets or sets the unique id of the node
  123408. */
  123409. uniqueId: number;
  123410. /**
  123411. * Gets or sets the comments associated with this block
  123412. */
  123413. comments: string;
  123414. /**
  123415. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  123416. */
  123417. readonly isUnique: boolean;
  123418. /**
  123419. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  123420. */
  123421. readonly isFinalMerger: boolean;
  123422. /**
  123423. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  123424. */
  123425. readonly isInput: boolean;
  123426. /**
  123427. * Gets or sets the build Id
  123428. */
  123429. buildId: number;
  123430. /**
  123431. * Gets or sets the target of the block
  123432. */
  123433. target: NodeMaterialBlockTargets;
  123434. /**
  123435. * Gets the list of input points
  123436. */
  123437. readonly inputs: NodeMaterialConnectionPoint[];
  123438. /** Gets the list of output points */
  123439. readonly outputs: NodeMaterialConnectionPoint[];
  123440. /**
  123441. * Find an input by its name
  123442. * @param name defines the name of the input to look for
  123443. * @returns the input or null if not found
  123444. */
  123445. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123446. /**
  123447. * Find an output by its name
  123448. * @param name defines the name of the outputto look for
  123449. * @returns the output or null if not found
  123450. */
  123451. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123452. /**
  123453. * Creates a new NodeMaterialBlock
  123454. * @param name defines the block name
  123455. * @param target defines the target of that block (Vertex by default)
  123456. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  123457. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  123458. */
  123459. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  123460. /**
  123461. * Initialize the block and prepare the context for build
  123462. * @param state defines the state that will be used for the build
  123463. */
  123464. initialize(state: NodeMaterialBuildState): void;
  123465. /**
  123466. * Bind data to effect. Will only be called for blocks with isBindable === true
  123467. * @param effect defines the effect to bind data to
  123468. * @param nodeMaterial defines the hosting NodeMaterial
  123469. * @param mesh defines the mesh that will be rendered
  123470. */
  123471. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123472. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  123473. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  123474. protected _writeFloat(value: number): string;
  123475. /**
  123476. * Gets the current class name e.g. "NodeMaterialBlock"
  123477. * @returns the class name
  123478. */
  123479. getClassName(): string;
  123480. /**
  123481. * Register a new input. Must be called inside a block constructor
  123482. * @param name defines the connection point name
  123483. * @param type defines the connection point type
  123484. * @param isOptional defines a boolean indicating that this input can be omitted
  123485. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123486. * @returns the current block
  123487. */
  123488. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  123489. /**
  123490. * Register a new output. Must be called inside a block constructor
  123491. * @param name defines the connection point name
  123492. * @param type defines the connection point type
  123493. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123494. * @returns the current block
  123495. */
  123496. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  123497. /**
  123498. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  123499. * @param forOutput defines an optional connection point to check compatibility with
  123500. * @returns the first available input or null
  123501. */
  123502. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  123503. /**
  123504. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  123505. * @param forBlock defines an optional block to check compatibility with
  123506. * @returns the first available input or null
  123507. */
  123508. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  123509. /**
  123510. * Gets the sibling of the given output
  123511. * @param current defines the current output
  123512. * @returns the next output in the list or null
  123513. */
  123514. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  123515. /**
  123516. * Connect current block with another block
  123517. * @param other defines the block to connect with
  123518. * @param options define the various options to help pick the right connections
  123519. * @returns the current block
  123520. */
  123521. connectTo(other: NodeMaterialBlock, options?: {
  123522. input?: string;
  123523. output?: string;
  123524. outputSwizzle?: string;
  123525. }): this | undefined;
  123526. protected _buildBlock(state: NodeMaterialBuildState): void;
  123527. /**
  123528. * Add uniforms, samplers and uniform buffers at compilation time
  123529. * @param state defines the state to update
  123530. * @param nodeMaterial defines the node material requesting the update
  123531. * @param defines defines the material defines to update
  123532. * @param uniformBuffers defines the list of uniform buffer names
  123533. */
  123534. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123535. /**
  123536. * Add potential fallbacks if shader compilation fails
  123537. * @param mesh defines the mesh to be rendered
  123538. * @param fallbacks defines the current prioritized list of fallbacks
  123539. */
  123540. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123541. /**
  123542. * Initialize defines for shader compilation
  123543. * @param mesh defines the mesh to be rendered
  123544. * @param nodeMaterial defines the node material requesting the update
  123545. * @param defines defines the material defines to update
  123546. * @param useInstances specifies that instances should be used
  123547. */
  123548. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123549. /**
  123550. * Update defines for shader compilation
  123551. * @param mesh defines the mesh to be rendered
  123552. * @param nodeMaterial defines the node material requesting the update
  123553. * @param defines defines the material defines to update
  123554. * @param useInstances specifies that instances should be used
  123555. */
  123556. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123557. /**
  123558. * Lets the block try to connect some inputs automatically
  123559. * @param material defines the hosting NodeMaterial
  123560. */
  123561. autoConfigure(material: NodeMaterial): void;
  123562. /**
  123563. * Function called when a block is declared as repeatable content generator
  123564. * @param vertexShaderState defines the current compilation state for the vertex shader
  123565. * @param fragmentShaderState defines the current compilation state for the fragment shader
  123566. * @param mesh defines the mesh to be rendered
  123567. * @param defines defines the material defines to update
  123568. */
  123569. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123570. /**
  123571. * Checks if the block is ready
  123572. * @param mesh defines the mesh to be rendered
  123573. * @param nodeMaterial defines the node material requesting the update
  123574. * @param defines defines the material defines to update
  123575. * @param useInstances specifies that instances should be used
  123576. * @returns true if the block is ready
  123577. */
  123578. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  123579. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  123580. private _processBuild;
  123581. /**
  123582. * Compile the current node and generate the shader code
  123583. * @param state defines the current compilation state (uniforms, samplers, current string)
  123584. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  123585. * @returns true if already built
  123586. */
  123587. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  123588. protected _inputRename(name: string): string;
  123589. protected _outputRename(name: string): string;
  123590. protected _dumpPropertiesCode(): string;
  123591. /** @hidden */
  123592. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  123593. /** @hidden */
  123594. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  123595. /**
  123596. * Clone the current block to a new identical block
  123597. * @param scene defines the hosting scene
  123598. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123599. * @returns a copy of the current block
  123600. */
  123601. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  123602. /**
  123603. * Serializes this block in a JSON representation
  123604. * @returns the serialized block object
  123605. */
  123606. serialize(): any;
  123607. /** @hidden */
  123608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123609. /**
  123610. * Release resources
  123611. */
  123612. dispose(): void;
  123613. }
  123614. }
  123615. declare module BABYLON {
  123616. /**
  123617. * Enum defining the type of animations supported by InputBlock
  123618. */
  123619. export enum AnimatedInputBlockTypes {
  123620. /** No animation */
  123621. None = 0,
  123622. /** Time based animation. Will only work for floats */
  123623. Time = 1
  123624. }
  123625. }
  123626. declare module BABYLON {
  123627. /**
  123628. * Block used to expose an input value
  123629. */
  123630. export class InputBlock extends NodeMaterialBlock {
  123631. private _mode;
  123632. private _associatedVariableName;
  123633. private _storedValue;
  123634. private _valueCallback;
  123635. private _type;
  123636. private _animationType;
  123637. /** Gets or set a value used to limit the range of float values */
  123638. min: number;
  123639. /** Gets or set a value used to limit the range of float values */
  123640. max: number;
  123641. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  123642. matrixMode: number;
  123643. /** @hidden */
  123644. _systemValue: Nullable<NodeMaterialSystemValues>;
  123645. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  123646. visibleInInspector: boolean;
  123647. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  123648. isConstant: boolean;
  123649. /**
  123650. * Gets or sets the connection point type (default is float)
  123651. */
  123652. readonly type: NodeMaterialBlockConnectionPointTypes;
  123653. /**
  123654. * Creates a new InputBlock
  123655. * @param name defines the block name
  123656. * @param target defines the target of that block (Vertex by default)
  123657. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  123658. */
  123659. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  123660. /**
  123661. * Gets the output component
  123662. */
  123663. readonly output: NodeMaterialConnectionPoint;
  123664. /**
  123665. * Set the source of this connection point to a vertex attribute
  123666. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  123667. * @returns the current connection point
  123668. */
  123669. setAsAttribute(attributeName?: string): InputBlock;
  123670. /**
  123671. * Set the source of this connection point to a system value
  123672. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  123673. * @returns the current connection point
  123674. */
  123675. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  123676. /**
  123677. * Gets or sets the value of that point.
  123678. * Please note that this value will be ignored if valueCallback is defined
  123679. */
  123680. value: any;
  123681. /**
  123682. * Gets or sets a callback used to get the value of that point.
  123683. * Please note that setting this value will force the connection point to ignore the value property
  123684. */
  123685. valueCallback: () => any;
  123686. /**
  123687. * Gets or sets the associated variable name in the shader
  123688. */
  123689. associatedVariableName: string;
  123690. /** Gets or sets the type of animation applied to the input */
  123691. animationType: AnimatedInputBlockTypes;
  123692. /**
  123693. * Gets a boolean indicating that this connection point not defined yet
  123694. */
  123695. readonly isUndefined: boolean;
  123696. /**
  123697. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  123698. * In this case the connection point name must be the name of the uniform to use.
  123699. * Can only be set on inputs
  123700. */
  123701. isUniform: boolean;
  123702. /**
  123703. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  123704. * In this case the connection point name must be the name of the attribute to use
  123705. * Can only be set on inputs
  123706. */
  123707. isAttribute: boolean;
  123708. /**
  123709. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  123710. * Can only be set on exit points
  123711. */
  123712. isVarying: boolean;
  123713. /**
  123714. * Gets a boolean indicating that the current connection point is a system value
  123715. */
  123716. readonly isSystemValue: boolean;
  123717. /**
  123718. * Gets or sets the current well known value or null if not defined as a system value
  123719. */
  123720. systemValue: Nullable<NodeMaterialSystemValues>;
  123721. /**
  123722. * Gets the current class name
  123723. * @returns the class name
  123724. */
  123725. getClassName(): string;
  123726. /**
  123727. * Animate the input if animationType !== None
  123728. * @param scene defines the rendering scene
  123729. */
  123730. animate(scene: Scene): void;
  123731. private _emitDefine;
  123732. initialize(state: NodeMaterialBuildState): void;
  123733. /**
  123734. * Set the input block to its default value (based on its type)
  123735. */
  123736. setDefaultValue(): void;
  123737. private _emitConstant;
  123738. private _emit;
  123739. /** @hidden */
  123740. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  123741. /** @hidden */
  123742. _transmit(effect: Effect, scene: Scene): void;
  123743. protected _buildBlock(state: NodeMaterialBuildState): void;
  123744. protected _dumpPropertiesCode(): string;
  123745. serialize(): any;
  123746. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123747. }
  123748. }
  123749. declare module BABYLON {
  123750. /**
  123751. * Enum used to define the compatibility state between two connection points
  123752. */
  123753. export enum NodeMaterialConnectionPointCompatibilityStates {
  123754. /** Points are compatibles */
  123755. Compatible = 0,
  123756. /** Points are incompatible because of their types */
  123757. TypeIncompatible = 1,
  123758. /** Points are incompatible because of their targets (vertex vs fragment) */
  123759. TargetIncompatible = 2
  123760. }
  123761. /**
  123762. * Defines the direction of a connection point
  123763. */
  123764. export enum NodeMaterialConnectionPointDirection {
  123765. /** Input */
  123766. Input = 0,
  123767. /** Output */
  123768. Output = 1
  123769. }
  123770. /**
  123771. * Defines a connection point for a block
  123772. */
  123773. export class NodeMaterialConnectionPoint {
  123774. /** @hidden */
  123775. _ownerBlock: NodeMaterialBlock;
  123776. /** @hidden */
  123777. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123778. private _endpoints;
  123779. private _associatedVariableName;
  123780. private _direction;
  123781. /** @hidden */
  123782. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123783. /** @hidden */
  123784. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123785. private _type;
  123786. /** @hidden */
  123787. _enforceAssociatedVariableName: boolean;
  123788. /** Gets the direction of the point */
  123789. readonly direction: NodeMaterialConnectionPointDirection;
  123790. /**
  123791. * Gets or sets the additional types supported by this connection point
  123792. */
  123793. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123794. /**
  123795. * Gets or sets the additional types excluded by this connection point
  123796. */
  123797. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123798. /**
  123799. * Observable triggered when this point is connected
  123800. */
  123801. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  123802. /**
  123803. * Gets or sets the associated variable name in the shader
  123804. */
  123805. associatedVariableName: string;
  123806. /**
  123807. * Gets or sets the connection point type (default is float)
  123808. */
  123809. type: NodeMaterialBlockConnectionPointTypes;
  123810. /**
  123811. * Gets or sets the connection point name
  123812. */
  123813. name: string;
  123814. /**
  123815. * Gets or sets a boolean indicating that this connection point can be omitted
  123816. */
  123817. isOptional: boolean;
  123818. /**
  123819. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  123820. */
  123821. define: string;
  123822. /** @hidden */
  123823. _prioritizeVertex: boolean;
  123824. private _target;
  123825. /** Gets or sets the target of that connection point */
  123826. target: NodeMaterialBlockTargets;
  123827. /**
  123828. * Gets a boolean indicating that the current point is connected
  123829. */
  123830. readonly isConnected: boolean;
  123831. /**
  123832. * Gets a boolean indicating that the current point is connected to an input block
  123833. */
  123834. readonly isConnectedToInputBlock: boolean;
  123835. /**
  123836. * Gets a the connected input block (if any)
  123837. */
  123838. readonly connectInputBlock: Nullable<InputBlock>;
  123839. /** Get the other side of the connection (if any) */
  123840. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123841. /** Get the block that owns this connection point */
  123842. readonly ownerBlock: NodeMaterialBlock;
  123843. /** Get the block connected on the other side of this connection (if any) */
  123844. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  123845. /** Get the block connected on the endpoints of this connection (if any) */
  123846. readonly connectedBlocks: Array<NodeMaterialBlock>;
  123847. /** Gets the list of connected endpoints */
  123848. readonly endpoints: NodeMaterialConnectionPoint[];
  123849. /** Gets a boolean indicating if that output point is connected to at least one input */
  123850. readonly hasEndpoints: boolean;
  123851. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  123852. readonly isConnectedInVertexShader: boolean;
  123853. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  123854. readonly isConnectedInFragmentShader: boolean;
  123855. /**
  123856. * Creates a new connection point
  123857. * @param name defines the connection point name
  123858. * @param ownerBlock defines the block hosting this connection point
  123859. * @param direction defines the direction of the connection point
  123860. */
  123861. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  123862. /**
  123863. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  123864. * @returns the class name
  123865. */
  123866. getClassName(): string;
  123867. /**
  123868. * Gets a boolean indicating if the current point can be connected to another point
  123869. * @param connectionPoint defines the other connection point
  123870. * @returns a boolean
  123871. */
  123872. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  123873. /**
  123874. * Gets a number indicating if the current point can be connected to another point
  123875. * @param connectionPoint defines the other connection point
  123876. * @returns a number defining the compatibility state
  123877. */
  123878. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  123879. /**
  123880. * Connect this point to another connection point
  123881. * @param connectionPoint defines the other connection point
  123882. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  123883. * @returns the current connection point
  123884. */
  123885. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  123886. /**
  123887. * Disconnect this point from one of his endpoint
  123888. * @param endpoint defines the other connection point
  123889. * @returns the current connection point
  123890. */
  123891. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  123892. /**
  123893. * Serializes this point in a JSON representation
  123894. * @returns the serialized point object
  123895. */
  123896. serialize(): any;
  123897. /**
  123898. * Release resources
  123899. */
  123900. dispose(): void;
  123901. }
  123902. }
  123903. declare module BABYLON {
  123904. /**
  123905. * Block used to add support for vertex skinning (bones)
  123906. */
  123907. export class BonesBlock extends NodeMaterialBlock {
  123908. /**
  123909. * Creates a new BonesBlock
  123910. * @param name defines the block name
  123911. */
  123912. constructor(name: string);
  123913. /**
  123914. * Initialize the block and prepare the context for build
  123915. * @param state defines the state that will be used for the build
  123916. */
  123917. initialize(state: NodeMaterialBuildState): void;
  123918. /**
  123919. * Gets the current class name
  123920. * @returns the class name
  123921. */
  123922. getClassName(): string;
  123923. /**
  123924. * Gets the matrix indices input component
  123925. */
  123926. readonly matricesIndices: NodeMaterialConnectionPoint;
  123927. /**
  123928. * Gets the matrix weights input component
  123929. */
  123930. readonly matricesWeights: NodeMaterialConnectionPoint;
  123931. /**
  123932. * Gets the extra matrix indices input component
  123933. */
  123934. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  123935. /**
  123936. * Gets the extra matrix weights input component
  123937. */
  123938. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  123939. /**
  123940. * Gets the world input component
  123941. */
  123942. readonly world: NodeMaterialConnectionPoint;
  123943. /**
  123944. * Gets the output component
  123945. */
  123946. readonly output: NodeMaterialConnectionPoint;
  123947. autoConfigure(material: NodeMaterial): void;
  123948. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123949. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123950. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123951. protected _buildBlock(state: NodeMaterialBuildState): this;
  123952. }
  123953. }
  123954. declare module BABYLON {
  123955. /**
  123956. * Block used to add support for instances
  123957. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  123958. */
  123959. export class InstancesBlock extends NodeMaterialBlock {
  123960. /**
  123961. * Creates a new InstancesBlock
  123962. * @param name defines the block name
  123963. */
  123964. constructor(name: string);
  123965. /**
  123966. * Gets the current class name
  123967. * @returns the class name
  123968. */
  123969. getClassName(): string;
  123970. /**
  123971. * Gets the first world row input component
  123972. */
  123973. readonly world0: NodeMaterialConnectionPoint;
  123974. /**
  123975. * Gets the second world row input component
  123976. */
  123977. readonly world1: NodeMaterialConnectionPoint;
  123978. /**
  123979. * Gets the third world row input component
  123980. */
  123981. readonly world2: NodeMaterialConnectionPoint;
  123982. /**
  123983. * Gets the forth world row input component
  123984. */
  123985. readonly world3: NodeMaterialConnectionPoint;
  123986. /**
  123987. * Gets the world input component
  123988. */
  123989. readonly world: NodeMaterialConnectionPoint;
  123990. /**
  123991. * Gets the output component
  123992. */
  123993. readonly output: NodeMaterialConnectionPoint;
  123994. autoConfigure(material: NodeMaterial): void;
  123995. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123996. protected _buildBlock(state: NodeMaterialBuildState): this;
  123997. }
  123998. }
  123999. declare module BABYLON {
  124000. /**
  124001. * Block used to add morph targets support to vertex shader
  124002. */
  124003. export class MorphTargetsBlock extends NodeMaterialBlock {
  124004. private _repeatableContentAnchor;
  124005. private _repeatebleContentGenerated;
  124006. /**
  124007. * Create a new MorphTargetsBlock
  124008. * @param name defines the block name
  124009. */
  124010. constructor(name: string);
  124011. /**
  124012. * Gets the current class name
  124013. * @returns the class name
  124014. */
  124015. getClassName(): string;
  124016. /**
  124017. * Gets the position input component
  124018. */
  124019. readonly position: NodeMaterialConnectionPoint;
  124020. /**
  124021. * Gets the normal input component
  124022. */
  124023. readonly normal: NodeMaterialConnectionPoint;
  124024. /**
  124025. * Gets the tangent input component
  124026. */
  124027. readonly tangent: NodeMaterialConnectionPoint;
  124028. /**
  124029. * Gets the tangent input component
  124030. */
  124031. readonly uv: NodeMaterialConnectionPoint;
  124032. /**
  124033. * Gets the position output component
  124034. */
  124035. readonly positionOutput: NodeMaterialConnectionPoint;
  124036. /**
  124037. * Gets the normal output component
  124038. */
  124039. readonly normalOutput: NodeMaterialConnectionPoint;
  124040. /**
  124041. * Gets the tangent output component
  124042. */
  124043. readonly tangentOutput: NodeMaterialConnectionPoint;
  124044. /**
  124045. * Gets the tangent output component
  124046. */
  124047. readonly uvOutput: NodeMaterialConnectionPoint;
  124048. initialize(state: NodeMaterialBuildState): void;
  124049. autoConfigure(material: NodeMaterial): void;
  124050. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124051. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124052. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124053. protected _buildBlock(state: NodeMaterialBuildState): this;
  124054. }
  124055. }
  124056. declare module BABYLON {
  124057. /**
  124058. * Block used to get data information from a light
  124059. */
  124060. export class LightInformationBlock extends NodeMaterialBlock {
  124061. private _lightDataUniformName;
  124062. private _lightColorUniformName;
  124063. private _lightTypeDefineName;
  124064. /**
  124065. * Gets or sets the light associated with this block
  124066. */
  124067. light: Nullable<Light>;
  124068. /**
  124069. * Creates a new LightInformationBlock
  124070. * @param name defines the block name
  124071. */
  124072. constructor(name: string);
  124073. /**
  124074. * Gets the current class name
  124075. * @returns the class name
  124076. */
  124077. getClassName(): string;
  124078. /**
  124079. * Gets the world position input component
  124080. */
  124081. readonly worldPosition: NodeMaterialConnectionPoint;
  124082. /**
  124083. * Gets the direction output component
  124084. */
  124085. readonly direction: NodeMaterialConnectionPoint;
  124086. /**
  124087. * Gets the direction output component
  124088. */
  124089. readonly color: NodeMaterialConnectionPoint;
  124090. /**
  124091. * Gets the direction output component
  124092. */
  124093. readonly intensity: NodeMaterialConnectionPoint;
  124094. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124096. protected _buildBlock(state: NodeMaterialBuildState): this;
  124097. serialize(): any;
  124098. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124099. }
  124100. }
  124101. declare module BABYLON {
  124102. /**
  124103. * Block used to add image processing support to fragment shader
  124104. */
  124105. export class ImageProcessingBlock extends NodeMaterialBlock {
  124106. /**
  124107. * Create a new ImageProcessingBlock
  124108. * @param name defines the block name
  124109. */
  124110. constructor(name: string);
  124111. /**
  124112. * Gets the current class name
  124113. * @returns the class name
  124114. */
  124115. getClassName(): string;
  124116. /**
  124117. * Gets the color input component
  124118. */
  124119. readonly color: NodeMaterialConnectionPoint;
  124120. /**
  124121. * Gets the output component
  124122. */
  124123. readonly output: NodeMaterialConnectionPoint;
  124124. /**
  124125. * Initialize the block and prepare the context for build
  124126. * @param state defines the state that will be used for the build
  124127. */
  124128. initialize(state: NodeMaterialBuildState): void;
  124129. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  124130. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124131. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124132. protected _buildBlock(state: NodeMaterialBuildState): this;
  124133. }
  124134. }
  124135. declare module BABYLON {
  124136. /**
  124137. * Block used to pertub normals based on a normal map
  124138. */
  124139. export class PerturbNormalBlock extends NodeMaterialBlock {
  124140. private _tangentSpaceParameterName;
  124141. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124142. invertX: boolean;
  124143. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  124144. invertY: boolean;
  124145. /**
  124146. * Create a new PerturbNormalBlock
  124147. * @param name defines the block name
  124148. */
  124149. constructor(name: string);
  124150. /**
  124151. * Gets the current class name
  124152. * @returns the class name
  124153. */
  124154. getClassName(): string;
  124155. /**
  124156. * Gets the world position input component
  124157. */
  124158. readonly worldPosition: NodeMaterialConnectionPoint;
  124159. /**
  124160. * Gets the world normal input component
  124161. */
  124162. readonly worldNormal: NodeMaterialConnectionPoint;
  124163. /**
  124164. * Gets the uv input component
  124165. */
  124166. readonly uv: NodeMaterialConnectionPoint;
  124167. /**
  124168. * Gets the normal map color input component
  124169. */
  124170. readonly normalMapColor: NodeMaterialConnectionPoint;
  124171. /**
  124172. * Gets the strength input component
  124173. */
  124174. readonly strength: NodeMaterialConnectionPoint;
  124175. /**
  124176. * Gets the output component
  124177. */
  124178. readonly output: NodeMaterialConnectionPoint;
  124179. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124180. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124181. autoConfigure(material: NodeMaterial): void;
  124182. protected _buildBlock(state: NodeMaterialBuildState): this;
  124183. protected _dumpPropertiesCode(): string;
  124184. serialize(): any;
  124185. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124186. }
  124187. }
  124188. declare module BABYLON {
  124189. /**
  124190. * Block used to discard a pixel if a value is smaller than a cutoff
  124191. */
  124192. export class DiscardBlock extends NodeMaterialBlock {
  124193. /**
  124194. * Create a new DiscardBlock
  124195. * @param name defines the block name
  124196. */
  124197. constructor(name: string);
  124198. /**
  124199. * Gets the current class name
  124200. * @returns the class name
  124201. */
  124202. getClassName(): string;
  124203. /**
  124204. * Gets the color input component
  124205. */
  124206. readonly value: NodeMaterialConnectionPoint;
  124207. /**
  124208. * Gets the cutoff input component
  124209. */
  124210. readonly cutoff: NodeMaterialConnectionPoint;
  124211. protected _buildBlock(state: NodeMaterialBuildState): this;
  124212. }
  124213. }
  124214. declare module BABYLON {
  124215. /**
  124216. * Block used to test if the fragment shader is front facing
  124217. */
  124218. export class FrontFacingBlock extends NodeMaterialBlock {
  124219. /**
  124220. * Creates a new FrontFacingBlock
  124221. * @param name defines the block name
  124222. */
  124223. constructor(name: string);
  124224. /**
  124225. * Gets the current class name
  124226. * @returns the class name
  124227. */
  124228. getClassName(): string;
  124229. /**
  124230. * Gets the output component
  124231. */
  124232. readonly output: NodeMaterialConnectionPoint;
  124233. protected _buildBlock(state: NodeMaterialBuildState): this;
  124234. }
  124235. }
  124236. declare module BABYLON {
  124237. /**
  124238. * Block used to get the derivative value on x and y of a given input
  124239. */
  124240. export class DerivativeBlock extends NodeMaterialBlock {
  124241. /**
  124242. * Create a new DerivativeBlock
  124243. * @param name defines the block name
  124244. */
  124245. constructor(name: string);
  124246. /**
  124247. * Gets the current class name
  124248. * @returns the class name
  124249. */
  124250. getClassName(): string;
  124251. /**
  124252. * Gets the input component
  124253. */
  124254. readonly input: NodeMaterialConnectionPoint;
  124255. /**
  124256. * Gets the derivative output on x
  124257. */
  124258. readonly dx: NodeMaterialConnectionPoint;
  124259. /**
  124260. * Gets the derivative output on y
  124261. */
  124262. readonly dy: NodeMaterialConnectionPoint;
  124263. protected _buildBlock(state: NodeMaterialBuildState): this;
  124264. }
  124265. }
  124266. declare module BABYLON {
  124267. /**
  124268. * Block used to add support for scene fog
  124269. */
  124270. export class FogBlock extends NodeMaterialBlock {
  124271. private _fogDistanceName;
  124272. private _fogParameters;
  124273. /**
  124274. * Create a new FogBlock
  124275. * @param name defines the block name
  124276. */
  124277. constructor(name: string);
  124278. /**
  124279. * Gets the current class name
  124280. * @returns the class name
  124281. */
  124282. getClassName(): string;
  124283. /**
  124284. * Gets the world position input component
  124285. */
  124286. readonly worldPosition: NodeMaterialConnectionPoint;
  124287. /**
  124288. * Gets the view input component
  124289. */
  124290. readonly view: NodeMaterialConnectionPoint;
  124291. /**
  124292. * Gets the color input component
  124293. */
  124294. readonly input: NodeMaterialConnectionPoint;
  124295. /**
  124296. * Gets the fog color input component
  124297. */
  124298. readonly fogColor: NodeMaterialConnectionPoint;
  124299. /**
  124300. * Gets the output component
  124301. */
  124302. readonly output: NodeMaterialConnectionPoint;
  124303. autoConfigure(material: NodeMaterial): void;
  124304. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124305. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124306. protected _buildBlock(state: NodeMaterialBuildState): this;
  124307. }
  124308. }
  124309. declare module BABYLON {
  124310. /**
  124311. * Block used to add light in the fragment shader
  124312. */
  124313. export class LightBlock extends NodeMaterialBlock {
  124314. private _lightId;
  124315. /**
  124316. * Gets or sets the light associated with this block
  124317. */
  124318. light: Nullable<Light>;
  124319. /**
  124320. * Create a new LightBlock
  124321. * @param name defines the block name
  124322. */
  124323. constructor(name: string);
  124324. /**
  124325. * Gets the current class name
  124326. * @returns the class name
  124327. */
  124328. getClassName(): string;
  124329. /**
  124330. * Gets the world position input component
  124331. */
  124332. readonly worldPosition: NodeMaterialConnectionPoint;
  124333. /**
  124334. * Gets the world normal input component
  124335. */
  124336. readonly worldNormal: NodeMaterialConnectionPoint;
  124337. /**
  124338. * Gets the camera (or eye) position component
  124339. */
  124340. readonly cameraPosition: NodeMaterialConnectionPoint;
  124341. /**
  124342. * Gets the glossiness component
  124343. */
  124344. readonly glossiness: NodeMaterialConnectionPoint;
  124345. /**
  124346. * Gets the glossinness power component
  124347. */
  124348. readonly glossPower: NodeMaterialConnectionPoint;
  124349. /**
  124350. * Gets the diffuse color component
  124351. */
  124352. readonly diffuseColor: NodeMaterialConnectionPoint;
  124353. /**
  124354. * Gets the specular color component
  124355. */
  124356. readonly specularColor: NodeMaterialConnectionPoint;
  124357. /**
  124358. * Gets the diffuse output component
  124359. */
  124360. readonly diffuseOutput: NodeMaterialConnectionPoint;
  124361. /**
  124362. * Gets the specular output component
  124363. */
  124364. readonly specularOutput: NodeMaterialConnectionPoint;
  124365. autoConfigure(material: NodeMaterial): void;
  124366. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124367. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  124368. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124369. private _injectVertexCode;
  124370. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124371. serialize(): any;
  124372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124373. }
  124374. }
  124375. declare module BABYLON {
  124376. /**
  124377. * Block used to multiply 2 values
  124378. */
  124379. export class MultiplyBlock extends NodeMaterialBlock {
  124380. /**
  124381. * Creates a new MultiplyBlock
  124382. * @param name defines the block name
  124383. */
  124384. constructor(name: string);
  124385. /**
  124386. * Gets the current class name
  124387. * @returns the class name
  124388. */
  124389. getClassName(): string;
  124390. /**
  124391. * Gets the left operand input component
  124392. */
  124393. readonly left: NodeMaterialConnectionPoint;
  124394. /**
  124395. * Gets the right operand input component
  124396. */
  124397. readonly right: NodeMaterialConnectionPoint;
  124398. /**
  124399. * Gets the output component
  124400. */
  124401. readonly output: NodeMaterialConnectionPoint;
  124402. protected _buildBlock(state: NodeMaterialBuildState): this;
  124403. }
  124404. }
  124405. declare module BABYLON {
  124406. /**
  124407. * Block used to add 2 vectors
  124408. */
  124409. export class AddBlock extends NodeMaterialBlock {
  124410. /**
  124411. * Creates a new AddBlock
  124412. * @param name defines the block name
  124413. */
  124414. constructor(name: string);
  124415. /**
  124416. * Gets the current class name
  124417. * @returns the class name
  124418. */
  124419. getClassName(): string;
  124420. /**
  124421. * Gets the left operand input component
  124422. */
  124423. readonly left: NodeMaterialConnectionPoint;
  124424. /**
  124425. * Gets the right operand input component
  124426. */
  124427. readonly right: NodeMaterialConnectionPoint;
  124428. /**
  124429. * Gets the output component
  124430. */
  124431. readonly output: NodeMaterialConnectionPoint;
  124432. protected _buildBlock(state: NodeMaterialBuildState): this;
  124433. }
  124434. }
  124435. declare module BABYLON {
  124436. /**
  124437. * Block used to scale a vector by a float
  124438. */
  124439. export class ScaleBlock extends NodeMaterialBlock {
  124440. /**
  124441. * Creates a new ScaleBlock
  124442. * @param name defines the block name
  124443. */
  124444. constructor(name: string);
  124445. /**
  124446. * Gets the current class name
  124447. * @returns the class name
  124448. */
  124449. getClassName(): string;
  124450. /**
  124451. * Gets the input component
  124452. */
  124453. readonly input: NodeMaterialConnectionPoint;
  124454. /**
  124455. * Gets the factor input component
  124456. */
  124457. readonly factor: NodeMaterialConnectionPoint;
  124458. /**
  124459. * Gets the output component
  124460. */
  124461. readonly output: NodeMaterialConnectionPoint;
  124462. protected _buildBlock(state: NodeMaterialBuildState): this;
  124463. }
  124464. }
  124465. declare module BABYLON {
  124466. /**
  124467. * Block used to clamp a float
  124468. */
  124469. export class ClampBlock extends NodeMaterialBlock {
  124470. /** Gets or sets the minimum range */
  124471. minimum: number;
  124472. /** Gets or sets the maximum range */
  124473. maximum: number;
  124474. /**
  124475. * Creates a new ClampBlock
  124476. * @param name defines the block name
  124477. */
  124478. constructor(name: string);
  124479. /**
  124480. * Gets the current class name
  124481. * @returns the class name
  124482. */
  124483. getClassName(): string;
  124484. /**
  124485. * Gets the value input component
  124486. */
  124487. readonly value: NodeMaterialConnectionPoint;
  124488. /**
  124489. * Gets the output component
  124490. */
  124491. readonly output: NodeMaterialConnectionPoint;
  124492. protected _buildBlock(state: NodeMaterialBuildState): this;
  124493. protected _dumpPropertiesCode(): string;
  124494. serialize(): any;
  124495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124496. }
  124497. }
  124498. declare module BABYLON {
  124499. /**
  124500. * Block used to apply a cross product between 2 vectors
  124501. */
  124502. export class CrossBlock extends NodeMaterialBlock {
  124503. /**
  124504. * Creates a new CrossBlock
  124505. * @param name defines the block name
  124506. */
  124507. constructor(name: string);
  124508. /**
  124509. * Gets the current class name
  124510. * @returns the class name
  124511. */
  124512. getClassName(): string;
  124513. /**
  124514. * Gets the left operand input component
  124515. */
  124516. readonly left: NodeMaterialConnectionPoint;
  124517. /**
  124518. * Gets the right operand input component
  124519. */
  124520. readonly right: NodeMaterialConnectionPoint;
  124521. /**
  124522. * Gets the output component
  124523. */
  124524. readonly output: NodeMaterialConnectionPoint;
  124525. protected _buildBlock(state: NodeMaterialBuildState): this;
  124526. }
  124527. }
  124528. declare module BABYLON {
  124529. /**
  124530. * Block used to apply a dot product between 2 vectors
  124531. */
  124532. export class DotBlock extends NodeMaterialBlock {
  124533. /**
  124534. * Creates a new DotBlock
  124535. * @param name defines the block name
  124536. */
  124537. constructor(name: string);
  124538. /**
  124539. * Gets the current class name
  124540. * @returns the class name
  124541. */
  124542. getClassName(): string;
  124543. /**
  124544. * Gets the left operand input component
  124545. */
  124546. readonly left: NodeMaterialConnectionPoint;
  124547. /**
  124548. * Gets the right operand input component
  124549. */
  124550. readonly right: NodeMaterialConnectionPoint;
  124551. /**
  124552. * Gets the output component
  124553. */
  124554. readonly output: NodeMaterialConnectionPoint;
  124555. protected _buildBlock(state: NodeMaterialBuildState): this;
  124556. }
  124557. }
  124558. declare module BABYLON {
  124559. /**
  124560. * Block used to remap a float from a range to a new one
  124561. */
  124562. export class RemapBlock extends NodeMaterialBlock {
  124563. /**
  124564. * Gets or sets the source range
  124565. */
  124566. sourceRange: Vector2;
  124567. /**
  124568. * Gets or sets the target range
  124569. */
  124570. targetRange: Vector2;
  124571. /**
  124572. * Creates a new RemapBlock
  124573. * @param name defines the block name
  124574. */
  124575. constructor(name: string);
  124576. /**
  124577. * Gets the current class name
  124578. * @returns the class name
  124579. */
  124580. getClassName(): string;
  124581. /**
  124582. * Gets the input component
  124583. */
  124584. readonly input: NodeMaterialConnectionPoint;
  124585. /**
  124586. * Gets the source min input component
  124587. */
  124588. readonly sourceMin: NodeMaterialConnectionPoint;
  124589. /**
  124590. * Gets the source max input component
  124591. */
  124592. readonly sourceMax: NodeMaterialConnectionPoint;
  124593. /**
  124594. * Gets the target min input component
  124595. */
  124596. readonly targetMin: NodeMaterialConnectionPoint;
  124597. /**
  124598. * Gets the target max input component
  124599. */
  124600. readonly targetMax: NodeMaterialConnectionPoint;
  124601. /**
  124602. * Gets the output component
  124603. */
  124604. readonly output: NodeMaterialConnectionPoint;
  124605. protected _buildBlock(state: NodeMaterialBuildState): this;
  124606. protected _dumpPropertiesCode(): string;
  124607. serialize(): any;
  124608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124609. }
  124610. }
  124611. declare module BABYLON {
  124612. /**
  124613. * Block used to normalize a vector
  124614. */
  124615. export class NormalizeBlock extends NodeMaterialBlock {
  124616. /**
  124617. * Creates a new NormalizeBlock
  124618. * @param name defines the block name
  124619. */
  124620. constructor(name: string);
  124621. /**
  124622. * Gets the current class name
  124623. * @returns the class name
  124624. */
  124625. getClassName(): string;
  124626. /**
  124627. * Gets the input component
  124628. */
  124629. readonly input: NodeMaterialConnectionPoint;
  124630. /**
  124631. * Gets the output component
  124632. */
  124633. readonly output: NodeMaterialConnectionPoint;
  124634. protected _buildBlock(state: NodeMaterialBuildState): this;
  124635. }
  124636. }
  124637. declare module BABYLON {
  124638. /**
  124639. * Operations supported by the Trigonometry block
  124640. */
  124641. export enum TrigonometryBlockOperations {
  124642. /** Cos */
  124643. Cos = 0,
  124644. /** Sin */
  124645. Sin = 1,
  124646. /** Abs */
  124647. Abs = 2,
  124648. /** Exp */
  124649. Exp = 3,
  124650. /** Exp2 */
  124651. Exp2 = 4,
  124652. /** Round */
  124653. Round = 5,
  124654. /** Floor */
  124655. Floor = 6,
  124656. /** Ceiling */
  124657. Ceiling = 7,
  124658. /** Square root */
  124659. Sqrt = 8,
  124660. /** Log */
  124661. Log = 9,
  124662. /** Tangent */
  124663. Tan = 10,
  124664. /** Arc tangent */
  124665. ArcTan = 11,
  124666. /** Arc cosinus */
  124667. ArcCos = 12,
  124668. /** Arc sinus */
  124669. ArcSin = 13,
  124670. /** Fraction */
  124671. Fract = 14,
  124672. /** Sign */
  124673. Sign = 15,
  124674. /** To radians (from degrees) */
  124675. Radians = 16,
  124676. /** To degrees (from radians) */
  124677. Degrees = 17
  124678. }
  124679. /**
  124680. * Block used to apply trigonometry operation to floats
  124681. */
  124682. export class TrigonometryBlock extends NodeMaterialBlock {
  124683. /**
  124684. * Gets or sets the operation applied by the block
  124685. */
  124686. operation: TrigonometryBlockOperations;
  124687. /**
  124688. * Creates a new TrigonometryBlock
  124689. * @param name defines the block name
  124690. */
  124691. constructor(name: string);
  124692. /**
  124693. * Gets the current class name
  124694. * @returns the class name
  124695. */
  124696. getClassName(): string;
  124697. /**
  124698. * Gets the input component
  124699. */
  124700. readonly input: NodeMaterialConnectionPoint;
  124701. /**
  124702. * Gets the output component
  124703. */
  124704. readonly output: NodeMaterialConnectionPoint;
  124705. protected _buildBlock(state: NodeMaterialBuildState): this;
  124706. serialize(): any;
  124707. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124708. protected _dumpPropertiesCode(): string;
  124709. }
  124710. }
  124711. declare module BABYLON {
  124712. /**
  124713. * Block used to create a Color3/4 out of individual inputs (one for each component)
  124714. */
  124715. export class ColorMergerBlock extends NodeMaterialBlock {
  124716. /**
  124717. * Create a new ColorMergerBlock
  124718. * @param name defines the block name
  124719. */
  124720. constructor(name: string);
  124721. /**
  124722. * Gets the current class name
  124723. * @returns the class name
  124724. */
  124725. getClassName(): string;
  124726. /**
  124727. * Gets the rgb component (input)
  124728. */
  124729. readonly rgbIn: NodeMaterialConnectionPoint;
  124730. /**
  124731. * Gets the r component (input)
  124732. */
  124733. readonly r: NodeMaterialConnectionPoint;
  124734. /**
  124735. * Gets the g component (input)
  124736. */
  124737. readonly g: NodeMaterialConnectionPoint;
  124738. /**
  124739. * Gets the b component (input)
  124740. */
  124741. readonly b: NodeMaterialConnectionPoint;
  124742. /**
  124743. * Gets the a component (input)
  124744. */
  124745. readonly a: NodeMaterialConnectionPoint;
  124746. /**
  124747. * Gets the rgba component (output)
  124748. */
  124749. readonly rgba: NodeMaterialConnectionPoint;
  124750. /**
  124751. * Gets the rgb component (output)
  124752. */
  124753. readonly rgbOut: NodeMaterialConnectionPoint;
  124754. /**
  124755. * Gets the rgb component (output)
  124756. * @deprecated Please use rgbOut instead.
  124757. */
  124758. readonly rgb: NodeMaterialConnectionPoint;
  124759. protected _buildBlock(state: NodeMaterialBuildState): this;
  124760. }
  124761. }
  124762. declare module BABYLON {
  124763. /**
  124764. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  124765. */
  124766. export class VectorMergerBlock extends NodeMaterialBlock {
  124767. /**
  124768. * Create a new VectorMergerBlock
  124769. * @param name defines the block name
  124770. */
  124771. constructor(name: string);
  124772. /**
  124773. * Gets the current class name
  124774. * @returns the class name
  124775. */
  124776. getClassName(): string;
  124777. /**
  124778. * Gets the xyz component (input)
  124779. */
  124780. readonly xyzIn: NodeMaterialConnectionPoint;
  124781. /**
  124782. * Gets the xy component (input)
  124783. */
  124784. readonly xyIn: NodeMaterialConnectionPoint;
  124785. /**
  124786. * Gets the x component (input)
  124787. */
  124788. readonly x: NodeMaterialConnectionPoint;
  124789. /**
  124790. * Gets the y component (input)
  124791. */
  124792. readonly y: NodeMaterialConnectionPoint;
  124793. /**
  124794. * Gets the z component (input)
  124795. */
  124796. readonly z: NodeMaterialConnectionPoint;
  124797. /**
  124798. * Gets the w component (input)
  124799. */
  124800. readonly w: NodeMaterialConnectionPoint;
  124801. /**
  124802. * Gets the xyzw component (output)
  124803. */
  124804. readonly xyzw: NodeMaterialConnectionPoint;
  124805. /**
  124806. * Gets the xyz component (output)
  124807. */
  124808. readonly xyzOut: NodeMaterialConnectionPoint;
  124809. /**
  124810. * Gets the xy component (output)
  124811. */
  124812. readonly xyOut: NodeMaterialConnectionPoint;
  124813. /**
  124814. * Gets the xy component (output)
  124815. * @deprecated Please use xyOut instead.
  124816. */
  124817. readonly xy: NodeMaterialConnectionPoint;
  124818. /**
  124819. * Gets the xyz component (output)
  124820. * @deprecated Please use xyzOut instead.
  124821. */
  124822. readonly xyz: NodeMaterialConnectionPoint;
  124823. protected _buildBlock(state: NodeMaterialBuildState): this;
  124824. }
  124825. }
  124826. declare module BABYLON {
  124827. /**
  124828. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  124829. */
  124830. export class ColorSplitterBlock extends NodeMaterialBlock {
  124831. /**
  124832. * Create a new ColorSplitterBlock
  124833. * @param name defines the block name
  124834. */
  124835. constructor(name: string);
  124836. /**
  124837. * Gets the current class name
  124838. * @returns the class name
  124839. */
  124840. getClassName(): string;
  124841. /**
  124842. * Gets the rgba component (input)
  124843. */
  124844. readonly rgba: NodeMaterialConnectionPoint;
  124845. /**
  124846. * Gets the rgb component (input)
  124847. */
  124848. readonly rgbIn: NodeMaterialConnectionPoint;
  124849. /**
  124850. * Gets the rgb component (output)
  124851. */
  124852. readonly rgbOut: NodeMaterialConnectionPoint;
  124853. /**
  124854. * Gets the r component (output)
  124855. */
  124856. readonly r: NodeMaterialConnectionPoint;
  124857. /**
  124858. * Gets the g component (output)
  124859. */
  124860. readonly g: NodeMaterialConnectionPoint;
  124861. /**
  124862. * Gets the b component (output)
  124863. */
  124864. readonly b: NodeMaterialConnectionPoint;
  124865. /**
  124866. * Gets the a component (output)
  124867. */
  124868. readonly a: NodeMaterialConnectionPoint;
  124869. protected _inputRename(name: string): string;
  124870. protected _outputRename(name: string): string;
  124871. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124872. }
  124873. }
  124874. declare module BABYLON {
  124875. /**
  124876. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  124877. */
  124878. export class VectorSplitterBlock extends NodeMaterialBlock {
  124879. /**
  124880. * Create a new VectorSplitterBlock
  124881. * @param name defines the block name
  124882. */
  124883. constructor(name: string);
  124884. /**
  124885. * Gets the current class name
  124886. * @returns the class name
  124887. */
  124888. getClassName(): string;
  124889. /**
  124890. * Gets the xyzw component (input)
  124891. */
  124892. readonly xyzw: NodeMaterialConnectionPoint;
  124893. /**
  124894. * Gets the xyz component (input)
  124895. */
  124896. readonly xyzIn: NodeMaterialConnectionPoint;
  124897. /**
  124898. * Gets the xy component (input)
  124899. */
  124900. readonly xyIn: NodeMaterialConnectionPoint;
  124901. /**
  124902. * Gets the xyz component (output)
  124903. */
  124904. readonly xyzOut: NodeMaterialConnectionPoint;
  124905. /**
  124906. * Gets the xy component (output)
  124907. */
  124908. readonly xyOut: NodeMaterialConnectionPoint;
  124909. /**
  124910. * Gets the x component (output)
  124911. */
  124912. readonly x: NodeMaterialConnectionPoint;
  124913. /**
  124914. * Gets the y component (output)
  124915. */
  124916. readonly y: NodeMaterialConnectionPoint;
  124917. /**
  124918. * Gets the z component (output)
  124919. */
  124920. readonly z: NodeMaterialConnectionPoint;
  124921. /**
  124922. * Gets the w component (output)
  124923. */
  124924. readonly w: NodeMaterialConnectionPoint;
  124925. protected _inputRename(name: string): string;
  124926. protected _outputRename(name: string): string;
  124927. protected _buildBlock(state: NodeMaterialBuildState): this;
  124928. }
  124929. }
  124930. declare module BABYLON {
  124931. /**
  124932. * Block used to lerp between 2 values
  124933. */
  124934. export class LerpBlock extends NodeMaterialBlock {
  124935. /**
  124936. * Creates a new LerpBlock
  124937. * @param name defines the block name
  124938. */
  124939. constructor(name: string);
  124940. /**
  124941. * Gets the current class name
  124942. * @returns the class name
  124943. */
  124944. getClassName(): string;
  124945. /**
  124946. * Gets the left operand input component
  124947. */
  124948. readonly left: NodeMaterialConnectionPoint;
  124949. /**
  124950. * Gets the right operand input component
  124951. */
  124952. readonly right: NodeMaterialConnectionPoint;
  124953. /**
  124954. * Gets the gradient operand input component
  124955. */
  124956. readonly gradient: NodeMaterialConnectionPoint;
  124957. /**
  124958. * Gets the output component
  124959. */
  124960. readonly output: NodeMaterialConnectionPoint;
  124961. protected _buildBlock(state: NodeMaterialBuildState): this;
  124962. }
  124963. }
  124964. declare module BABYLON {
  124965. /**
  124966. * Block used to divide 2 vectors
  124967. */
  124968. export class DivideBlock extends NodeMaterialBlock {
  124969. /**
  124970. * Creates a new DivideBlock
  124971. * @param name defines the block name
  124972. */
  124973. constructor(name: string);
  124974. /**
  124975. * Gets the current class name
  124976. * @returns the class name
  124977. */
  124978. getClassName(): string;
  124979. /**
  124980. * Gets the left operand input component
  124981. */
  124982. readonly left: NodeMaterialConnectionPoint;
  124983. /**
  124984. * Gets the right operand input component
  124985. */
  124986. readonly right: NodeMaterialConnectionPoint;
  124987. /**
  124988. * Gets the output component
  124989. */
  124990. readonly output: NodeMaterialConnectionPoint;
  124991. protected _buildBlock(state: NodeMaterialBuildState): this;
  124992. }
  124993. }
  124994. declare module BABYLON {
  124995. /**
  124996. * Block used to subtract 2 vectors
  124997. */
  124998. export class SubtractBlock extends NodeMaterialBlock {
  124999. /**
  125000. * Creates a new SubtractBlock
  125001. * @param name defines the block name
  125002. */
  125003. constructor(name: string);
  125004. /**
  125005. * Gets the current class name
  125006. * @returns the class name
  125007. */
  125008. getClassName(): string;
  125009. /**
  125010. * Gets the left operand input component
  125011. */
  125012. readonly left: NodeMaterialConnectionPoint;
  125013. /**
  125014. * Gets the right operand input component
  125015. */
  125016. readonly right: NodeMaterialConnectionPoint;
  125017. /**
  125018. * Gets the output component
  125019. */
  125020. readonly output: NodeMaterialConnectionPoint;
  125021. protected _buildBlock(state: NodeMaterialBuildState): this;
  125022. }
  125023. }
  125024. declare module BABYLON {
  125025. /**
  125026. * Block used to step a value
  125027. */
  125028. export class StepBlock extends NodeMaterialBlock {
  125029. /**
  125030. * Creates a new StepBlock
  125031. * @param name defines the block name
  125032. */
  125033. constructor(name: string);
  125034. /**
  125035. * Gets the current class name
  125036. * @returns the class name
  125037. */
  125038. getClassName(): string;
  125039. /**
  125040. * Gets the value operand input component
  125041. */
  125042. readonly value: NodeMaterialConnectionPoint;
  125043. /**
  125044. * Gets the edge operand input component
  125045. */
  125046. readonly edge: NodeMaterialConnectionPoint;
  125047. /**
  125048. * Gets the output component
  125049. */
  125050. readonly output: NodeMaterialConnectionPoint;
  125051. protected _buildBlock(state: NodeMaterialBuildState): this;
  125052. }
  125053. }
  125054. declare module BABYLON {
  125055. /**
  125056. * Block used to get the opposite (1 - x) of a value
  125057. */
  125058. export class OneMinusBlock extends NodeMaterialBlock {
  125059. /**
  125060. * Creates a new OneMinusBlock
  125061. * @param name defines the block name
  125062. */
  125063. constructor(name: string);
  125064. /**
  125065. * Gets the current class name
  125066. * @returns the class name
  125067. */
  125068. getClassName(): string;
  125069. /**
  125070. * Gets the input component
  125071. */
  125072. readonly input: NodeMaterialConnectionPoint;
  125073. /**
  125074. * Gets the output component
  125075. */
  125076. readonly output: NodeMaterialConnectionPoint;
  125077. protected _buildBlock(state: NodeMaterialBuildState): this;
  125078. }
  125079. }
  125080. declare module BABYLON {
  125081. /**
  125082. * Block used to get the view direction
  125083. */
  125084. export class ViewDirectionBlock extends NodeMaterialBlock {
  125085. /**
  125086. * Creates a new ViewDirectionBlock
  125087. * @param name defines the block name
  125088. */
  125089. constructor(name: string);
  125090. /**
  125091. * Gets the current class name
  125092. * @returns the class name
  125093. */
  125094. getClassName(): string;
  125095. /**
  125096. * Gets the world position component
  125097. */
  125098. readonly worldPosition: NodeMaterialConnectionPoint;
  125099. /**
  125100. * Gets the camera position component
  125101. */
  125102. readonly cameraPosition: NodeMaterialConnectionPoint;
  125103. /**
  125104. * Gets the output component
  125105. */
  125106. readonly output: NodeMaterialConnectionPoint;
  125107. autoConfigure(material: NodeMaterial): void;
  125108. protected _buildBlock(state: NodeMaterialBuildState): this;
  125109. }
  125110. }
  125111. declare module BABYLON {
  125112. /**
  125113. * Block used to compute fresnel value
  125114. */
  125115. export class FresnelBlock extends NodeMaterialBlock {
  125116. /**
  125117. * Create a new FresnelBlock
  125118. * @param name defines the block name
  125119. */
  125120. constructor(name: string);
  125121. /**
  125122. * Gets the current class name
  125123. * @returns the class name
  125124. */
  125125. getClassName(): string;
  125126. /**
  125127. * Gets the world normal input component
  125128. */
  125129. readonly worldNormal: NodeMaterialConnectionPoint;
  125130. /**
  125131. * Gets the view direction input component
  125132. */
  125133. readonly viewDirection: NodeMaterialConnectionPoint;
  125134. /**
  125135. * Gets the bias input component
  125136. */
  125137. readonly bias: NodeMaterialConnectionPoint;
  125138. /**
  125139. * Gets the camera (or eye) position component
  125140. */
  125141. readonly power: NodeMaterialConnectionPoint;
  125142. /**
  125143. * Gets the fresnel output component
  125144. */
  125145. readonly fresnel: NodeMaterialConnectionPoint;
  125146. autoConfigure(material: NodeMaterial): void;
  125147. protected _buildBlock(state: NodeMaterialBuildState): this;
  125148. }
  125149. }
  125150. declare module BABYLON {
  125151. /**
  125152. * Block used to get the max of 2 values
  125153. */
  125154. export class MaxBlock extends NodeMaterialBlock {
  125155. /**
  125156. * Creates a new MaxBlock
  125157. * @param name defines the block name
  125158. */
  125159. constructor(name: string);
  125160. /**
  125161. * Gets the current class name
  125162. * @returns the class name
  125163. */
  125164. getClassName(): string;
  125165. /**
  125166. * Gets the left operand input component
  125167. */
  125168. readonly left: NodeMaterialConnectionPoint;
  125169. /**
  125170. * Gets the right operand input component
  125171. */
  125172. readonly right: NodeMaterialConnectionPoint;
  125173. /**
  125174. * Gets the output component
  125175. */
  125176. readonly output: NodeMaterialConnectionPoint;
  125177. protected _buildBlock(state: NodeMaterialBuildState): this;
  125178. }
  125179. }
  125180. declare module BABYLON {
  125181. /**
  125182. * Block used to get the min of 2 values
  125183. */
  125184. export class MinBlock extends NodeMaterialBlock {
  125185. /**
  125186. * Creates a new MinBlock
  125187. * @param name defines the block name
  125188. */
  125189. constructor(name: string);
  125190. /**
  125191. * Gets the current class name
  125192. * @returns the class name
  125193. */
  125194. getClassName(): string;
  125195. /**
  125196. * Gets the left operand input component
  125197. */
  125198. readonly left: NodeMaterialConnectionPoint;
  125199. /**
  125200. * Gets the right operand input component
  125201. */
  125202. readonly right: NodeMaterialConnectionPoint;
  125203. /**
  125204. * Gets the output component
  125205. */
  125206. readonly output: NodeMaterialConnectionPoint;
  125207. protected _buildBlock(state: NodeMaterialBuildState): this;
  125208. }
  125209. }
  125210. declare module BABYLON {
  125211. /**
  125212. * Block used to get the distance between 2 values
  125213. */
  125214. export class DistanceBlock extends NodeMaterialBlock {
  125215. /**
  125216. * Creates a new DistanceBlock
  125217. * @param name defines the block name
  125218. */
  125219. constructor(name: string);
  125220. /**
  125221. * Gets the current class name
  125222. * @returns the class name
  125223. */
  125224. getClassName(): string;
  125225. /**
  125226. * Gets the left operand input component
  125227. */
  125228. readonly left: NodeMaterialConnectionPoint;
  125229. /**
  125230. * Gets the right operand input component
  125231. */
  125232. readonly right: NodeMaterialConnectionPoint;
  125233. /**
  125234. * Gets the output component
  125235. */
  125236. readonly output: NodeMaterialConnectionPoint;
  125237. protected _buildBlock(state: NodeMaterialBuildState): this;
  125238. }
  125239. }
  125240. declare module BABYLON {
  125241. /**
  125242. * Block used to get the length of a vector
  125243. */
  125244. export class LengthBlock extends NodeMaterialBlock {
  125245. /**
  125246. * Creates a new LengthBlock
  125247. * @param name defines the block name
  125248. */
  125249. constructor(name: string);
  125250. /**
  125251. * Gets the current class name
  125252. * @returns the class name
  125253. */
  125254. getClassName(): string;
  125255. /**
  125256. * Gets the value input component
  125257. */
  125258. readonly value: NodeMaterialConnectionPoint;
  125259. /**
  125260. * Gets the output component
  125261. */
  125262. readonly output: NodeMaterialConnectionPoint;
  125263. protected _buildBlock(state: NodeMaterialBuildState): this;
  125264. }
  125265. }
  125266. declare module BABYLON {
  125267. /**
  125268. * Block used to get negative version of a value (i.e. x * -1)
  125269. */
  125270. export class NegateBlock extends NodeMaterialBlock {
  125271. /**
  125272. * Creates a new NegateBlock
  125273. * @param name defines the block name
  125274. */
  125275. constructor(name: string);
  125276. /**
  125277. * Gets the current class name
  125278. * @returns the class name
  125279. */
  125280. getClassName(): string;
  125281. /**
  125282. * Gets the value input component
  125283. */
  125284. readonly value: NodeMaterialConnectionPoint;
  125285. /**
  125286. * Gets the output component
  125287. */
  125288. readonly output: NodeMaterialConnectionPoint;
  125289. protected _buildBlock(state: NodeMaterialBuildState): this;
  125290. }
  125291. }
  125292. declare module BABYLON {
  125293. /**
  125294. * Block used to get the value of the first parameter raised to the power of the second
  125295. */
  125296. export class PowBlock extends NodeMaterialBlock {
  125297. /**
  125298. * Creates a new PowBlock
  125299. * @param name defines the block name
  125300. */
  125301. constructor(name: string);
  125302. /**
  125303. * Gets the current class name
  125304. * @returns the class name
  125305. */
  125306. getClassName(): string;
  125307. /**
  125308. * Gets the value operand input component
  125309. */
  125310. readonly value: NodeMaterialConnectionPoint;
  125311. /**
  125312. * Gets the power operand input component
  125313. */
  125314. readonly power: NodeMaterialConnectionPoint;
  125315. /**
  125316. * Gets the output component
  125317. */
  125318. readonly output: NodeMaterialConnectionPoint;
  125319. protected _buildBlock(state: NodeMaterialBuildState): this;
  125320. }
  125321. }
  125322. declare module BABYLON {
  125323. /**
  125324. * Block used to get a random number
  125325. */
  125326. export class RandomNumberBlock extends NodeMaterialBlock {
  125327. /**
  125328. * Creates a new RandomNumberBlock
  125329. * @param name defines the block name
  125330. */
  125331. constructor(name: string);
  125332. /**
  125333. * Gets the current class name
  125334. * @returns the class name
  125335. */
  125336. getClassName(): string;
  125337. /**
  125338. * Gets the seed input component
  125339. */
  125340. readonly seed: NodeMaterialConnectionPoint;
  125341. /**
  125342. * Gets the output component
  125343. */
  125344. readonly output: NodeMaterialConnectionPoint;
  125345. protected _buildBlock(state: NodeMaterialBuildState): this;
  125346. }
  125347. }
  125348. declare module BABYLON {
  125349. /**
  125350. * Block used to compute arc tangent of 2 values
  125351. */
  125352. export class ArcTan2Block extends NodeMaterialBlock {
  125353. /**
  125354. * Creates a new ArcTan2Block
  125355. * @param name defines the block name
  125356. */
  125357. constructor(name: string);
  125358. /**
  125359. * Gets the current class name
  125360. * @returns the class name
  125361. */
  125362. getClassName(): string;
  125363. /**
  125364. * Gets the x operand input component
  125365. */
  125366. readonly x: NodeMaterialConnectionPoint;
  125367. /**
  125368. * Gets the y operand input component
  125369. */
  125370. readonly y: NodeMaterialConnectionPoint;
  125371. /**
  125372. * Gets the output component
  125373. */
  125374. readonly output: NodeMaterialConnectionPoint;
  125375. protected _buildBlock(state: NodeMaterialBuildState): this;
  125376. }
  125377. }
  125378. declare module BABYLON {
  125379. /**
  125380. * Block used to smooth step a value
  125381. */
  125382. export class SmoothStepBlock extends NodeMaterialBlock {
  125383. /**
  125384. * Creates a new SmoothStepBlock
  125385. * @param name defines the block name
  125386. */
  125387. constructor(name: string);
  125388. /**
  125389. * Gets the current class name
  125390. * @returns the class name
  125391. */
  125392. getClassName(): string;
  125393. /**
  125394. * Gets the value operand input component
  125395. */
  125396. readonly value: NodeMaterialConnectionPoint;
  125397. /**
  125398. * Gets the first edge operand input component
  125399. */
  125400. readonly edge0: NodeMaterialConnectionPoint;
  125401. /**
  125402. * Gets the second edge operand input component
  125403. */
  125404. readonly edge1: NodeMaterialConnectionPoint;
  125405. /**
  125406. * Gets the output component
  125407. */
  125408. readonly output: NodeMaterialConnectionPoint;
  125409. protected _buildBlock(state: NodeMaterialBuildState): this;
  125410. }
  125411. }
  125412. declare module BABYLON {
  125413. /**
  125414. * Block used to get the reciprocal (1 / x) of a value
  125415. */
  125416. export class ReciprocalBlock extends NodeMaterialBlock {
  125417. /**
  125418. * Creates a new ReciprocalBlock
  125419. * @param name defines the block name
  125420. */
  125421. constructor(name: string);
  125422. /**
  125423. * Gets the current class name
  125424. * @returns the class name
  125425. */
  125426. getClassName(): string;
  125427. /**
  125428. * Gets the input component
  125429. */
  125430. readonly input: NodeMaterialConnectionPoint;
  125431. /**
  125432. * Gets the output component
  125433. */
  125434. readonly output: NodeMaterialConnectionPoint;
  125435. protected _buildBlock(state: NodeMaterialBuildState): this;
  125436. }
  125437. }
  125438. declare module BABYLON {
  125439. /**
  125440. * Block used to replace a color by another one
  125441. */
  125442. export class ReplaceColorBlock extends NodeMaterialBlock {
  125443. /**
  125444. * Creates a new ReplaceColorBlock
  125445. * @param name defines the block name
  125446. */
  125447. constructor(name: string);
  125448. /**
  125449. * Gets the current class name
  125450. * @returns the class name
  125451. */
  125452. getClassName(): string;
  125453. /**
  125454. * Gets the value input component
  125455. */
  125456. readonly value: NodeMaterialConnectionPoint;
  125457. /**
  125458. * Gets the reference input component
  125459. */
  125460. readonly reference: NodeMaterialConnectionPoint;
  125461. /**
  125462. * Gets the distance input component
  125463. */
  125464. readonly distance: NodeMaterialConnectionPoint;
  125465. /**
  125466. * Gets the replacement input component
  125467. */
  125468. readonly replacement: NodeMaterialConnectionPoint;
  125469. /**
  125470. * Gets the output component
  125471. */
  125472. readonly output: NodeMaterialConnectionPoint;
  125473. protected _buildBlock(state: NodeMaterialBuildState): this;
  125474. }
  125475. }
  125476. declare module BABYLON {
  125477. /**
  125478. * Block used to posterize a value
  125479. * @see https://en.wikipedia.org/wiki/Posterization
  125480. */
  125481. export class PosterizeBlock extends NodeMaterialBlock {
  125482. /**
  125483. * Creates a new PosterizeBlock
  125484. * @param name defines the block name
  125485. */
  125486. constructor(name: string);
  125487. /**
  125488. * Gets the current class name
  125489. * @returns the class name
  125490. */
  125491. getClassName(): string;
  125492. /**
  125493. * Gets the value input component
  125494. */
  125495. readonly value: NodeMaterialConnectionPoint;
  125496. /**
  125497. * Gets the steps input component
  125498. */
  125499. readonly steps: NodeMaterialConnectionPoint;
  125500. /**
  125501. * Gets the output component
  125502. */
  125503. readonly output: NodeMaterialConnectionPoint;
  125504. protected _buildBlock(state: NodeMaterialBuildState): this;
  125505. }
  125506. }
  125507. declare module BABYLON {
  125508. /**
  125509. * Operations supported by the Wave block
  125510. */
  125511. export enum WaveBlockKind {
  125512. /** SawTooth */
  125513. SawTooth = 0,
  125514. /** Square */
  125515. Square = 1,
  125516. /** Triangle */
  125517. Triangle = 2
  125518. }
  125519. /**
  125520. * Block used to apply wave operation to floats
  125521. */
  125522. export class WaveBlock extends NodeMaterialBlock {
  125523. /**
  125524. * Gets or sets the kibnd of wave to be applied by the block
  125525. */
  125526. kind: WaveBlockKind;
  125527. /**
  125528. * Creates a new WaveBlock
  125529. * @param name defines the block name
  125530. */
  125531. constructor(name: string);
  125532. /**
  125533. * Gets the current class name
  125534. * @returns the class name
  125535. */
  125536. getClassName(): string;
  125537. /**
  125538. * Gets the input component
  125539. */
  125540. readonly input: NodeMaterialConnectionPoint;
  125541. /**
  125542. * Gets the output component
  125543. */
  125544. readonly output: NodeMaterialConnectionPoint;
  125545. protected _buildBlock(state: NodeMaterialBuildState): this;
  125546. serialize(): any;
  125547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125548. }
  125549. }
  125550. declare module BABYLON {
  125551. /**
  125552. * Class used to store a color step for the GradientBlock
  125553. */
  125554. export class GradientBlockColorStep {
  125555. /**
  125556. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125557. */
  125558. step: number;
  125559. /**
  125560. * Gets or sets the color associated with this step
  125561. */
  125562. color: Color3;
  125563. /**
  125564. * Creates a new GradientBlockColorStep
  125565. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  125566. * @param color defines the color associated with this step
  125567. */
  125568. constructor(
  125569. /**
  125570. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125571. */
  125572. step: number,
  125573. /**
  125574. * Gets or sets the color associated with this step
  125575. */
  125576. color: Color3);
  125577. }
  125578. /**
  125579. * Block used to return a color from a gradient based on an input value between 0 and 1
  125580. */
  125581. export class GradientBlock extends NodeMaterialBlock {
  125582. /**
  125583. * Gets or sets the list of color steps
  125584. */
  125585. colorSteps: GradientBlockColorStep[];
  125586. /**
  125587. * Creates a new GradientBlock
  125588. * @param name defines the block name
  125589. */
  125590. constructor(name: string);
  125591. /**
  125592. * Gets the current class name
  125593. * @returns the class name
  125594. */
  125595. getClassName(): string;
  125596. /**
  125597. * Gets the gradient input component
  125598. */
  125599. readonly gradient: NodeMaterialConnectionPoint;
  125600. /**
  125601. * Gets the output component
  125602. */
  125603. readonly output: NodeMaterialConnectionPoint;
  125604. private _writeColorConstant;
  125605. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125606. serialize(): any;
  125607. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125608. protected _dumpPropertiesCode(): string;
  125609. }
  125610. }
  125611. declare module BABYLON {
  125612. /**
  125613. * Block used to normalize lerp between 2 values
  125614. */
  125615. export class NLerpBlock extends NodeMaterialBlock {
  125616. /**
  125617. * Creates a new NLerpBlock
  125618. * @param name defines the block name
  125619. */
  125620. constructor(name: string);
  125621. /**
  125622. * Gets the current class name
  125623. * @returns the class name
  125624. */
  125625. getClassName(): string;
  125626. /**
  125627. * Gets the left operand input component
  125628. */
  125629. readonly left: NodeMaterialConnectionPoint;
  125630. /**
  125631. * Gets the right operand input component
  125632. */
  125633. readonly right: NodeMaterialConnectionPoint;
  125634. /**
  125635. * Gets the gradient operand input component
  125636. */
  125637. readonly gradient: NodeMaterialConnectionPoint;
  125638. /**
  125639. * Gets the output component
  125640. */
  125641. readonly output: NodeMaterialConnectionPoint;
  125642. protected _buildBlock(state: NodeMaterialBuildState): this;
  125643. }
  125644. }
  125645. declare module BABYLON {
  125646. /**
  125647. * block used to Generate a Worley Noise 3D Noise Pattern
  125648. */
  125649. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  125650. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  125651. manhattanDistance: boolean;
  125652. /**
  125653. * Creates a new WorleyNoise3DBlock
  125654. * @param name defines the block name
  125655. */
  125656. constructor(name: string);
  125657. /**
  125658. * Gets the current class name
  125659. * @returns the class name
  125660. */
  125661. getClassName(): string;
  125662. /**
  125663. * Gets the seed input component
  125664. */
  125665. readonly seed: NodeMaterialConnectionPoint;
  125666. /**
  125667. * Gets the jitter input component
  125668. */
  125669. readonly jitter: NodeMaterialConnectionPoint;
  125670. /**
  125671. * Gets the output component
  125672. */
  125673. readonly output: NodeMaterialConnectionPoint;
  125674. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125675. /**
  125676. * Exposes the properties to the UI?
  125677. */
  125678. protected _dumpPropertiesCode(): string;
  125679. /**
  125680. * Exposes the properties to the Seralize?
  125681. */
  125682. serialize(): any;
  125683. /**
  125684. * Exposes the properties to the deseralize?
  125685. */
  125686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125687. }
  125688. }
  125689. declare module BABYLON {
  125690. /**
  125691. * block used to Generate a Simplex Perlin 3d Noise Pattern
  125692. */
  125693. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  125694. /**
  125695. * Creates a new SimplexPerlin3DBlock
  125696. * @param name defines the block name
  125697. */
  125698. constructor(name: string);
  125699. /**
  125700. * Gets the current class name
  125701. * @returns the class name
  125702. */
  125703. getClassName(): string;
  125704. /**
  125705. * Gets the seed operand input component
  125706. */
  125707. readonly seed: NodeMaterialConnectionPoint;
  125708. /**
  125709. * Gets the output component
  125710. */
  125711. readonly output: NodeMaterialConnectionPoint;
  125712. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125713. }
  125714. }
  125715. declare module BABYLON {
  125716. /**
  125717. * Block used to blend normals
  125718. */
  125719. export class NormalBlendBlock extends NodeMaterialBlock {
  125720. /**
  125721. * Creates a new NormalBlendBlock
  125722. * @param name defines the block name
  125723. */
  125724. constructor(name: string);
  125725. /**
  125726. * Gets the current class name
  125727. * @returns the class name
  125728. */
  125729. getClassName(): string;
  125730. /**
  125731. * Gets the first input component
  125732. */
  125733. readonly normalMap0: NodeMaterialConnectionPoint;
  125734. /**
  125735. * Gets the second input component
  125736. */
  125737. readonly normalMap1: NodeMaterialConnectionPoint;
  125738. /**
  125739. * Gets the output component
  125740. */
  125741. readonly output: NodeMaterialConnectionPoint;
  125742. protected _buildBlock(state: NodeMaterialBuildState): this;
  125743. }
  125744. }
  125745. declare module BABYLON {
  125746. /**
  125747. * Block used to rotate a 2d vector by a given angle
  125748. */
  125749. export class Rotate2dBlock extends NodeMaterialBlock {
  125750. /**
  125751. * Creates a new Rotate2dBlock
  125752. * @param name defines the block name
  125753. */
  125754. constructor(name: string);
  125755. /**
  125756. * Gets the current class name
  125757. * @returns the class name
  125758. */
  125759. getClassName(): string;
  125760. /**
  125761. * Gets the input vector
  125762. */
  125763. readonly input: NodeMaterialConnectionPoint;
  125764. /**
  125765. * Gets the input angle
  125766. */
  125767. readonly angle: NodeMaterialConnectionPoint;
  125768. /**
  125769. * Gets the output component
  125770. */
  125771. readonly output: NodeMaterialConnectionPoint;
  125772. autoConfigure(material: NodeMaterial): void;
  125773. protected _buildBlock(state: NodeMaterialBuildState): this;
  125774. }
  125775. }
  125776. declare module BABYLON {
  125777. /**
  125778. * Block used to get the reflected vector from a direction and a normal
  125779. */
  125780. export class ReflectBlock extends NodeMaterialBlock {
  125781. /**
  125782. * Creates a new ReflectBlock
  125783. * @param name defines the block name
  125784. */
  125785. constructor(name: string);
  125786. /**
  125787. * Gets the current class name
  125788. * @returns the class name
  125789. */
  125790. getClassName(): string;
  125791. /**
  125792. * Gets the incident component
  125793. */
  125794. readonly incident: NodeMaterialConnectionPoint;
  125795. /**
  125796. * Gets the normal component
  125797. */
  125798. readonly normal: NodeMaterialConnectionPoint;
  125799. /**
  125800. * Gets the output component
  125801. */
  125802. readonly output: NodeMaterialConnectionPoint;
  125803. protected _buildBlock(state: NodeMaterialBuildState): this;
  125804. }
  125805. }
  125806. declare module BABYLON {
  125807. /**
  125808. * Block used to get the refracted vector from a direction and a normal
  125809. */
  125810. export class RefractBlock extends NodeMaterialBlock {
  125811. /**
  125812. * Creates a new RefractBlock
  125813. * @param name defines the block name
  125814. */
  125815. constructor(name: string);
  125816. /**
  125817. * Gets the current class name
  125818. * @returns the class name
  125819. */
  125820. getClassName(): string;
  125821. /**
  125822. * Gets the incident component
  125823. */
  125824. readonly incident: NodeMaterialConnectionPoint;
  125825. /**
  125826. * Gets the normal component
  125827. */
  125828. readonly normal: NodeMaterialConnectionPoint;
  125829. /**
  125830. * Gets the index of refraction component
  125831. */
  125832. readonly ior: NodeMaterialConnectionPoint;
  125833. /**
  125834. * Gets the output component
  125835. */
  125836. readonly output: NodeMaterialConnectionPoint;
  125837. protected _buildBlock(state: NodeMaterialBuildState): this;
  125838. }
  125839. }
  125840. declare module BABYLON {
  125841. /**
  125842. * Block used to desaturate a color
  125843. */
  125844. export class DesaturateBlock extends NodeMaterialBlock {
  125845. /**
  125846. * Creates a new DesaturateBlock
  125847. * @param name defines the block name
  125848. */
  125849. constructor(name: string);
  125850. /**
  125851. * Gets the current class name
  125852. * @returns the class name
  125853. */
  125854. getClassName(): string;
  125855. /**
  125856. * Gets the color operand input component
  125857. */
  125858. readonly color: NodeMaterialConnectionPoint;
  125859. /**
  125860. * Gets the level operand input component
  125861. */
  125862. readonly level: NodeMaterialConnectionPoint;
  125863. /**
  125864. * Gets the output component
  125865. */
  125866. readonly output: NodeMaterialConnectionPoint;
  125867. protected _buildBlock(state: NodeMaterialBuildState): this;
  125868. }
  125869. }
  125870. declare module BABYLON {
  125871. /**
  125872. * Effect Render Options
  125873. */
  125874. export interface IEffectRendererOptions {
  125875. /**
  125876. * Defines the vertices positions.
  125877. */
  125878. positions?: number[];
  125879. /**
  125880. * Defines the indices.
  125881. */
  125882. indices?: number[];
  125883. }
  125884. /**
  125885. * Helper class to render one or more effects
  125886. */
  125887. export class EffectRenderer {
  125888. private engine;
  125889. private static _DefaultOptions;
  125890. private _vertexBuffers;
  125891. private _indexBuffer;
  125892. private _ringBufferIndex;
  125893. private _ringScreenBuffer;
  125894. private _fullscreenViewport;
  125895. private _getNextFrameBuffer;
  125896. /**
  125897. * Creates an effect renderer
  125898. * @param engine the engine to use for rendering
  125899. * @param options defines the options of the effect renderer
  125900. */
  125901. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  125902. /**
  125903. * Sets the current viewport in normalized coordinates 0-1
  125904. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  125905. */
  125906. setViewport(viewport?: Viewport): void;
  125907. /**
  125908. * Binds the embedded attributes buffer to the effect.
  125909. * @param effect Defines the effect to bind the attributes for
  125910. */
  125911. bindBuffers(effect: Effect): void;
  125912. /**
  125913. * Sets the current effect wrapper to use during draw.
  125914. * The effect needs to be ready before calling this api.
  125915. * This also sets the default full screen position attribute.
  125916. * @param effectWrapper Defines the effect to draw with
  125917. */
  125918. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  125919. /**
  125920. * Draws a full screen quad.
  125921. */
  125922. draw(): void;
  125923. /**
  125924. * renders one or more effects to a specified texture
  125925. * @param effectWrappers list of effects to renderer
  125926. * @param outputTexture texture to draw to, if null it will render to the screen
  125927. */
  125928. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  125929. /**
  125930. * Disposes of the effect renderer
  125931. */
  125932. dispose(): void;
  125933. }
  125934. /**
  125935. * Options to create an EffectWrapper
  125936. */
  125937. interface EffectWrapperCreationOptions {
  125938. /**
  125939. * Engine to use to create the effect
  125940. */
  125941. engine: ThinEngine;
  125942. /**
  125943. * Fragment shader for the effect
  125944. */
  125945. fragmentShader: string;
  125946. /**
  125947. * Vertex shader for the effect
  125948. */
  125949. vertexShader?: string;
  125950. /**
  125951. * Attributes to use in the shader
  125952. */
  125953. attributeNames?: Array<string>;
  125954. /**
  125955. * Uniforms to use in the shader
  125956. */
  125957. uniformNames?: Array<string>;
  125958. /**
  125959. * Texture sampler names to use in the shader
  125960. */
  125961. samplerNames?: Array<string>;
  125962. /**
  125963. * The friendly name of the effect displayed in Spector.
  125964. */
  125965. name?: string;
  125966. }
  125967. /**
  125968. * Wraps an effect to be used for rendering
  125969. */
  125970. export class EffectWrapper {
  125971. /**
  125972. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  125973. */
  125974. onApplyObservable: Observable<{}>;
  125975. /**
  125976. * The underlying effect
  125977. */
  125978. effect: Effect;
  125979. /**
  125980. * Creates an effect to be renderer
  125981. * @param creationOptions options to create the effect
  125982. */
  125983. constructor(creationOptions: EffectWrapperCreationOptions);
  125984. /**
  125985. * Disposes of the effect wrapper
  125986. */
  125987. dispose(): void;
  125988. }
  125989. }
  125990. declare module BABYLON {
  125991. /**
  125992. * Helper class to push actions to a pool of workers.
  125993. */
  125994. export class WorkerPool implements IDisposable {
  125995. private _workerInfos;
  125996. private _pendingActions;
  125997. /**
  125998. * Constructor
  125999. * @param workers Array of workers to use for actions
  126000. */
  126001. constructor(workers: Array<Worker>);
  126002. /**
  126003. * Terminates all workers and clears any pending actions.
  126004. */
  126005. dispose(): void;
  126006. /**
  126007. * Pushes an action to the worker pool. If all the workers are active, the action will be
  126008. * pended until a worker has completed its action.
  126009. * @param action The action to perform. Call onComplete when the action is complete.
  126010. */
  126011. push(action: (worker: Worker, onComplete: () => void) => void): void;
  126012. private _execute;
  126013. }
  126014. }
  126015. declare module BABYLON {
  126016. /**
  126017. * Configuration for Draco compression
  126018. */
  126019. export interface IDracoCompressionConfiguration {
  126020. /**
  126021. * Configuration for the decoder.
  126022. */
  126023. decoder: {
  126024. /**
  126025. * The url to the WebAssembly module.
  126026. */
  126027. wasmUrl?: string;
  126028. /**
  126029. * The url to the WebAssembly binary.
  126030. */
  126031. wasmBinaryUrl?: string;
  126032. /**
  126033. * The url to the fallback JavaScript module.
  126034. */
  126035. fallbackUrl?: string;
  126036. };
  126037. }
  126038. /**
  126039. * Draco compression (https://google.github.io/draco/)
  126040. *
  126041. * This class wraps the Draco module.
  126042. *
  126043. * **Encoder**
  126044. *
  126045. * The encoder is not currently implemented.
  126046. *
  126047. * **Decoder**
  126048. *
  126049. * 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.
  126050. *
  126051. * To update the configuration, use the following code:
  126052. * ```javascript
  126053. * DracoCompression.Configuration = {
  126054. * decoder: {
  126055. * wasmUrl: "<url to the WebAssembly library>",
  126056. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  126057. * fallbackUrl: "<url to the fallback JavaScript library>",
  126058. * }
  126059. * };
  126060. * ```
  126061. *
  126062. * 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.
  126063. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  126064. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  126065. *
  126066. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  126067. * ```javascript
  126068. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  126069. * ```
  126070. *
  126071. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  126072. */
  126073. export class DracoCompression implements IDisposable {
  126074. private _workerPoolPromise?;
  126075. private _decoderModulePromise?;
  126076. /**
  126077. * The configuration. Defaults to the following urls:
  126078. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  126079. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  126080. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  126081. */
  126082. static Configuration: IDracoCompressionConfiguration;
  126083. /**
  126084. * Returns true if the decoder configuration is available.
  126085. */
  126086. static readonly DecoderAvailable: boolean;
  126087. /**
  126088. * Default number of workers to create when creating the draco compression object.
  126089. */
  126090. static DefaultNumWorkers: number;
  126091. private static GetDefaultNumWorkers;
  126092. private static _Default;
  126093. /**
  126094. * Default instance for the draco compression object.
  126095. */
  126096. static readonly Default: DracoCompression;
  126097. /**
  126098. * Constructor
  126099. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  126100. */
  126101. constructor(numWorkers?: number);
  126102. /**
  126103. * Stop all async operations and release resources.
  126104. */
  126105. dispose(): void;
  126106. /**
  126107. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  126108. * @returns a promise that resolves when ready
  126109. */
  126110. whenReadyAsync(): Promise<void>;
  126111. /**
  126112. * Decode Draco compressed mesh data to vertex data.
  126113. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  126114. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  126115. * @returns A promise that resolves with the decoded vertex data
  126116. */
  126117. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  126118. [kind: string]: number;
  126119. }): Promise<VertexData>;
  126120. }
  126121. }
  126122. declare module BABYLON {
  126123. /**
  126124. * Class for building Constructive Solid Geometry
  126125. */
  126126. export class CSG {
  126127. private polygons;
  126128. /**
  126129. * The world matrix
  126130. */
  126131. matrix: Matrix;
  126132. /**
  126133. * Stores the position
  126134. */
  126135. position: Vector3;
  126136. /**
  126137. * Stores the rotation
  126138. */
  126139. rotation: Vector3;
  126140. /**
  126141. * Stores the rotation quaternion
  126142. */
  126143. rotationQuaternion: Nullable<Quaternion>;
  126144. /**
  126145. * Stores the scaling vector
  126146. */
  126147. scaling: Vector3;
  126148. /**
  126149. * Convert the Mesh to CSG
  126150. * @param mesh The Mesh to convert to CSG
  126151. * @returns A new CSG from the Mesh
  126152. */
  126153. static FromMesh(mesh: Mesh): CSG;
  126154. /**
  126155. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  126156. * @param polygons Polygons used to construct a CSG solid
  126157. */
  126158. private static FromPolygons;
  126159. /**
  126160. * Clones, or makes a deep copy, of the CSG
  126161. * @returns A new CSG
  126162. */
  126163. clone(): CSG;
  126164. /**
  126165. * Unions this CSG with another CSG
  126166. * @param csg The CSG to union against this CSG
  126167. * @returns The unioned CSG
  126168. */
  126169. union(csg: CSG): CSG;
  126170. /**
  126171. * Unions this CSG with another CSG in place
  126172. * @param csg The CSG to union against this CSG
  126173. */
  126174. unionInPlace(csg: CSG): void;
  126175. /**
  126176. * Subtracts this CSG with another CSG
  126177. * @param csg The CSG to subtract against this CSG
  126178. * @returns A new CSG
  126179. */
  126180. subtract(csg: CSG): CSG;
  126181. /**
  126182. * Subtracts this CSG with another CSG in place
  126183. * @param csg The CSG to subtact against this CSG
  126184. */
  126185. subtractInPlace(csg: CSG): void;
  126186. /**
  126187. * Intersect this CSG with another CSG
  126188. * @param csg The CSG to intersect against this CSG
  126189. * @returns A new CSG
  126190. */
  126191. intersect(csg: CSG): CSG;
  126192. /**
  126193. * Intersects this CSG with another CSG in place
  126194. * @param csg The CSG to intersect against this CSG
  126195. */
  126196. intersectInPlace(csg: CSG): void;
  126197. /**
  126198. * Return a new CSG solid with solid and empty space switched. This solid is
  126199. * not modified.
  126200. * @returns A new CSG solid with solid and empty space switched
  126201. */
  126202. inverse(): CSG;
  126203. /**
  126204. * Inverses the CSG in place
  126205. */
  126206. inverseInPlace(): void;
  126207. /**
  126208. * This is used to keep meshes transformations so they can be restored
  126209. * when we build back a Babylon Mesh
  126210. * NB : All CSG operations are performed in world coordinates
  126211. * @param csg The CSG to copy the transform attributes from
  126212. * @returns This CSG
  126213. */
  126214. copyTransformAttributes(csg: CSG): CSG;
  126215. /**
  126216. * Build Raw mesh from CSG
  126217. * Coordinates here are in world space
  126218. * @param name The name of the mesh geometry
  126219. * @param scene The Scene
  126220. * @param keepSubMeshes Specifies if the submeshes should be kept
  126221. * @returns A new Mesh
  126222. */
  126223. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126224. /**
  126225. * Build Mesh from CSG taking material and transforms into account
  126226. * @param name The name of the Mesh
  126227. * @param material The material of the Mesh
  126228. * @param scene The Scene
  126229. * @param keepSubMeshes Specifies if submeshes should be kept
  126230. * @returns The new Mesh
  126231. */
  126232. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126233. }
  126234. }
  126235. declare module BABYLON {
  126236. /**
  126237. * Class used to create a trail following a mesh
  126238. */
  126239. export class TrailMesh extends Mesh {
  126240. private _generator;
  126241. private _autoStart;
  126242. private _running;
  126243. private _diameter;
  126244. private _length;
  126245. private _sectionPolygonPointsCount;
  126246. private _sectionVectors;
  126247. private _sectionNormalVectors;
  126248. private _beforeRenderObserver;
  126249. /**
  126250. * @constructor
  126251. * @param name The value used by scene.getMeshByName() to do a lookup.
  126252. * @param generator The mesh to generate a trail.
  126253. * @param scene The scene to add this mesh to.
  126254. * @param diameter Diameter of trailing mesh. Default is 1.
  126255. * @param length Length of trailing mesh. Default is 60.
  126256. * @param autoStart Automatically start trailing mesh. Default true.
  126257. */
  126258. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  126259. /**
  126260. * "TrailMesh"
  126261. * @returns "TrailMesh"
  126262. */
  126263. getClassName(): string;
  126264. private _createMesh;
  126265. /**
  126266. * Start trailing mesh.
  126267. */
  126268. start(): void;
  126269. /**
  126270. * Stop trailing mesh.
  126271. */
  126272. stop(): void;
  126273. /**
  126274. * Update trailing mesh geometry.
  126275. */
  126276. update(): void;
  126277. /**
  126278. * Returns a new TrailMesh object.
  126279. * @param name is a string, the name given to the new mesh
  126280. * @param newGenerator use new generator object for cloned trail mesh
  126281. * @returns a new mesh
  126282. */
  126283. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  126284. /**
  126285. * Serializes this trail mesh
  126286. * @param serializationObject object to write serialization to
  126287. */
  126288. serialize(serializationObject: any): void;
  126289. /**
  126290. * Parses a serialized trail mesh
  126291. * @param parsedMesh the serialized mesh
  126292. * @param scene the scene to create the trail mesh in
  126293. * @returns the created trail mesh
  126294. */
  126295. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  126296. }
  126297. }
  126298. declare module BABYLON {
  126299. /**
  126300. * Class containing static functions to help procedurally build meshes
  126301. */
  126302. export class TiledBoxBuilder {
  126303. /**
  126304. * Creates a box mesh
  126305. * 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)
  126306. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126310. * @param name defines the name of the mesh
  126311. * @param options defines the options used to create the mesh
  126312. * @param scene defines the hosting scene
  126313. * @returns the box mesh
  126314. */
  126315. static CreateTiledBox(name: string, options: {
  126316. pattern?: number;
  126317. width?: number;
  126318. height?: number;
  126319. depth?: number;
  126320. tileSize?: number;
  126321. tileWidth?: number;
  126322. tileHeight?: number;
  126323. alignHorizontal?: number;
  126324. alignVertical?: number;
  126325. faceUV?: Vector4[];
  126326. faceColors?: Color4[];
  126327. sideOrientation?: number;
  126328. updatable?: boolean;
  126329. }, scene?: Nullable<Scene>): Mesh;
  126330. }
  126331. }
  126332. declare module BABYLON {
  126333. /**
  126334. * Class containing static functions to help procedurally build meshes
  126335. */
  126336. export class TorusKnotBuilder {
  126337. /**
  126338. * Creates a torus knot mesh
  126339. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  126340. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  126341. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  126342. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  126343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126346. * @param name defines the name of the mesh
  126347. * @param options defines the options used to create the mesh
  126348. * @param scene defines the hosting scene
  126349. * @returns the torus knot mesh
  126350. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  126351. */
  126352. static CreateTorusKnot(name: string, options: {
  126353. radius?: number;
  126354. tube?: number;
  126355. radialSegments?: number;
  126356. tubularSegments?: number;
  126357. p?: number;
  126358. q?: number;
  126359. updatable?: boolean;
  126360. sideOrientation?: number;
  126361. frontUVs?: Vector4;
  126362. backUVs?: Vector4;
  126363. }, scene: any): Mesh;
  126364. }
  126365. }
  126366. declare module BABYLON {
  126367. /**
  126368. * Polygon
  126369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  126370. */
  126371. export class Polygon {
  126372. /**
  126373. * Creates a rectangle
  126374. * @param xmin bottom X coord
  126375. * @param ymin bottom Y coord
  126376. * @param xmax top X coord
  126377. * @param ymax top Y coord
  126378. * @returns points that make the resulting rectation
  126379. */
  126380. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  126381. /**
  126382. * Creates a circle
  126383. * @param radius radius of circle
  126384. * @param cx scale in x
  126385. * @param cy scale in y
  126386. * @param numberOfSides number of sides that make up the circle
  126387. * @returns points that make the resulting circle
  126388. */
  126389. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  126390. /**
  126391. * Creates a polygon from input string
  126392. * @param input Input polygon data
  126393. * @returns the parsed points
  126394. */
  126395. static Parse(input: string): Vector2[];
  126396. /**
  126397. * Starts building a polygon from x and y coordinates
  126398. * @param x x coordinate
  126399. * @param y y coordinate
  126400. * @returns the started path2
  126401. */
  126402. static StartingAt(x: number, y: number): Path2;
  126403. }
  126404. /**
  126405. * Builds a polygon
  126406. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  126407. */
  126408. export class PolygonMeshBuilder {
  126409. private _points;
  126410. private _outlinepoints;
  126411. private _holes;
  126412. private _name;
  126413. private _scene;
  126414. private _epoints;
  126415. private _eholes;
  126416. private _addToepoint;
  126417. /**
  126418. * Babylon reference to the earcut plugin.
  126419. */
  126420. bjsEarcut: any;
  126421. /**
  126422. * Creates a PolygonMeshBuilder
  126423. * @param name name of the builder
  126424. * @param contours Path of the polygon
  126425. * @param scene scene to add to when creating the mesh
  126426. * @param earcutInjection can be used to inject your own earcut reference
  126427. */
  126428. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  126429. /**
  126430. * Adds a whole within the polygon
  126431. * @param hole Array of points defining the hole
  126432. * @returns this
  126433. */
  126434. addHole(hole: Vector2[]): PolygonMeshBuilder;
  126435. /**
  126436. * Creates the polygon
  126437. * @param updatable If the mesh should be updatable
  126438. * @param depth The depth of the mesh created
  126439. * @returns the created mesh
  126440. */
  126441. build(updatable?: boolean, depth?: number): Mesh;
  126442. /**
  126443. * Creates the polygon
  126444. * @param depth The depth of the mesh created
  126445. * @returns the created VertexData
  126446. */
  126447. buildVertexData(depth?: number): VertexData;
  126448. /**
  126449. * Adds a side to the polygon
  126450. * @param positions points that make the polygon
  126451. * @param normals normals of the polygon
  126452. * @param uvs uvs of the polygon
  126453. * @param indices indices of the polygon
  126454. * @param bounds bounds of the polygon
  126455. * @param points points of the polygon
  126456. * @param depth depth of the polygon
  126457. * @param flip flip of the polygon
  126458. */
  126459. private addSide;
  126460. }
  126461. }
  126462. declare module BABYLON {
  126463. /**
  126464. * Class containing static functions to help procedurally build meshes
  126465. */
  126466. export class PolygonBuilder {
  126467. /**
  126468. * Creates a polygon mesh
  126469. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126470. * * 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
  126471. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126474. * * Remember you can only change the shape positions, not their number when updating a polygon
  126475. * @param name defines the name of the mesh
  126476. * @param options defines the options used to create the mesh
  126477. * @param scene defines the hosting scene
  126478. * @param earcutInjection can be used to inject your own earcut reference
  126479. * @returns the polygon mesh
  126480. */
  126481. static CreatePolygon(name: string, options: {
  126482. shape: Vector3[];
  126483. holes?: Vector3[][];
  126484. depth?: number;
  126485. faceUV?: Vector4[];
  126486. faceColors?: Color4[];
  126487. updatable?: boolean;
  126488. sideOrientation?: number;
  126489. frontUVs?: Vector4;
  126490. backUVs?: Vector4;
  126491. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126492. /**
  126493. * Creates an extruded polygon mesh, with depth in the Y direction.
  126494. * * 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)
  126495. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126496. * @param name defines the name of the mesh
  126497. * @param options defines the options used to create the mesh
  126498. * @param scene defines the hosting scene
  126499. * @param earcutInjection can be used to inject your own earcut reference
  126500. * @returns the polygon mesh
  126501. */
  126502. static ExtrudePolygon(name: string, options: {
  126503. shape: Vector3[];
  126504. holes?: Vector3[][];
  126505. depth?: number;
  126506. faceUV?: Vector4[];
  126507. faceColors?: Color4[];
  126508. updatable?: boolean;
  126509. sideOrientation?: number;
  126510. frontUVs?: Vector4;
  126511. backUVs?: Vector4;
  126512. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126513. }
  126514. }
  126515. declare module BABYLON {
  126516. /**
  126517. * Class containing static functions to help procedurally build meshes
  126518. */
  126519. export class LatheBuilder {
  126520. /**
  126521. * Creates lathe mesh.
  126522. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  126523. * * 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
  126524. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  126525. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  126526. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  126527. * * 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
  126528. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  126529. * * 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
  126530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126531. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126532. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126534. * @param name defines the name of the mesh
  126535. * @param options defines the options used to create the mesh
  126536. * @param scene defines the hosting scene
  126537. * @returns the lathe mesh
  126538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  126539. */
  126540. static CreateLathe(name: string, options: {
  126541. shape: Vector3[];
  126542. radius?: number;
  126543. tessellation?: number;
  126544. clip?: number;
  126545. arc?: number;
  126546. closed?: boolean;
  126547. updatable?: boolean;
  126548. sideOrientation?: number;
  126549. frontUVs?: Vector4;
  126550. backUVs?: Vector4;
  126551. cap?: number;
  126552. invertUV?: boolean;
  126553. }, scene?: Nullable<Scene>): Mesh;
  126554. }
  126555. }
  126556. declare module BABYLON {
  126557. /**
  126558. * Class containing static functions to help procedurally build meshes
  126559. */
  126560. export class TiledPlaneBuilder {
  126561. /**
  126562. * Creates a tiled plane mesh
  126563. * * The parameter `pattern` will, depending on value, do nothing or
  126564. * * * flip (reflect about central vertical) alternate tiles across and up
  126565. * * * flip every tile on alternate rows
  126566. * * * rotate (180 degs) alternate tiles across and up
  126567. * * * rotate every tile on alternate rows
  126568. * * * flip and rotate alternate tiles across and up
  126569. * * * flip and rotate every tile on alternate rows
  126570. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  126571. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  126572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126574. * * 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)
  126575. * * 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)
  126576. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126577. * @param name defines the name of the mesh
  126578. * @param options defines the options used to create the mesh
  126579. * @param scene defines the hosting scene
  126580. * @returns the box mesh
  126581. */
  126582. static CreateTiledPlane(name: string, options: {
  126583. pattern?: number;
  126584. tileSize?: number;
  126585. tileWidth?: number;
  126586. tileHeight?: number;
  126587. size?: number;
  126588. width?: number;
  126589. height?: number;
  126590. alignHorizontal?: number;
  126591. alignVertical?: number;
  126592. sideOrientation?: number;
  126593. frontUVs?: Vector4;
  126594. backUVs?: Vector4;
  126595. updatable?: boolean;
  126596. }, scene?: Nullable<Scene>): Mesh;
  126597. }
  126598. }
  126599. declare module BABYLON {
  126600. /**
  126601. * Class containing static functions to help procedurally build meshes
  126602. */
  126603. export class TubeBuilder {
  126604. /**
  126605. * Creates a tube mesh.
  126606. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126607. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126608. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126609. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126610. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126611. * * 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)
  126612. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126613. * * 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
  126614. * * 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
  126615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126619. * @param name defines the name of the mesh
  126620. * @param options defines the options used to create the mesh
  126621. * @param scene defines the hosting scene
  126622. * @returns the tube mesh
  126623. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126624. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126625. */
  126626. static CreateTube(name: string, options: {
  126627. path: Vector3[];
  126628. radius?: number;
  126629. tessellation?: number;
  126630. radiusFunction?: {
  126631. (i: number, distance: number): number;
  126632. };
  126633. cap?: number;
  126634. arc?: number;
  126635. updatable?: boolean;
  126636. sideOrientation?: number;
  126637. frontUVs?: Vector4;
  126638. backUVs?: Vector4;
  126639. instance?: Mesh;
  126640. invertUV?: boolean;
  126641. }, scene?: Nullable<Scene>): Mesh;
  126642. }
  126643. }
  126644. declare module BABYLON {
  126645. /**
  126646. * Class containing static functions to help procedurally build meshes
  126647. */
  126648. export class IcoSphereBuilder {
  126649. /**
  126650. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126651. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126652. * * 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`)
  126653. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126654. * * 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
  126655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126658. * @param name defines the name of the mesh
  126659. * @param options defines the options used to create the mesh
  126660. * @param scene defines the hosting scene
  126661. * @returns the icosahedron mesh
  126662. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126663. */
  126664. static CreateIcoSphere(name: string, options: {
  126665. radius?: number;
  126666. radiusX?: number;
  126667. radiusY?: number;
  126668. radiusZ?: number;
  126669. flat?: boolean;
  126670. subdivisions?: number;
  126671. sideOrientation?: number;
  126672. frontUVs?: Vector4;
  126673. backUVs?: Vector4;
  126674. updatable?: boolean;
  126675. }, scene?: Nullable<Scene>): Mesh;
  126676. }
  126677. }
  126678. declare module BABYLON {
  126679. /**
  126680. * Class containing static functions to help procedurally build meshes
  126681. */
  126682. export class DecalBuilder {
  126683. /**
  126684. * Creates a decal mesh.
  126685. * 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
  126686. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126687. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126688. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126689. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126690. * @param name defines the name of the mesh
  126691. * @param sourceMesh defines the mesh where the decal must be applied
  126692. * @param options defines the options used to create the mesh
  126693. * @param scene defines the hosting scene
  126694. * @returns the decal mesh
  126695. * @see https://doc.babylonjs.com/how_to/decals
  126696. */
  126697. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126698. position?: Vector3;
  126699. normal?: Vector3;
  126700. size?: Vector3;
  126701. angle?: number;
  126702. }): Mesh;
  126703. }
  126704. }
  126705. declare module BABYLON {
  126706. /**
  126707. * Class containing static functions to help procedurally build meshes
  126708. */
  126709. export class MeshBuilder {
  126710. /**
  126711. * Creates a box mesh
  126712. * * The parameter `size` sets the size (float) of each box side (default 1)
  126713. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126714. * * 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)
  126715. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126719. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126720. * @param name defines the name of the mesh
  126721. * @param options defines the options used to create the mesh
  126722. * @param scene defines the hosting scene
  126723. * @returns the box mesh
  126724. */
  126725. static CreateBox(name: string, options: {
  126726. size?: number;
  126727. width?: number;
  126728. height?: number;
  126729. depth?: number;
  126730. faceUV?: Vector4[];
  126731. faceColors?: Color4[];
  126732. sideOrientation?: number;
  126733. frontUVs?: Vector4;
  126734. backUVs?: Vector4;
  126735. updatable?: boolean;
  126736. }, scene?: Nullable<Scene>): Mesh;
  126737. /**
  126738. * Creates a tiled box mesh
  126739. * * faceTiles sets the pattern, tile size and number of tiles for a face
  126740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126741. * @param name defines the name of the mesh
  126742. * @param options defines the options used to create the mesh
  126743. * @param scene defines the hosting scene
  126744. * @returns the tiled box mesh
  126745. */
  126746. static CreateTiledBox(name: string, options: {
  126747. pattern?: number;
  126748. size?: number;
  126749. width?: number;
  126750. height?: number;
  126751. depth: number;
  126752. tileSize?: number;
  126753. tileWidth?: number;
  126754. tileHeight?: number;
  126755. faceUV?: Vector4[];
  126756. faceColors?: Color4[];
  126757. alignHorizontal?: number;
  126758. alignVertical?: number;
  126759. sideOrientation?: number;
  126760. updatable?: boolean;
  126761. }, scene?: Nullable<Scene>): Mesh;
  126762. /**
  126763. * Creates a sphere mesh
  126764. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126765. * * 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`)
  126766. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126767. * * 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
  126768. * * 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)
  126769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126772. * @param name defines the name of the mesh
  126773. * @param options defines the options used to create the mesh
  126774. * @param scene defines the hosting scene
  126775. * @returns the sphere mesh
  126776. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126777. */
  126778. static CreateSphere(name: string, options: {
  126779. segments?: number;
  126780. diameter?: number;
  126781. diameterX?: number;
  126782. diameterY?: number;
  126783. diameterZ?: number;
  126784. arc?: number;
  126785. slice?: number;
  126786. sideOrientation?: number;
  126787. frontUVs?: Vector4;
  126788. backUVs?: Vector4;
  126789. updatable?: boolean;
  126790. }, scene?: Nullable<Scene>): Mesh;
  126791. /**
  126792. * Creates a plane polygonal mesh. By default, this is a disc
  126793. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  126794. * * 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
  126795. * * 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
  126796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126799. * @param name defines the name of the mesh
  126800. * @param options defines the options used to create the mesh
  126801. * @param scene defines the hosting scene
  126802. * @returns the plane polygonal mesh
  126803. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  126804. */
  126805. static CreateDisc(name: string, options: {
  126806. radius?: number;
  126807. tessellation?: number;
  126808. arc?: number;
  126809. updatable?: boolean;
  126810. sideOrientation?: number;
  126811. frontUVs?: Vector4;
  126812. backUVs?: Vector4;
  126813. }, scene?: Nullable<Scene>): Mesh;
  126814. /**
  126815. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126816. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126817. * * 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`)
  126818. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126819. * * 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
  126820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126823. * @param name defines the name of the mesh
  126824. * @param options defines the options used to create the mesh
  126825. * @param scene defines the hosting scene
  126826. * @returns the icosahedron mesh
  126827. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126828. */
  126829. static CreateIcoSphere(name: string, options: {
  126830. radius?: number;
  126831. radiusX?: number;
  126832. radiusY?: number;
  126833. radiusZ?: number;
  126834. flat?: boolean;
  126835. subdivisions?: number;
  126836. sideOrientation?: number;
  126837. frontUVs?: Vector4;
  126838. backUVs?: Vector4;
  126839. updatable?: boolean;
  126840. }, scene?: Nullable<Scene>): Mesh;
  126841. /**
  126842. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126843. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  126844. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  126845. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  126846. * * 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
  126847. * * 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
  126848. * * 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
  126849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126851. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126852. * * 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
  126853. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  126854. * * 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
  126855. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  126856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126857. * @param name defines the name of the mesh
  126858. * @param options defines the options used to create the mesh
  126859. * @param scene defines the hosting scene
  126860. * @returns the ribbon mesh
  126861. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  126862. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126863. */
  126864. static CreateRibbon(name: string, options: {
  126865. pathArray: Vector3[][];
  126866. closeArray?: boolean;
  126867. closePath?: boolean;
  126868. offset?: number;
  126869. updatable?: boolean;
  126870. sideOrientation?: number;
  126871. frontUVs?: Vector4;
  126872. backUVs?: Vector4;
  126873. instance?: Mesh;
  126874. invertUV?: boolean;
  126875. uvs?: Vector2[];
  126876. colors?: Color4[];
  126877. }, scene?: Nullable<Scene>): Mesh;
  126878. /**
  126879. * Creates a cylinder or a cone mesh
  126880. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126881. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126882. * * 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.
  126883. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126884. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126885. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126886. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126887. * * 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).
  126888. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126889. * * 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).
  126890. * * 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
  126891. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126892. * * 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
  126893. * * 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.
  126894. * * If `enclose` is false, a ring surface is one element.
  126895. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126896. * * 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
  126897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126900. * @param name defines the name of the mesh
  126901. * @param options defines the options used to create the mesh
  126902. * @param scene defines the hosting scene
  126903. * @returns the cylinder mesh
  126904. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126905. */
  126906. static CreateCylinder(name: string, options: {
  126907. height?: number;
  126908. diameterTop?: number;
  126909. diameterBottom?: number;
  126910. diameter?: number;
  126911. tessellation?: number;
  126912. subdivisions?: number;
  126913. arc?: number;
  126914. faceColors?: Color4[];
  126915. faceUV?: Vector4[];
  126916. updatable?: boolean;
  126917. hasRings?: boolean;
  126918. enclose?: boolean;
  126919. cap?: number;
  126920. sideOrientation?: number;
  126921. frontUVs?: Vector4;
  126922. backUVs?: Vector4;
  126923. }, scene?: Nullable<Scene>): Mesh;
  126924. /**
  126925. * Creates a torus mesh
  126926. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126927. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126928. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126932. * @param name defines the name of the mesh
  126933. * @param options defines the options used to create the mesh
  126934. * @param scene defines the hosting scene
  126935. * @returns the torus mesh
  126936. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126937. */
  126938. static CreateTorus(name: string, options: {
  126939. diameter?: number;
  126940. thickness?: number;
  126941. tessellation?: number;
  126942. updatable?: boolean;
  126943. sideOrientation?: number;
  126944. frontUVs?: Vector4;
  126945. backUVs?: Vector4;
  126946. }, scene?: Nullable<Scene>): Mesh;
  126947. /**
  126948. * Creates a torus knot mesh
  126949. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  126950. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  126951. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  126952. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  126953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126956. * @param name defines the name of the mesh
  126957. * @param options defines the options used to create the mesh
  126958. * @param scene defines the hosting scene
  126959. * @returns the torus knot mesh
  126960. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  126961. */
  126962. static CreateTorusKnot(name: string, options: {
  126963. radius?: number;
  126964. tube?: number;
  126965. radialSegments?: number;
  126966. tubularSegments?: number;
  126967. p?: number;
  126968. q?: number;
  126969. updatable?: boolean;
  126970. sideOrientation?: number;
  126971. frontUVs?: Vector4;
  126972. backUVs?: Vector4;
  126973. }, scene?: Nullable<Scene>): Mesh;
  126974. /**
  126975. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126976. * * 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
  126977. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126978. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126979. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126980. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126981. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126982. * * 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
  126983. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126985. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126986. * @param name defines the name of the new line system
  126987. * @param options defines the options used to create the line system
  126988. * @param scene defines the hosting scene
  126989. * @returns a new line system mesh
  126990. */
  126991. static CreateLineSystem(name: string, options: {
  126992. lines: Vector3[][];
  126993. updatable?: boolean;
  126994. instance?: Nullable<LinesMesh>;
  126995. colors?: Nullable<Color4[][]>;
  126996. useVertexAlpha?: boolean;
  126997. }, scene: Nullable<Scene>): LinesMesh;
  126998. /**
  126999. * Creates a line mesh
  127000. * 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
  127001. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127002. * * The parameter `points` is an array successive Vector3
  127003. * * 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
  127004. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127005. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127006. * * When updating an instance, remember that only point positions can change, not the number of points
  127007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127009. * @param name defines the name of the new line system
  127010. * @param options defines the options used to create the line system
  127011. * @param scene defines the hosting scene
  127012. * @returns a new line mesh
  127013. */
  127014. static CreateLines(name: string, options: {
  127015. points: Vector3[];
  127016. updatable?: boolean;
  127017. instance?: Nullable<LinesMesh>;
  127018. colors?: Color4[];
  127019. useVertexAlpha?: boolean;
  127020. }, scene?: Nullable<Scene>): LinesMesh;
  127021. /**
  127022. * Creates a dashed line mesh
  127023. * * 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
  127024. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127025. * * The parameter `points` is an array successive Vector3
  127026. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127027. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127028. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127029. * * 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
  127030. * * When updating an instance, remember that only point positions can change, not the number of points
  127031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127032. * @param name defines the name of the mesh
  127033. * @param options defines the options used to create the mesh
  127034. * @param scene defines the hosting scene
  127035. * @returns the dashed line mesh
  127036. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127037. */
  127038. static CreateDashedLines(name: string, options: {
  127039. points: Vector3[];
  127040. dashSize?: number;
  127041. gapSize?: number;
  127042. dashNb?: number;
  127043. updatable?: boolean;
  127044. instance?: LinesMesh;
  127045. }, scene?: Nullable<Scene>): LinesMesh;
  127046. /**
  127047. * 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.
  127048. * * 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.
  127049. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127050. * * 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.
  127051. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127052. * * 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
  127053. * * 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
  127054. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127057. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127059. * @param name defines the name of the mesh
  127060. * @param options defines the options used to create the mesh
  127061. * @param scene defines the hosting scene
  127062. * @returns the extruded shape mesh
  127063. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127065. */
  127066. static ExtrudeShape(name: string, options: {
  127067. shape: Vector3[];
  127068. path: Vector3[];
  127069. scale?: number;
  127070. rotation?: number;
  127071. cap?: number;
  127072. updatable?: boolean;
  127073. sideOrientation?: number;
  127074. frontUVs?: Vector4;
  127075. backUVs?: Vector4;
  127076. instance?: Mesh;
  127077. invertUV?: boolean;
  127078. }, scene?: Nullable<Scene>): Mesh;
  127079. /**
  127080. * Creates an custom extruded shape mesh.
  127081. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127082. * * 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.
  127083. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127084. * * 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
  127085. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127086. * * 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
  127087. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127088. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127089. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127090. * * 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
  127091. * * 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
  127092. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127097. * @param name defines the name of the mesh
  127098. * @param options defines the options used to create the mesh
  127099. * @param scene defines the hosting scene
  127100. * @returns the custom extruded shape mesh
  127101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127102. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127104. */
  127105. static ExtrudeShapeCustom(name: string, options: {
  127106. shape: Vector3[];
  127107. path: Vector3[];
  127108. scaleFunction?: any;
  127109. rotationFunction?: any;
  127110. ribbonCloseArray?: boolean;
  127111. ribbonClosePath?: boolean;
  127112. cap?: number;
  127113. updatable?: boolean;
  127114. sideOrientation?: number;
  127115. frontUVs?: Vector4;
  127116. backUVs?: Vector4;
  127117. instance?: Mesh;
  127118. invertUV?: boolean;
  127119. }, scene?: Nullable<Scene>): Mesh;
  127120. /**
  127121. * Creates lathe mesh.
  127122. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127123. * * 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
  127124. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127125. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127126. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127127. * * 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
  127128. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127129. * * 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
  127130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127132. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127134. * @param name defines the name of the mesh
  127135. * @param options defines the options used to create the mesh
  127136. * @param scene defines the hosting scene
  127137. * @returns the lathe mesh
  127138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127139. */
  127140. static CreateLathe(name: string, options: {
  127141. shape: Vector3[];
  127142. radius?: number;
  127143. tessellation?: number;
  127144. clip?: number;
  127145. arc?: number;
  127146. closed?: boolean;
  127147. updatable?: boolean;
  127148. sideOrientation?: number;
  127149. frontUVs?: Vector4;
  127150. backUVs?: Vector4;
  127151. cap?: number;
  127152. invertUV?: boolean;
  127153. }, scene?: Nullable<Scene>): Mesh;
  127154. /**
  127155. * Creates a tiled plane mesh
  127156. * * You can set a limited pattern arrangement with the tiles
  127157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127160. * @param name defines the name of the mesh
  127161. * @param options defines the options used to create the mesh
  127162. * @param scene defines the hosting scene
  127163. * @returns the plane mesh
  127164. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127165. */
  127166. static CreateTiledPlane(name: string, options: {
  127167. pattern?: number;
  127168. tileSize?: number;
  127169. tileWidth?: number;
  127170. tileHeight?: number;
  127171. size?: number;
  127172. width?: number;
  127173. height?: number;
  127174. alignHorizontal?: number;
  127175. alignVertical?: number;
  127176. sideOrientation?: number;
  127177. frontUVs?: Vector4;
  127178. backUVs?: Vector4;
  127179. updatable?: boolean;
  127180. }, scene?: Nullable<Scene>): Mesh;
  127181. /**
  127182. * Creates a plane mesh
  127183. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127184. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127185. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127189. * @param name defines the name of the mesh
  127190. * @param options defines the options used to create the mesh
  127191. * @param scene defines the hosting scene
  127192. * @returns the plane mesh
  127193. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127194. */
  127195. static CreatePlane(name: string, options: {
  127196. size?: number;
  127197. width?: number;
  127198. height?: number;
  127199. sideOrientation?: number;
  127200. frontUVs?: Vector4;
  127201. backUVs?: Vector4;
  127202. updatable?: boolean;
  127203. sourcePlane?: Plane;
  127204. }, scene?: Nullable<Scene>): Mesh;
  127205. /**
  127206. * Creates a ground mesh
  127207. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127208. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127210. * @param name defines the name of the mesh
  127211. * @param options defines the options used to create the mesh
  127212. * @param scene defines the hosting scene
  127213. * @returns the ground mesh
  127214. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127215. */
  127216. static CreateGround(name: string, options: {
  127217. width?: number;
  127218. height?: number;
  127219. subdivisions?: number;
  127220. subdivisionsX?: number;
  127221. subdivisionsY?: number;
  127222. updatable?: boolean;
  127223. }, scene?: Nullable<Scene>): Mesh;
  127224. /**
  127225. * Creates a tiled ground mesh
  127226. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127227. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127228. * * 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
  127229. * * 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
  127230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127231. * @param name defines the name of the mesh
  127232. * @param options defines the options used to create the mesh
  127233. * @param scene defines the hosting scene
  127234. * @returns the tiled ground mesh
  127235. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127236. */
  127237. static CreateTiledGround(name: string, options: {
  127238. xmin: number;
  127239. zmin: number;
  127240. xmax: number;
  127241. zmax: number;
  127242. subdivisions?: {
  127243. w: number;
  127244. h: number;
  127245. };
  127246. precision?: {
  127247. w: number;
  127248. h: number;
  127249. };
  127250. updatable?: boolean;
  127251. }, scene?: Nullable<Scene>): Mesh;
  127252. /**
  127253. * Creates a ground mesh from a height map
  127254. * * The parameter `url` sets the URL of the height map image resource.
  127255. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127256. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127257. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127258. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127259. * * 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.
  127260. * * 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).
  127261. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127263. * @param name defines the name of the mesh
  127264. * @param url defines the url to the height map
  127265. * @param options defines the options used to create the mesh
  127266. * @param scene defines the hosting scene
  127267. * @returns the ground mesh
  127268. * @see https://doc.babylonjs.com/babylon101/height_map
  127269. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127270. */
  127271. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127272. width?: number;
  127273. height?: number;
  127274. subdivisions?: number;
  127275. minHeight?: number;
  127276. maxHeight?: number;
  127277. colorFilter?: Color3;
  127278. alphaFilter?: number;
  127279. updatable?: boolean;
  127280. onReady?: (mesh: GroundMesh) => void;
  127281. }, scene?: Nullable<Scene>): GroundMesh;
  127282. /**
  127283. * Creates a polygon mesh
  127284. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  127285. * * 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
  127286. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  127289. * * Remember you can only change the shape positions, not their number when updating a polygon
  127290. * @param name defines the name of the mesh
  127291. * @param options defines the options used to create the mesh
  127292. * @param scene defines the hosting scene
  127293. * @param earcutInjection can be used to inject your own earcut reference
  127294. * @returns the polygon mesh
  127295. */
  127296. static CreatePolygon(name: string, options: {
  127297. shape: Vector3[];
  127298. holes?: Vector3[][];
  127299. depth?: number;
  127300. faceUV?: Vector4[];
  127301. faceColors?: Color4[];
  127302. updatable?: boolean;
  127303. sideOrientation?: number;
  127304. frontUVs?: Vector4;
  127305. backUVs?: Vector4;
  127306. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127307. /**
  127308. * Creates an extruded polygon mesh, with depth in the Y direction.
  127309. * * 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)
  127310. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127311. * @param name defines the name of the mesh
  127312. * @param options defines the options used to create the mesh
  127313. * @param scene defines the hosting scene
  127314. * @param earcutInjection can be used to inject your own earcut reference
  127315. * @returns the polygon mesh
  127316. */
  127317. static ExtrudePolygon(name: string, options: {
  127318. shape: Vector3[];
  127319. holes?: Vector3[][];
  127320. depth?: number;
  127321. faceUV?: Vector4[];
  127322. faceColors?: Color4[];
  127323. updatable?: boolean;
  127324. sideOrientation?: number;
  127325. frontUVs?: Vector4;
  127326. backUVs?: Vector4;
  127327. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127328. /**
  127329. * Creates a tube mesh.
  127330. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127331. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  127332. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  127333. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  127334. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  127335. * * 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)
  127336. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  127337. * * 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
  127338. * * 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
  127339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127343. * @param name defines the name of the mesh
  127344. * @param options defines the options used to create the mesh
  127345. * @param scene defines the hosting scene
  127346. * @returns the tube mesh
  127347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127348. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  127349. */
  127350. static CreateTube(name: string, options: {
  127351. path: Vector3[];
  127352. radius?: number;
  127353. tessellation?: number;
  127354. radiusFunction?: {
  127355. (i: number, distance: number): number;
  127356. };
  127357. cap?: number;
  127358. arc?: number;
  127359. updatable?: boolean;
  127360. sideOrientation?: number;
  127361. frontUVs?: Vector4;
  127362. backUVs?: Vector4;
  127363. instance?: Mesh;
  127364. invertUV?: boolean;
  127365. }, scene?: Nullable<Scene>): Mesh;
  127366. /**
  127367. * Creates a polyhedron mesh
  127368. * * 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
  127369. * * The parameter `size` (positive float, default 1) sets the polygon size
  127370. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  127371. * * 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`
  127372. * * 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
  127373. * * 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)`)
  127374. * * 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
  127375. * * 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
  127376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127379. * @param name defines the name of the mesh
  127380. * @param options defines the options used to create the mesh
  127381. * @param scene defines the hosting scene
  127382. * @returns the polyhedron mesh
  127383. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  127384. */
  127385. static CreatePolyhedron(name: string, options: {
  127386. type?: number;
  127387. size?: number;
  127388. sizeX?: number;
  127389. sizeY?: number;
  127390. sizeZ?: number;
  127391. custom?: any;
  127392. faceUV?: Vector4[];
  127393. faceColors?: Color4[];
  127394. flat?: boolean;
  127395. updatable?: boolean;
  127396. sideOrientation?: number;
  127397. frontUVs?: Vector4;
  127398. backUVs?: Vector4;
  127399. }, scene?: Nullable<Scene>): Mesh;
  127400. /**
  127401. * Creates a decal mesh.
  127402. * 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
  127403. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  127404. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  127405. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  127406. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  127407. * @param name defines the name of the mesh
  127408. * @param sourceMesh defines the mesh where the decal must be applied
  127409. * @param options defines the options used to create the mesh
  127410. * @param scene defines the hosting scene
  127411. * @returns the decal mesh
  127412. * @see https://doc.babylonjs.com/how_to/decals
  127413. */
  127414. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  127415. position?: Vector3;
  127416. normal?: Vector3;
  127417. size?: Vector3;
  127418. angle?: number;
  127419. }): Mesh;
  127420. }
  127421. }
  127422. declare module BABYLON {
  127423. /**
  127424. * A simplifier interface for future simplification implementations
  127425. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127426. */
  127427. export interface ISimplifier {
  127428. /**
  127429. * Simplification of a given mesh according to the given settings.
  127430. * Since this requires computation, it is assumed that the function runs async.
  127431. * @param settings The settings of the simplification, including quality and distance
  127432. * @param successCallback A callback that will be called after the mesh was simplified.
  127433. * @param errorCallback in case of an error, this callback will be called. optional.
  127434. */
  127435. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  127436. }
  127437. /**
  127438. * Expected simplification settings.
  127439. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  127440. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127441. */
  127442. export interface ISimplificationSettings {
  127443. /**
  127444. * Gets or sets the expected quality
  127445. */
  127446. quality: number;
  127447. /**
  127448. * Gets or sets the distance when this optimized version should be used
  127449. */
  127450. distance: number;
  127451. /**
  127452. * Gets an already optimized mesh
  127453. */
  127454. optimizeMesh?: boolean;
  127455. }
  127456. /**
  127457. * Class used to specify simplification options
  127458. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127459. */
  127460. export class SimplificationSettings implements ISimplificationSettings {
  127461. /** expected quality */
  127462. quality: number;
  127463. /** distance when this optimized version should be used */
  127464. distance: number;
  127465. /** already optimized mesh */
  127466. optimizeMesh?: boolean | undefined;
  127467. /**
  127468. * Creates a SimplificationSettings
  127469. * @param quality expected quality
  127470. * @param distance distance when this optimized version should be used
  127471. * @param optimizeMesh already optimized mesh
  127472. */
  127473. constructor(
  127474. /** expected quality */
  127475. quality: number,
  127476. /** distance when this optimized version should be used */
  127477. distance: number,
  127478. /** already optimized mesh */
  127479. optimizeMesh?: boolean | undefined);
  127480. }
  127481. /**
  127482. * Interface used to define a simplification task
  127483. */
  127484. export interface ISimplificationTask {
  127485. /**
  127486. * Array of settings
  127487. */
  127488. settings: Array<ISimplificationSettings>;
  127489. /**
  127490. * Simplification type
  127491. */
  127492. simplificationType: SimplificationType;
  127493. /**
  127494. * Mesh to simplify
  127495. */
  127496. mesh: Mesh;
  127497. /**
  127498. * Callback called on success
  127499. */
  127500. successCallback?: () => void;
  127501. /**
  127502. * Defines if parallel processing can be used
  127503. */
  127504. parallelProcessing: boolean;
  127505. }
  127506. /**
  127507. * Queue used to order the simplification tasks
  127508. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127509. */
  127510. export class SimplificationQueue {
  127511. private _simplificationArray;
  127512. /**
  127513. * Gets a boolean indicating that the process is still running
  127514. */
  127515. running: boolean;
  127516. /**
  127517. * Creates a new queue
  127518. */
  127519. constructor();
  127520. /**
  127521. * Adds a new simplification task
  127522. * @param task defines a task to add
  127523. */
  127524. addTask(task: ISimplificationTask): void;
  127525. /**
  127526. * Execute next task
  127527. */
  127528. executeNext(): void;
  127529. /**
  127530. * Execute a simplification task
  127531. * @param task defines the task to run
  127532. */
  127533. runSimplification(task: ISimplificationTask): void;
  127534. private getSimplifier;
  127535. }
  127536. /**
  127537. * The implemented types of simplification
  127538. * At the moment only Quadratic Error Decimation is implemented
  127539. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127540. */
  127541. export enum SimplificationType {
  127542. /** Quadratic error decimation */
  127543. QUADRATIC = 0
  127544. }
  127545. }
  127546. declare module BABYLON {
  127547. interface Scene {
  127548. /** @hidden (Backing field) */
  127549. _simplificationQueue: SimplificationQueue;
  127550. /**
  127551. * Gets or sets the simplification queue attached to the scene
  127552. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127553. */
  127554. simplificationQueue: SimplificationQueue;
  127555. }
  127556. interface Mesh {
  127557. /**
  127558. * Simplify the mesh according to the given array of settings.
  127559. * Function will return immediately and will simplify async
  127560. * @param settings a collection of simplification settings
  127561. * @param parallelProcessing should all levels calculate parallel or one after the other
  127562. * @param simplificationType the type of simplification to run
  127563. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  127564. * @returns the current mesh
  127565. */
  127566. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  127567. }
  127568. /**
  127569. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  127570. * created in a scene
  127571. */
  127572. export class SimplicationQueueSceneComponent implements ISceneComponent {
  127573. /**
  127574. * The component name helpfull to identify the component in the list of scene components.
  127575. */
  127576. readonly name: string;
  127577. /**
  127578. * The scene the component belongs to.
  127579. */
  127580. scene: Scene;
  127581. /**
  127582. * Creates a new instance of the component for the given scene
  127583. * @param scene Defines the scene to register the component in
  127584. */
  127585. constructor(scene: Scene);
  127586. /**
  127587. * Registers the component in a given scene
  127588. */
  127589. register(): void;
  127590. /**
  127591. * Rebuilds the elements related to this component in case of
  127592. * context lost for instance.
  127593. */
  127594. rebuild(): void;
  127595. /**
  127596. * Disposes the component and the associated ressources
  127597. */
  127598. dispose(): void;
  127599. private _beforeCameraUpdate;
  127600. }
  127601. }
  127602. declare module BABYLON {
  127603. /**
  127604. * Navigation plugin interface to add navigation constrained by a navigation mesh
  127605. */
  127606. export interface INavigationEnginePlugin {
  127607. /**
  127608. * plugin name
  127609. */
  127610. name: string;
  127611. /**
  127612. * Creates a navigation mesh
  127613. * @param meshes array of all the geometry used to compute the navigatio mesh
  127614. * @param parameters bunch of parameters used to filter geometry
  127615. */
  127616. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127617. /**
  127618. * Create a navigation mesh debug mesh
  127619. * @param scene is where the mesh will be added
  127620. * @returns debug display mesh
  127621. */
  127622. createDebugNavMesh(scene: Scene): Mesh;
  127623. /**
  127624. * Get a navigation mesh constrained position, closest to the parameter position
  127625. * @param position world position
  127626. * @returns the closest point to position constrained by the navigation mesh
  127627. */
  127628. getClosestPoint(position: Vector3): Vector3;
  127629. /**
  127630. * Get a navigation mesh constrained position, within a particular radius
  127631. * @param position world position
  127632. * @param maxRadius the maximum distance to the constrained world position
  127633. * @returns the closest point to position constrained by the navigation mesh
  127634. */
  127635. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127636. /**
  127637. * Compute the final position from a segment made of destination-position
  127638. * @param position world position
  127639. * @param destination world position
  127640. * @returns the resulting point along the navmesh
  127641. */
  127642. moveAlong(position: Vector3, destination: Vector3): Vector3;
  127643. /**
  127644. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  127645. * @param start world position
  127646. * @param end world position
  127647. * @returns array containing world position composing the path
  127648. */
  127649. computePath(start: Vector3, end: Vector3): Vector3[];
  127650. /**
  127651. * If this plugin is supported
  127652. * @returns true if plugin is supported
  127653. */
  127654. isSupported(): boolean;
  127655. /**
  127656. * Create a new Crowd so you can add agents
  127657. * @param maxAgents the maximum agent count in the crowd
  127658. * @param maxAgentRadius the maximum radius an agent can have
  127659. * @param scene to attach the crowd to
  127660. * @returns the crowd you can add agents to
  127661. */
  127662. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  127663. /**
  127664. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127665. * The queries will try to find a solution within those bounds
  127666. * default is (1,1,1)
  127667. * @param extent x,y,z value that define the extent around the queries point of reference
  127668. */
  127669. setDefaultQueryExtent(extent: Vector3): void;
  127670. /**
  127671. * Get the Bounding box extent specified by setDefaultQueryExtent
  127672. * @returns the box extent values
  127673. */
  127674. getDefaultQueryExtent(): Vector3;
  127675. /**
  127676. * Release all resources
  127677. */
  127678. dispose(): void;
  127679. }
  127680. /**
  127681. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  127682. */
  127683. export interface ICrowd {
  127684. /**
  127685. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  127686. * You can attach anything to that node. The node position is updated in the scene update tick.
  127687. * @param pos world position that will be constrained by the navigation mesh
  127688. * @param parameters agent parameters
  127689. * @param transform hooked to the agent that will be update by the scene
  127690. * @returns agent index
  127691. */
  127692. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  127693. /**
  127694. * Returns the agent position in world space
  127695. * @param index agent index returned by addAgent
  127696. * @returns world space position
  127697. */
  127698. getAgentPosition(index: number): Vector3;
  127699. /**
  127700. * Gets the agent velocity in world space
  127701. * @param index agent index returned by addAgent
  127702. * @returns world space velocity
  127703. */
  127704. getAgentVelocity(index: number): Vector3;
  127705. /**
  127706. * remove a particular agent previously created
  127707. * @param index agent index returned by addAgent
  127708. */
  127709. removeAgent(index: number): void;
  127710. /**
  127711. * get the list of all agents attached to this crowd
  127712. * @returns list of agent indices
  127713. */
  127714. getAgents(): number[];
  127715. /**
  127716. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  127717. * @param deltaTime in seconds
  127718. */
  127719. update(deltaTime: number): void;
  127720. /**
  127721. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127722. * @param index agent index returned by addAgent
  127723. * @param destination targeted world position
  127724. */
  127725. agentGoto(index: number, destination: Vector3): void;
  127726. /**
  127727. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127728. * The queries will try to find a solution within those bounds
  127729. * default is (1,1,1)
  127730. * @param extent x,y,z value that define the extent around the queries point of reference
  127731. */
  127732. setDefaultQueryExtent(extent: Vector3): void;
  127733. /**
  127734. * Get the Bounding box extent specified by setDefaultQueryExtent
  127735. * @returns the box extent values
  127736. */
  127737. getDefaultQueryExtent(): Vector3;
  127738. /**
  127739. * Release all resources
  127740. */
  127741. dispose(): void;
  127742. }
  127743. /**
  127744. * Configures an agent
  127745. */
  127746. export interface IAgentParameters {
  127747. /**
  127748. * Agent radius. [Limit: >= 0]
  127749. */
  127750. radius: number;
  127751. /**
  127752. * Agent height. [Limit: > 0]
  127753. */
  127754. height: number;
  127755. /**
  127756. * Maximum allowed acceleration. [Limit: >= 0]
  127757. */
  127758. maxAcceleration: number;
  127759. /**
  127760. * Maximum allowed speed. [Limit: >= 0]
  127761. */
  127762. maxSpeed: number;
  127763. /**
  127764. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  127765. */
  127766. collisionQueryRange: number;
  127767. /**
  127768. * The path visibility optimization range. [Limit: > 0]
  127769. */
  127770. pathOptimizationRange: number;
  127771. /**
  127772. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  127773. */
  127774. separationWeight: number;
  127775. }
  127776. /**
  127777. * Configures the navigation mesh creation
  127778. */
  127779. export interface INavMeshParameters {
  127780. /**
  127781. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  127782. */
  127783. cs: number;
  127784. /**
  127785. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  127786. */
  127787. ch: number;
  127788. /**
  127789. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  127790. */
  127791. walkableSlopeAngle: number;
  127792. /**
  127793. * Minimum floor to 'ceiling' height that will still allow the floor area to
  127794. * be considered walkable. [Limit: >= 3] [Units: vx]
  127795. */
  127796. walkableHeight: number;
  127797. /**
  127798. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  127799. */
  127800. walkableClimb: number;
  127801. /**
  127802. * The distance to erode/shrink the walkable area of the heightfield away from
  127803. * obstructions. [Limit: >=0] [Units: vx]
  127804. */
  127805. walkableRadius: number;
  127806. /**
  127807. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  127808. */
  127809. maxEdgeLen: number;
  127810. /**
  127811. * The maximum distance a simplfied contour's border edges should deviate
  127812. * the original raw contour. [Limit: >=0] [Units: vx]
  127813. */
  127814. maxSimplificationError: number;
  127815. /**
  127816. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  127817. */
  127818. minRegionArea: number;
  127819. /**
  127820. * Any regions with a span count smaller than this value will, if possible,
  127821. * be merged with larger regions. [Limit: >=0] [Units: vx]
  127822. */
  127823. mergeRegionArea: number;
  127824. /**
  127825. * The maximum number of vertices allowed for polygons generated during the
  127826. * contour to polygon conversion process. [Limit: >= 3]
  127827. */
  127828. maxVertsPerPoly: number;
  127829. /**
  127830. * Sets the sampling distance to use when generating the detail mesh.
  127831. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  127832. */
  127833. detailSampleDist: number;
  127834. /**
  127835. * The maximum distance the detail mesh surface should deviate from heightfield
  127836. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  127837. */
  127838. detailSampleMaxError: number;
  127839. }
  127840. }
  127841. declare module BABYLON {
  127842. /**
  127843. * RecastJS navigation plugin
  127844. */
  127845. export class RecastJSPlugin implements INavigationEnginePlugin {
  127846. /**
  127847. * Reference to the Recast library
  127848. */
  127849. bjsRECAST: any;
  127850. /**
  127851. * plugin name
  127852. */
  127853. name: string;
  127854. /**
  127855. * the first navmesh created. We might extend this to support multiple navmeshes
  127856. */
  127857. navMesh: any;
  127858. /**
  127859. * Initializes the recastJS plugin
  127860. * @param recastInjection can be used to inject your own recast reference
  127861. */
  127862. constructor(recastInjection?: any);
  127863. /**
  127864. * Creates a navigation mesh
  127865. * @param meshes array of all the geometry used to compute the navigatio mesh
  127866. * @param parameters bunch of parameters used to filter geometry
  127867. */
  127868. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127869. /**
  127870. * Create a navigation mesh debug mesh
  127871. * @param scene is where the mesh will be added
  127872. * @returns debug display mesh
  127873. */
  127874. createDebugNavMesh(scene: Scene): Mesh;
  127875. /**
  127876. * Get a navigation mesh constrained position, closest to the parameter position
  127877. * @param position world position
  127878. * @returns the closest point to position constrained by the navigation mesh
  127879. */
  127880. getClosestPoint(position: Vector3): Vector3;
  127881. /**
  127882. * Get a navigation mesh constrained position, within a particular radius
  127883. * @param position world position
  127884. * @param maxRadius the maximum distance to the constrained world position
  127885. * @returns the closest point to position constrained by the navigation mesh
  127886. */
  127887. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127888. /**
  127889. * Compute the final position from a segment made of destination-position
  127890. * @param position world position
  127891. * @param destination world position
  127892. * @returns the resulting point along the navmesh
  127893. */
  127894. moveAlong(position: Vector3, destination: Vector3): Vector3;
  127895. /**
  127896. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  127897. * @param start world position
  127898. * @param end world position
  127899. * @returns array containing world position composing the path
  127900. */
  127901. computePath(start: Vector3, end: Vector3): Vector3[];
  127902. /**
  127903. * Create a new Crowd so you can add agents
  127904. * @param maxAgents the maximum agent count in the crowd
  127905. * @param maxAgentRadius the maximum radius an agent can have
  127906. * @param scene to attach the crowd to
  127907. * @returns the crowd you can add agents to
  127908. */
  127909. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  127910. /**
  127911. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127912. * The queries will try to find a solution within those bounds
  127913. * default is (1,1,1)
  127914. * @param extent x,y,z value that define the extent around the queries point of reference
  127915. */
  127916. setDefaultQueryExtent(extent: Vector3): void;
  127917. /**
  127918. * Get the Bounding box extent specified by setDefaultQueryExtent
  127919. * @returns the box extent values
  127920. */
  127921. getDefaultQueryExtent(): Vector3;
  127922. /**
  127923. * Disposes
  127924. */
  127925. dispose(): void;
  127926. /**
  127927. * If this plugin is supported
  127928. * @returns true if plugin is supported
  127929. */
  127930. isSupported(): boolean;
  127931. }
  127932. /**
  127933. * Recast detour crowd implementation
  127934. */
  127935. export class RecastJSCrowd implements ICrowd {
  127936. /**
  127937. * Recast/detour plugin
  127938. */
  127939. bjsRECASTPlugin: RecastJSPlugin;
  127940. /**
  127941. * Link to the detour crowd
  127942. */
  127943. recastCrowd: any;
  127944. /**
  127945. * One transform per agent
  127946. */
  127947. transforms: TransformNode[];
  127948. /**
  127949. * All agents created
  127950. */
  127951. agents: number[];
  127952. /**
  127953. * Link to the scene is kept to unregister the crowd from the scene
  127954. */
  127955. private _scene;
  127956. /**
  127957. * Observer for crowd updates
  127958. */
  127959. private _onBeforeAnimationsObserver;
  127960. /**
  127961. * Constructor
  127962. * @param plugin recastJS plugin
  127963. * @param maxAgents the maximum agent count in the crowd
  127964. * @param maxAgentRadius the maximum radius an agent can have
  127965. * @param scene to attach the crowd to
  127966. * @returns the crowd you can add agents to
  127967. */
  127968. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  127969. /**
  127970. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  127971. * You can attach anything to that node. The node position is updated in the scene update tick.
  127972. * @param pos world position that will be constrained by the navigation mesh
  127973. * @param parameters agent parameters
  127974. * @param transform hooked to the agent that will be update by the scene
  127975. * @returns agent index
  127976. */
  127977. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  127978. /**
  127979. * Returns the agent position in world space
  127980. * @param index agent index returned by addAgent
  127981. * @returns world space position
  127982. */
  127983. getAgentPosition(index: number): Vector3;
  127984. /**
  127985. * Returns the agent velocity in world space
  127986. * @param index agent index returned by addAgent
  127987. * @returns world space velocity
  127988. */
  127989. getAgentVelocity(index: number): Vector3;
  127990. /**
  127991. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127992. * @param index agent index returned by addAgent
  127993. * @param destination targeted world position
  127994. */
  127995. agentGoto(index: number, destination: Vector3): void;
  127996. /**
  127997. * remove a particular agent previously created
  127998. * @param index agent index returned by addAgent
  127999. */
  128000. removeAgent(index: number): void;
  128001. /**
  128002. * get the list of all agents attached to this crowd
  128003. * @returns list of agent indices
  128004. */
  128005. getAgents(): number[];
  128006. /**
  128007. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128008. * @param deltaTime in seconds
  128009. */
  128010. update(deltaTime: number): void;
  128011. /**
  128012. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128013. * The queries will try to find a solution within those bounds
  128014. * default is (1,1,1)
  128015. * @param extent x,y,z value that define the extent around the queries point of reference
  128016. */
  128017. setDefaultQueryExtent(extent: Vector3): void;
  128018. /**
  128019. * Get the Bounding box extent specified by setDefaultQueryExtent
  128020. * @returns the box extent values
  128021. */
  128022. getDefaultQueryExtent(): Vector3;
  128023. /**
  128024. * Release all resources
  128025. */
  128026. dispose(): void;
  128027. }
  128028. }
  128029. declare module BABYLON {
  128030. /**
  128031. * Class used to enable access to IndexedDB
  128032. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  128033. */
  128034. export class Database implements IOfflineProvider {
  128035. private _callbackManifestChecked;
  128036. private _currentSceneUrl;
  128037. private _db;
  128038. private _enableSceneOffline;
  128039. private _enableTexturesOffline;
  128040. private _manifestVersionFound;
  128041. private _mustUpdateRessources;
  128042. private _hasReachedQuota;
  128043. private _isSupported;
  128044. private _idbFactory;
  128045. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  128046. private static IsUASupportingBlobStorage;
  128047. /**
  128048. * Gets a boolean indicating if Database storate is enabled (off by default)
  128049. */
  128050. static IDBStorageEnabled: boolean;
  128051. /**
  128052. * Gets a boolean indicating if scene must be saved in the database
  128053. */
  128054. readonly enableSceneOffline: boolean;
  128055. /**
  128056. * Gets a boolean indicating if textures must be saved in the database
  128057. */
  128058. readonly enableTexturesOffline: boolean;
  128059. /**
  128060. * Creates a new Database
  128061. * @param urlToScene defines the url to load the scene
  128062. * @param callbackManifestChecked defines the callback to use when manifest is checked
  128063. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  128064. */
  128065. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  128066. private static _ParseURL;
  128067. private static _ReturnFullUrlLocation;
  128068. private _checkManifestFile;
  128069. /**
  128070. * Open the database and make it available
  128071. * @param successCallback defines the callback to call on success
  128072. * @param errorCallback defines the callback to call on error
  128073. */
  128074. open(successCallback: () => void, errorCallback: () => void): void;
  128075. /**
  128076. * Loads an image from the database
  128077. * @param url defines the url to load from
  128078. * @param image defines the target DOM image
  128079. */
  128080. loadImage(url: string, image: HTMLImageElement): void;
  128081. private _loadImageFromDBAsync;
  128082. private _saveImageIntoDBAsync;
  128083. private _checkVersionFromDB;
  128084. private _loadVersionFromDBAsync;
  128085. private _saveVersionIntoDBAsync;
  128086. /**
  128087. * Loads a file from database
  128088. * @param url defines the URL to load from
  128089. * @param sceneLoaded defines a callback to call on success
  128090. * @param progressCallBack defines a callback to call when progress changed
  128091. * @param errorCallback defines a callback to call on error
  128092. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  128093. */
  128094. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  128095. private _loadFileAsync;
  128096. private _saveFileAsync;
  128097. /**
  128098. * Validates if xhr data is correct
  128099. * @param xhr defines the request to validate
  128100. * @param dataType defines the expected data type
  128101. * @returns true if data is correct
  128102. */
  128103. private static _ValidateXHRData;
  128104. }
  128105. }
  128106. declare module BABYLON {
  128107. /** @hidden */
  128108. export var gpuUpdateParticlesPixelShader: {
  128109. name: string;
  128110. shader: string;
  128111. };
  128112. }
  128113. declare module BABYLON {
  128114. /** @hidden */
  128115. export var gpuUpdateParticlesVertexShader: {
  128116. name: string;
  128117. shader: string;
  128118. };
  128119. }
  128120. declare module BABYLON {
  128121. /** @hidden */
  128122. export var clipPlaneFragmentDeclaration2: {
  128123. name: string;
  128124. shader: string;
  128125. };
  128126. }
  128127. declare module BABYLON {
  128128. /** @hidden */
  128129. export var gpuRenderParticlesPixelShader: {
  128130. name: string;
  128131. shader: string;
  128132. };
  128133. }
  128134. declare module BABYLON {
  128135. /** @hidden */
  128136. export var clipPlaneVertexDeclaration2: {
  128137. name: string;
  128138. shader: string;
  128139. };
  128140. }
  128141. declare module BABYLON {
  128142. /** @hidden */
  128143. export var gpuRenderParticlesVertexShader: {
  128144. name: string;
  128145. shader: string;
  128146. };
  128147. }
  128148. declare module BABYLON {
  128149. /**
  128150. * This represents a GPU particle system in Babylon
  128151. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  128152. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  128153. */
  128154. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  128155. /**
  128156. * The layer mask we are rendering the particles through.
  128157. */
  128158. layerMask: number;
  128159. private _capacity;
  128160. private _activeCount;
  128161. private _currentActiveCount;
  128162. private _accumulatedCount;
  128163. private _renderEffect;
  128164. private _updateEffect;
  128165. private _buffer0;
  128166. private _buffer1;
  128167. private _spriteBuffer;
  128168. private _updateVAO;
  128169. private _renderVAO;
  128170. private _targetIndex;
  128171. private _sourceBuffer;
  128172. private _targetBuffer;
  128173. private _engine;
  128174. private _currentRenderId;
  128175. private _started;
  128176. private _stopped;
  128177. private _timeDelta;
  128178. private _randomTexture;
  128179. private _randomTexture2;
  128180. private _attributesStrideSize;
  128181. private _updateEffectOptions;
  128182. private _randomTextureSize;
  128183. private _actualFrame;
  128184. private readonly _rawTextureWidth;
  128185. /**
  128186. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  128187. */
  128188. static readonly IsSupported: boolean;
  128189. /**
  128190. * An event triggered when the system is disposed.
  128191. */
  128192. onDisposeObservable: Observable<GPUParticleSystem>;
  128193. /**
  128194. * Gets the maximum number of particles active at the same time.
  128195. * @returns The max number of active particles.
  128196. */
  128197. getCapacity(): number;
  128198. /**
  128199. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  128200. * to override the particles.
  128201. */
  128202. forceDepthWrite: boolean;
  128203. /**
  128204. * Gets or set the number of active particles
  128205. */
  128206. activeParticleCount: number;
  128207. private _preWarmDone;
  128208. /**
  128209. * Is this system ready to be used/rendered
  128210. * @return true if the system is ready
  128211. */
  128212. isReady(): boolean;
  128213. /**
  128214. * Gets if the system has been started. (Note: this will still be true after stop is called)
  128215. * @returns True if it has been started, otherwise false.
  128216. */
  128217. isStarted(): boolean;
  128218. /**
  128219. * Starts the particle system and begins to emit
  128220. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  128221. */
  128222. start(delay?: number): void;
  128223. /**
  128224. * Stops the particle system.
  128225. */
  128226. stop(): void;
  128227. /**
  128228. * Remove all active particles
  128229. */
  128230. reset(): void;
  128231. /**
  128232. * Returns the string "GPUParticleSystem"
  128233. * @returns a string containing the class name
  128234. */
  128235. getClassName(): string;
  128236. private _colorGradientsTexture;
  128237. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  128238. /**
  128239. * Adds a new color gradient
  128240. * @param gradient defines the gradient to use (between 0 and 1)
  128241. * @param color1 defines the color to affect to the specified gradient
  128242. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  128243. * @returns the current particle system
  128244. */
  128245. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  128246. /**
  128247. * Remove a specific color gradient
  128248. * @param gradient defines the gradient to remove
  128249. * @returns the current particle system
  128250. */
  128251. removeColorGradient(gradient: number): GPUParticleSystem;
  128252. private _angularSpeedGradientsTexture;
  128253. private _sizeGradientsTexture;
  128254. private _velocityGradientsTexture;
  128255. private _limitVelocityGradientsTexture;
  128256. private _dragGradientsTexture;
  128257. private _addFactorGradient;
  128258. /**
  128259. * Adds a new size gradient
  128260. * @param gradient defines the gradient to use (between 0 and 1)
  128261. * @param factor defines the size factor to affect to the specified gradient
  128262. * @returns the current particle system
  128263. */
  128264. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  128265. /**
  128266. * Remove a specific size gradient
  128267. * @param gradient defines the gradient to remove
  128268. * @returns the current particle system
  128269. */
  128270. removeSizeGradient(gradient: number): GPUParticleSystem;
  128271. /**
  128272. * Adds a new angular speed gradient
  128273. * @param gradient defines the gradient to use (between 0 and 1)
  128274. * @param factor defines the angular speed to affect to the specified gradient
  128275. * @returns the current particle system
  128276. */
  128277. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  128278. /**
  128279. * Remove a specific angular speed gradient
  128280. * @param gradient defines the gradient to remove
  128281. * @returns the current particle system
  128282. */
  128283. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  128284. /**
  128285. * Adds a new velocity gradient
  128286. * @param gradient defines the gradient to use (between 0 and 1)
  128287. * @param factor defines the velocity to affect to the specified gradient
  128288. * @returns the current particle system
  128289. */
  128290. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128291. /**
  128292. * Remove a specific velocity gradient
  128293. * @param gradient defines the gradient to remove
  128294. * @returns the current particle system
  128295. */
  128296. removeVelocityGradient(gradient: number): GPUParticleSystem;
  128297. /**
  128298. * Adds a new limit velocity gradient
  128299. * @param gradient defines the gradient to use (between 0 and 1)
  128300. * @param factor defines the limit velocity value to affect to the specified gradient
  128301. * @returns the current particle system
  128302. */
  128303. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128304. /**
  128305. * Remove a specific limit velocity gradient
  128306. * @param gradient defines the gradient to remove
  128307. * @returns the current particle system
  128308. */
  128309. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  128310. /**
  128311. * Adds a new drag gradient
  128312. * @param gradient defines the gradient to use (between 0 and 1)
  128313. * @param factor defines the drag value to affect to the specified gradient
  128314. * @returns the current particle system
  128315. */
  128316. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  128317. /**
  128318. * Remove a specific drag gradient
  128319. * @param gradient defines the gradient to remove
  128320. * @returns the current particle system
  128321. */
  128322. removeDragGradient(gradient: number): GPUParticleSystem;
  128323. /**
  128324. * Not supported by GPUParticleSystem
  128325. * @param gradient defines the gradient to use (between 0 and 1)
  128326. * @param factor defines the emit rate value to affect to the specified gradient
  128327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128328. * @returns the current particle system
  128329. */
  128330. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128331. /**
  128332. * Not supported by GPUParticleSystem
  128333. * @param gradient defines the gradient to remove
  128334. * @returns the current particle system
  128335. */
  128336. removeEmitRateGradient(gradient: number): IParticleSystem;
  128337. /**
  128338. * Not supported by GPUParticleSystem
  128339. * @param gradient defines the gradient to use (between 0 and 1)
  128340. * @param factor defines the start size value to affect to the specified gradient
  128341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128342. * @returns the current particle system
  128343. */
  128344. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128345. /**
  128346. * Not supported by GPUParticleSystem
  128347. * @param gradient defines the gradient to remove
  128348. * @returns the current particle system
  128349. */
  128350. removeStartSizeGradient(gradient: number): IParticleSystem;
  128351. /**
  128352. * Not supported by GPUParticleSystem
  128353. * @param gradient defines the gradient to use (between 0 and 1)
  128354. * @param min defines the color remap minimal range
  128355. * @param max defines the color remap maximal range
  128356. * @returns the current particle system
  128357. */
  128358. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128359. /**
  128360. * Not supported by GPUParticleSystem
  128361. * @param gradient defines the gradient to remove
  128362. * @returns the current particle system
  128363. */
  128364. removeColorRemapGradient(): IParticleSystem;
  128365. /**
  128366. * Not supported by GPUParticleSystem
  128367. * @param gradient defines the gradient to use (between 0 and 1)
  128368. * @param min defines the alpha remap minimal range
  128369. * @param max defines the alpha remap maximal range
  128370. * @returns the current particle system
  128371. */
  128372. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128373. /**
  128374. * Not supported by GPUParticleSystem
  128375. * @param gradient defines the gradient to remove
  128376. * @returns the current particle system
  128377. */
  128378. removeAlphaRemapGradient(): IParticleSystem;
  128379. /**
  128380. * Not supported by GPUParticleSystem
  128381. * @param gradient defines the gradient to use (between 0 and 1)
  128382. * @param color defines the color to affect to the specified gradient
  128383. * @returns the current particle system
  128384. */
  128385. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  128386. /**
  128387. * Not supported by GPUParticleSystem
  128388. * @param gradient defines the gradient to remove
  128389. * @returns the current particle system
  128390. */
  128391. removeRampGradient(): IParticleSystem;
  128392. /**
  128393. * Not supported by GPUParticleSystem
  128394. * @returns the list of ramp gradients
  128395. */
  128396. getRampGradients(): Nullable<Array<Color3Gradient>>;
  128397. /**
  128398. * Not supported by GPUParticleSystem
  128399. * Gets or sets a boolean indicating that ramp gradients must be used
  128400. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  128401. */
  128402. useRampGradients: boolean;
  128403. /**
  128404. * Not supported by GPUParticleSystem
  128405. * @param gradient defines the gradient to use (between 0 and 1)
  128406. * @param factor defines the life time factor to affect to the specified gradient
  128407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128408. * @returns the current particle system
  128409. */
  128410. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128411. /**
  128412. * Not supported by GPUParticleSystem
  128413. * @param gradient defines the gradient to remove
  128414. * @returns the current particle system
  128415. */
  128416. removeLifeTimeGradient(gradient: number): IParticleSystem;
  128417. /**
  128418. * Instantiates a GPU particle system.
  128419. * 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.
  128420. * @param name The name of the particle system
  128421. * @param options The options used to create the system
  128422. * @param scene The scene the particle system belongs to
  128423. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  128424. */
  128425. constructor(name: string, options: Partial<{
  128426. capacity: number;
  128427. randomTextureSize: number;
  128428. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  128429. protected _reset(): void;
  128430. private _createUpdateVAO;
  128431. private _createRenderVAO;
  128432. private _initialize;
  128433. /** @hidden */
  128434. _recreateUpdateEffect(): void;
  128435. /** @hidden */
  128436. _recreateRenderEffect(): void;
  128437. /**
  128438. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  128439. * @param preWarm defines if we are in the pre-warmimg phase
  128440. */
  128441. animate(preWarm?: boolean): void;
  128442. private _createFactorGradientTexture;
  128443. private _createSizeGradientTexture;
  128444. private _createAngularSpeedGradientTexture;
  128445. private _createVelocityGradientTexture;
  128446. private _createLimitVelocityGradientTexture;
  128447. private _createDragGradientTexture;
  128448. private _createColorGradientTexture;
  128449. /**
  128450. * Renders the particle system in its current state
  128451. * @param preWarm defines if the system should only update the particles but not render them
  128452. * @returns the current number of particles
  128453. */
  128454. render(preWarm?: boolean): number;
  128455. /**
  128456. * Rebuilds the particle system
  128457. */
  128458. rebuild(): void;
  128459. private _releaseBuffers;
  128460. private _releaseVAOs;
  128461. /**
  128462. * Disposes the particle system and free the associated resources
  128463. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  128464. */
  128465. dispose(disposeTexture?: boolean): void;
  128466. /**
  128467. * Clones the particle system.
  128468. * @param name The name of the cloned object
  128469. * @param newEmitter The new emitter to use
  128470. * @returns the cloned particle system
  128471. */
  128472. clone(name: string, newEmitter: any): GPUParticleSystem;
  128473. /**
  128474. * Serializes the particle system to a JSON object.
  128475. * @returns the JSON object
  128476. */
  128477. serialize(): any;
  128478. /**
  128479. * Parses a JSON object to create a GPU particle system.
  128480. * @param parsedParticleSystem The JSON object to parse
  128481. * @param scene The scene to create the particle system in
  128482. * @param rootUrl The root url to use to load external dependencies like texture
  128483. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  128484. * @returns the parsed GPU particle system
  128485. */
  128486. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  128487. }
  128488. }
  128489. declare module BABYLON {
  128490. /**
  128491. * Represents a set of particle systems working together to create a specific effect
  128492. */
  128493. export class ParticleSystemSet implements IDisposable {
  128494. /**
  128495. * Gets or sets base Assets URL
  128496. */
  128497. static BaseAssetsUrl: string;
  128498. private _emitterCreationOptions;
  128499. private _emitterNode;
  128500. /**
  128501. * Gets the particle system list
  128502. */
  128503. systems: IParticleSystem[];
  128504. /**
  128505. * Gets the emitter node used with this set
  128506. */
  128507. readonly emitterNode: Nullable<TransformNode>;
  128508. /**
  128509. * Creates a new emitter mesh as a sphere
  128510. * @param options defines the options used to create the sphere
  128511. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  128512. * @param scene defines the hosting scene
  128513. */
  128514. setEmitterAsSphere(options: {
  128515. diameter: number;
  128516. segments: number;
  128517. color: Color3;
  128518. }, renderingGroupId: number, scene: Scene): void;
  128519. /**
  128520. * Starts all particle systems of the set
  128521. * @param emitter defines an optional mesh to use as emitter for the particle systems
  128522. */
  128523. start(emitter?: AbstractMesh): void;
  128524. /**
  128525. * Release all associated resources
  128526. */
  128527. dispose(): void;
  128528. /**
  128529. * Serialize the set into a JSON compatible object
  128530. * @returns a JSON compatible representation of the set
  128531. */
  128532. serialize(): any;
  128533. /**
  128534. * Parse a new ParticleSystemSet from a serialized source
  128535. * @param data defines a JSON compatible representation of the set
  128536. * @param scene defines the hosting scene
  128537. * @param gpu defines if we want GPU particles or CPU particles
  128538. * @returns a new ParticleSystemSet
  128539. */
  128540. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  128541. }
  128542. }
  128543. declare module BABYLON {
  128544. /**
  128545. * This class is made for on one-liner static method to help creating particle system set.
  128546. */
  128547. export class ParticleHelper {
  128548. /**
  128549. * Gets or sets base Assets URL
  128550. */
  128551. static BaseAssetsUrl: string;
  128552. /**
  128553. * Create a default particle system that you can tweak
  128554. * @param emitter defines the emitter to use
  128555. * @param capacity defines the system capacity (default is 500 particles)
  128556. * @param scene defines the hosting scene
  128557. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  128558. * @returns the new Particle system
  128559. */
  128560. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  128561. /**
  128562. * This is the main static method (one-liner) of this helper to create different particle systems
  128563. * @param type This string represents the type to the particle system to create
  128564. * @param scene The scene where the particle system should live
  128565. * @param gpu If the system will use gpu
  128566. * @returns the ParticleSystemSet created
  128567. */
  128568. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  128569. /**
  128570. * Static function used to export a particle system to a ParticleSystemSet variable.
  128571. * Please note that the emitter shape is not exported
  128572. * @param systems defines the particle systems to export
  128573. * @returns the created particle system set
  128574. */
  128575. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  128576. }
  128577. }
  128578. declare module BABYLON {
  128579. interface Engine {
  128580. /**
  128581. * Create an effect to use with particle systems.
  128582. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  128583. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  128584. * @param uniformsNames defines a list of attribute names
  128585. * @param samplers defines an array of string used to represent textures
  128586. * @param defines defines the string containing the defines to use to compile the shaders
  128587. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  128588. * @param onCompiled defines a function to call when the effect creation is successful
  128589. * @param onError defines a function to call when the effect creation has failed
  128590. * @returns the new Effect
  128591. */
  128592. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  128593. }
  128594. interface Mesh {
  128595. /**
  128596. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  128597. * @returns an array of IParticleSystem
  128598. */
  128599. getEmittedParticleSystems(): IParticleSystem[];
  128600. /**
  128601. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  128602. * @returns an array of IParticleSystem
  128603. */
  128604. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  128605. }
  128606. /**
  128607. * @hidden
  128608. */
  128609. export var _IDoNeedToBeInTheBuild: number;
  128610. }
  128611. declare module BABYLON {
  128612. /** Defines the 4 color options */
  128613. export enum PointColor {
  128614. /** color value */
  128615. Color = 2,
  128616. /** uv value */
  128617. UV = 1,
  128618. /** random value */
  128619. Random = 0,
  128620. /** stated value */
  128621. Stated = 3
  128622. }
  128623. /**
  128624. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  128625. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  128626. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  128627. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  128628. *
  128629. * Full documentation here : TO BE ENTERED
  128630. */
  128631. export class PointsCloudSystem implements IDisposable {
  128632. /**
  128633. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  128634. * Example : var p = SPS.particles[i];
  128635. */
  128636. particles: CloudPoint[];
  128637. /**
  128638. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  128639. */
  128640. nbParticles: number;
  128641. /**
  128642. * This a counter for your own usage. It's not set by any SPS functions.
  128643. */
  128644. counter: number;
  128645. /**
  128646. * The PCS name. This name is also given to the underlying mesh.
  128647. */
  128648. name: string;
  128649. /**
  128650. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  128651. */
  128652. mesh: Mesh;
  128653. /**
  128654. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  128655. * Please read :
  128656. */
  128657. vars: any;
  128658. /**
  128659. * @hidden
  128660. */
  128661. _size: number;
  128662. private _scene;
  128663. private _promises;
  128664. private _positions;
  128665. private _indices;
  128666. private _normals;
  128667. private _colors;
  128668. private _uvs;
  128669. private _indices32;
  128670. private _positions32;
  128671. private _colors32;
  128672. private _uvs32;
  128673. private _updatable;
  128674. private _isVisibilityBoxLocked;
  128675. private _alwaysVisible;
  128676. private _groups;
  128677. private _groupCounter;
  128678. private _computeParticleColor;
  128679. private _computeParticleTexture;
  128680. private _computeParticleRotation;
  128681. private _computeBoundingBox;
  128682. private _isReady;
  128683. /**
  128684. * Creates a PCS (Points Cloud System) object
  128685. * @param name (String) is the PCS name, this will be the underlying mesh name
  128686. * @param pointSize (number) is the size for each point
  128687. * @param scene (Scene) is the scene in which the PCS is added
  128688. * @param options defines the options of the PCS e.g.
  128689. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  128690. */
  128691. constructor(name: string, pointSize: number, scene: Scene, options?: {
  128692. updatable?: boolean;
  128693. });
  128694. /**
  128695. * Builds the PCS underlying mesh. Returns a standard Mesh.
  128696. * If no points were added to the PCS, the returned mesh is just a single point.
  128697. * @returns a promise for the created mesh
  128698. */
  128699. buildMeshAsync(): Promise<Mesh>;
  128700. /**
  128701. * @hidden
  128702. */
  128703. private _buildMesh;
  128704. private _addParticle;
  128705. private _randomUnitVector;
  128706. private _getColorIndicesForCoord;
  128707. private _setPointsColorOrUV;
  128708. private _colorFromTexture;
  128709. private _calculateDensity;
  128710. /**
  128711. * Adds points to the PCS in random positions within a unit sphere
  128712. * @param nb (positive integer) the number of particles to be created from this model
  128713. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  128714. * @returns the number of groups in the system
  128715. */
  128716. addPoints(nb: number, pointFunction?: any): number;
  128717. /**
  128718. * Adds points to the PCS from the surface of the model shape
  128719. * @param mesh is any Mesh object that will be used as a surface model for the points
  128720. * @param nb (positive integer) the number of particles to be created from this model
  128721. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128722. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128723. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128724. * @returns the number of groups in the system
  128725. */
  128726. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128727. /**
  128728. * Adds points to the PCS inside the model shape
  128729. * @param mesh is any Mesh object that will be used as a surface model for the points
  128730. * @param nb (positive integer) the number of particles to be created from this model
  128731. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128732. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128733. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128734. * @returns the number of groups in the system
  128735. */
  128736. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128737. /**
  128738. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  128739. * This method calls `updateParticle()` for each particle of the SPS.
  128740. * For an animated SPS, it is usually called within the render loop.
  128741. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  128742. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  128743. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  128744. * @returns the PCS.
  128745. */
  128746. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  128747. /**
  128748. * Disposes the PCS.
  128749. */
  128750. dispose(): void;
  128751. /**
  128752. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  128753. * doc :
  128754. * @returns the PCS.
  128755. */
  128756. refreshVisibleSize(): PointsCloudSystem;
  128757. /**
  128758. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  128759. * @param size the size (float) of the visibility box
  128760. * note : this doesn't lock the PCS mesh bounding box.
  128761. * doc :
  128762. */
  128763. setVisibilityBox(size: number): void;
  128764. /**
  128765. * Gets whether the PCS is always visible or not
  128766. * doc :
  128767. */
  128768. /**
  128769. * Sets the PCS as always visible or not
  128770. * doc :
  128771. */
  128772. isAlwaysVisible: boolean;
  128773. /**
  128774. * Tells to `setParticles()` to compute the particle rotations or not
  128775. * Default value : false. The PCS is faster when it's set to false
  128776. * Note : particle rotations are only applied to parent particles
  128777. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  128778. */
  128779. computeParticleRotation: boolean;
  128780. /**
  128781. * Tells to `setParticles()` to compute the particle colors or not.
  128782. * Default value : true. The PCS is faster when it's set to false.
  128783. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128784. */
  128785. /**
  128786. * Gets if `setParticles()` computes the particle colors or not.
  128787. * Default value : false. The PCS is faster when it's set to false.
  128788. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128789. */
  128790. computeParticleColor: boolean;
  128791. /**
  128792. * Gets if `setParticles()` computes the particle textures or not.
  128793. * Default value : false. The PCS is faster when it's set to false.
  128794. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  128795. */
  128796. computeParticleTexture: boolean;
  128797. /**
  128798. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  128799. */
  128800. /**
  128801. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  128802. */
  128803. computeBoundingBox: boolean;
  128804. /**
  128805. * This function does nothing. It may be overwritten to set all the particle first values.
  128806. * The PCS doesn't call this function, you may have to call it by your own.
  128807. * doc :
  128808. */
  128809. initParticles(): void;
  128810. /**
  128811. * This function does nothing. It may be overwritten to recycle a particle
  128812. * The PCS doesn't call this function, you can to call it
  128813. * doc :
  128814. * @param particle The particle to recycle
  128815. * @returns the recycled particle
  128816. */
  128817. recycleParticle(particle: CloudPoint): CloudPoint;
  128818. /**
  128819. * Updates a particle : this function should be overwritten by the user.
  128820. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  128821. * doc :
  128822. * @example : just set a particle position or velocity and recycle conditions
  128823. * @param particle The particle to update
  128824. * @returns the updated particle
  128825. */
  128826. updateParticle(particle: CloudPoint): CloudPoint;
  128827. /**
  128828. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  128829. * This does nothing and may be overwritten by the user.
  128830. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  128831. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  128832. * @param update the boolean update value actually passed to setParticles()
  128833. */
  128834. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  128835. /**
  128836. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  128837. * This will be passed three parameters.
  128838. * This does nothing and may be overwritten by the user.
  128839. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  128840. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  128841. * @param update the boolean update value actually passed to setParticles()
  128842. */
  128843. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  128844. }
  128845. }
  128846. declare module BABYLON {
  128847. /**
  128848. * Represents one particle of a points cloud system.
  128849. */
  128850. export class CloudPoint {
  128851. /**
  128852. * particle global index
  128853. */
  128854. idx: number;
  128855. /**
  128856. * The color of the particle
  128857. */
  128858. color: Nullable<Color4>;
  128859. /**
  128860. * The world space position of the particle.
  128861. */
  128862. position: Vector3;
  128863. /**
  128864. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  128865. */
  128866. rotation: Vector3;
  128867. /**
  128868. * The world space rotation quaternion of the particle.
  128869. */
  128870. rotationQuaternion: Nullable<Quaternion>;
  128871. /**
  128872. * The uv of the particle.
  128873. */
  128874. uv: Nullable<Vector2>;
  128875. /**
  128876. * The current speed of the particle.
  128877. */
  128878. velocity: Vector3;
  128879. /**
  128880. * The pivot point in the particle local space.
  128881. */
  128882. pivot: Vector3;
  128883. /**
  128884. * Must the particle be translated from its pivot point in its local space ?
  128885. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  128886. * Default : false
  128887. */
  128888. translateFromPivot: boolean;
  128889. /**
  128890. * Index of this particle in the global "positions" array (Internal use)
  128891. * @hidden
  128892. */
  128893. _pos: number;
  128894. /**
  128895. * @hidden Index of this particle in the global "indices" array (Internal use)
  128896. */
  128897. _ind: number;
  128898. /**
  128899. * Group this particle belongs to
  128900. */
  128901. _group: PointsGroup;
  128902. /**
  128903. * Group id of this particle
  128904. */
  128905. groupId: number;
  128906. /**
  128907. * Index of the particle in its group id (Internal use)
  128908. */
  128909. idxInGroup: number;
  128910. /**
  128911. * @hidden Particle BoundingInfo object (Internal use)
  128912. */
  128913. _boundingInfo: BoundingInfo;
  128914. /**
  128915. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  128916. */
  128917. _pcs: PointsCloudSystem;
  128918. /**
  128919. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  128920. */
  128921. _stillInvisible: boolean;
  128922. /**
  128923. * @hidden Last computed particle rotation matrix
  128924. */
  128925. _rotationMatrix: number[];
  128926. /**
  128927. * Parent particle Id, if any.
  128928. * Default null.
  128929. */
  128930. parentId: Nullable<number>;
  128931. /**
  128932. * @hidden Internal global position in the PCS.
  128933. */
  128934. _globalPosition: Vector3;
  128935. /**
  128936. * Creates a Point Cloud object.
  128937. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  128938. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  128939. * @param group (PointsGroup) is the group the particle belongs to
  128940. * @param groupId (integer) is the group identifier in the PCS.
  128941. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  128942. * @param pcs defines the PCS it is associated to
  128943. */
  128944. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  128945. /**
  128946. * get point size
  128947. */
  128948. /**
  128949. * Set point size
  128950. */
  128951. size: Vector3;
  128952. /**
  128953. * Legacy support, changed quaternion to rotationQuaternion
  128954. */
  128955. /**
  128956. * Legacy support, changed quaternion to rotationQuaternion
  128957. */
  128958. quaternion: Nullable<Quaternion>;
  128959. /**
  128960. * Returns a boolean. True if the particle intersects a mesh, else false
  128961. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  128962. * @param target is the object (point or mesh) what the intersection is computed against
  128963. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  128964. * @returns true if it intersects
  128965. */
  128966. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  128967. /**
  128968. * get the rotation matrix of the particle
  128969. * @hidden
  128970. */
  128971. getRotationMatrix(m: Matrix): void;
  128972. }
  128973. /**
  128974. * Represents a group of points in a points cloud system
  128975. * * PCS internal tool, don't use it manually.
  128976. */
  128977. export class PointsGroup {
  128978. /**
  128979. * The group id
  128980. * @hidden
  128981. */
  128982. groupID: number;
  128983. /**
  128984. * image data for group (internal use)
  128985. * @hidden
  128986. */
  128987. _groupImageData: Nullable<ArrayBufferView>;
  128988. /**
  128989. * Image Width (internal use)
  128990. * @hidden
  128991. */
  128992. _groupImgWidth: number;
  128993. /**
  128994. * Image Height (internal use)
  128995. * @hidden
  128996. */
  128997. _groupImgHeight: number;
  128998. /**
  128999. * Custom position function (internal use)
  129000. * @hidden
  129001. */
  129002. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  129003. /**
  129004. * density per facet for surface points
  129005. * @hidden
  129006. */
  129007. _groupDensity: number[];
  129008. /**
  129009. * Only when points are colored by texture carries pointer to texture list array
  129010. * @hidden
  129011. */
  129012. _textureNb: number;
  129013. /**
  129014. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  129015. * PCS internal tool, don't use it manually.
  129016. * @hidden
  129017. */
  129018. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  129019. }
  129020. }
  129021. declare module BABYLON {
  129022. interface Scene {
  129023. /** @hidden (Backing field) */
  129024. _physicsEngine: Nullable<IPhysicsEngine>;
  129025. /** @hidden */
  129026. _physicsTimeAccumulator: number;
  129027. /**
  129028. * Gets the current physics engine
  129029. * @returns a IPhysicsEngine or null if none attached
  129030. */
  129031. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  129032. /**
  129033. * Enables physics to the current scene
  129034. * @param gravity defines the scene's gravity for the physics engine
  129035. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  129036. * @return a boolean indicating if the physics engine was initialized
  129037. */
  129038. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  129039. /**
  129040. * Disables and disposes the physics engine associated with the scene
  129041. */
  129042. disablePhysicsEngine(): void;
  129043. /**
  129044. * Gets a boolean indicating if there is an active physics engine
  129045. * @returns a boolean indicating if there is an active physics engine
  129046. */
  129047. isPhysicsEnabled(): boolean;
  129048. /**
  129049. * Deletes a physics compound impostor
  129050. * @param compound defines the compound to delete
  129051. */
  129052. deleteCompoundImpostor(compound: any): void;
  129053. /**
  129054. * An event triggered when physic simulation is about to be run
  129055. */
  129056. onBeforePhysicsObservable: Observable<Scene>;
  129057. /**
  129058. * An event triggered when physic simulation has been done
  129059. */
  129060. onAfterPhysicsObservable: Observable<Scene>;
  129061. }
  129062. interface AbstractMesh {
  129063. /** @hidden */
  129064. _physicsImpostor: Nullable<PhysicsImpostor>;
  129065. /**
  129066. * Gets or sets impostor used for physic simulation
  129067. * @see http://doc.babylonjs.com/features/physics_engine
  129068. */
  129069. physicsImpostor: Nullable<PhysicsImpostor>;
  129070. /**
  129071. * Gets the current physics impostor
  129072. * @see http://doc.babylonjs.com/features/physics_engine
  129073. * @returns a physics impostor or null
  129074. */
  129075. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  129076. /** Apply a physic impulse to the mesh
  129077. * @param force defines the force to apply
  129078. * @param contactPoint defines where to apply the force
  129079. * @returns the current mesh
  129080. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129081. */
  129082. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  129083. /**
  129084. * Creates a physic joint between two meshes
  129085. * @param otherMesh defines the other mesh to use
  129086. * @param pivot1 defines the pivot to use on this mesh
  129087. * @param pivot2 defines the pivot to use on the other mesh
  129088. * @param options defines additional options (can be plugin dependent)
  129089. * @returns the current mesh
  129090. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  129091. */
  129092. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  129093. /** @hidden */
  129094. _disposePhysicsObserver: Nullable<Observer<Node>>;
  129095. }
  129096. /**
  129097. * Defines the physics engine scene component responsible to manage a physics engine
  129098. */
  129099. export class PhysicsEngineSceneComponent implements ISceneComponent {
  129100. /**
  129101. * The component name helpful to identify the component in the list of scene components.
  129102. */
  129103. readonly name: string;
  129104. /**
  129105. * The scene the component belongs to.
  129106. */
  129107. scene: Scene;
  129108. /**
  129109. * Creates a new instance of the component for the given scene
  129110. * @param scene Defines the scene to register the component in
  129111. */
  129112. constructor(scene: Scene);
  129113. /**
  129114. * Registers the component in a given scene
  129115. */
  129116. register(): void;
  129117. /**
  129118. * Rebuilds the elements related to this component in case of
  129119. * context lost for instance.
  129120. */
  129121. rebuild(): void;
  129122. /**
  129123. * Disposes the component and the associated ressources
  129124. */
  129125. dispose(): void;
  129126. }
  129127. }
  129128. declare module BABYLON {
  129129. /**
  129130. * A helper for physics simulations
  129131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129132. */
  129133. export class PhysicsHelper {
  129134. private _scene;
  129135. private _physicsEngine;
  129136. /**
  129137. * Initializes the Physics helper
  129138. * @param scene Babylon.js scene
  129139. */
  129140. constructor(scene: Scene);
  129141. /**
  129142. * Applies a radial explosion impulse
  129143. * @param origin the origin of the explosion
  129144. * @param radiusOrEventOptions the radius or the options of radial explosion
  129145. * @param strength the explosion strength
  129146. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129147. * @returns A physics radial explosion event, or null
  129148. */
  129149. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129150. /**
  129151. * Applies a radial explosion force
  129152. * @param origin the origin of the explosion
  129153. * @param radiusOrEventOptions the radius or the options of radial explosion
  129154. * @param strength the explosion strength
  129155. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129156. * @returns A physics radial explosion event, or null
  129157. */
  129158. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129159. /**
  129160. * Creates a gravitational field
  129161. * @param origin the origin of the explosion
  129162. * @param radiusOrEventOptions the radius or the options of radial explosion
  129163. * @param strength the explosion strength
  129164. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129165. * @returns A physics gravitational field event, or null
  129166. */
  129167. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  129168. /**
  129169. * Creates a physics updraft event
  129170. * @param origin the origin of the updraft
  129171. * @param radiusOrEventOptions the radius or the options of the updraft
  129172. * @param strength the strength of the updraft
  129173. * @param height the height of the updraft
  129174. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  129175. * @returns A physics updraft event, or null
  129176. */
  129177. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  129178. /**
  129179. * Creates a physics vortex event
  129180. * @param origin the of the vortex
  129181. * @param radiusOrEventOptions the radius or the options of the vortex
  129182. * @param strength the strength of the vortex
  129183. * @param height the height of the vortex
  129184. * @returns a Physics vortex event, or null
  129185. * A physics vortex event or null
  129186. */
  129187. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  129188. }
  129189. /**
  129190. * Represents a physics radial explosion event
  129191. */
  129192. class PhysicsRadialExplosionEvent {
  129193. private _scene;
  129194. private _options;
  129195. private _sphere;
  129196. private _dataFetched;
  129197. /**
  129198. * Initializes a radial explosioin event
  129199. * @param _scene BabylonJS scene
  129200. * @param _options The options for the vortex event
  129201. */
  129202. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  129203. /**
  129204. * Returns the data related to the radial explosion event (sphere).
  129205. * @returns The radial explosion event data
  129206. */
  129207. getData(): PhysicsRadialExplosionEventData;
  129208. /**
  129209. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  129210. * @param impostor A physics imposter
  129211. * @param origin the origin of the explosion
  129212. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  129213. */
  129214. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  129215. /**
  129216. * Triggers affecterd impostors callbacks
  129217. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  129218. */
  129219. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  129220. /**
  129221. * Disposes the sphere.
  129222. * @param force Specifies if the sphere should be disposed by force
  129223. */
  129224. dispose(force?: boolean): void;
  129225. /*** Helpers ***/
  129226. private _prepareSphere;
  129227. private _intersectsWithSphere;
  129228. }
  129229. /**
  129230. * Represents a gravitational field event
  129231. */
  129232. class PhysicsGravitationalFieldEvent {
  129233. private _physicsHelper;
  129234. private _scene;
  129235. private _origin;
  129236. private _options;
  129237. private _tickCallback;
  129238. private _sphere;
  129239. private _dataFetched;
  129240. /**
  129241. * Initializes the physics gravitational field event
  129242. * @param _physicsHelper A physics helper
  129243. * @param _scene BabylonJS scene
  129244. * @param _origin The origin position of the gravitational field event
  129245. * @param _options The options for the vortex event
  129246. */
  129247. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  129248. /**
  129249. * Returns the data related to the gravitational field event (sphere).
  129250. * @returns A gravitational field event
  129251. */
  129252. getData(): PhysicsGravitationalFieldEventData;
  129253. /**
  129254. * Enables the gravitational field.
  129255. */
  129256. enable(): void;
  129257. /**
  129258. * Disables the gravitational field.
  129259. */
  129260. disable(): void;
  129261. /**
  129262. * Disposes the sphere.
  129263. * @param force The force to dispose from the gravitational field event
  129264. */
  129265. dispose(force?: boolean): void;
  129266. private _tick;
  129267. }
  129268. /**
  129269. * Represents a physics updraft event
  129270. */
  129271. class PhysicsUpdraftEvent {
  129272. private _scene;
  129273. private _origin;
  129274. private _options;
  129275. private _physicsEngine;
  129276. private _originTop;
  129277. private _originDirection;
  129278. private _tickCallback;
  129279. private _cylinder;
  129280. private _cylinderPosition;
  129281. private _dataFetched;
  129282. /**
  129283. * Initializes the physics updraft event
  129284. * @param _scene BabylonJS scene
  129285. * @param _origin The origin position of the updraft
  129286. * @param _options The options for the updraft event
  129287. */
  129288. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  129289. /**
  129290. * Returns the data related to the updraft event (cylinder).
  129291. * @returns A physics updraft event
  129292. */
  129293. getData(): PhysicsUpdraftEventData;
  129294. /**
  129295. * Enables the updraft.
  129296. */
  129297. enable(): void;
  129298. /**
  129299. * Disables the updraft.
  129300. */
  129301. disable(): void;
  129302. /**
  129303. * Disposes the cylinder.
  129304. * @param force Specifies if the updraft should be disposed by force
  129305. */
  129306. dispose(force?: boolean): void;
  129307. private getImpostorHitData;
  129308. private _tick;
  129309. /*** Helpers ***/
  129310. private _prepareCylinder;
  129311. private _intersectsWithCylinder;
  129312. }
  129313. /**
  129314. * Represents a physics vortex event
  129315. */
  129316. class PhysicsVortexEvent {
  129317. private _scene;
  129318. private _origin;
  129319. private _options;
  129320. private _physicsEngine;
  129321. private _originTop;
  129322. private _tickCallback;
  129323. private _cylinder;
  129324. private _cylinderPosition;
  129325. private _dataFetched;
  129326. /**
  129327. * Initializes the physics vortex event
  129328. * @param _scene The BabylonJS scene
  129329. * @param _origin The origin position of the vortex
  129330. * @param _options The options for the vortex event
  129331. */
  129332. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  129333. /**
  129334. * Returns the data related to the vortex event (cylinder).
  129335. * @returns The physics vortex event data
  129336. */
  129337. getData(): PhysicsVortexEventData;
  129338. /**
  129339. * Enables the vortex.
  129340. */
  129341. enable(): void;
  129342. /**
  129343. * Disables the cortex.
  129344. */
  129345. disable(): void;
  129346. /**
  129347. * Disposes the sphere.
  129348. * @param force
  129349. */
  129350. dispose(force?: boolean): void;
  129351. private getImpostorHitData;
  129352. private _tick;
  129353. /*** Helpers ***/
  129354. private _prepareCylinder;
  129355. private _intersectsWithCylinder;
  129356. }
  129357. /**
  129358. * Options fot the radial explosion event
  129359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129360. */
  129361. export class PhysicsRadialExplosionEventOptions {
  129362. /**
  129363. * The radius of the sphere for the radial explosion.
  129364. */
  129365. radius: number;
  129366. /**
  129367. * The strenth of the explosion.
  129368. */
  129369. strength: number;
  129370. /**
  129371. * The strenght of the force in correspondence to the distance of the affected object
  129372. */
  129373. falloff: PhysicsRadialImpulseFalloff;
  129374. /**
  129375. * Sphere options for the radial explosion.
  129376. */
  129377. sphere: {
  129378. segments: number;
  129379. diameter: number;
  129380. };
  129381. /**
  129382. * Sphere options for the radial explosion.
  129383. */
  129384. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  129385. }
  129386. /**
  129387. * Options fot the updraft event
  129388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129389. */
  129390. export class PhysicsUpdraftEventOptions {
  129391. /**
  129392. * The radius of the cylinder for the vortex
  129393. */
  129394. radius: number;
  129395. /**
  129396. * The strenth of the updraft.
  129397. */
  129398. strength: number;
  129399. /**
  129400. * The height of the cylinder for the updraft.
  129401. */
  129402. height: number;
  129403. /**
  129404. * The mode for the the updraft.
  129405. */
  129406. updraftMode: PhysicsUpdraftMode;
  129407. }
  129408. /**
  129409. * Options fot the vortex event
  129410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129411. */
  129412. export class PhysicsVortexEventOptions {
  129413. /**
  129414. * The radius of the cylinder for the vortex
  129415. */
  129416. radius: number;
  129417. /**
  129418. * The strenth of the vortex.
  129419. */
  129420. strength: number;
  129421. /**
  129422. * The height of the cylinder for the vortex.
  129423. */
  129424. height: number;
  129425. /**
  129426. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  129427. */
  129428. centripetalForceThreshold: number;
  129429. /**
  129430. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  129431. */
  129432. centripetalForceMultiplier: number;
  129433. /**
  129434. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  129435. */
  129436. centrifugalForceMultiplier: number;
  129437. /**
  129438. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  129439. */
  129440. updraftForceMultiplier: number;
  129441. }
  129442. /**
  129443. * The strenght of the force in correspondence to the distance of the affected object
  129444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129445. */
  129446. export enum PhysicsRadialImpulseFalloff {
  129447. /** Defines that impulse is constant in strength across it's whole radius */
  129448. Constant = 0,
  129449. /** Defines that impulse gets weaker if it's further from the origin */
  129450. Linear = 1
  129451. }
  129452. /**
  129453. * The strength of the force in correspondence to the distance of the affected object
  129454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129455. */
  129456. export enum PhysicsUpdraftMode {
  129457. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  129458. Center = 0,
  129459. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  129460. Perpendicular = 1
  129461. }
  129462. /**
  129463. * Interface for a physics hit data
  129464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129465. */
  129466. export interface PhysicsHitData {
  129467. /**
  129468. * The force applied at the contact point
  129469. */
  129470. force: Vector3;
  129471. /**
  129472. * The contact point
  129473. */
  129474. contactPoint: Vector3;
  129475. /**
  129476. * The distance from the origin to the contact point
  129477. */
  129478. distanceFromOrigin: number;
  129479. }
  129480. /**
  129481. * Interface for radial explosion event data
  129482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129483. */
  129484. export interface PhysicsRadialExplosionEventData {
  129485. /**
  129486. * A sphere used for the radial explosion event
  129487. */
  129488. sphere: Mesh;
  129489. }
  129490. /**
  129491. * Interface for gravitational field event data
  129492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129493. */
  129494. export interface PhysicsGravitationalFieldEventData {
  129495. /**
  129496. * A sphere mesh used for the gravitational field event
  129497. */
  129498. sphere: Mesh;
  129499. }
  129500. /**
  129501. * Interface for updraft event data
  129502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129503. */
  129504. export interface PhysicsUpdraftEventData {
  129505. /**
  129506. * A cylinder used for the updraft event
  129507. */
  129508. cylinder: Mesh;
  129509. }
  129510. /**
  129511. * Interface for vortex event data
  129512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129513. */
  129514. export interface PhysicsVortexEventData {
  129515. /**
  129516. * A cylinder used for the vortex event
  129517. */
  129518. cylinder: Mesh;
  129519. }
  129520. /**
  129521. * Interface for an affected physics impostor
  129522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129523. */
  129524. export interface PhysicsAffectedImpostorWithData {
  129525. /**
  129526. * The impostor affected by the effect
  129527. */
  129528. impostor: PhysicsImpostor;
  129529. /**
  129530. * The data about the hit/horce from the explosion
  129531. */
  129532. hitData: PhysicsHitData;
  129533. }
  129534. }
  129535. declare module BABYLON {
  129536. /** @hidden */
  129537. export var blackAndWhitePixelShader: {
  129538. name: string;
  129539. shader: string;
  129540. };
  129541. }
  129542. declare module BABYLON {
  129543. /**
  129544. * Post process used to render in black and white
  129545. */
  129546. export class BlackAndWhitePostProcess extends PostProcess {
  129547. /**
  129548. * Linear about to convert he result to black and white (default: 1)
  129549. */
  129550. degree: number;
  129551. /**
  129552. * Creates a black and white post process
  129553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  129554. * @param name The name of the effect.
  129555. * @param options The required width/height ratio to downsize to before computing the render pass.
  129556. * @param camera The camera to apply the render pass to.
  129557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129558. * @param engine The engine which the post process will be applied. (default: current engine)
  129559. * @param reusable If the post process can be reused on the same frame. (default: false)
  129560. */
  129561. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129562. }
  129563. }
  129564. declare module BABYLON {
  129565. /**
  129566. * This represents a set of one or more post processes in Babylon.
  129567. * A post process can be used to apply a shader to a texture after it is rendered.
  129568. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129569. */
  129570. export class PostProcessRenderEffect {
  129571. private _postProcesses;
  129572. private _getPostProcesses;
  129573. private _singleInstance;
  129574. private _cameras;
  129575. private _indicesForCamera;
  129576. /**
  129577. * Name of the effect
  129578. * @hidden
  129579. */
  129580. _name: string;
  129581. /**
  129582. * Instantiates a post process render effect.
  129583. * A post process can be used to apply a shader to a texture after it is rendered.
  129584. * @param engine The engine the effect is tied to
  129585. * @param name The name of the effect
  129586. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  129587. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  129588. */
  129589. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  129590. /**
  129591. * Checks if all the post processes in the effect are supported.
  129592. */
  129593. readonly isSupported: boolean;
  129594. /**
  129595. * Updates the current state of the effect
  129596. * @hidden
  129597. */
  129598. _update(): void;
  129599. /**
  129600. * Attaches the effect on cameras
  129601. * @param cameras The camera to attach to.
  129602. * @hidden
  129603. */
  129604. _attachCameras(cameras: Camera): void;
  129605. /**
  129606. * Attaches the effect on cameras
  129607. * @param cameras The camera to attach to.
  129608. * @hidden
  129609. */
  129610. _attachCameras(cameras: Camera[]): void;
  129611. /**
  129612. * Detaches the effect on cameras
  129613. * @param cameras The camera to detatch from.
  129614. * @hidden
  129615. */
  129616. _detachCameras(cameras: Camera): void;
  129617. /**
  129618. * Detatches the effect on cameras
  129619. * @param cameras The camera to detatch from.
  129620. * @hidden
  129621. */
  129622. _detachCameras(cameras: Camera[]): void;
  129623. /**
  129624. * Enables the effect on given cameras
  129625. * @param cameras The camera to enable.
  129626. * @hidden
  129627. */
  129628. _enable(cameras: Camera): void;
  129629. /**
  129630. * Enables the effect on given cameras
  129631. * @param cameras The camera to enable.
  129632. * @hidden
  129633. */
  129634. _enable(cameras: Nullable<Camera[]>): void;
  129635. /**
  129636. * Disables the effect on the given cameras
  129637. * @param cameras The camera to disable.
  129638. * @hidden
  129639. */
  129640. _disable(cameras: Camera): void;
  129641. /**
  129642. * Disables the effect on the given cameras
  129643. * @param cameras The camera to disable.
  129644. * @hidden
  129645. */
  129646. _disable(cameras: Nullable<Camera[]>): void;
  129647. /**
  129648. * Gets a list of the post processes contained in the effect.
  129649. * @param camera The camera to get the post processes on.
  129650. * @returns The list of the post processes in the effect.
  129651. */
  129652. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  129653. }
  129654. }
  129655. declare module BABYLON {
  129656. /** @hidden */
  129657. export var extractHighlightsPixelShader: {
  129658. name: string;
  129659. shader: string;
  129660. };
  129661. }
  129662. declare module BABYLON {
  129663. /**
  129664. * 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.
  129665. */
  129666. export class ExtractHighlightsPostProcess extends PostProcess {
  129667. /**
  129668. * The luminance threshold, pixels below this value will be set to black.
  129669. */
  129670. threshold: number;
  129671. /** @hidden */
  129672. _exposure: number;
  129673. /**
  129674. * Post process which has the input texture to be used when performing highlight extraction
  129675. * @hidden
  129676. */
  129677. _inputPostProcess: Nullable<PostProcess>;
  129678. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129679. }
  129680. }
  129681. declare module BABYLON {
  129682. /** @hidden */
  129683. export var bloomMergePixelShader: {
  129684. name: string;
  129685. shader: string;
  129686. };
  129687. }
  129688. declare module BABYLON {
  129689. /**
  129690. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  129691. */
  129692. export class BloomMergePostProcess extends PostProcess {
  129693. /** Weight of the bloom to be added to the original input. */
  129694. weight: number;
  129695. /**
  129696. * Creates a new instance of @see BloomMergePostProcess
  129697. * @param name The name of the effect.
  129698. * @param originalFromInput Post process which's input will be used for the merge.
  129699. * @param blurred Blurred highlights post process which's output will be used.
  129700. * @param weight Weight of the bloom to be added to the original input.
  129701. * @param options The required width/height ratio to downsize to before computing the render pass.
  129702. * @param camera The camera to apply the render pass to.
  129703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129704. * @param engine The engine which the post process will be applied. (default: current engine)
  129705. * @param reusable If the post process can be reused on the same frame. (default: false)
  129706. * @param textureType Type of textures used when performing the post process. (default: 0)
  129707. * @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)
  129708. */
  129709. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  129710. /** Weight of the bloom to be added to the original input. */
  129711. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129712. }
  129713. }
  129714. declare module BABYLON {
  129715. /**
  129716. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  129717. */
  129718. export class BloomEffect extends PostProcessRenderEffect {
  129719. private bloomScale;
  129720. /**
  129721. * @hidden Internal
  129722. */
  129723. _effects: Array<PostProcess>;
  129724. /**
  129725. * @hidden Internal
  129726. */
  129727. _downscale: ExtractHighlightsPostProcess;
  129728. private _blurX;
  129729. private _blurY;
  129730. private _merge;
  129731. /**
  129732. * The luminance threshold to find bright areas of the image to bloom.
  129733. */
  129734. threshold: number;
  129735. /**
  129736. * The strength of the bloom.
  129737. */
  129738. weight: number;
  129739. /**
  129740. * Specifies the size of the bloom blur kernel, relative to the final output size
  129741. */
  129742. kernel: number;
  129743. /**
  129744. * Creates a new instance of @see BloomEffect
  129745. * @param scene The scene the effect belongs to.
  129746. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  129747. * @param bloomKernel The size of the kernel to be used when applying the blur.
  129748. * @param bloomWeight The the strength of bloom.
  129749. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  129750. * @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)
  129751. */
  129752. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  129753. /**
  129754. * Disposes each of the internal effects for a given camera.
  129755. * @param camera The camera to dispose the effect on.
  129756. */
  129757. disposeEffects(camera: Camera): void;
  129758. /**
  129759. * @hidden Internal
  129760. */
  129761. _updateEffects(): void;
  129762. /**
  129763. * Internal
  129764. * @returns if all the contained post processes are ready.
  129765. * @hidden
  129766. */
  129767. _isReady(): boolean;
  129768. }
  129769. }
  129770. declare module BABYLON {
  129771. /** @hidden */
  129772. export var chromaticAberrationPixelShader: {
  129773. name: string;
  129774. shader: string;
  129775. };
  129776. }
  129777. declare module BABYLON {
  129778. /**
  129779. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  129780. */
  129781. export class ChromaticAberrationPostProcess extends PostProcess {
  129782. /**
  129783. * The amount of seperation of rgb channels (default: 30)
  129784. */
  129785. aberrationAmount: number;
  129786. /**
  129787. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  129788. */
  129789. radialIntensity: number;
  129790. /**
  129791. * 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))
  129792. */
  129793. direction: Vector2;
  129794. /**
  129795. * 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))
  129796. */
  129797. centerPosition: Vector2;
  129798. /**
  129799. * Creates a new instance ChromaticAberrationPostProcess
  129800. * @param name The name of the effect.
  129801. * @param screenWidth The width of the screen to apply the effect on.
  129802. * @param screenHeight The height of the screen to apply the effect on.
  129803. * @param options The required width/height ratio to downsize to before computing the render pass.
  129804. * @param camera The camera to apply the render pass to.
  129805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129806. * @param engine The engine which the post process will be applied. (default: current engine)
  129807. * @param reusable If the post process can be reused on the same frame. (default: false)
  129808. * @param textureType Type of textures used when performing the post process. (default: 0)
  129809. * @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)
  129810. */
  129811. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129812. }
  129813. }
  129814. declare module BABYLON {
  129815. /** @hidden */
  129816. export var circleOfConfusionPixelShader: {
  129817. name: string;
  129818. shader: string;
  129819. };
  129820. }
  129821. declare module BABYLON {
  129822. /**
  129823. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  129824. */
  129825. export class CircleOfConfusionPostProcess extends PostProcess {
  129826. /**
  129827. * 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.
  129828. */
  129829. lensSize: number;
  129830. /**
  129831. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  129832. */
  129833. fStop: number;
  129834. /**
  129835. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  129836. */
  129837. focusDistance: number;
  129838. /**
  129839. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  129840. */
  129841. focalLength: number;
  129842. private _depthTexture;
  129843. /**
  129844. * Creates a new instance CircleOfConfusionPostProcess
  129845. * @param name The name of the effect.
  129846. * @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.
  129847. * @param options The required width/height ratio to downsize to before computing the render pass.
  129848. * @param camera The camera to apply the render pass to.
  129849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129850. * @param engine The engine which the post process will be applied. (default: current engine)
  129851. * @param reusable If the post process can be reused on the same frame. (default: false)
  129852. * @param textureType Type of textures used when performing the post process. (default: 0)
  129853. * @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)
  129854. */
  129855. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129856. /**
  129857. * 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.
  129858. */
  129859. depthTexture: RenderTargetTexture;
  129860. }
  129861. }
  129862. declare module BABYLON {
  129863. /** @hidden */
  129864. export var colorCorrectionPixelShader: {
  129865. name: string;
  129866. shader: string;
  129867. };
  129868. }
  129869. declare module BABYLON {
  129870. /**
  129871. *
  129872. * This post-process allows the modification of rendered colors by using
  129873. * a 'look-up table' (LUT). This effect is also called Color Grading.
  129874. *
  129875. * The object needs to be provided an url to a texture containing the color
  129876. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  129877. * Use an image editing software to tweak the LUT to match your needs.
  129878. *
  129879. * For an example of a color LUT, see here:
  129880. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  129881. * For explanations on color grading, see here:
  129882. * @see http://udn.epicgames.com/Three/ColorGrading.html
  129883. *
  129884. */
  129885. export class ColorCorrectionPostProcess extends PostProcess {
  129886. private _colorTableTexture;
  129887. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129888. }
  129889. }
  129890. declare module BABYLON {
  129891. /** @hidden */
  129892. export var convolutionPixelShader: {
  129893. name: string;
  129894. shader: string;
  129895. };
  129896. }
  129897. declare module BABYLON {
  129898. /**
  129899. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  129900. * input texture to perform effects such as edge detection or sharpening
  129901. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129902. */
  129903. export class ConvolutionPostProcess extends PostProcess {
  129904. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  129905. kernel: number[];
  129906. /**
  129907. * Creates a new instance ConvolutionPostProcess
  129908. * @param name The name of the effect.
  129909. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  129910. * @param options The required width/height ratio to downsize to before computing the render pass.
  129911. * @param camera The camera to apply the render pass to.
  129912. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129913. * @param engine The engine which the post process will be applied. (default: current engine)
  129914. * @param reusable If the post process can be reused on the same frame. (default: false)
  129915. * @param textureType Type of textures used when performing the post process. (default: 0)
  129916. */
  129917. constructor(name: string,
  129918. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  129919. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129920. /**
  129921. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129922. */
  129923. static EdgeDetect0Kernel: number[];
  129924. /**
  129925. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129926. */
  129927. static EdgeDetect1Kernel: number[];
  129928. /**
  129929. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129930. */
  129931. static EdgeDetect2Kernel: number[];
  129932. /**
  129933. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129934. */
  129935. static SharpenKernel: number[];
  129936. /**
  129937. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129938. */
  129939. static EmbossKernel: number[];
  129940. /**
  129941. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129942. */
  129943. static GaussianKernel: number[];
  129944. }
  129945. }
  129946. declare module BABYLON {
  129947. /**
  129948. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  129949. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  129950. * based on samples that have a large difference in distance than the center pixel.
  129951. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  129952. */
  129953. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  129954. direction: Vector2;
  129955. /**
  129956. * Creates a new instance CircleOfConfusionPostProcess
  129957. * @param name The name of the effect.
  129958. * @param scene The scene the effect belongs to.
  129959. * @param direction The direction the blur should be applied.
  129960. * @param kernel The size of the kernel used to blur.
  129961. * @param options The required width/height ratio to downsize to before computing the render pass.
  129962. * @param camera The camera to apply the render pass to.
  129963. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  129964. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  129965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129966. * @param engine The engine which the post process will be applied. (default: current engine)
  129967. * @param reusable If the post process can be reused on the same frame. (default: false)
  129968. * @param textureType Type of textures used when performing the post process. (default: 0)
  129969. * @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)
  129970. */
  129971. 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);
  129972. }
  129973. }
  129974. declare module BABYLON {
  129975. /** @hidden */
  129976. export var depthOfFieldMergePixelShader: {
  129977. name: string;
  129978. shader: string;
  129979. };
  129980. }
  129981. declare module BABYLON {
  129982. /**
  129983. * Options to be set when merging outputs from the default pipeline.
  129984. */
  129985. export class DepthOfFieldMergePostProcessOptions {
  129986. /**
  129987. * The original image to merge on top of
  129988. */
  129989. originalFromInput: PostProcess;
  129990. /**
  129991. * Parameters to perform the merge of the depth of field effect
  129992. */
  129993. depthOfField?: {
  129994. circleOfConfusion: PostProcess;
  129995. blurSteps: Array<PostProcess>;
  129996. };
  129997. /**
  129998. * Parameters to perform the merge of bloom effect
  129999. */
  130000. bloom?: {
  130001. blurred: PostProcess;
  130002. weight: number;
  130003. };
  130004. }
  130005. /**
  130006. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130007. */
  130008. export class DepthOfFieldMergePostProcess extends PostProcess {
  130009. private blurSteps;
  130010. /**
  130011. * Creates a new instance of DepthOfFieldMergePostProcess
  130012. * @param name The name of the effect.
  130013. * @param originalFromInput Post process which's input will be used for the merge.
  130014. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  130015. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  130016. * @param options The required width/height ratio to downsize to before computing the render pass.
  130017. * @param camera The camera to apply the render pass to.
  130018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130019. * @param engine The engine which the post process will be applied. (default: current engine)
  130020. * @param reusable If the post process can be reused on the same frame. (default: false)
  130021. * @param textureType Type of textures used when performing the post process. (default: 0)
  130022. * @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)
  130023. */
  130024. 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);
  130025. /**
  130026. * Updates the effect with the current post process compile time values and recompiles the shader.
  130027. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  130028. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  130029. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  130030. * @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
  130031. * @param onCompiled Called when the shader has been compiled.
  130032. * @param onError Called if there is an error when compiling a shader.
  130033. */
  130034. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  130035. }
  130036. }
  130037. declare module BABYLON {
  130038. /**
  130039. * Specifies the level of max blur that should be applied when using the depth of field effect
  130040. */
  130041. export enum DepthOfFieldEffectBlurLevel {
  130042. /**
  130043. * Subtle blur
  130044. */
  130045. Low = 0,
  130046. /**
  130047. * Medium blur
  130048. */
  130049. Medium = 1,
  130050. /**
  130051. * Large blur
  130052. */
  130053. High = 2
  130054. }
  130055. /**
  130056. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  130057. */
  130058. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  130059. private _circleOfConfusion;
  130060. /**
  130061. * @hidden Internal, blurs from high to low
  130062. */
  130063. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  130064. private _depthOfFieldBlurY;
  130065. private _dofMerge;
  130066. /**
  130067. * @hidden Internal post processes in depth of field effect
  130068. */
  130069. _effects: Array<PostProcess>;
  130070. /**
  130071. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  130072. */
  130073. focalLength: number;
  130074. /**
  130075. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130076. */
  130077. fStop: number;
  130078. /**
  130079. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130080. */
  130081. focusDistance: number;
  130082. /**
  130083. * 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.
  130084. */
  130085. lensSize: number;
  130086. /**
  130087. * Creates a new instance DepthOfFieldEffect
  130088. * @param scene The scene the effect belongs to.
  130089. * @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.
  130090. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130091. * @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)
  130092. */
  130093. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  130094. /**
  130095. * Get the current class name of the current effet
  130096. * @returns "DepthOfFieldEffect"
  130097. */
  130098. getClassName(): string;
  130099. /**
  130100. * 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.
  130101. */
  130102. depthTexture: RenderTargetTexture;
  130103. /**
  130104. * Disposes each of the internal effects for a given camera.
  130105. * @param camera The camera to dispose the effect on.
  130106. */
  130107. disposeEffects(camera: Camera): void;
  130108. /**
  130109. * @hidden Internal
  130110. */
  130111. _updateEffects(): void;
  130112. /**
  130113. * Internal
  130114. * @returns if all the contained post processes are ready.
  130115. * @hidden
  130116. */
  130117. _isReady(): boolean;
  130118. }
  130119. }
  130120. declare module BABYLON {
  130121. /** @hidden */
  130122. export var displayPassPixelShader: {
  130123. name: string;
  130124. shader: string;
  130125. };
  130126. }
  130127. declare module BABYLON {
  130128. /**
  130129. * DisplayPassPostProcess which produces an output the same as it's input
  130130. */
  130131. export class DisplayPassPostProcess extends PostProcess {
  130132. /**
  130133. * Creates the DisplayPassPostProcess
  130134. * @param name The name of the effect.
  130135. * @param options The required width/height ratio to downsize to before computing the render pass.
  130136. * @param camera The camera to apply the render pass to.
  130137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130138. * @param engine The engine which the post process will be applied. (default: current engine)
  130139. * @param reusable If the post process can be reused on the same frame. (default: false)
  130140. */
  130141. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130142. }
  130143. }
  130144. declare module BABYLON {
  130145. /** @hidden */
  130146. export var filterPixelShader: {
  130147. name: string;
  130148. shader: string;
  130149. };
  130150. }
  130151. declare module BABYLON {
  130152. /**
  130153. * Applies a kernel filter to the image
  130154. */
  130155. export class FilterPostProcess extends PostProcess {
  130156. /** The matrix to be applied to the image */
  130157. kernelMatrix: Matrix;
  130158. /**
  130159. *
  130160. * @param name The name of the effect.
  130161. * @param kernelMatrix The matrix to be applied to the image
  130162. * @param options The required width/height ratio to downsize to before computing the render pass.
  130163. * @param camera The camera to apply the render pass to.
  130164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130165. * @param engine The engine which the post process will be applied. (default: current engine)
  130166. * @param reusable If the post process can be reused on the same frame. (default: false)
  130167. */
  130168. constructor(name: string,
  130169. /** The matrix to be applied to the image */
  130170. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130171. }
  130172. }
  130173. declare module BABYLON {
  130174. /** @hidden */
  130175. export var fxaaPixelShader: {
  130176. name: string;
  130177. shader: string;
  130178. };
  130179. }
  130180. declare module BABYLON {
  130181. /** @hidden */
  130182. export var fxaaVertexShader: {
  130183. name: string;
  130184. shader: string;
  130185. };
  130186. }
  130187. declare module BABYLON {
  130188. /**
  130189. * Fxaa post process
  130190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  130191. */
  130192. export class FxaaPostProcess extends PostProcess {
  130193. /** @hidden */
  130194. texelWidth: number;
  130195. /** @hidden */
  130196. texelHeight: number;
  130197. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130198. private _getDefines;
  130199. }
  130200. }
  130201. declare module BABYLON {
  130202. /** @hidden */
  130203. export var grainPixelShader: {
  130204. name: string;
  130205. shader: string;
  130206. };
  130207. }
  130208. declare module BABYLON {
  130209. /**
  130210. * The GrainPostProcess adds noise to the image at mid luminance levels
  130211. */
  130212. export class GrainPostProcess extends PostProcess {
  130213. /**
  130214. * The intensity of the grain added (default: 30)
  130215. */
  130216. intensity: number;
  130217. /**
  130218. * If the grain should be randomized on every frame
  130219. */
  130220. animated: boolean;
  130221. /**
  130222. * Creates a new instance of @see GrainPostProcess
  130223. * @param name The name of the effect.
  130224. * @param options The required width/height ratio to downsize to before computing the render pass.
  130225. * @param camera The camera to apply the render pass to.
  130226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130227. * @param engine The engine which the post process will be applied. (default: current engine)
  130228. * @param reusable If the post process can be reused on the same frame. (default: false)
  130229. * @param textureType Type of textures used when performing the post process. (default: 0)
  130230. * @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)
  130231. */
  130232. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130233. }
  130234. }
  130235. declare module BABYLON {
  130236. /** @hidden */
  130237. export var highlightsPixelShader: {
  130238. name: string;
  130239. shader: string;
  130240. };
  130241. }
  130242. declare module BABYLON {
  130243. /**
  130244. * Extracts highlights from the image
  130245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130246. */
  130247. export class HighlightsPostProcess extends PostProcess {
  130248. /**
  130249. * Extracts highlights from the image
  130250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130251. * @param name The name of the effect.
  130252. * @param options The required width/height ratio to downsize to before computing the render pass.
  130253. * @param camera The camera to apply the render pass to.
  130254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130255. * @param engine The engine which the post process will be applied. (default: current engine)
  130256. * @param reusable If the post process can be reused on the same frame. (default: false)
  130257. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  130258. */
  130259. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130260. }
  130261. }
  130262. declare module BABYLON {
  130263. /** @hidden */
  130264. export var mrtFragmentDeclaration: {
  130265. name: string;
  130266. shader: string;
  130267. };
  130268. }
  130269. declare module BABYLON {
  130270. /** @hidden */
  130271. export var geometryPixelShader: {
  130272. name: string;
  130273. shader: string;
  130274. };
  130275. }
  130276. declare module BABYLON {
  130277. /** @hidden */
  130278. export var geometryVertexShader: {
  130279. name: string;
  130280. shader: string;
  130281. };
  130282. }
  130283. declare module BABYLON {
  130284. /** @hidden */
  130285. interface ISavedTransformationMatrix {
  130286. world: Matrix;
  130287. viewProjection: Matrix;
  130288. }
  130289. /**
  130290. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  130291. */
  130292. export class GeometryBufferRenderer {
  130293. /**
  130294. * Constant used to retrieve the position texture index in the G-Buffer textures array
  130295. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  130296. */
  130297. static readonly POSITION_TEXTURE_TYPE: number;
  130298. /**
  130299. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  130300. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  130301. */
  130302. static readonly VELOCITY_TEXTURE_TYPE: number;
  130303. /**
  130304. * Dictionary used to store the previous transformation matrices of each rendered mesh
  130305. * in order to compute objects velocities when enableVelocity is set to "true"
  130306. * @hidden
  130307. */
  130308. _previousTransformationMatrices: {
  130309. [index: number]: ISavedTransformationMatrix;
  130310. };
  130311. /**
  130312. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  130313. * in order to compute objects velocities when enableVelocity is set to "true"
  130314. * @hidden
  130315. */
  130316. _previousBonesTransformationMatrices: {
  130317. [index: number]: Float32Array;
  130318. };
  130319. /**
  130320. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  130321. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  130322. */
  130323. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  130324. private _scene;
  130325. private _multiRenderTarget;
  130326. private _ratio;
  130327. private _enablePosition;
  130328. private _enableVelocity;
  130329. private _positionIndex;
  130330. private _velocityIndex;
  130331. protected _effect: Effect;
  130332. protected _cachedDefines: string;
  130333. /**
  130334. * Set the render list (meshes to be rendered) used in the G buffer.
  130335. */
  130336. renderList: Mesh[];
  130337. /**
  130338. * Gets wether or not G buffer are supported by the running hardware.
  130339. * This requires draw buffer supports
  130340. */
  130341. readonly isSupported: boolean;
  130342. /**
  130343. * Returns the index of the given texture type in the G-Buffer textures array
  130344. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  130345. * @returns the index of the given texture type in the G-Buffer textures array
  130346. */
  130347. getTextureIndex(textureType: number): number;
  130348. /**
  130349. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  130350. */
  130351. /**
  130352. * Sets whether or not objects positions are enabled for the G buffer.
  130353. */
  130354. enablePosition: boolean;
  130355. /**
  130356. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  130357. */
  130358. /**
  130359. * Sets wether or not objects velocities are enabled for the G buffer.
  130360. */
  130361. enableVelocity: boolean;
  130362. /**
  130363. * Gets the scene associated with the buffer.
  130364. */
  130365. readonly scene: Scene;
  130366. /**
  130367. * Gets the ratio used by the buffer during its creation.
  130368. * How big is the buffer related to the main canvas.
  130369. */
  130370. readonly ratio: number;
  130371. /** @hidden */
  130372. static _SceneComponentInitialization: (scene: Scene) => void;
  130373. /**
  130374. * Creates a new G Buffer for the scene
  130375. * @param scene The scene the buffer belongs to
  130376. * @param ratio How big is the buffer related to the main canvas.
  130377. */
  130378. constructor(scene: Scene, ratio?: number);
  130379. /**
  130380. * Checks wether everything is ready to render a submesh to the G buffer.
  130381. * @param subMesh the submesh to check readiness for
  130382. * @param useInstances is the mesh drawn using instance or not
  130383. * @returns true if ready otherwise false
  130384. */
  130385. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130386. /**
  130387. * Gets the current underlying G Buffer.
  130388. * @returns the buffer
  130389. */
  130390. getGBuffer(): MultiRenderTarget;
  130391. /**
  130392. * Gets the number of samples used to render the buffer (anti aliasing).
  130393. */
  130394. /**
  130395. * Sets the number of samples used to render the buffer (anti aliasing).
  130396. */
  130397. samples: number;
  130398. /**
  130399. * Disposes the renderer and frees up associated resources.
  130400. */
  130401. dispose(): void;
  130402. protected _createRenderTargets(): void;
  130403. private _copyBonesTransformationMatrices;
  130404. }
  130405. }
  130406. declare module BABYLON {
  130407. interface Scene {
  130408. /** @hidden (Backing field) */
  130409. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130410. /**
  130411. * Gets or Sets the current geometry buffer associated to the scene.
  130412. */
  130413. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130414. /**
  130415. * Enables a GeometryBufferRender and associates it with the scene
  130416. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  130417. * @returns the GeometryBufferRenderer
  130418. */
  130419. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  130420. /**
  130421. * Disables the GeometryBufferRender associated with the scene
  130422. */
  130423. disableGeometryBufferRenderer(): void;
  130424. }
  130425. /**
  130426. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  130427. * in several rendering techniques.
  130428. */
  130429. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  130430. /**
  130431. * The component name helpful to identify the component in the list of scene components.
  130432. */
  130433. readonly name: string;
  130434. /**
  130435. * The scene the component belongs to.
  130436. */
  130437. scene: Scene;
  130438. /**
  130439. * Creates a new instance of the component for the given scene
  130440. * @param scene Defines the scene to register the component in
  130441. */
  130442. constructor(scene: Scene);
  130443. /**
  130444. * Registers the component in a given scene
  130445. */
  130446. register(): void;
  130447. /**
  130448. * Rebuilds the elements related to this component in case of
  130449. * context lost for instance.
  130450. */
  130451. rebuild(): void;
  130452. /**
  130453. * Disposes the component and the associated ressources
  130454. */
  130455. dispose(): void;
  130456. private _gatherRenderTargets;
  130457. }
  130458. }
  130459. declare module BABYLON {
  130460. /** @hidden */
  130461. export var motionBlurPixelShader: {
  130462. name: string;
  130463. shader: string;
  130464. };
  130465. }
  130466. declare module BABYLON {
  130467. /**
  130468. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  130469. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  130470. * As an example, all you have to do is to create the post-process:
  130471. * var mb = new BABYLON.MotionBlurPostProcess(
  130472. * 'mb', // The name of the effect.
  130473. * scene, // The scene containing the objects to blur according to their velocity.
  130474. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  130475. * camera // The camera to apply the render pass to.
  130476. * );
  130477. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  130478. */
  130479. export class MotionBlurPostProcess extends PostProcess {
  130480. /**
  130481. * Defines how much the image is blurred by the movement. Default value is equal to 1
  130482. */
  130483. motionStrength: number;
  130484. /**
  130485. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  130486. */
  130487. /**
  130488. * Sets the number of iterations to be used for motion blur quality
  130489. */
  130490. motionBlurSamples: number;
  130491. private _motionBlurSamples;
  130492. private _geometryBufferRenderer;
  130493. /**
  130494. * Creates a new instance MotionBlurPostProcess
  130495. * @param name The name of the effect.
  130496. * @param scene The scene containing the objects to blur according to their velocity.
  130497. * @param options The required width/height ratio to downsize to before computing the render pass.
  130498. * @param camera The camera to apply the render pass to.
  130499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130500. * @param engine The engine which the post process will be applied. (default: current engine)
  130501. * @param reusable If the post process can be reused on the same frame. (default: false)
  130502. * @param textureType Type of textures used when performing the post process. (default: 0)
  130503. * @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)
  130504. */
  130505. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130506. /**
  130507. * Excludes the given skinned mesh from computing bones velocities.
  130508. * 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.
  130509. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  130510. */
  130511. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130512. /**
  130513. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  130514. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  130515. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  130516. */
  130517. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130518. /**
  130519. * Disposes the post process.
  130520. * @param camera The camera to dispose the post process on.
  130521. */
  130522. dispose(camera?: Camera): void;
  130523. }
  130524. }
  130525. declare module BABYLON {
  130526. /** @hidden */
  130527. export var refractionPixelShader: {
  130528. name: string;
  130529. shader: string;
  130530. };
  130531. }
  130532. declare module BABYLON {
  130533. /**
  130534. * Post process which applies a refractin texture
  130535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130536. */
  130537. export class RefractionPostProcess extends PostProcess {
  130538. /** the base color of the refraction (used to taint the rendering) */
  130539. color: Color3;
  130540. /** simulated refraction depth */
  130541. depth: number;
  130542. /** the coefficient of the base color (0 to remove base color tainting) */
  130543. colorLevel: number;
  130544. private _refTexture;
  130545. private _ownRefractionTexture;
  130546. /**
  130547. * Gets or sets the refraction texture
  130548. * Please note that you are responsible for disposing the texture if you set it manually
  130549. */
  130550. refractionTexture: Texture;
  130551. /**
  130552. * Initializes the RefractionPostProcess
  130553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130554. * @param name The name of the effect.
  130555. * @param refractionTextureUrl Url of the refraction texture to use
  130556. * @param color the base color of the refraction (used to taint the rendering)
  130557. * @param depth simulated refraction depth
  130558. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  130559. * @param camera The camera to apply the render pass to.
  130560. * @param options The required width/height ratio to downsize to before computing the render pass.
  130561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130562. * @param engine The engine which the post process will be applied. (default: current engine)
  130563. * @param reusable If the post process can be reused on the same frame. (default: false)
  130564. */
  130565. constructor(name: string, refractionTextureUrl: string,
  130566. /** the base color of the refraction (used to taint the rendering) */
  130567. color: Color3,
  130568. /** simulated refraction depth */
  130569. depth: number,
  130570. /** the coefficient of the base color (0 to remove base color tainting) */
  130571. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130572. /**
  130573. * Disposes of the post process
  130574. * @param camera Camera to dispose post process on
  130575. */
  130576. dispose(camera: Camera): void;
  130577. }
  130578. }
  130579. declare module BABYLON {
  130580. /** @hidden */
  130581. export var sharpenPixelShader: {
  130582. name: string;
  130583. shader: string;
  130584. };
  130585. }
  130586. declare module BABYLON {
  130587. /**
  130588. * The SharpenPostProcess applies a sharpen kernel to every pixel
  130589. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130590. */
  130591. export class SharpenPostProcess extends PostProcess {
  130592. /**
  130593. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  130594. */
  130595. colorAmount: number;
  130596. /**
  130597. * How much sharpness should be applied (default: 0.3)
  130598. */
  130599. edgeAmount: number;
  130600. /**
  130601. * Creates a new instance ConvolutionPostProcess
  130602. * @param name The name of the effect.
  130603. * @param options The required width/height ratio to downsize to before computing the render pass.
  130604. * @param camera The camera to apply the render pass to.
  130605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130606. * @param engine The engine which the post process will be applied. (default: current engine)
  130607. * @param reusable If the post process can be reused on the same frame. (default: false)
  130608. * @param textureType Type of textures used when performing the post process. (default: 0)
  130609. * @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)
  130610. */
  130611. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130612. }
  130613. }
  130614. declare module BABYLON {
  130615. /**
  130616. * PostProcessRenderPipeline
  130617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130618. */
  130619. export class PostProcessRenderPipeline {
  130620. private engine;
  130621. private _renderEffects;
  130622. private _renderEffectsForIsolatedPass;
  130623. /**
  130624. * List of inspectable custom properties (used by the Inspector)
  130625. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  130626. */
  130627. inspectableCustomProperties: IInspectable[];
  130628. /**
  130629. * @hidden
  130630. */
  130631. protected _cameras: Camera[];
  130632. /** @hidden */
  130633. _name: string;
  130634. /**
  130635. * Gets pipeline name
  130636. */
  130637. readonly name: string;
  130638. /** Gets the list of attached cameras */
  130639. readonly cameras: Camera[];
  130640. /**
  130641. * Initializes a PostProcessRenderPipeline
  130642. * @param engine engine to add the pipeline to
  130643. * @param name name of the pipeline
  130644. */
  130645. constructor(engine: Engine, name: string);
  130646. /**
  130647. * Gets the class name
  130648. * @returns "PostProcessRenderPipeline"
  130649. */
  130650. getClassName(): string;
  130651. /**
  130652. * If all the render effects in the pipeline are supported
  130653. */
  130654. readonly isSupported: boolean;
  130655. /**
  130656. * Adds an effect to the pipeline
  130657. * @param renderEffect the effect to add
  130658. */
  130659. addEffect(renderEffect: PostProcessRenderEffect): void;
  130660. /** @hidden */
  130661. _rebuild(): void;
  130662. /** @hidden */
  130663. _enableEffect(renderEffectName: string, cameras: Camera): void;
  130664. /** @hidden */
  130665. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  130666. /** @hidden */
  130667. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130668. /** @hidden */
  130669. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130670. /** @hidden */
  130671. _attachCameras(cameras: Camera, unique: boolean): void;
  130672. /** @hidden */
  130673. _attachCameras(cameras: Camera[], unique: boolean): void;
  130674. /** @hidden */
  130675. _detachCameras(cameras: Camera): void;
  130676. /** @hidden */
  130677. _detachCameras(cameras: Nullable<Camera[]>): void;
  130678. /** @hidden */
  130679. _update(): void;
  130680. /** @hidden */
  130681. _reset(): void;
  130682. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  130683. /**
  130684. * Disposes of the pipeline
  130685. */
  130686. dispose(): void;
  130687. }
  130688. }
  130689. declare module BABYLON {
  130690. /**
  130691. * PostProcessRenderPipelineManager class
  130692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130693. */
  130694. export class PostProcessRenderPipelineManager {
  130695. private _renderPipelines;
  130696. /**
  130697. * Initializes a PostProcessRenderPipelineManager
  130698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130699. */
  130700. constructor();
  130701. /**
  130702. * Gets the list of supported render pipelines
  130703. */
  130704. readonly supportedPipelines: PostProcessRenderPipeline[];
  130705. /**
  130706. * Adds a pipeline to the manager
  130707. * @param renderPipeline The pipeline to add
  130708. */
  130709. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  130710. /**
  130711. * Attaches a camera to the pipeline
  130712. * @param renderPipelineName The name of the pipeline to attach to
  130713. * @param cameras the camera to attach
  130714. * @param unique if the camera can be attached multiple times to the pipeline
  130715. */
  130716. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  130717. /**
  130718. * Detaches a camera from the pipeline
  130719. * @param renderPipelineName The name of the pipeline to detach from
  130720. * @param cameras the camera to detach
  130721. */
  130722. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  130723. /**
  130724. * Enables an effect by name on a pipeline
  130725. * @param renderPipelineName the name of the pipeline to enable the effect in
  130726. * @param renderEffectName the name of the effect to enable
  130727. * @param cameras the cameras that the effect should be enabled on
  130728. */
  130729. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130730. /**
  130731. * Disables an effect by name on a pipeline
  130732. * @param renderPipelineName the name of the pipeline to disable the effect in
  130733. * @param renderEffectName the name of the effect to disable
  130734. * @param cameras the cameras that the effect should be disabled on
  130735. */
  130736. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130737. /**
  130738. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  130739. */
  130740. update(): void;
  130741. /** @hidden */
  130742. _rebuild(): void;
  130743. /**
  130744. * Disposes of the manager and pipelines
  130745. */
  130746. dispose(): void;
  130747. }
  130748. }
  130749. declare module BABYLON {
  130750. interface Scene {
  130751. /** @hidden (Backing field) */
  130752. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130753. /**
  130754. * Gets the postprocess render pipeline manager
  130755. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130756. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130757. */
  130758. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130759. }
  130760. /**
  130761. * Defines the Render Pipeline scene component responsible to rendering pipelines
  130762. */
  130763. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  130764. /**
  130765. * The component name helpfull to identify the component in the list of scene components.
  130766. */
  130767. readonly name: string;
  130768. /**
  130769. * The scene the component belongs to.
  130770. */
  130771. scene: Scene;
  130772. /**
  130773. * Creates a new instance of the component for the given scene
  130774. * @param scene Defines the scene to register the component in
  130775. */
  130776. constructor(scene: Scene);
  130777. /**
  130778. * Registers the component in a given scene
  130779. */
  130780. register(): void;
  130781. /**
  130782. * Rebuilds the elements related to this component in case of
  130783. * context lost for instance.
  130784. */
  130785. rebuild(): void;
  130786. /**
  130787. * Disposes the component and the associated ressources
  130788. */
  130789. dispose(): void;
  130790. private _gatherRenderTargets;
  130791. }
  130792. }
  130793. declare module BABYLON {
  130794. /**
  130795. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  130796. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130797. */
  130798. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130799. private _scene;
  130800. private _camerasToBeAttached;
  130801. /**
  130802. * ID of the sharpen post process,
  130803. */
  130804. private readonly SharpenPostProcessId;
  130805. /**
  130806. * @ignore
  130807. * ID of the image processing post process;
  130808. */
  130809. readonly ImageProcessingPostProcessId: string;
  130810. /**
  130811. * @ignore
  130812. * ID of the Fast Approximate Anti-Aliasing post process;
  130813. */
  130814. readonly FxaaPostProcessId: string;
  130815. /**
  130816. * ID of the chromatic aberration post process,
  130817. */
  130818. private readonly ChromaticAberrationPostProcessId;
  130819. /**
  130820. * ID of the grain post process
  130821. */
  130822. private readonly GrainPostProcessId;
  130823. /**
  130824. * Sharpen post process which will apply a sharpen convolution to enhance edges
  130825. */
  130826. sharpen: SharpenPostProcess;
  130827. private _sharpenEffect;
  130828. private bloom;
  130829. /**
  130830. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  130831. */
  130832. depthOfField: DepthOfFieldEffect;
  130833. /**
  130834. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130835. */
  130836. fxaa: FxaaPostProcess;
  130837. /**
  130838. * Image post processing pass used to perform operations such as tone mapping or color grading.
  130839. */
  130840. imageProcessing: ImageProcessingPostProcess;
  130841. /**
  130842. * Chromatic aberration post process which will shift rgb colors in the image
  130843. */
  130844. chromaticAberration: ChromaticAberrationPostProcess;
  130845. private _chromaticAberrationEffect;
  130846. /**
  130847. * Grain post process which add noise to the image
  130848. */
  130849. grain: GrainPostProcess;
  130850. private _grainEffect;
  130851. /**
  130852. * Glow post process which adds a glow to emissive areas of the image
  130853. */
  130854. private _glowLayer;
  130855. /**
  130856. * Animations which can be used to tweak settings over a period of time
  130857. */
  130858. animations: Animation[];
  130859. private _imageProcessingConfigurationObserver;
  130860. private _sharpenEnabled;
  130861. private _bloomEnabled;
  130862. private _depthOfFieldEnabled;
  130863. private _depthOfFieldBlurLevel;
  130864. private _fxaaEnabled;
  130865. private _imageProcessingEnabled;
  130866. private _defaultPipelineTextureType;
  130867. private _bloomScale;
  130868. private _chromaticAberrationEnabled;
  130869. private _grainEnabled;
  130870. private _buildAllowed;
  130871. /**
  130872. * Gets active scene
  130873. */
  130874. readonly scene: Scene;
  130875. /**
  130876. * Enable or disable the sharpen process from the pipeline
  130877. */
  130878. sharpenEnabled: boolean;
  130879. private _resizeObserver;
  130880. private _hardwareScaleLevel;
  130881. private _bloomKernel;
  130882. /**
  130883. * Specifies the size of the bloom blur kernel, relative to the final output size
  130884. */
  130885. bloomKernel: number;
  130886. /**
  130887. * Specifies the weight of the bloom in the final rendering
  130888. */
  130889. private _bloomWeight;
  130890. /**
  130891. * Specifies the luma threshold for the area that will be blurred by the bloom
  130892. */
  130893. private _bloomThreshold;
  130894. private _hdr;
  130895. /**
  130896. * The strength of the bloom.
  130897. */
  130898. bloomWeight: number;
  130899. /**
  130900. * The strength of the bloom.
  130901. */
  130902. bloomThreshold: number;
  130903. /**
  130904. * The scale of the bloom, lower value will provide better performance.
  130905. */
  130906. bloomScale: number;
  130907. /**
  130908. * Enable or disable the bloom from the pipeline
  130909. */
  130910. bloomEnabled: boolean;
  130911. private _rebuildBloom;
  130912. /**
  130913. * If the depth of field is enabled.
  130914. */
  130915. depthOfFieldEnabled: boolean;
  130916. /**
  130917. * Blur level of the depth of field effect. (Higher blur will effect performance)
  130918. */
  130919. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  130920. /**
  130921. * If the anti aliasing is enabled.
  130922. */
  130923. fxaaEnabled: boolean;
  130924. private _samples;
  130925. /**
  130926. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130927. */
  130928. samples: number;
  130929. /**
  130930. * If image processing is enabled.
  130931. */
  130932. imageProcessingEnabled: boolean;
  130933. /**
  130934. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  130935. */
  130936. glowLayerEnabled: boolean;
  130937. /**
  130938. * Gets the glow layer (or null if not defined)
  130939. */
  130940. readonly glowLayer: Nullable<GlowLayer>;
  130941. /**
  130942. * Enable or disable the chromaticAberration process from the pipeline
  130943. */
  130944. chromaticAberrationEnabled: boolean;
  130945. /**
  130946. * Enable or disable the grain process from the pipeline
  130947. */
  130948. grainEnabled: boolean;
  130949. /**
  130950. * @constructor
  130951. * @param name - The rendering pipeline name (default: "")
  130952. * @param hdr - If high dynamic range textures should be used (default: true)
  130953. * @param scene - The scene linked to this pipeline (default: the last created scene)
  130954. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  130955. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  130956. */
  130957. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  130958. /**
  130959. * Get the class name
  130960. * @returns "DefaultRenderingPipeline"
  130961. */
  130962. getClassName(): string;
  130963. /**
  130964. * Force the compilation of the entire pipeline.
  130965. */
  130966. prepare(): void;
  130967. private _hasCleared;
  130968. private _prevPostProcess;
  130969. private _prevPrevPostProcess;
  130970. private _setAutoClearAndTextureSharing;
  130971. private _depthOfFieldSceneObserver;
  130972. private _buildPipeline;
  130973. private _disposePostProcesses;
  130974. /**
  130975. * Adds a camera to the pipeline
  130976. * @param camera the camera to be added
  130977. */
  130978. addCamera(camera: Camera): void;
  130979. /**
  130980. * Removes a camera from the pipeline
  130981. * @param camera the camera to remove
  130982. */
  130983. removeCamera(camera: Camera): void;
  130984. /**
  130985. * Dispose of the pipeline and stop all post processes
  130986. */
  130987. dispose(): void;
  130988. /**
  130989. * Serialize the rendering pipeline (Used when exporting)
  130990. * @returns the serialized object
  130991. */
  130992. serialize(): any;
  130993. /**
  130994. * Parse the serialized pipeline
  130995. * @param source Source pipeline.
  130996. * @param scene The scene to load the pipeline to.
  130997. * @param rootUrl The URL of the serialized pipeline.
  130998. * @returns An instantiated pipeline from the serialized object.
  130999. */
  131000. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  131001. }
  131002. }
  131003. declare module BABYLON {
  131004. /** @hidden */
  131005. export var lensHighlightsPixelShader: {
  131006. name: string;
  131007. shader: string;
  131008. };
  131009. }
  131010. declare module BABYLON {
  131011. /** @hidden */
  131012. export var depthOfFieldPixelShader: {
  131013. name: string;
  131014. shader: string;
  131015. };
  131016. }
  131017. declare module BABYLON {
  131018. /**
  131019. * BABYLON.JS Chromatic Aberration GLSL Shader
  131020. * Author: Olivier Guyot
  131021. * Separates very slightly R, G and B colors on the edges of the screen
  131022. * Inspired by Francois Tarlier & Martins Upitis
  131023. */
  131024. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  131025. /**
  131026. * @ignore
  131027. * The chromatic aberration PostProcess id in the pipeline
  131028. */
  131029. LensChromaticAberrationEffect: string;
  131030. /**
  131031. * @ignore
  131032. * The highlights enhancing PostProcess id in the pipeline
  131033. */
  131034. HighlightsEnhancingEffect: string;
  131035. /**
  131036. * @ignore
  131037. * The depth-of-field PostProcess id in the pipeline
  131038. */
  131039. LensDepthOfFieldEffect: string;
  131040. private _scene;
  131041. private _depthTexture;
  131042. private _grainTexture;
  131043. private _chromaticAberrationPostProcess;
  131044. private _highlightsPostProcess;
  131045. private _depthOfFieldPostProcess;
  131046. private _edgeBlur;
  131047. private _grainAmount;
  131048. private _chromaticAberration;
  131049. private _distortion;
  131050. private _highlightsGain;
  131051. private _highlightsThreshold;
  131052. private _dofDistance;
  131053. private _dofAperture;
  131054. private _dofDarken;
  131055. private _dofPentagon;
  131056. private _blurNoise;
  131057. /**
  131058. * @constructor
  131059. *
  131060. * Effect parameters are as follow:
  131061. * {
  131062. * chromatic_aberration: number; // from 0 to x (1 for realism)
  131063. * edge_blur: number; // from 0 to x (1 for realism)
  131064. * distortion: number; // from 0 to x (1 for realism)
  131065. * grain_amount: number; // from 0 to 1
  131066. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  131067. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  131068. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  131069. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  131070. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  131071. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  131072. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  131073. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  131074. * }
  131075. * Note: if an effect parameter is unset, effect is disabled
  131076. *
  131077. * @param name The rendering pipeline name
  131078. * @param parameters - An object containing all parameters (see above)
  131079. * @param scene The scene linked to this pipeline
  131080. * @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)
  131081. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131082. */
  131083. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  131084. /**
  131085. * Get the class name
  131086. * @returns "LensRenderingPipeline"
  131087. */
  131088. getClassName(): string;
  131089. /**
  131090. * Gets associated scene
  131091. */
  131092. readonly scene: Scene;
  131093. /**
  131094. * Gets or sets the edge blur
  131095. */
  131096. edgeBlur: number;
  131097. /**
  131098. * Gets or sets the grain amount
  131099. */
  131100. grainAmount: number;
  131101. /**
  131102. * Gets or sets the chromatic aberration amount
  131103. */
  131104. chromaticAberration: number;
  131105. /**
  131106. * Gets or sets the depth of field aperture
  131107. */
  131108. dofAperture: number;
  131109. /**
  131110. * Gets or sets the edge distortion
  131111. */
  131112. edgeDistortion: number;
  131113. /**
  131114. * Gets or sets the depth of field distortion
  131115. */
  131116. dofDistortion: number;
  131117. /**
  131118. * Gets or sets the darken out of focus amount
  131119. */
  131120. darkenOutOfFocus: number;
  131121. /**
  131122. * Gets or sets a boolean indicating if blur noise is enabled
  131123. */
  131124. blurNoise: boolean;
  131125. /**
  131126. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  131127. */
  131128. pentagonBokeh: boolean;
  131129. /**
  131130. * Gets or sets the highlight grain amount
  131131. */
  131132. highlightsGain: number;
  131133. /**
  131134. * Gets or sets the highlight threshold
  131135. */
  131136. highlightsThreshold: number;
  131137. /**
  131138. * Sets the amount of blur at the edges
  131139. * @param amount blur amount
  131140. */
  131141. setEdgeBlur(amount: number): void;
  131142. /**
  131143. * Sets edge blur to 0
  131144. */
  131145. disableEdgeBlur(): void;
  131146. /**
  131147. * Sets the amout of grain
  131148. * @param amount Amount of grain
  131149. */
  131150. setGrainAmount(amount: number): void;
  131151. /**
  131152. * Set grain amount to 0
  131153. */
  131154. disableGrain(): void;
  131155. /**
  131156. * Sets the chromatic aberration amount
  131157. * @param amount amount of chromatic aberration
  131158. */
  131159. setChromaticAberration(amount: number): void;
  131160. /**
  131161. * Sets chromatic aberration amount to 0
  131162. */
  131163. disableChromaticAberration(): void;
  131164. /**
  131165. * Sets the EdgeDistortion amount
  131166. * @param amount amount of EdgeDistortion
  131167. */
  131168. setEdgeDistortion(amount: number): void;
  131169. /**
  131170. * Sets edge distortion to 0
  131171. */
  131172. disableEdgeDistortion(): void;
  131173. /**
  131174. * Sets the FocusDistance amount
  131175. * @param amount amount of FocusDistance
  131176. */
  131177. setFocusDistance(amount: number): void;
  131178. /**
  131179. * Disables depth of field
  131180. */
  131181. disableDepthOfField(): void;
  131182. /**
  131183. * Sets the Aperture amount
  131184. * @param amount amount of Aperture
  131185. */
  131186. setAperture(amount: number): void;
  131187. /**
  131188. * Sets the DarkenOutOfFocus amount
  131189. * @param amount amount of DarkenOutOfFocus
  131190. */
  131191. setDarkenOutOfFocus(amount: number): void;
  131192. private _pentagonBokehIsEnabled;
  131193. /**
  131194. * Creates a pentagon bokeh effect
  131195. */
  131196. enablePentagonBokeh(): void;
  131197. /**
  131198. * Disables the pentagon bokeh effect
  131199. */
  131200. disablePentagonBokeh(): void;
  131201. /**
  131202. * Enables noise blur
  131203. */
  131204. enableNoiseBlur(): void;
  131205. /**
  131206. * Disables noise blur
  131207. */
  131208. disableNoiseBlur(): void;
  131209. /**
  131210. * Sets the HighlightsGain amount
  131211. * @param amount amount of HighlightsGain
  131212. */
  131213. setHighlightsGain(amount: number): void;
  131214. /**
  131215. * Sets the HighlightsThreshold amount
  131216. * @param amount amount of HighlightsThreshold
  131217. */
  131218. setHighlightsThreshold(amount: number): void;
  131219. /**
  131220. * Disables highlights
  131221. */
  131222. disableHighlights(): void;
  131223. /**
  131224. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  131225. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  131226. */
  131227. dispose(disableDepthRender?: boolean): void;
  131228. private _createChromaticAberrationPostProcess;
  131229. private _createHighlightsPostProcess;
  131230. private _createDepthOfFieldPostProcess;
  131231. private _createGrainTexture;
  131232. }
  131233. }
  131234. declare module BABYLON {
  131235. /** @hidden */
  131236. export var ssao2PixelShader: {
  131237. name: string;
  131238. shader: string;
  131239. };
  131240. }
  131241. declare module BABYLON {
  131242. /** @hidden */
  131243. export var ssaoCombinePixelShader: {
  131244. name: string;
  131245. shader: string;
  131246. };
  131247. }
  131248. declare module BABYLON {
  131249. /**
  131250. * Render pipeline to produce ssao effect
  131251. */
  131252. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  131253. /**
  131254. * @ignore
  131255. * The PassPostProcess id in the pipeline that contains the original scene color
  131256. */
  131257. SSAOOriginalSceneColorEffect: string;
  131258. /**
  131259. * @ignore
  131260. * The SSAO PostProcess id in the pipeline
  131261. */
  131262. SSAORenderEffect: string;
  131263. /**
  131264. * @ignore
  131265. * The horizontal blur PostProcess id in the pipeline
  131266. */
  131267. SSAOBlurHRenderEffect: string;
  131268. /**
  131269. * @ignore
  131270. * The vertical blur PostProcess id in the pipeline
  131271. */
  131272. SSAOBlurVRenderEffect: string;
  131273. /**
  131274. * @ignore
  131275. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131276. */
  131277. SSAOCombineRenderEffect: string;
  131278. /**
  131279. * The output strength of the SSAO post-process. Default value is 1.0.
  131280. */
  131281. totalStrength: number;
  131282. /**
  131283. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  131284. */
  131285. maxZ: number;
  131286. /**
  131287. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  131288. */
  131289. minZAspect: number;
  131290. private _samples;
  131291. /**
  131292. * Number of samples used for the SSAO calculations. Default value is 8
  131293. */
  131294. samples: number;
  131295. private _textureSamples;
  131296. /**
  131297. * Number of samples to use for antialiasing
  131298. */
  131299. textureSamples: number;
  131300. /**
  131301. * Ratio object used for SSAO ratio and blur ratio
  131302. */
  131303. private _ratio;
  131304. /**
  131305. * Dynamically generated sphere sampler.
  131306. */
  131307. private _sampleSphere;
  131308. /**
  131309. * Blur filter offsets
  131310. */
  131311. private _samplerOffsets;
  131312. private _expensiveBlur;
  131313. /**
  131314. * If bilateral blur should be used
  131315. */
  131316. expensiveBlur: boolean;
  131317. /**
  131318. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  131319. */
  131320. radius: number;
  131321. /**
  131322. * The base color of the SSAO post-process
  131323. * The final result is "base + ssao" between [0, 1]
  131324. */
  131325. base: number;
  131326. /**
  131327. * Support test.
  131328. */
  131329. static readonly IsSupported: boolean;
  131330. private _scene;
  131331. private _depthTexture;
  131332. private _normalTexture;
  131333. private _randomTexture;
  131334. private _originalColorPostProcess;
  131335. private _ssaoPostProcess;
  131336. private _blurHPostProcess;
  131337. private _blurVPostProcess;
  131338. private _ssaoCombinePostProcess;
  131339. /**
  131340. * Gets active scene
  131341. */
  131342. readonly scene: Scene;
  131343. /**
  131344. * @constructor
  131345. * @param name The rendering pipeline name
  131346. * @param scene The scene linked to this pipeline
  131347. * @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 }
  131348. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131349. */
  131350. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131351. /**
  131352. * Get the class name
  131353. * @returns "SSAO2RenderingPipeline"
  131354. */
  131355. getClassName(): string;
  131356. /**
  131357. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131358. */
  131359. dispose(disableGeometryBufferRenderer?: boolean): void;
  131360. private _createBlurPostProcess;
  131361. /** @hidden */
  131362. _rebuild(): void;
  131363. private _bits;
  131364. private _radicalInverse_VdC;
  131365. private _hammersley;
  131366. private _hemisphereSample_uniform;
  131367. private _generateHemisphere;
  131368. private _createSSAOPostProcess;
  131369. private _createSSAOCombinePostProcess;
  131370. private _createRandomTexture;
  131371. /**
  131372. * Serialize the rendering pipeline (Used when exporting)
  131373. * @returns the serialized object
  131374. */
  131375. serialize(): any;
  131376. /**
  131377. * Parse the serialized pipeline
  131378. * @param source Source pipeline.
  131379. * @param scene The scene to load the pipeline to.
  131380. * @param rootUrl The URL of the serialized pipeline.
  131381. * @returns An instantiated pipeline from the serialized object.
  131382. */
  131383. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  131384. }
  131385. }
  131386. declare module BABYLON {
  131387. /** @hidden */
  131388. export var ssaoPixelShader: {
  131389. name: string;
  131390. shader: string;
  131391. };
  131392. }
  131393. declare module BABYLON {
  131394. /**
  131395. * Render pipeline to produce ssao effect
  131396. */
  131397. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  131398. /**
  131399. * @ignore
  131400. * The PassPostProcess id in the pipeline that contains the original scene color
  131401. */
  131402. SSAOOriginalSceneColorEffect: string;
  131403. /**
  131404. * @ignore
  131405. * The SSAO PostProcess id in the pipeline
  131406. */
  131407. SSAORenderEffect: string;
  131408. /**
  131409. * @ignore
  131410. * The horizontal blur PostProcess id in the pipeline
  131411. */
  131412. SSAOBlurHRenderEffect: string;
  131413. /**
  131414. * @ignore
  131415. * The vertical blur PostProcess id in the pipeline
  131416. */
  131417. SSAOBlurVRenderEffect: string;
  131418. /**
  131419. * @ignore
  131420. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131421. */
  131422. SSAOCombineRenderEffect: string;
  131423. /**
  131424. * The output strength of the SSAO post-process. Default value is 1.0.
  131425. */
  131426. totalStrength: number;
  131427. /**
  131428. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  131429. */
  131430. radius: number;
  131431. /**
  131432. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  131433. * Must not be equal to fallOff and superior to fallOff.
  131434. * Default value is 0.0075
  131435. */
  131436. area: number;
  131437. /**
  131438. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  131439. * Must not be equal to area and inferior to area.
  131440. * Default value is 0.000001
  131441. */
  131442. fallOff: number;
  131443. /**
  131444. * The base color of the SSAO post-process
  131445. * The final result is "base + ssao" between [0, 1]
  131446. */
  131447. base: number;
  131448. private _scene;
  131449. private _depthTexture;
  131450. private _randomTexture;
  131451. private _originalColorPostProcess;
  131452. private _ssaoPostProcess;
  131453. private _blurHPostProcess;
  131454. private _blurVPostProcess;
  131455. private _ssaoCombinePostProcess;
  131456. private _firstUpdate;
  131457. /**
  131458. * Gets active scene
  131459. */
  131460. readonly scene: Scene;
  131461. /**
  131462. * @constructor
  131463. * @param name - The rendering pipeline name
  131464. * @param scene - The scene linked to this pipeline
  131465. * @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 }
  131466. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  131467. */
  131468. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131469. /**
  131470. * Get the class name
  131471. * @returns "SSAORenderingPipeline"
  131472. */
  131473. getClassName(): string;
  131474. /**
  131475. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131476. */
  131477. dispose(disableDepthRender?: boolean): void;
  131478. private _createBlurPostProcess;
  131479. /** @hidden */
  131480. _rebuild(): void;
  131481. private _createSSAOPostProcess;
  131482. private _createSSAOCombinePostProcess;
  131483. private _createRandomTexture;
  131484. }
  131485. }
  131486. declare module BABYLON {
  131487. /** @hidden */
  131488. export var standardPixelShader: {
  131489. name: string;
  131490. shader: string;
  131491. };
  131492. }
  131493. declare module BABYLON {
  131494. /**
  131495. * Standard rendering pipeline
  131496. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131497. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  131498. */
  131499. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  131500. /**
  131501. * Public members
  131502. */
  131503. /**
  131504. * Post-process which contains the original scene color before the pipeline applies all the effects
  131505. */
  131506. originalPostProcess: Nullable<PostProcess>;
  131507. /**
  131508. * Post-process used to down scale an image x4
  131509. */
  131510. downSampleX4PostProcess: Nullable<PostProcess>;
  131511. /**
  131512. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  131513. */
  131514. brightPassPostProcess: Nullable<PostProcess>;
  131515. /**
  131516. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  131517. */
  131518. blurHPostProcesses: PostProcess[];
  131519. /**
  131520. * Post-process array storing all the vertical blur post-processes used by the pipeline
  131521. */
  131522. blurVPostProcesses: PostProcess[];
  131523. /**
  131524. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  131525. */
  131526. textureAdderPostProcess: Nullable<PostProcess>;
  131527. /**
  131528. * Post-process used to create volumetric lighting effect
  131529. */
  131530. volumetricLightPostProcess: Nullable<PostProcess>;
  131531. /**
  131532. * Post-process used to smooth the previous volumetric light post-process on the X axis
  131533. */
  131534. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  131535. /**
  131536. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  131537. */
  131538. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  131539. /**
  131540. * Post-process used to merge the volumetric light effect and the real scene color
  131541. */
  131542. volumetricLightMergePostProces: Nullable<PostProcess>;
  131543. /**
  131544. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  131545. */
  131546. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  131547. /**
  131548. * Base post-process used to calculate the average luminance of the final image for HDR
  131549. */
  131550. luminancePostProcess: Nullable<PostProcess>;
  131551. /**
  131552. * Post-processes used to create down sample post-processes in order to get
  131553. * the average luminance of the final image for HDR
  131554. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  131555. */
  131556. luminanceDownSamplePostProcesses: PostProcess[];
  131557. /**
  131558. * Post-process used to create a HDR effect (light adaptation)
  131559. */
  131560. hdrPostProcess: Nullable<PostProcess>;
  131561. /**
  131562. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  131563. */
  131564. textureAdderFinalPostProcess: Nullable<PostProcess>;
  131565. /**
  131566. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  131567. */
  131568. lensFlareFinalPostProcess: Nullable<PostProcess>;
  131569. /**
  131570. * Post-process used to merge the final HDR post-process and the real scene color
  131571. */
  131572. hdrFinalPostProcess: Nullable<PostProcess>;
  131573. /**
  131574. * Post-process used to create a lens flare effect
  131575. */
  131576. lensFlarePostProcess: Nullable<PostProcess>;
  131577. /**
  131578. * Post-process that merges the result of the lens flare post-process and the real scene color
  131579. */
  131580. lensFlareComposePostProcess: Nullable<PostProcess>;
  131581. /**
  131582. * Post-process used to create a motion blur effect
  131583. */
  131584. motionBlurPostProcess: Nullable<PostProcess>;
  131585. /**
  131586. * Post-process used to create a depth of field effect
  131587. */
  131588. depthOfFieldPostProcess: Nullable<PostProcess>;
  131589. /**
  131590. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131591. */
  131592. fxaaPostProcess: Nullable<FxaaPostProcess>;
  131593. /**
  131594. * Represents the brightness threshold in order to configure the illuminated surfaces
  131595. */
  131596. brightThreshold: number;
  131597. /**
  131598. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  131599. */
  131600. blurWidth: number;
  131601. /**
  131602. * Sets if the blur for highlighted surfaces must be only horizontal
  131603. */
  131604. horizontalBlur: boolean;
  131605. /**
  131606. * Gets the overall exposure used by the pipeline
  131607. */
  131608. /**
  131609. * Sets the overall exposure used by the pipeline
  131610. */
  131611. exposure: number;
  131612. /**
  131613. * Texture used typically to simulate "dirty" on camera lens
  131614. */
  131615. lensTexture: Nullable<Texture>;
  131616. /**
  131617. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  131618. */
  131619. volumetricLightCoefficient: number;
  131620. /**
  131621. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  131622. */
  131623. volumetricLightPower: number;
  131624. /**
  131625. * Used the set the blur intensity to smooth the volumetric lights
  131626. */
  131627. volumetricLightBlurScale: number;
  131628. /**
  131629. * Light (spot or directional) used to generate the volumetric lights rays
  131630. * The source light must have a shadow generate so the pipeline can get its
  131631. * depth map
  131632. */
  131633. sourceLight: Nullable<SpotLight | DirectionalLight>;
  131634. /**
  131635. * For eye adaptation, represents the minimum luminance the eye can see
  131636. */
  131637. hdrMinimumLuminance: number;
  131638. /**
  131639. * For eye adaptation, represents the decrease luminance speed
  131640. */
  131641. hdrDecreaseRate: number;
  131642. /**
  131643. * For eye adaptation, represents the increase luminance speed
  131644. */
  131645. hdrIncreaseRate: number;
  131646. /**
  131647. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131648. */
  131649. /**
  131650. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131651. */
  131652. hdrAutoExposure: boolean;
  131653. /**
  131654. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  131655. */
  131656. lensColorTexture: Nullable<Texture>;
  131657. /**
  131658. * The overall strengh for the lens flare effect
  131659. */
  131660. lensFlareStrength: number;
  131661. /**
  131662. * Dispersion coefficient for lens flare ghosts
  131663. */
  131664. lensFlareGhostDispersal: number;
  131665. /**
  131666. * Main lens flare halo width
  131667. */
  131668. lensFlareHaloWidth: number;
  131669. /**
  131670. * Based on the lens distortion effect, defines how much the lens flare result
  131671. * is distorted
  131672. */
  131673. lensFlareDistortionStrength: number;
  131674. /**
  131675. * Configures the blur intensity used for for lens flare (halo)
  131676. */
  131677. lensFlareBlurWidth: number;
  131678. /**
  131679. * Lens star texture must be used to simulate rays on the flares and is available
  131680. * in the documentation
  131681. */
  131682. lensStarTexture: Nullable<Texture>;
  131683. /**
  131684. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  131685. * flare effect by taking account of the dirt texture
  131686. */
  131687. lensFlareDirtTexture: Nullable<Texture>;
  131688. /**
  131689. * Represents the focal length for the depth of field effect
  131690. */
  131691. depthOfFieldDistance: number;
  131692. /**
  131693. * Represents the blur intensity for the blurred part of the depth of field effect
  131694. */
  131695. depthOfFieldBlurWidth: number;
  131696. /**
  131697. * Gets how much the image is blurred by the movement while using the motion blur post-process
  131698. */
  131699. /**
  131700. * Sets how much the image is blurred by the movement while using the motion blur post-process
  131701. */
  131702. motionStrength: number;
  131703. /**
  131704. * Gets wether or not the motion blur post-process is object based or screen based.
  131705. */
  131706. /**
  131707. * Sets wether or not the motion blur post-process should be object based or screen based
  131708. */
  131709. objectBasedMotionBlur: boolean;
  131710. /**
  131711. * List of animations for the pipeline (IAnimatable implementation)
  131712. */
  131713. animations: Animation[];
  131714. /**
  131715. * Private members
  131716. */
  131717. private _scene;
  131718. private _currentDepthOfFieldSource;
  131719. private _basePostProcess;
  131720. private _fixedExposure;
  131721. private _currentExposure;
  131722. private _hdrAutoExposure;
  131723. private _hdrCurrentLuminance;
  131724. private _motionStrength;
  131725. private _isObjectBasedMotionBlur;
  131726. private _floatTextureType;
  131727. private _camerasToBeAttached;
  131728. private _ratio;
  131729. private _bloomEnabled;
  131730. private _depthOfFieldEnabled;
  131731. private _vlsEnabled;
  131732. private _lensFlareEnabled;
  131733. private _hdrEnabled;
  131734. private _motionBlurEnabled;
  131735. private _fxaaEnabled;
  131736. private _motionBlurSamples;
  131737. private _volumetricLightStepsCount;
  131738. private _samples;
  131739. /**
  131740. * @ignore
  131741. * Specifies if the bloom pipeline is enabled
  131742. */
  131743. BloomEnabled: boolean;
  131744. /**
  131745. * @ignore
  131746. * Specifies if the depth of field pipeline is enabed
  131747. */
  131748. DepthOfFieldEnabled: boolean;
  131749. /**
  131750. * @ignore
  131751. * Specifies if the lens flare pipeline is enabed
  131752. */
  131753. LensFlareEnabled: boolean;
  131754. /**
  131755. * @ignore
  131756. * Specifies if the HDR pipeline is enabled
  131757. */
  131758. HDREnabled: boolean;
  131759. /**
  131760. * @ignore
  131761. * Specifies if the volumetric lights scattering effect is enabled
  131762. */
  131763. VLSEnabled: boolean;
  131764. /**
  131765. * @ignore
  131766. * Specifies if the motion blur effect is enabled
  131767. */
  131768. MotionBlurEnabled: boolean;
  131769. /**
  131770. * Specifies if anti-aliasing is enabled
  131771. */
  131772. fxaaEnabled: boolean;
  131773. /**
  131774. * Specifies the number of steps used to calculate the volumetric lights
  131775. * Typically in interval [50, 200]
  131776. */
  131777. volumetricLightStepsCount: number;
  131778. /**
  131779. * Specifies the number of samples used for the motion blur effect
  131780. * Typically in interval [16, 64]
  131781. */
  131782. motionBlurSamples: number;
  131783. /**
  131784. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131785. */
  131786. samples: number;
  131787. /**
  131788. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131789. * @constructor
  131790. * @param name The rendering pipeline name
  131791. * @param scene The scene linked to this pipeline
  131792. * @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)
  131793. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  131794. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131795. */
  131796. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  131797. private _buildPipeline;
  131798. private _createDownSampleX4PostProcess;
  131799. private _createBrightPassPostProcess;
  131800. private _createBlurPostProcesses;
  131801. private _createTextureAdderPostProcess;
  131802. private _createVolumetricLightPostProcess;
  131803. private _createLuminancePostProcesses;
  131804. private _createHdrPostProcess;
  131805. private _createLensFlarePostProcess;
  131806. private _createDepthOfFieldPostProcess;
  131807. private _createMotionBlurPostProcess;
  131808. private _getDepthTexture;
  131809. private _disposePostProcesses;
  131810. /**
  131811. * Dispose of the pipeline and stop all post processes
  131812. */
  131813. dispose(): void;
  131814. /**
  131815. * Serialize the rendering pipeline (Used when exporting)
  131816. * @returns the serialized object
  131817. */
  131818. serialize(): any;
  131819. /**
  131820. * Parse the serialized pipeline
  131821. * @param source Source pipeline.
  131822. * @param scene The scene to load the pipeline to.
  131823. * @param rootUrl The URL of the serialized pipeline.
  131824. * @returns An instantiated pipeline from the serialized object.
  131825. */
  131826. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  131827. /**
  131828. * Luminance steps
  131829. */
  131830. static LuminanceSteps: number;
  131831. }
  131832. }
  131833. declare module BABYLON {
  131834. /** @hidden */
  131835. export var tonemapPixelShader: {
  131836. name: string;
  131837. shader: string;
  131838. };
  131839. }
  131840. declare module BABYLON {
  131841. /** Defines operator used for tonemapping */
  131842. export enum TonemappingOperator {
  131843. /** Hable */
  131844. Hable = 0,
  131845. /** Reinhard */
  131846. Reinhard = 1,
  131847. /** HejiDawson */
  131848. HejiDawson = 2,
  131849. /** Photographic */
  131850. Photographic = 3
  131851. }
  131852. /**
  131853. * Defines a post process to apply tone mapping
  131854. */
  131855. export class TonemapPostProcess extends PostProcess {
  131856. private _operator;
  131857. /** Defines the required exposure adjustement */
  131858. exposureAdjustment: number;
  131859. /**
  131860. * Creates a new TonemapPostProcess
  131861. * @param name defines the name of the postprocess
  131862. * @param _operator defines the operator to use
  131863. * @param exposureAdjustment defines the required exposure adjustement
  131864. * @param camera defines the camera to use (can be null)
  131865. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  131866. * @param engine defines the hosting engine (can be ignore if camera is set)
  131867. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131868. */
  131869. constructor(name: string, _operator: TonemappingOperator,
  131870. /** Defines the required exposure adjustement */
  131871. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  131872. }
  131873. }
  131874. declare module BABYLON {
  131875. /** @hidden */
  131876. export var depthVertexShader: {
  131877. name: string;
  131878. shader: string;
  131879. };
  131880. }
  131881. declare module BABYLON {
  131882. /** @hidden */
  131883. export var volumetricLightScatteringPixelShader: {
  131884. name: string;
  131885. shader: string;
  131886. };
  131887. }
  131888. declare module BABYLON {
  131889. /** @hidden */
  131890. export var volumetricLightScatteringPassVertexShader: {
  131891. name: string;
  131892. shader: string;
  131893. };
  131894. }
  131895. declare module BABYLON {
  131896. /** @hidden */
  131897. export var volumetricLightScatteringPassPixelShader: {
  131898. name: string;
  131899. shader: string;
  131900. };
  131901. }
  131902. declare module BABYLON {
  131903. /**
  131904. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  131905. */
  131906. export class VolumetricLightScatteringPostProcess extends PostProcess {
  131907. private _volumetricLightScatteringPass;
  131908. private _volumetricLightScatteringRTT;
  131909. private _viewPort;
  131910. private _screenCoordinates;
  131911. private _cachedDefines;
  131912. /**
  131913. * If not undefined, the mesh position is computed from the attached node position
  131914. */
  131915. attachedNode: {
  131916. position: Vector3;
  131917. };
  131918. /**
  131919. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  131920. */
  131921. customMeshPosition: Vector3;
  131922. /**
  131923. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  131924. */
  131925. useCustomMeshPosition: boolean;
  131926. /**
  131927. * If the post-process should inverse the light scattering direction
  131928. */
  131929. invert: boolean;
  131930. /**
  131931. * The internal mesh used by the post-process
  131932. */
  131933. mesh: Mesh;
  131934. /**
  131935. * @hidden
  131936. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  131937. */
  131938. useDiffuseColor: boolean;
  131939. /**
  131940. * Array containing the excluded meshes not rendered in the internal pass
  131941. */
  131942. excludedMeshes: AbstractMesh[];
  131943. /**
  131944. * Controls the overall intensity of the post-process
  131945. */
  131946. exposure: number;
  131947. /**
  131948. * Dissipates each sample's contribution in range [0, 1]
  131949. */
  131950. decay: number;
  131951. /**
  131952. * Controls the overall intensity of each sample
  131953. */
  131954. weight: number;
  131955. /**
  131956. * Controls the density of each sample
  131957. */
  131958. density: number;
  131959. /**
  131960. * @constructor
  131961. * @param name The post-process name
  131962. * @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)
  131963. * @param camera The camera that the post-process will be attached to
  131964. * @param mesh The mesh used to create the light scattering
  131965. * @param samples The post-process quality, default 100
  131966. * @param samplingModeThe post-process filtering mode
  131967. * @param engine The babylon engine
  131968. * @param reusable If the post-process is reusable
  131969. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  131970. */
  131971. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  131972. /**
  131973. * Returns the string "VolumetricLightScatteringPostProcess"
  131974. * @returns "VolumetricLightScatteringPostProcess"
  131975. */
  131976. getClassName(): string;
  131977. private _isReady;
  131978. /**
  131979. * Sets the new light position for light scattering effect
  131980. * @param position The new custom light position
  131981. */
  131982. setCustomMeshPosition(position: Vector3): void;
  131983. /**
  131984. * Returns the light position for light scattering effect
  131985. * @return Vector3 The custom light position
  131986. */
  131987. getCustomMeshPosition(): Vector3;
  131988. /**
  131989. * Disposes the internal assets and detaches the post-process from the camera
  131990. */
  131991. dispose(camera: Camera): void;
  131992. /**
  131993. * Returns the render target texture used by the post-process
  131994. * @return the render target texture used by the post-process
  131995. */
  131996. getPass(): RenderTargetTexture;
  131997. private _meshExcluded;
  131998. private _createPass;
  131999. private _updateMeshScreenCoordinates;
  132000. /**
  132001. * Creates a default mesh for the Volumeric Light Scattering post-process
  132002. * @param name The mesh name
  132003. * @param scene The scene where to create the mesh
  132004. * @return the default mesh
  132005. */
  132006. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  132007. }
  132008. }
  132009. declare module BABYLON {
  132010. interface Scene {
  132011. /** @hidden (Backing field) */
  132012. _boundingBoxRenderer: BoundingBoxRenderer;
  132013. /** @hidden (Backing field) */
  132014. _forceShowBoundingBoxes: boolean;
  132015. /**
  132016. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  132017. */
  132018. forceShowBoundingBoxes: boolean;
  132019. /**
  132020. * Gets the bounding box renderer associated with the scene
  132021. * @returns a BoundingBoxRenderer
  132022. */
  132023. getBoundingBoxRenderer(): BoundingBoxRenderer;
  132024. }
  132025. interface AbstractMesh {
  132026. /** @hidden (Backing field) */
  132027. _showBoundingBox: boolean;
  132028. /**
  132029. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  132030. */
  132031. showBoundingBox: boolean;
  132032. }
  132033. /**
  132034. * Component responsible of rendering the bounding box of the meshes in a scene.
  132035. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  132036. */
  132037. export class BoundingBoxRenderer implements ISceneComponent {
  132038. /**
  132039. * The component name helpfull to identify the component in the list of scene components.
  132040. */
  132041. readonly name: string;
  132042. /**
  132043. * The scene the component belongs to.
  132044. */
  132045. scene: Scene;
  132046. /**
  132047. * Color of the bounding box lines placed in front of an object
  132048. */
  132049. frontColor: Color3;
  132050. /**
  132051. * Color of the bounding box lines placed behind an object
  132052. */
  132053. backColor: Color3;
  132054. /**
  132055. * Defines if the renderer should show the back lines or not
  132056. */
  132057. showBackLines: boolean;
  132058. /**
  132059. * @hidden
  132060. */
  132061. renderList: SmartArray<BoundingBox>;
  132062. private _colorShader;
  132063. private _vertexBuffers;
  132064. private _indexBuffer;
  132065. private _fillIndexBuffer;
  132066. private _fillIndexData;
  132067. /**
  132068. * Instantiates a new bounding box renderer in a scene.
  132069. * @param scene the scene the renderer renders in
  132070. */
  132071. constructor(scene: Scene);
  132072. /**
  132073. * Registers the component in a given scene
  132074. */
  132075. register(): void;
  132076. private _evaluateSubMesh;
  132077. private _activeMesh;
  132078. private _prepareRessources;
  132079. private _createIndexBuffer;
  132080. /**
  132081. * Rebuilds the elements related to this component in case of
  132082. * context lost for instance.
  132083. */
  132084. rebuild(): void;
  132085. /**
  132086. * @hidden
  132087. */
  132088. reset(): void;
  132089. /**
  132090. * Render the bounding boxes of a specific rendering group
  132091. * @param renderingGroupId defines the rendering group to render
  132092. */
  132093. render(renderingGroupId: number): void;
  132094. /**
  132095. * In case of occlusion queries, we can render the occlusion bounding box through this method
  132096. * @param mesh Define the mesh to render the occlusion bounding box for
  132097. */
  132098. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  132099. /**
  132100. * Dispose and release the resources attached to this renderer.
  132101. */
  132102. dispose(): void;
  132103. }
  132104. }
  132105. declare module BABYLON {
  132106. /** @hidden */
  132107. export var depthPixelShader: {
  132108. name: string;
  132109. shader: string;
  132110. };
  132111. }
  132112. declare module BABYLON {
  132113. /**
  132114. * This represents a depth renderer in Babylon.
  132115. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  132116. */
  132117. export class DepthRenderer {
  132118. private _scene;
  132119. private _depthMap;
  132120. private _effect;
  132121. private readonly _storeNonLinearDepth;
  132122. private readonly _clearColor;
  132123. /** Get if the depth renderer is using packed depth or not */
  132124. readonly isPacked: boolean;
  132125. private _cachedDefines;
  132126. private _camera;
  132127. /**
  132128. * Specifiess that the depth renderer will only be used within
  132129. * the camera it is created for.
  132130. * This can help forcing its rendering during the camera processing.
  132131. */
  132132. useOnlyInActiveCamera: boolean;
  132133. /** @hidden */
  132134. static _SceneComponentInitialization: (scene: Scene) => void;
  132135. /**
  132136. * Instantiates a depth renderer
  132137. * @param scene The scene the renderer belongs to
  132138. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  132139. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  132140. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132141. */
  132142. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  132143. /**
  132144. * Creates the depth rendering effect and checks if the effect is ready.
  132145. * @param subMesh The submesh to be used to render the depth map of
  132146. * @param useInstances If multiple world instances should be used
  132147. * @returns if the depth renderer is ready to render the depth map
  132148. */
  132149. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132150. /**
  132151. * Gets the texture which the depth map will be written to.
  132152. * @returns The depth map texture
  132153. */
  132154. getDepthMap(): RenderTargetTexture;
  132155. /**
  132156. * Disposes of the depth renderer.
  132157. */
  132158. dispose(): void;
  132159. }
  132160. }
  132161. declare module BABYLON {
  132162. interface Scene {
  132163. /** @hidden (Backing field) */
  132164. _depthRenderer: {
  132165. [id: string]: DepthRenderer;
  132166. };
  132167. /**
  132168. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  132169. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  132170. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132171. * @returns the created depth renderer
  132172. */
  132173. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  132174. /**
  132175. * Disables a depth renderer for a given camera
  132176. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  132177. */
  132178. disableDepthRenderer(camera?: Nullable<Camera>): void;
  132179. }
  132180. /**
  132181. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  132182. * in several rendering techniques.
  132183. */
  132184. export class DepthRendererSceneComponent implements ISceneComponent {
  132185. /**
  132186. * The component name helpfull to identify the component in the list of scene components.
  132187. */
  132188. readonly name: string;
  132189. /**
  132190. * The scene the component belongs to.
  132191. */
  132192. scene: Scene;
  132193. /**
  132194. * Creates a new instance of the component for the given scene
  132195. * @param scene Defines the scene to register the component in
  132196. */
  132197. constructor(scene: Scene);
  132198. /**
  132199. * Registers the component in a given scene
  132200. */
  132201. register(): void;
  132202. /**
  132203. * Rebuilds the elements related to this component in case of
  132204. * context lost for instance.
  132205. */
  132206. rebuild(): void;
  132207. /**
  132208. * Disposes the component and the associated ressources
  132209. */
  132210. dispose(): void;
  132211. private _gatherRenderTargets;
  132212. private _gatherActiveCameraRenderTargets;
  132213. }
  132214. }
  132215. declare module BABYLON {
  132216. /** @hidden */
  132217. export var outlinePixelShader: {
  132218. name: string;
  132219. shader: string;
  132220. };
  132221. }
  132222. declare module BABYLON {
  132223. /** @hidden */
  132224. export var outlineVertexShader: {
  132225. name: string;
  132226. shader: string;
  132227. };
  132228. }
  132229. declare module BABYLON {
  132230. interface Scene {
  132231. /** @hidden */
  132232. _outlineRenderer: OutlineRenderer;
  132233. /**
  132234. * Gets the outline renderer associated with the scene
  132235. * @returns a OutlineRenderer
  132236. */
  132237. getOutlineRenderer(): OutlineRenderer;
  132238. }
  132239. interface AbstractMesh {
  132240. /** @hidden (Backing field) */
  132241. _renderOutline: boolean;
  132242. /**
  132243. * Gets or sets a boolean indicating if the outline must be rendered as well
  132244. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  132245. */
  132246. renderOutline: boolean;
  132247. /** @hidden (Backing field) */
  132248. _renderOverlay: boolean;
  132249. /**
  132250. * Gets or sets a boolean indicating if the overlay must be rendered as well
  132251. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  132252. */
  132253. renderOverlay: boolean;
  132254. }
  132255. /**
  132256. * This class is responsible to draw bothe outline/overlay of meshes.
  132257. * It should not be used directly but through the available method on mesh.
  132258. */
  132259. export class OutlineRenderer implements ISceneComponent {
  132260. /**
  132261. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  132262. */
  132263. private static _StencilReference;
  132264. /**
  132265. * The name of the component. Each component must have a unique name.
  132266. */
  132267. name: string;
  132268. /**
  132269. * The scene the component belongs to.
  132270. */
  132271. scene: Scene;
  132272. /**
  132273. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  132274. */
  132275. zOffset: number;
  132276. private _engine;
  132277. private _effect;
  132278. private _cachedDefines;
  132279. private _savedDepthWrite;
  132280. /**
  132281. * Instantiates a new outline renderer. (There could be only one per scene).
  132282. * @param scene Defines the scene it belongs to
  132283. */
  132284. constructor(scene: Scene);
  132285. /**
  132286. * Register the component to one instance of a scene.
  132287. */
  132288. register(): void;
  132289. /**
  132290. * Rebuilds the elements related to this component in case of
  132291. * context lost for instance.
  132292. */
  132293. rebuild(): void;
  132294. /**
  132295. * Disposes the component and the associated ressources.
  132296. */
  132297. dispose(): void;
  132298. /**
  132299. * Renders the outline in the canvas.
  132300. * @param subMesh Defines the sumesh to render
  132301. * @param batch Defines the batch of meshes in case of instances
  132302. * @param useOverlay Defines if the rendering is for the overlay or the outline
  132303. */
  132304. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  132305. /**
  132306. * Returns whether or not the outline renderer is ready for a given submesh.
  132307. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  132308. * @param subMesh Defines the submesh to check readyness for
  132309. * @param useInstances Defines wheter wee are trying to render instances or not
  132310. * @returns true if ready otherwise false
  132311. */
  132312. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132313. private _beforeRenderingMesh;
  132314. private _afterRenderingMesh;
  132315. }
  132316. }
  132317. declare module BABYLON {
  132318. /**
  132319. * Class used to manage multiple sprites of different sizes on the same spritesheet
  132320. * @see http://doc.babylonjs.com/babylon101/sprites
  132321. */
  132322. export class SpritePackedManager extends SpriteManager {
  132323. /** defines the packed manager's name */
  132324. name: string;
  132325. /**
  132326. * Creates a new sprite manager from a packed sprite sheet
  132327. * @param name defines the manager's name
  132328. * @param imgUrl defines the sprite sheet url
  132329. * @param capacity defines the maximum allowed number of sprites
  132330. * @param scene defines the hosting scene
  132331. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  132332. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  132333. * @param samplingMode defines the smapling mode to use with spritesheet
  132334. * @param fromPacked set to true; do not alter
  132335. */
  132336. constructor(
  132337. /** defines the packed manager's name */
  132338. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  132339. }
  132340. }
  132341. declare module BABYLON {
  132342. /**
  132343. * Defines the list of states available for a task inside a AssetsManager
  132344. */
  132345. export enum AssetTaskState {
  132346. /**
  132347. * Initialization
  132348. */
  132349. INIT = 0,
  132350. /**
  132351. * Running
  132352. */
  132353. RUNNING = 1,
  132354. /**
  132355. * Done
  132356. */
  132357. DONE = 2,
  132358. /**
  132359. * Error
  132360. */
  132361. ERROR = 3
  132362. }
  132363. /**
  132364. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  132365. */
  132366. export abstract class AbstractAssetTask {
  132367. /**
  132368. * Task name
  132369. */ name: string;
  132370. /**
  132371. * Callback called when the task is successful
  132372. */
  132373. onSuccess: (task: any) => void;
  132374. /**
  132375. * Callback called when the task is not successful
  132376. */
  132377. onError: (task: any, message?: string, exception?: any) => void;
  132378. /**
  132379. * Creates a new AssetsManager
  132380. * @param name defines the name of the task
  132381. */
  132382. constructor(
  132383. /**
  132384. * Task name
  132385. */ name: string);
  132386. private _isCompleted;
  132387. private _taskState;
  132388. private _errorObject;
  132389. /**
  132390. * Get if the task is completed
  132391. */
  132392. readonly isCompleted: boolean;
  132393. /**
  132394. * Gets the current state of the task
  132395. */
  132396. readonly taskState: AssetTaskState;
  132397. /**
  132398. * Gets the current error object (if task is in error)
  132399. */
  132400. readonly errorObject: {
  132401. message?: string;
  132402. exception?: any;
  132403. };
  132404. /**
  132405. * Internal only
  132406. * @hidden
  132407. */
  132408. _setErrorObject(message?: string, exception?: any): void;
  132409. /**
  132410. * Execute the current task
  132411. * @param scene defines the scene where you want your assets to be loaded
  132412. * @param onSuccess is a callback called when the task is successfully executed
  132413. * @param onError is a callback called if an error occurs
  132414. */
  132415. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132416. /**
  132417. * Execute the current task
  132418. * @param scene defines the scene where you want your assets to be loaded
  132419. * @param onSuccess is a callback called when the task is successfully executed
  132420. * @param onError is a callback called if an error occurs
  132421. */
  132422. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132423. /**
  132424. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  132425. * This can be used with failed tasks that have the reason for failure fixed.
  132426. */
  132427. reset(): void;
  132428. private onErrorCallback;
  132429. private onDoneCallback;
  132430. }
  132431. /**
  132432. * Define the interface used by progress events raised during assets loading
  132433. */
  132434. export interface IAssetsProgressEvent {
  132435. /**
  132436. * Defines the number of remaining tasks to process
  132437. */
  132438. remainingCount: number;
  132439. /**
  132440. * Defines the total number of tasks
  132441. */
  132442. totalCount: number;
  132443. /**
  132444. * Defines the task that was just processed
  132445. */
  132446. task: AbstractAssetTask;
  132447. }
  132448. /**
  132449. * Class used to share progress information about assets loading
  132450. */
  132451. export class AssetsProgressEvent implements IAssetsProgressEvent {
  132452. /**
  132453. * Defines the number of remaining tasks to process
  132454. */
  132455. remainingCount: number;
  132456. /**
  132457. * Defines the total number of tasks
  132458. */
  132459. totalCount: number;
  132460. /**
  132461. * Defines the task that was just processed
  132462. */
  132463. task: AbstractAssetTask;
  132464. /**
  132465. * Creates a AssetsProgressEvent
  132466. * @param remainingCount defines the number of remaining tasks to process
  132467. * @param totalCount defines the total number of tasks
  132468. * @param task defines the task that was just processed
  132469. */
  132470. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  132471. }
  132472. /**
  132473. * Define a task used by AssetsManager to load meshes
  132474. */
  132475. export class MeshAssetTask extends AbstractAssetTask {
  132476. /**
  132477. * Defines the name of the task
  132478. */
  132479. name: string;
  132480. /**
  132481. * Defines the list of mesh's names you want to load
  132482. */
  132483. meshesNames: any;
  132484. /**
  132485. * Defines the root url to use as a base to load your meshes and associated resources
  132486. */
  132487. rootUrl: string;
  132488. /**
  132489. * Defines the filename of the scene to load from
  132490. */
  132491. sceneFilename: string;
  132492. /**
  132493. * Gets the list of loaded meshes
  132494. */
  132495. loadedMeshes: Array<AbstractMesh>;
  132496. /**
  132497. * Gets the list of loaded particle systems
  132498. */
  132499. loadedParticleSystems: Array<IParticleSystem>;
  132500. /**
  132501. * Gets the list of loaded skeletons
  132502. */
  132503. loadedSkeletons: Array<Skeleton>;
  132504. /**
  132505. * Gets the list of loaded animation groups
  132506. */
  132507. loadedAnimationGroups: Array<AnimationGroup>;
  132508. /**
  132509. * Callback called when the task is successful
  132510. */
  132511. onSuccess: (task: MeshAssetTask) => void;
  132512. /**
  132513. * Callback called when the task is successful
  132514. */
  132515. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  132516. /**
  132517. * Creates a new MeshAssetTask
  132518. * @param name defines the name of the task
  132519. * @param meshesNames defines the list of mesh's names you want to load
  132520. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  132521. * @param sceneFilename defines the filename of the scene to load from
  132522. */
  132523. constructor(
  132524. /**
  132525. * Defines the name of the task
  132526. */
  132527. name: string,
  132528. /**
  132529. * Defines the list of mesh's names you want to load
  132530. */
  132531. meshesNames: any,
  132532. /**
  132533. * Defines the root url to use as a base to load your meshes and associated resources
  132534. */
  132535. rootUrl: string,
  132536. /**
  132537. * Defines the filename of the scene to load from
  132538. */
  132539. sceneFilename: string);
  132540. /**
  132541. * Execute the current task
  132542. * @param scene defines the scene where you want your assets to be loaded
  132543. * @param onSuccess is a callback called when the task is successfully executed
  132544. * @param onError is a callback called if an error occurs
  132545. */
  132546. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132547. }
  132548. /**
  132549. * Define a task used by AssetsManager to load text content
  132550. */
  132551. export class TextFileAssetTask extends AbstractAssetTask {
  132552. /**
  132553. * Defines the name of the task
  132554. */
  132555. name: string;
  132556. /**
  132557. * Defines the location of the file to load
  132558. */
  132559. url: string;
  132560. /**
  132561. * Gets the loaded text string
  132562. */
  132563. text: string;
  132564. /**
  132565. * Callback called when the task is successful
  132566. */
  132567. onSuccess: (task: TextFileAssetTask) => void;
  132568. /**
  132569. * Callback called when the task is successful
  132570. */
  132571. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  132572. /**
  132573. * Creates a new TextFileAssetTask object
  132574. * @param name defines the name of the task
  132575. * @param url defines the location of the file to load
  132576. */
  132577. constructor(
  132578. /**
  132579. * Defines the name of the task
  132580. */
  132581. name: string,
  132582. /**
  132583. * Defines the location of the file to load
  132584. */
  132585. url: string);
  132586. /**
  132587. * Execute the current task
  132588. * @param scene defines the scene where you want your assets to be loaded
  132589. * @param onSuccess is a callback called when the task is successfully executed
  132590. * @param onError is a callback called if an error occurs
  132591. */
  132592. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132593. }
  132594. /**
  132595. * Define a task used by AssetsManager to load binary data
  132596. */
  132597. export class BinaryFileAssetTask extends AbstractAssetTask {
  132598. /**
  132599. * Defines the name of the task
  132600. */
  132601. name: string;
  132602. /**
  132603. * Defines the location of the file to load
  132604. */
  132605. url: string;
  132606. /**
  132607. * Gets the lodaded data (as an array buffer)
  132608. */
  132609. data: ArrayBuffer;
  132610. /**
  132611. * Callback called when the task is successful
  132612. */
  132613. onSuccess: (task: BinaryFileAssetTask) => void;
  132614. /**
  132615. * Callback called when the task is successful
  132616. */
  132617. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  132618. /**
  132619. * Creates a new BinaryFileAssetTask object
  132620. * @param name defines the name of the new task
  132621. * @param url defines the location of the file to load
  132622. */
  132623. constructor(
  132624. /**
  132625. * Defines the name of the task
  132626. */
  132627. name: string,
  132628. /**
  132629. * Defines the location of the file to load
  132630. */
  132631. url: string);
  132632. /**
  132633. * Execute the current task
  132634. * @param scene defines the scene where you want your assets to be loaded
  132635. * @param onSuccess is a callback called when the task is successfully executed
  132636. * @param onError is a callback called if an error occurs
  132637. */
  132638. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132639. }
  132640. /**
  132641. * Define a task used by AssetsManager to load images
  132642. */
  132643. export class ImageAssetTask extends AbstractAssetTask {
  132644. /**
  132645. * Defines the name of the task
  132646. */
  132647. name: string;
  132648. /**
  132649. * Defines the location of the image to load
  132650. */
  132651. url: string;
  132652. /**
  132653. * Gets the loaded images
  132654. */
  132655. image: HTMLImageElement;
  132656. /**
  132657. * Callback called when the task is successful
  132658. */
  132659. onSuccess: (task: ImageAssetTask) => void;
  132660. /**
  132661. * Callback called when the task is successful
  132662. */
  132663. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  132664. /**
  132665. * Creates a new ImageAssetTask
  132666. * @param name defines the name of the task
  132667. * @param url defines the location of the image to load
  132668. */
  132669. constructor(
  132670. /**
  132671. * Defines the name of the task
  132672. */
  132673. name: string,
  132674. /**
  132675. * Defines the location of the image to load
  132676. */
  132677. url: string);
  132678. /**
  132679. * Execute the current task
  132680. * @param scene defines the scene where you want your assets to be loaded
  132681. * @param onSuccess is a callback called when the task is successfully executed
  132682. * @param onError is a callback called if an error occurs
  132683. */
  132684. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132685. }
  132686. /**
  132687. * Defines the interface used by texture loading tasks
  132688. */
  132689. export interface ITextureAssetTask<TEX extends BaseTexture> {
  132690. /**
  132691. * Gets the loaded texture
  132692. */
  132693. texture: TEX;
  132694. }
  132695. /**
  132696. * Define a task used by AssetsManager to load 2D textures
  132697. */
  132698. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  132699. /**
  132700. * Defines the name of the task
  132701. */
  132702. name: string;
  132703. /**
  132704. * Defines the location of the file to load
  132705. */
  132706. url: string;
  132707. /**
  132708. * Defines if mipmap should not be generated (default is false)
  132709. */
  132710. noMipmap?: boolean | undefined;
  132711. /**
  132712. * Defines if texture must be inverted on Y axis (default is false)
  132713. */
  132714. invertY?: boolean | undefined;
  132715. /**
  132716. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132717. */
  132718. samplingMode: number;
  132719. /**
  132720. * Gets the loaded texture
  132721. */
  132722. texture: Texture;
  132723. /**
  132724. * Callback called when the task is successful
  132725. */
  132726. onSuccess: (task: TextureAssetTask) => void;
  132727. /**
  132728. * Callback called when the task is successful
  132729. */
  132730. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  132731. /**
  132732. * Creates a new TextureAssetTask object
  132733. * @param name defines the name of the task
  132734. * @param url defines the location of the file to load
  132735. * @param noMipmap defines if mipmap should not be generated (default is false)
  132736. * @param invertY defines if texture must be inverted on Y axis (default is false)
  132737. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132738. */
  132739. constructor(
  132740. /**
  132741. * Defines the name of the task
  132742. */
  132743. name: string,
  132744. /**
  132745. * Defines the location of the file to load
  132746. */
  132747. url: string,
  132748. /**
  132749. * Defines if mipmap should not be generated (default is false)
  132750. */
  132751. noMipmap?: boolean | undefined,
  132752. /**
  132753. * Defines if texture must be inverted on Y axis (default is false)
  132754. */
  132755. invertY?: boolean | undefined,
  132756. /**
  132757. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132758. */
  132759. samplingMode?: number);
  132760. /**
  132761. * Execute the current task
  132762. * @param scene defines the scene where you want your assets to be loaded
  132763. * @param onSuccess is a callback called when the task is successfully executed
  132764. * @param onError is a callback called if an error occurs
  132765. */
  132766. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132767. }
  132768. /**
  132769. * Define a task used by AssetsManager to load cube textures
  132770. */
  132771. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  132772. /**
  132773. * Defines the name of the task
  132774. */
  132775. name: string;
  132776. /**
  132777. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132778. */
  132779. url: string;
  132780. /**
  132781. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132782. */
  132783. extensions?: string[] | undefined;
  132784. /**
  132785. * Defines if mipmaps should not be generated (default is false)
  132786. */
  132787. noMipmap?: boolean | undefined;
  132788. /**
  132789. * Defines the explicit list of files (undefined by default)
  132790. */
  132791. files?: string[] | undefined;
  132792. /**
  132793. * Gets the loaded texture
  132794. */
  132795. texture: CubeTexture;
  132796. /**
  132797. * Callback called when the task is successful
  132798. */
  132799. onSuccess: (task: CubeTextureAssetTask) => void;
  132800. /**
  132801. * Callback called when the task is successful
  132802. */
  132803. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  132804. /**
  132805. * Creates a new CubeTextureAssetTask
  132806. * @param name defines the name of the task
  132807. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132808. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132809. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132810. * @param files defines the explicit list of files (undefined by default)
  132811. */
  132812. constructor(
  132813. /**
  132814. * Defines the name of the task
  132815. */
  132816. name: string,
  132817. /**
  132818. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132819. */
  132820. url: string,
  132821. /**
  132822. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132823. */
  132824. extensions?: string[] | undefined,
  132825. /**
  132826. * Defines if mipmaps should not be generated (default is false)
  132827. */
  132828. noMipmap?: boolean | undefined,
  132829. /**
  132830. * Defines the explicit list of files (undefined by default)
  132831. */
  132832. files?: string[] | undefined);
  132833. /**
  132834. * Execute the current task
  132835. * @param scene defines the scene where you want your assets to be loaded
  132836. * @param onSuccess is a callback called when the task is successfully executed
  132837. * @param onError is a callback called if an error occurs
  132838. */
  132839. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132840. }
  132841. /**
  132842. * Define a task used by AssetsManager to load HDR cube textures
  132843. */
  132844. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  132845. /**
  132846. * Defines the name of the task
  132847. */
  132848. name: string;
  132849. /**
  132850. * Defines the location of the file to load
  132851. */
  132852. url: string;
  132853. /**
  132854. * Defines the desired size (the more it increases the longer the generation will be)
  132855. */
  132856. size: number;
  132857. /**
  132858. * Defines if mipmaps should not be generated (default is false)
  132859. */
  132860. noMipmap: boolean;
  132861. /**
  132862. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132863. */
  132864. generateHarmonics: boolean;
  132865. /**
  132866. * 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)
  132867. */
  132868. gammaSpace: boolean;
  132869. /**
  132870. * Internal Use Only
  132871. */
  132872. reserved: boolean;
  132873. /**
  132874. * Gets the loaded texture
  132875. */
  132876. texture: HDRCubeTexture;
  132877. /**
  132878. * Callback called when the task is successful
  132879. */
  132880. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  132881. /**
  132882. * Callback called when the task is successful
  132883. */
  132884. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  132885. /**
  132886. * Creates a new HDRCubeTextureAssetTask object
  132887. * @param name defines the name of the task
  132888. * @param url defines the location of the file to load
  132889. * @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.
  132890. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132891. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132892. * @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)
  132893. * @param reserved Internal use only
  132894. */
  132895. constructor(
  132896. /**
  132897. * Defines the name of the task
  132898. */
  132899. name: string,
  132900. /**
  132901. * Defines the location of the file to load
  132902. */
  132903. url: string,
  132904. /**
  132905. * Defines the desired size (the more it increases the longer the generation will be)
  132906. */
  132907. size: number,
  132908. /**
  132909. * Defines if mipmaps should not be generated (default is false)
  132910. */
  132911. noMipmap?: boolean,
  132912. /**
  132913. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132914. */
  132915. generateHarmonics?: boolean,
  132916. /**
  132917. * 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)
  132918. */
  132919. gammaSpace?: boolean,
  132920. /**
  132921. * Internal Use Only
  132922. */
  132923. reserved?: boolean);
  132924. /**
  132925. * Execute the current task
  132926. * @param scene defines the scene where you want your assets to be loaded
  132927. * @param onSuccess is a callback called when the task is successfully executed
  132928. * @param onError is a callback called if an error occurs
  132929. */
  132930. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132931. }
  132932. /**
  132933. * Define a task used by AssetsManager to load Equirectangular cube textures
  132934. */
  132935. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  132936. /**
  132937. * Defines the name of the task
  132938. */
  132939. name: string;
  132940. /**
  132941. * Defines the location of the file to load
  132942. */
  132943. url: string;
  132944. /**
  132945. * Defines the desired size (the more it increases the longer the generation will be)
  132946. */
  132947. size: number;
  132948. /**
  132949. * Defines if mipmaps should not be generated (default is false)
  132950. */
  132951. noMipmap: boolean;
  132952. /**
  132953. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  132954. * but the standard material would require them in Gamma space) (default is true)
  132955. */
  132956. gammaSpace: boolean;
  132957. /**
  132958. * Gets the loaded texture
  132959. */
  132960. texture: EquiRectangularCubeTexture;
  132961. /**
  132962. * Callback called when the task is successful
  132963. */
  132964. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  132965. /**
  132966. * Callback called when the task is successful
  132967. */
  132968. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  132969. /**
  132970. * Creates a new EquiRectangularCubeTextureAssetTask object
  132971. * @param name defines the name of the task
  132972. * @param url defines the location of the file to load
  132973. * @param size defines the desired size (the more it increases the longer the generation will be)
  132974. * If the size is omitted this implies you are using a preprocessed cubemap.
  132975. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132976. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  132977. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  132978. * (default is true)
  132979. */
  132980. constructor(
  132981. /**
  132982. * Defines the name of the task
  132983. */
  132984. name: string,
  132985. /**
  132986. * Defines the location of the file to load
  132987. */
  132988. url: string,
  132989. /**
  132990. * Defines the desired size (the more it increases the longer the generation will be)
  132991. */
  132992. size: number,
  132993. /**
  132994. * Defines if mipmaps should not be generated (default is false)
  132995. */
  132996. noMipmap?: boolean,
  132997. /**
  132998. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  132999. * but the standard material would require them in Gamma space) (default is true)
  133000. */
  133001. gammaSpace?: boolean);
  133002. /**
  133003. * Execute the current task
  133004. * @param scene defines the scene where you want your assets to be loaded
  133005. * @param onSuccess is a callback called when the task is successfully executed
  133006. * @param onError is a callback called if an error occurs
  133007. */
  133008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133009. }
  133010. /**
  133011. * This class can be used to easily import assets into a scene
  133012. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  133013. */
  133014. export class AssetsManager {
  133015. private _scene;
  133016. private _isLoading;
  133017. protected _tasks: AbstractAssetTask[];
  133018. protected _waitingTasksCount: number;
  133019. protected _totalTasksCount: number;
  133020. /**
  133021. * Callback called when all tasks are processed
  133022. */
  133023. onFinish: (tasks: AbstractAssetTask[]) => void;
  133024. /**
  133025. * Callback called when a task is successful
  133026. */
  133027. onTaskSuccess: (task: AbstractAssetTask) => void;
  133028. /**
  133029. * Callback called when a task had an error
  133030. */
  133031. onTaskError: (task: AbstractAssetTask) => void;
  133032. /**
  133033. * Callback called when a task is done (whatever the result is)
  133034. */
  133035. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  133036. /**
  133037. * Observable called when all tasks are processed
  133038. */
  133039. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  133040. /**
  133041. * Observable called when a task had an error
  133042. */
  133043. onTaskErrorObservable: Observable<AbstractAssetTask>;
  133044. /**
  133045. * Observable called when all tasks were executed
  133046. */
  133047. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  133048. /**
  133049. * Observable called when a task is done (whatever the result is)
  133050. */
  133051. onProgressObservable: Observable<IAssetsProgressEvent>;
  133052. /**
  133053. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  133054. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  133055. */
  133056. useDefaultLoadingScreen: boolean;
  133057. /**
  133058. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  133059. * when all assets have been downloaded.
  133060. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  133061. */
  133062. autoHideLoadingUI: boolean;
  133063. /**
  133064. * Creates a new AssetsManager
  133065. * @param scene defines the scene to work on
  133066. */
  133067. constructor(scene: Scene);
  133068. /**
  133069. * Add a MeshAssetTask to the list of active tasks
  133070. * @param taskName defines the name of the new task
  133071. * @param meshesNames defines the name of meshes to load
  133072. * @param rootUrl defines the root url to use to locate files
  133073. * @param sceneFilename defines the filename of the scene file
  133074. * @returns a new MeshAssetTask object
  133075. */
  133076. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  133077. /**
  133078. * Add a TextFileAssetTask to the list of active tasks
  133079. * @param taskName defines the name of the new task
  133080. * @param url defines the url of the file to load
  133081. * @returns a new TextFileAssetTask object
  133082. */
  133083. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  133084. /**
  133085. * Add a BinaryFileAssetTask to the list of active tasks
  133086. * @param taskName defines the name of the new task
  133087. * @param url defines the url of the file to load
  133088. * @returns a new BinaryFileAssetTask object
  133089. */
  133090. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  133091. /**
  133092. * Add a ImageAssetTask to the list of active tasks
  133093. * @param taskName defines the name of the new task
  133094. * @param url defines the url of the file to load
  133095. * @returns a new ImageAssetTask object
  133096. */
  133097. addImageTask(taskName: string, url: string): ImageAssetTask;
  133098. /**
  133099. * Add a TextureAssetTask to the list of active tasks
  133100. * @param taskName defines the name of the new task
  133101. * @param url defines the url of the file to load
  133102. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133103. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  133104. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133105. * @returns a new TextureAssetTask object
  133106. */
  133107. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  133108. /**
  133109. * Add a CubeTextureAssetTask to the list of active tasks
  133110. * @param taskName defines the name of the new task
  133111. * @param url defines the url of the file to load
  133112. * @param extensions defines the extension to use to load the cube map (can be null)
  133113. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133114. * @param files defines the list of files to load (can be null)
  133115. * @returns a new CubeTextureAssetTask object
  133116. */
  133117. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  133118. /**
  133119. *
  133120. * Add a HDRCubeTextureAssetTask to the list of active tasks
  133121. * @param taskName defines the name of the new task
  133122. * @param url defines the url of the file to load
  133123. * @param size defines the size you want for the cubemap (can be null)
  133124. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133125. * @param generateHarmonics defines if you want to automatically generate (true by default)
  133126. * @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)
  133127. * @param reserved Internal use only
  133128. * @returns a new HDRCubeTextureAssetTask object
  133129. */
  133130. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  133131. /**
  133132. *
  133133. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  133134. * @param taskName defines the name of the new task
  133135. * @param url defines the url of the file to load
  133136. * @param size defines the size you want for the cubemap (can be null)
  133137. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133138. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  133139. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  133140. * @returns a new EquiRectangularCubeTextureAssetTask object
  133141. */
  133142. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  133143. /**
  133144. * Remove a task from the assets manager.
  133145. * @param task the task to remove
  133146. */
  133147. removeTask(task: AbstractAssetTask): void;
  133148. private _decreaseWaitingTasksCount;
  133149. private _runTask;
  133150. /**
  133151. * Reset the AssetsManager and remove all tasks
  133152. * @return the current instance of the AssetsManager
  133153. */
  133154. reset(): AssetsManager;
  133155. /**
  133156. * Start the loading process
  133157. * @return the current instance of the AssetsManager
  133158. */
  133159. load(): AssetsManager;
  133160. /**
  133161. * Start the loading process as an async operation
  133162. * @return a promise returning the list of failed tasks
  133163. */
  133164. loadAsync(): Promise<void>;
  133165. }
  133166. }
  133167. declare module BABYLON {
  133168. /**
  133169. * Wrapper class for promise with external resolve and reject.
  133170. */
  133171. export class Deferred<T> {
  133172. /**
  133173. * The promise associated with this deferred object.
  133174. */
  133175. readonly promise: Promise<T>;
  133176. private _resolve;
  133177. private _reject;
  133178. /**
  133179. * The resolve method of the promise associated with this deferred object.
  133180. */
  133181. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  133182. /**
  133183. * The reject method of the promise associated with this deferred object.
  133184. */
  133185. readonly reject: (reason?: any) => void;
  133186. /**
  133187. * Constructor for this deferred object.
  133188. */
  133189. constructor();
  133190. }
  133191. }
  133192. declare module BABYLON {
  133193. /**
  133194. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  133195. */
  133196. export class MeshExploder {
  133197. private _centerMesh;
  133198. private _meshes;
  133199. private _meshesOrigins;
  133200. private _toCenterVectors;
  133201. private _scaledDirection;
  133202. private _newPosition;
  133203. private _centerPosition;
  133204. /**
  133205. * Explodes meshes from a center mesh.
  133206. * @param meshes The meshes to explode.
  133207. * @param centerMesh The mesh to be center of explosion.
  133208. */
  133209. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  133210. private _setCenterMesh;
  133211. /**
  133212. * Get class name
  133213. * @returns "MeshExploder"
  133214. */
  133215. getClassName(): string;
  133216. /**
  133217. * "Exploded meshes"
  133218. * @returns Array of meshes with the centerMesh at index 0.
  133219. */
  133220. getMeshes(): Array<Mesh>;
  133221. /**
  133222. * Explodes meshes giving a specific direction
  133223. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  133224. */
  133225. explode(direction?: number): void;
  133226. }
  133227. }
  133228. declare module BABYLON {
  133229. /**
  133230. * Class used to help managing file picking and drag'n'drop
  133231. */
  133232. export class FilesInput {
  133233. /**
  133234. * List of files ready to be loaded
  133235. */
  133236. static readonly FilesToLoad: {
  133237. [key: string]: File;
  133238. };
  133239. /**
  133240. * Callback called when a file is processed
  133241. */
  133242. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  133243. private _engine;
  133244. private _currentScene;
  133245. private _sceneLoadedCallback;
  133246. private _progressCallback;
  133247. private _additionalRenderLoopLogicCallback;
  133248. private _textureLoadingCallback;
  133249. private _startingProcessingFilesCallback;
  133250. private _onReloadCallback;
  133251. private _errorCallback;
  133252. private _elementToMonitor;
  133253. private _sceneFileToLoad;
  133254. private _filesToLoad;
  133255. /**
  133256. * Creates a new FilesInput
  133257. * @param engine defines the rendering engine
  133258. * @param scene defines the hosting scene
  133259. * @param sceneLoadedCallback callback called when scene is loaded
  133260. * @param progressCallback callback called to track progress
  133261. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  133262. * @param textureLoadingCallback callback called when a texture is loading
  133263. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  133264. * @param onReloadCallback callback called when a reload is requested
  133265. * @param errorCallback callback call if an error occurs
  133266. */
  133267. 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);
  133268. private _dragEnterHandler;
  133269. private _dragOverHandler;
  133270. private _dropHandler;
  133271. /**
  133272. * Calls this function to listen to drag'n'drop events on a specific DOM element
  133273. * @param elementToMonitor defines the DOM element to track
  133274. */
  133275. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  133276. /**
  133277. * Release all associated resources
  133278. */
  133279. dispose(): void;
  133280. private renderFunction;
  133281. private drag;
  133282. private drop;
  133283. private _traverseFolder;
  133284. private _processFiles;
  133285. /**
  133286. * Load files from a drop event
  133287. * @param event defines the drop event to use as source
  133288. */
  133289. loadFiles(event: any): void;
  133290. private _processReload;
  133291. /**
  133292. * Reload the current scene from the loaded files
  133293. */
  133294. reload(): void;
  133295. }
  133296. }
  133297. declare module BABYLON {
  133298. /**
  133299. * Defines the root class used to create scene optimization to use with SceneOptimizer
  133300. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133301. */
  133302. export class SceneOptimization {
  133303. /**
  133304. * Defines the priority of this optimization (0 by default which means first in the list)
  133305. */
  133306. priority: number;
  133307. /**
  133308. * Gets a string describing the action executed by the current optimization
  133309. * @returns description string
  133310. */
  133311. getDescription(): string;
  133312. /**
  133313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133314. * @param scene defines the current scene where to apply this optimization
  133315. * @param optimizer defines the current optimizer
  133316. * @returns true if everything that can be done was applied
  133317. */
  133318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133319. /**
  133320. * Creates the SceneOptimization object
  133321. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133322. * @param desc defines the description associated with the optimization
  133323. */
  133324. constructor(
  133325. /**
  133326. * Defines the priority of this optimization (0 by default which means first in the list)
  133327. */
  133328. priority?: number);
  133329. }
  133330. /**
  133331. * Defines an optimization used to reduce the size of render target textures
  133332. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133333. */
  133334. export class TextureOptimization extends SceneOptimization {
  133335. /**
  133336. * Defines the priority of this optimization (0 by default which means first in the list)
  133337. */
  133338. priority: number;
  133339. /**
  133340. * 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
  133341. */
  133342. maximumSize: number;
  133343. /**
  133344. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133345. */
  133346. step: number;
  133347. /**
  133348. * Gets a string describing the action executed by the current optimization
  133349. * @returns description string
  133350. */
  133351. getDescription(): string;
  133352. /**
  133353. * Creates the TextureOptimization object
  133354. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133355. * @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
  133356. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133357. */
  133358. constructor(
  133359. /**
  133360. * Defines the priority of this optimization (0 by default which means first in the list)
  133361. */
  133362. priority?: number,
  133363. /**
  133364. * 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
  133365. */
  133366. maximumSize?: number,
  133367. /**
  133368. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133369. */
  133370. step?: number);
  133371. /**
  133372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133373. * @param scene defines the current scene where to apply this optimization
  133374. * @param optimizer defines the current optimizer
  133375. * @returns true if everything that can be done was applied
  133376. */
  133377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133378. }
  133379. /**
  133380. * Defines an optimization used to increase or decrease the rendering resolution
  133381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133382. */
  133383. export class HardwareScalingOptimization extends SceneOptimization {
  133384. /**
  133385. * Defines the priority of this optimization (0 by default which means first in the list)
  133386. */
  133387. priority: number;
  133388. /**
  133389. * Defines the maximum scale to use (2 by default)
  133390. */
  133391. maximumScale: number;
  133392. /**
  133393. * Defines the step to use between two passes (0.5 by default)
  133394. */
  133395. step: number;
  133396. private _currentScale;
  133397. private _directionOffset;
  133398. /**
  133399. * Gets a string describing the action executed by the current optimization
  133400. * @return description string
  133401. */
  133402. getDescription(): string;
  133403. /**
  133404. * Creates the HardwareScalingOptimization object
  133405. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133406. * @param maximumScale defines the maximum scale to use (2 by default)
  133407. * @param step defines the step to use between two passes (0.5 by default)
  133408. */
  133409. constructor(
  133410. /**
  133411. * Defines the priority of this optimization (0 by default which means first in the list)
  133412. */
  133413. priority?: number,
  133414. /**
  133415. * Defines the maximum scale to use (2 by default)
  133416. */
  133417. maximumScale?: number,
  133418. /**
  133419. * Defines the step to use between two passes (0.5 by default)
  133420. */
  133421. step?: number);
  133422. /**
  133423. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133424. * @param scene defines the current scene where to apply this optimization
  133425. * @param optimizer defines the current optimizer
  133426. * @returns true if everything that can be done was applied
  133427. */
  133428. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133429. }
  133430. /**
  133431. * Defines an optimization used to remove shadows
  133432. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133433. */
  133434. export class ShadowsOptimization extends SceneOptimization {
  133435. /**
  133436. * Gets a string describing the action executed by the current optimization
  133437. * @return description string
  133438. */
  133439. getDescription(): string;
  133440. /**
  133441. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133442. * @param scene defines the current scene where to apply this optimization
  133443. * @param optimizer defines the current optimizer
  133444. * @returns true if everything that can be done was applied
  133445. */
  133446. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133447. }
  133448. /**
  133449. * Defines an optimization used to turn post-processes off
  133450. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133451. */
  133452. export class PostProcessesOptimization extends SceneOptimization {
  133453. /**
  133454. * Gets a string describing the action executed by the current optimization
  133455. * @return description string
  133456. */
  133457. getDescription(): string;
  133458. /**
  133459. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133460. * @param scene defines the current scene where to apply this optimization
  133461. * @param optimizer defines the current optimizer
  133462. * @returns true if everything that can be done was applied
  133463. */
  133464. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133465. }
  133466. /**
  133467. * Defines an optimization used to turn lens flares off
  133468. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133469. */
  133470. export class LensFlaresOptimization extends SceneOptimization {
  133471. /**
  133472. * Gets a string describing the action executed by the current optimization
  133473. * @return description string
  133474. */
  133475. getDescription(): string;
  133476. /**
  133477. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133478. * @param scene defines the current scene where to apply this optimization
  133479. * @param optimizer defines the current optimizer
  133480. * @returns true if everything that can be done was applied
  133481. */
  133482. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133483. }
  133484. /**
  133485. * Defines an optimization based on user defined callback.
  133486. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133487. */
  133488. export class CustomOptimization extends SceneOptimization {
  133489. /**
  133490. * Callback called to apply the custom optimization.
  133491. */
  133492. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  133493. /**
  133494. * Callback called to get custom description
  133495. */
  133496. onGetDescription: () => string;
  133497. /**
  133498. * Gets a string describing the action executed by the current optimization
  133499. * @returns description string
  133500. */
  133501. getDescription(): string;
  133502. /**
  133503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133504. * @param scene defines the current scene where to apply this optimization
  133505. * @param optimizer defines the current optimizer
  133506. * @returns true if everything that can be done was applied
  133507. */
  133508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133509. }
  133510. /**
  133511. * Defines an optimization used to turn particles off
  133512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133513. */
  133514. export class ParticlesOptimization extends SceneOptimization {
  133515. /**
  133516. * Gets a string describing the action executed by the current optimization
  133517. * @return description string
  133518. */
  133519. getDescription(): string;
  133520. /**
  133521. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133522. * @param scene defines the current scene where to apply this optimization
  133523. * @param optimizer defines the current optimizer
  133524. * @returns true if everything that can be done was applied
  133525. */
  133526. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133527. }
  133528. /**
  133529. * Defines an optimization used to turn render targets off
  133530. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133531. */
  133532. export class RenderTargetsOptimization extends SceneOptimization {
  133533. /**
  133534. * Gets a string describing the action executed by the current optimization
  133535. * @return description string
  133536. */
  133537. getDescription(): string;
  133538. /**
  133539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133540. * @param scene defines the current scene where to apply this optimization
  133541. * @param optimizer defines the current optimizer
  133542. * @returns true if everything that can be done was applied
  133543. */
  133544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133545. }
  133546. /**
  133547. * Defines an optimization used to merge meshes with compatible materials
  133548. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133549. */
  133550. export class MergeMeshesOptimization extends SceneOptimization {
  133551. private static _UpdateSelectionTree;
  133552. /**
  133553. * Gets or sets a boolean which defines if optimization octree has to be updated
  133554. */
  133555. /**
  133556. * Gets or sets a boolean which defines if optimization octree has to be updated
  133557. */
  133558. static UpdateSelectionTree: boolean;
  133559. /**
  133560. * Gets a string describing the action executed by the current optimization
  133561. * @return description string
  133562. */
  133563. getDescription(): string;
  133564. private _canBeMerged;
  133565. /**
  133566. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133567. * @param scene defines the current scene where to apply this optimization
  133568. * @param optimizer defines the current optimizer
  133569. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  133570. * @returns true if everything that can be done was applied
  133571. */
  133572. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  133573. }
  133574. /**
  133575. * Defines a list of options used by SceneOptimizer
  133576. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133577. */
  133578. export class SceneOptimizerOptions {
  133579. /**
  133580. * Defines the target frame rate to reach (60 by default)
  133581. */
  133582. targetFrameRate: number;
  133583. /**
  133584. * Defines the interval between two checkes (2000ms by default)
  133585. */
  133586. trackerDuration: number;
  133587. /**
  133588. * Gets the list of optimizations to apply
  133589. */
  133590. optimizations: SceneOptimization[];
  133591. /**
  133592. * Creates a new list of options used by SceneOptimizer
  133593. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  133594. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  133595. */
  133596. constructor(
  133597. /**
  133598. * Defines the target frame rate to reach (60 by default)
  133599. */
  133600. targetFrameRate?: number,
  133601. /**
  133602. * Defines the interval between two checkes (2000ms by default)
  133603. */
  133604. trackerDuration?: number);
  133605. /**
  133606. * Add a new optimization
  133607. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  133608. * @returns the current SceneOptimizerOptions
  133609. */
  133610. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  133611. /**
  133612. * Add a new custom optimization
  133613. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  133614. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  133615. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133616. * @returns the current SceneOptimizerOptions
  133617. */
  133618. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  133619. /**
  133620. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  133621. * @param targetFrameRate defines the target frame rate (60 by default)
  133622. * @returns a SceneOptimizerOptions object
  133623. */
  133624. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133625. /**
  133626. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  133627. * @param targetFrameRate defines the target frame rate (60 by default)
  133628. * @returns a SceneOptimizerOptions object
  133629. */
  133630. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133631. /**
  133632. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  133633. * @param targetFrameRate defines the target frame rate (60 by default)
  133634. * @returns a SceneOptimizerOptions object
  133635. */
  133636. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133637. }
  133638. /**
  133639. * Class used to run optimizations in order to reach a target frame rate
  133640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133641. */
  133642. export class SceneOptimizer implements IDisposable {
  133643. private _isRunning;
  133644. private _options;
  133645. private _scene;
  133646. private _currentPriorityLevel;
  133647. private _targetFrameRate;
  133648. private _trackerDuration;
  133649. private _currentFrameRate;
  133650. private _sceneDisposeObserver;
  133651. private _improvementMode;
  133652. /**
  133653. * Defines an observable called when the optimizer reaches the target frame rate
  133654. */
  133655. onSuccessObservable: Observable<SceneOptimizer>;
  133656. /**
  133657. * Defines an observable called when the optimizer enables an optimization
  133658. */
  133659. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  133660. /**
  133661. * Defines an observable called when the optimizer is not able to reach the target frame rate
  133662. */
  133663. onFailureObservable: Observable<SceneOptimizer>;
  133664. /**
  133665. * Gets a boolean indicating if the optimizer is in improvement mode
  133666. */
  133667. readonly isInImprovementMode: boolean;
  133668. /**
  133669. * Gets the current priority level (0 at start)
  133670. */
  133671. readonly currentPriorityLevel: number;
  133672. /**
  133673. * Gets the current frame rate checked by the SceneOptimizer
  133674. */
  133675. readonly currentFrameRate: number;
  133676. /**
  133677. * Gets or sets the current target frame rate (60 by default)
  133678. */
  133679. /**
  133680. * Gets or sets the current target frame rate (60 by default)
  133681. */
  133682. targetFrameRate: number;
  133683. /**
  133684. * Gets or sets the current interval between two checks (every 2000ms by default)
  133685. */
  133686. /**
  133687. * Gets or sets the current interval between two checks (every 2000ms by default)
  133688. */
  133689. trackerDuration: number;
  133690. /**
  133691. * Gets the list of active optimizations
  133692. */
  133693. readonly optimizations: SceneOptimization[];
  133694. /**
  133695. * Creates a new SceneOptimizer
  133696. * @param scene defines the scene to work on
  133697. * @param options defines the options to use with the SceneOptimizer
  133698. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  133699. * @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)
  133700. */
  133701. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  133702. /**
  133703. * Stops the current optimizer
  133704. */
  133705. stop(): void;
  133706. /**
  133707. * Reset the optimizer to initial step (current priority level = 0)
  133708. */
  133709. reset(): void;
  133710. /**
  133711. * Start the optimizer. By default it will try to reach a specific framerate
  133712. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  133713. */
  133714. start(): void;
  133715. private _checkCurrentState;
  133716. /**
  133717. * Release all resources
  133718. */
  133719. dispose(): void;
  133720. /**
  133721. * Helper function to create a SceneOptimizer with one single line of code
  133722. * @param scene defines the scene to work on
  133723. * @param options defines the options to use with the SceneOptimizer
  133724. * @param onSuccess defines a callback to call on success
  133725. * @param onFailure defines a callback to call on failure
  133726. * @returns the new SceneOptimizer object
  133727. */
  133728. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  133729. }
  133730. }
  133731. declare module BABYLON {
  133732. /**
  133733. * Class used to serialize a scene into a string
  133734. */
  133735. export class SceneSerializer {
  133736. /**
  133737. * Clear cache used by a previous serialization
  133738. */
  133739. static ClearCache(): void;
  133740. /**
  133741. * Serialize a scene into a JSON compatible object
  133742. * @param scene defines the scene to serialize
  133743. * @returns a JSON compatible object
  133744. */
  133745. static Serialize(scene: Scene): any;
  133746. /**
  133747. * Serialize a mesh into a JSON compatible object
  133748. * @param toSerialize defines the mesh to serialize
  133749. * @param withParents defines if parents must be serialized as well
  133750. * @param withChildren defines if children must be serialized as well
  133751. * @returns a JSON compatible object
  133752. */
  133753. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  133754. }
  133755. }
  133756. declare module BABYLON {
  133757. /**
  133758. * Class used to host texture specific utilities
  133759. */
  133760. export class TextureTools {
  133761. /**
  133762. * Uses the GPU to create a copy texture rescaled at a given size
  133763. * @param texture Texture to copy from
  133764. * @param width defines the desired width
  133765. * @param height defines the desired height
  133766. * @param useBilinearMode defines if bilinear mode has to be used
  133767. * @return the generated texture
  133768. */
  133769. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  133770. }
  133771. }
  133772. declare module BABYLON {
  133773. /**
  133774. * This represents the different options available for the video capture.
  133775. */
  133776. export interface VideoRecorderOptions {
  133777. /** Defines the mime type of the video. */
  133778. mimeType: string;
  133779. /** Defines the FPS the video should be recorded at. */
  133780. fps: number;
  133781. /** Defines the chunk size for the recording data. */
  133782. recordChunckSize: number;
  133783. /** The audio tracks to attach to the recording. */
  133784. audioTracks?: MediaStreamTrack[];
  133785. }
  133786. /**
  133787. * This can help with recording videos from BabylonJS.
  133788. * This is based on the available WebRTC functionalities of the browser.
  133789. *
  133790. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  133791. */
  133792. export class VideoRecorder {
  133793. private static readonly _defaultOptions;
  133794. /**
  133795. * Returns whether or not the VideoRecorder is available in your browser.
  133796. * @param engine Defines the Babylon Engine.
  133797. * @returns true if supported otherwise false.
  133798. */
  133799. static IsSupported(engine: Engine): boolean;
  133800. private readonly _options;
  133801. private _canvas;
  133802. private _mediaRecorder;
  133803. private _recordedChunks;
  133804. private _fileName;
  133805. private _resolve;
  133806. private _reject;
  133807. /**
  133808. * True when a recording is already in progress.
  133809. */
  133810. readonly isRecording: boolean;
  133811. /**
  133812. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  133813. * @param engine Defines the BabylonJS Engine you wish to record.
  133814. * @param options Defines options that can be used to customize the capture.
  133815. */
  133816. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  133817. /**
  133818. * Stops the current recording before the default capture timeout passed in the startRecording function.
  133819. */
  133820. stopRecording(): void;
  133821. /**
  133822. * Starts recording the canvas for a max duration specified in parameters.
  133823. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  133824. * If null no automatic download will start and you can rely on the promise to get the data back.
  133825. * @param maxDuration Defines the maximum recording time in seconds.
  133826. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  133827. * @return A promise callback at the end of the recording with the video data in Blob.
  133828. */
  133829. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  133830. /**
  133831. * Releases internal resources used during the recording.
  133832. */
  133833. dispose(): void;
  133834. private _handleDataAvailable;
  133835. private _handleError;
  133836. private _handleStop;
  133837. }
  133838. }
  133839. declare module BABYLON {
  133840. /**
  133841. * Class containing a set of static utilities functions for screenshots
  133842. */
  133843. export class ScreenshotTools {
  133844. /**
  133845. * Captures a screenshot of the current rendering
  133846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133847. * @param engine defines the rendering engine
  133848. * @param camera defines the source camera
  133849. * @param size This parameter can be set to a single number or to an object with the
  133850. * following (optional) properties: precision, width, height. If a single number is passed,
  133851. * it will be used for both width and height. If an object is passed, the screenshot size
  133852. * will be derived from the parameters. The precision property is a multiplier allowing
  133853. * rendering at a higher or lower resolution
  133854. * @param successCallback defines the callback receives a single parameter which contains the
  133855. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  133856. * src parameter of an <img> to display it
  133857. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  133858. * Check your browser for supported MIME types
  133859. */
  133860. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  133861. /**
  133862. * Captures a screenshot of the current rendering
  133863. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133864. * @param engine defines the rendering engine
  133865. * @param camera defines the source camera
  133866. * @param size This parameter can be set to a single number or to an object with the
  133867. * following (optional) properties: precision, width, height. If a single number is passed,
  133868. * it will be used for both width and height. If an object is passed, the screenshot size
  133869. * will be derived from the parameters. The precision property is a multiplier allowing
  133870. * rendering at a higher or lower resolution
  133871. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  133872. * Check your browser for supported MIME types
  133873. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  133874. * to the src parameter of an <img> to display it
  133875. */
  133876. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  133877. /**
  133878. * Generates an image screenshot from the specified camera.
  133879. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133880. * @param engine The engine to use for rendering
  133881. * @param camera The camera to use for rendering
  133882. * @param size This parameter can be set to a single number or to an object with the
  133883. * following (optional) properties: precision, width, height. If a single number is passed,
  133884. * it will be used for both width and height. If an object is passed, the screenshot size
  133885. * will be derived from the parameters. The precision property is a multiplier allowing
  133886. * rendering at a higher or lower resolution
  133887. * @param successCallback The callback receives a single parameter which contains the
  133888. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  133889. * src parameter of an <img> to display it
  133890. * @param mimeType The MIME type of the screenshot image (default: image/png).
  133891. * Check your browser for supported MIME types
  133892. * @param samples Texture samples (default: 1)
  133893. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  133894. * @param fileName A name for for the downloaded file.
  133895. */
  133896. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  133897. /**
  133898. * Generates an image screenshot from the specified camera.
  133899. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133900. * @param engine The engine to use for rendering
  133901. * @param camera The camera to use for rendering
  133902. * @param size This parameter can be set to a single number or to an object with the
  133903. * following (optional) properties: precision, width, height. If a single number is passed,
  133904. * it will be used for both width and height. If an object is passed, the screenshot size
  133905. * will be derived from the parameters. The precision property is a multiplier allowing
  133906. * rendering at a higher or lower resolution
  133907. * @param mimeType The MIME type of the screenshot image (default: image/png).
  133908. * Check your browser for supported MIME types
  133909. * @param samples Texture samples (default: 1)
  133910. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  133911. * @param fileName A name for for the downloaded file.
  133912. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  133913. * to the src parameter of an <img> to display it
  133914. */
  133915. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  133916. /**
  133917. * Gets height and width for screenshot size
  133918. * @private
  133919. */
  133920. private static _getScreenshotSize;
  133921. }
  133922. }
  133923. declare module BABYLON {
  133924. /**
  133925. * Interface for a data buffer
  133926. */
  133927. export interface IDataBuffer {
  133928. /**
  133929. * Reads bytes from the data buffer.
  133930. * @param byteOffset The byte offset to read
  133931. * @param byteLength The byte length to read
  133932. * @returns A promise that resolves when the bytes are read
  133933. */
  133934. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  133935. /**
  133936. * The byte length of the buffer.
  133937. */
  133938. readonly byteLength: number;
  133939. }
  133940. /**
  133941. * Utility class for reading from a data buffer
  133942. */
  133943. export class DataReader {
  133944. /**
  133945. * The data buffer associated with this data reader.
  133946. */
  133947. readonly buffer: IDataBuffer;
  133948. /**
  133949. * The current byte offset from the beginning of the data buffer.
  133950. */
  133951. byteOffset: number;
  133952. private _dataView;
  133953. private _dataByteOffset;
  133954. /**
  133955. * Constructor
  133956. * @param buffer The buffer to read
  133957. */
  133958. constructor(buffer: IDataBuffer);
  133959. /**
  133960. * Loads the given byte length.
  133961. * @param byteLength The byte length to load
  133962. * @returns A promise that resolves when the load is complete
  133963. */
  133964. loadAsync(byteLength: number): Promise<void>;
  133965. /**
  133966. * Read a unsigned 32-bit integer from the currently loaded data range.
  133967. * @returns The 32-bit integer read
  133968. */
  133969. readUint32(): number;
  133970. /**
  133971. * Read a byte array from the currently loaded data range.
  133972. * @param byteLength The byte length to read
  133973. * @returns The byte array read
  133974. */
  133975. readUint8Array(byteLength: number): Uint8Array;
  133976. /**
  133977. * Read a string from the currently loaded data range.
  133978. * @param byteLength The byte length to read
  133979. * @returns The string read
  133980. */
  133981. readString(byteLength: number): string;
  133982. /**
  133983. * Skips the given byte length the currently loaded data range.
  133984. * @param byteLength The byte length to skip
  133985. */
  133986. skipBytes(byteLength: number): void;
  133987. }
  133988. }
  133989. declare module BABYLON {
  133990. /**
  133991. * A cursor which tracks a point on a path
  133992. */
  133993. export class PathCursor {
  133994. private path;
  133995. /**
  133996. * Stores path cursor callbacks for when an onchange event is triggered
  133997. */
  133998. private _onchange;
  133999. /**
  134000. * The value of the path cursor
  134001. */
  134002. value: number;
  134003. /**
  134004. * The animation array of the path cursor
  134005. */
  134006. animations: Animation[];
  134007. /**
  134008. * Initializes the path cursor
  134009. * @param path The path to track
  134010. */
  134011. constructor(path: Path2);
  134012. /**
  134013. * Gets the cursor point on the path
  134014. * @returns A point on the path cursor at the cursor location
  134015. */
  134016. getPoint(): Vector3;
  134017. /**
  134018. * Moves the cursor ahead by the step amount
  134019. * @param step The amount to move the cursor forward
  134020. * @returns This path cursor
  134021. */
  134022. moveAhead(step?: number): PathCursor;
  134023. /**
  134024. * Moves the cursor behind by the step amount
  134025. * @param step The amount to move the cursor back
  134026. * @returns This path cursor
  134027. */
  134028. moveBack(step?: number): PathCursor;
  134029. /**
  134030. * Moves the cursor by the step amount
  134031. * If the step amount is greater than one, an exception is thrown
  134032. * @param step The amount to move the cursor
  134033. * @returns This path cursor
  134034. */
  134035. move(step: number): PathCursor;
  134036. /**
  134037. * Ensures that the value is limited between zero and one
  134038. * @returns This path cursor
  134039. */
  134040. private ensureLimits;
  134041. /**
  134042. * Runs onchange callbacks on change (used by the animation engine)
  134043. * @returns This path cursor
  134044. */
  134045. private raiseOnChange;
  134046. /**
  134047. * Executes a function on change
  134048. * @param f A path cursor onchange callback
  134049. * @returns This path cursor
  134050. */
  134051. onchange(f: (cursor: PathCursor) => void): PathCursor;
  134052. }
  134053. }
  134054. declare module BABYLON {
  134055. /** @hidden */
  134056. export var blurPixelShader: {
  134057. name: string;
  134058. shader: string;
  134059. };
  134060. }
  134061. declare module BABYLON {
  134062. /** @hidden */
  134063. export var pointCloudVertexDeclaration: {
  134064. name: string;
  134065. shader: string;
  134066. };
  134067. }
  134068. // Mixins
  134069. interface Window {
  134070. mozIndexedDB: IDBFactory;
  134071. webkitIndexedDB: IDBFactory;
  134072. msIndexedDB: IDBFactory;
  134073. webkitURL: typeof URL;
  134074. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  134075. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  134076. WebGLRenderingContext: WebGLRenderingContext;
  134077. MSGesture: MSGesture;
  134078. CANNON: any;
  134079. AudioContext: AudioContext;
  134080. webkitAudioContext: AudioContext;
  134081. PointerEvent: any;
  134082. Math: Math;
  134083. Uint8Array: Uint8ArrayConstructor;
  134084. Float32Array: Float32ArrayConstructor;
  134085. mozURL: typeof URL;
  134086. msURL: typeof URL;
  134087. VRFrameData: any; // WebVR, from specs 1.1
  134088. DracoDecoderModule: any;
  134089. setImmediate(handler: (...args: any[]) => void): number;
  134090. }
  134091. interface HTMLCanvasElement {
  134092. requestPointerLock(): void;
  134093. msRequestPointerLock?(): void;
  134094. mozRequestPointerLock?(): void;
  134095. webkitRequestPointerLock?(): void;
  134096. /** Track wether a record is in progress */
  134097. isRecording: boolean;
  134098. /** Capture Stream method defined by some browsers */
  134099. captureStream(fps?: number): MediaStream;
  134100. }
  134101. interface CanvasRenderingContext2D {
  134102. msImageSmoothingEnabled: boolean;
  134103. }
  134104. interface MouseEvent {
  134105. mozMovementX: number;
  134106. mozMovementY: number;
  134107. webkitMovementX: number;
  134108. webkitMovementY: number;
  134109. msMovementX: number;
  134110. msMovementY: number;
  134111. }
  134112. interface Navigator {
  134113. mozGetVRDevices: (any: any) => any;
  134114. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134115. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134116. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134117. webkitGetGamepads(): Gamepad[];
  134118. msGetGamepads(): Gamepad[];
  134119. webkitGamepads(): Gamepad[];
  134120. }
  134121. interface HTMLVideoElement {
  134122. mozSrcObject: any;
  134123. }
  134124. interface Math {
  134125. fround(x: number): number;
  134126. imul(a: number, b: number): number;
  134127. }
  134128. interface WebGLRenderingContext {
  134129. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  134130. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  134131. vertexAttribDivisor(index: number, divisor: number): void;
  134132. createVertexArray(): any;
  134133. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  134134. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  134135. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  134136. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  134137. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  134138. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  134139. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  134140. // Queries
  134141. createQuery(): WebGLQuery;
  134142. deleteQuery(query: WebGLQuery): void;
  134143. beginQuery(target: number, query: WebGLQuery): void;
  134144. endQuery(target: number): void;
  134145. getQueryParameter(query: WebGLQuery, pname: number): any;
  134146. getQuery(target: number, pname: number): any;
  134147. MAX_SAMPLES: number;
  134148. RGBA8: number;
  134149. READ_FRAMEBUFFER: number;
  134150. DRAW_FRAMEBUFFER: number;
  134151. UNIFORM_BUFFER: number;
  134152. HALF_FLOAT_OES: number;
  134153. RGBA16F: number;
  134154. RGBA32F: number;
  134155. R32F: number;
  134156. RG32F: number;
  134157. RGB32F: number;
  134158. R16F: number;
  134159. RG16F: number;
  134160. RGB16F: number;
  134161. RED: number;
  134162. RG: number;
  134163. R8: number;
  134164. RG8: number;
  134165. UNSIGNED_INT_24_8: number;
  134166. DEPTH24_STENCIL8: number;
  134167. MIN: number;
  134168. MAX: number;
  134169. /* Multiple Render Targets */
  134170. drawBuffers(buffers: number[]): void;
  134171. readBuffer(src: number): void;
  134172. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  134173. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  134174. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  134175. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  134176. // Occlusion Query
  134177. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  134178. ANY_SAMPLES_PASSED: number;
  134179. QUERY_RESULT_AVAILABLE: number;
  134180. QUERY_RESULT: number;
  134181. }
  134182. interface WebGLProgram {
  134183. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  134184. }
  134185. interface EXT_disjoint_timer_query {
  134186. QUERY_COUNTER_BITS_EXT: number;
  134187. TIME_ELAPSED_EXT: number;
  134188. TIMESTAMP_EXT: number;
  134189. GPU_DISJOINT_EXT: number;
  134190. QUERY_RESULT_EXT: number;
  134191. QUERY_RESULT_AVAILABLE_EXT: number;
  134192. queryCounterEXT(query: WebGLQuery, target: number): void;
  134193. createQueryEXT(): WebGLQuery;
  134194. beginQueryEXT(target: number, query: WebGLQuery): void;
  134195. endQueryEXT(target: number): void;
  134196. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  134197. deleteQueryEXT(query: WebGLQuery): void;
  134198. }
  134199. interface WebGLUniformLocation {
  134200. _currentState: any;
  134201. }
  134202. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  134203. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  134204. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  134205. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134206. interface WebGLRenderingContext {
  134207. readonly RASTERIZER_DISCARD: number;
  134208. readonly DEPTH_COMPONENT24: number;
  134209. readonly TEXTURE_3D: number;
  134210. readonly TEXTURE_2D_ARRAY: number;
  134211. readonly TEXTURE_COMPARE_FUNC: number;
  134212. readonly TEXTURE_COMPARE_MODE: number;
  134213. readonly COMPARE_REF_TO_TEXTURE: number;
  134214. readonly TEXTURE_WRAP_R: number;
  134215. readonly HALF_FLOAT: number;
  134216. readonly RGB8: number;
  134217. readonly RED_INTEGER: number;
  134218. readonly RG_INTEGER: number;
  134219. readonly RGB_INTEGER: number;
  134220. readonly RGBA_INTEGER: number;
  134221. readonly R8_SNORM: number;
  134222. readonly RG8_SNORM: number;
  134223. readonly RGB8_SNORM: number;
  134224. readonly RGBA8_SNORM: number;
  134225. readonly R8I: number;
  134226. readonly RG8I: number;
  134227. readonly RGB8I: number;
  134228. readonly RGBA8I: number;
  134229. readonly R8UI: number;
  134230. readonly RG8UI: number;
  134231. readonly RGB8UI: number;
  134232. readonly RGBA8UI: number;
  134233. readonly R16I: number;
  134234. readonly RG16I: number;
  134235. readonly RGB16I: number;
  134236. readonly RGBA16I: number;
  134237. readonly R16UI: number;
  134238. readonly RG16UI: number;
  134239. readonly RGB16UI: number;
  134240. readonly RGBA16UI: number;
  134241. readonly R32I: number;
  134242. readonly RG32I: number;
  134243. readonly RGB32I: number;
  134244. readonly RGBA32I: number;
  134245. readonly R32UI: number;
  134246. readonly RG32UI: number;
  134247. readonly RGB32UI: number;
  134248. readonly RGBA32UI: number;
  134249. readonly RGB10_A2UI: number;
  134250. readonly R11F_G11F_B10F: number;
  134251. readonly RGB9_E5: number;
  134252. readonly RGB10_A2: number;
  134253. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  134254. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  134255. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  134256. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  134257. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  134258. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  134259. 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;
  134260. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  134261. readonly TRANSFORM_FEEDBACK: number;
  134262. readonly INTERLEAVED_ATTRIBS: number;
  134263. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  134264. createTransformFeedback(): WebGLTransformFeedback;
  134265. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  134266. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  134267. beginTransformFeedback(primitiveMode: number): void;
  134268. endTransformFeedback(): void;
  134269. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  134270. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134271. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134272. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134273. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  134274. }
  134275. interface ImageBitmap {
  134276. readonly width: number;
  134277. readonly height: number;
  134278. close(): void;
  134279. }
  134280. interface WebGLQuery extends WebGLObject {
  134281. }
  134282. declare var WebGLQuery: {
  134283. prototype: WebGLQuery;
  134284. new(): WebGLQuery;
  134285. };
  134286. interface WebGLSampler extends WebGLObject {
  134287. }
  134288. declare var WebGLSampler: {
  134289. prototype: WebGLSampler;
  134290. new(): WebGLSampler;
  134291. };
  134292. interface WebGLSync extends WebGLObject {
  134293. }
  134294. declare var WebGLSync: {
  134295. prototype: WebGLSync;
  134296. new(): WebGLSync;
  134297. };
  134298. interface WebGLTransformFeedback extends WebGLObject {
  134299. }
  134300. declare var WebGLTransformFeedback: {
  134301. prototype: WebGLTransformFeedback;
  134302. new(): WebGLTransformFeedback;
  134303. };
  134304. interface WebGLVertexArrayObject extends WebGLObject {
  134305. }
  134306. declare var WebGLVertexArrayObject: {
  134307. prototype: WebGLVertexArrayObject;
  134308. new(): WebGLVertexArrayObject;
  134309. };
  134310. // Type definitions for WebVR API
  134311. // Project: https://w3c.github.io/webvr/
  134312. // Definitions by: six a <https://github.com/lostfictions>
  134313. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134314. interface VRDisplay extends EventTarget {
  134315. /**
  134316. * Dictionary of capabilities describing the VRDisplay.
  134317. */
  134318. readonly capabilities: VRDisplayCapabilities;
  134319. /**
  134320. * z-depth defining the far plane of the eye view frustum
  134321. * enables mapping of values in the render target depth
  134322. * attachment to scene coordinates. Initially set to 10000.0.
  134323. */
  134324. depthFar: number;
  134325. /**
  134326. * z-depth defining the near plane of the eye view frustum
  134327. * enables mapping of values in the render target depth
  134328. * attachment to scene coordinates. Initially set to 0.01.
  134329. */
  134330. depthNear: number;
  134331. /**
  134332. * An identifier for this distinct VRDisplay. Used as an
  134333. * association point in the Gamepad API.
  134334. */
  134335. readonly displayId: number;
  134336. /**
  134337. * A display name, a user-readable name identifying it.
  134338. */
  134339. readonly displayName: string;
  134340. readonly isConnected: boolean;
  134341. readonly isPresenting: boolean;
  134342. /**
  134343. * If this VRDisplay supports room-scale experiences, the optional
  134344. * stage attribute contains details on the room-scale parameters.
  134345. */
  134346. readonly stageParameters: VRStageParameters | null;
  134347. /**
  134348. * Passing the value returned by `requestAnimationFrame` to
  134349. * `cancelAnimationFrame` will unregister the callback.
  134350. * @param handle Define the hanle of the request to cancel
  134351. */
  134352. cancelAnimationFrame(handle: number): void;
  134353. /**
  134354. * Stops presenting to the VRDisplay.
  134355. * @returns a promise to know when it stopped
  134356. */
  134357. exitPresent(): Promise<void>;
  134358. /**
  134359. * Return the current VREyeParameters for the given eye.
  134360. * @param whichEye Define the eye we want the parameter for
  134361. * @returns the eye parameters
  134362. */
  134363. getEyeParameters(whichEye: string): VREyeParameters;
  134364. /**
  134365. * Populates the passed VRFrameData with the information required to render
  134366. * the current frame.
  134367. * @param frameData Define the data structure to populate
  134368. * @returns true if ok otherwise false
  134369. */
  134370. getFrameData(frameData: VRFrameData): boolean;
  134371. /**
  134372. * Get the layers currently being presented.
  134373. * @returns the list of VR layers
  134374. */
  134375. getLayers(): VRLayer[];
  134376. /**
  134377. * Return a VRPose containing the future predicted pose of the VRDisplay
  134378. * when the current frame will be presented. The value returned will not
  134379. * change until JavaScript has returned control to the browser.
  134380. *
  134381. * The VRPose will contain the position, orientation, velocity,
  134382. * and acceleration of each of these properties.
  134383. * @returns the pose object
  134384. */
  134385. getPose(): VRPose;
  134386. /**
  134387. * Return the current instantaneous pose of the VRDisplay, with no
  134388. * prediction applied.
  134389. * @returns the current instantaneous pose
  134390. */
  134391. getImmediatePose(): VRPose;
  134392. /**
  134393. * The callback passed to `requestAnimationFrame` will be called
  134394. * any time a new frame should be rendered. When the VRDisplay is
  134395. * presenting the callback will be called at the native refresh
  134396. * rate of the HMD. When not presenting this function acts
  134397. * identically to how window.requestAnimationFrame acts. Content should
  134398. * make no assumptions of frame rate or vsync behavior as the HMD runs
  134399. * asynchronously from other displays and at differing refresh rates.
  134400. * @param callback Define the eaction to run next frame
  134401. * @returns the request handle it
  134402. */
  134403. requestAnimationFrame(callback: FrameRequestCallback): number;
  134404. /**
  134405. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  134406. * Repeat calls while already presenting will update the VRLayers being displayed.
  134407. * @param layers Define the list of layer to present
  134408. * @returns a promise to know when the request has been fulfilled
  134409. */
  134410. requestPresent(layers: VRLayer[]): Promise<void>;
  134411. /**
  134412. * Reset the pose for this display, treating its current position and
  134413. * orientation as the "origin/zero" values. VRPose.position,
  134414. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  134415. * updated when calling resetPose(). This should be called in only
  134416. * sitting-space experiences.
  134417. */
  134418. resetPose(): void;
  134419. /**
  134420. * The VRLayer provided to the VRDisplay will be captured and presented
  134421. * in the HMD. Calling this function has the same effect on the source
  134422. * canvas as any other operation that uses its source image, and canvases
  134423. * created without preserveDrawingBuffer set to true will be cleared.
  134424. * @param pose Define the pose to submit
  134425. */
  134426. submitFrame(pose?: VRPose): void;
  134427. }
  134428. declare var VRDisplay: {
  134429. prototype: VRDisplay;
  134430. new(): VRDisplay;
  134431. };
  134432. interface VRLayer {
  134433. leftBounds?: number[] | Float32Array | null;
  134434. rightBounds?: number[] | Float32Array | null;
  134435. source?: HTMLCanvasElement | null;
  134436. }
  134437. interface VRDisplayCapabilities {
  134438. readonly canPresent: boolean;
  134439. readonly hasExternalDisplay: boolean;
  134440. readonly hasOrientation: boolean;
  134441. readonly hasPosition: boolean;
  134442. readonly maxLayers: number;
  134443. }
  134444. interface VREyeParameters {
  134445. /** @deprecated */
  134446. readonly fieldOfView: VRFieldOfView;
  134447. readonly offset: Float32Array;
  134448. readonly renderHeight: number;
  134449. readonly renderWidth: number;
  134450. }
  134451. interface VRFieldOfView {
  134452. readonly downDegrees: number;
  134453. readonly leftDegrees: number;
  134454. readonly rightDegrees: number;
  134455. readonly upDegrees: number;
  134456. }
  134457. interface VRFrameData {
  134458. readonly leftProjectionMatrix: Float32Array;
  134459. readonly leftViewMatrix: Float32Array;
  134460. readonly pose: VRPose;
  134461. readonly rightProjectionMatrix: Float32Array;
  134462. readonly rightViewMatrix: Float32Array;
  134463. readonly timestamp: number;
  134464. }
  134465. interface VRPose {
  134466. readonly angularAcceleration: Float32Array | null;
  134467. readonly angularVelocity: Float32Array | null;
  134468. readonly linearAcceleration: Float32Array | null;
  134469. readonly linearVelocity: Float32Array | null;
  134470. readonly orientation: Float32Array | null;
  134471. readonly position: Float32Array | null;
  134472. readonly timestamp: number;
  134473. }
  134474. interface VRStageParameters {
  134475. sittingToStandingTransform?: Float32Array;
  134476. sizeX?: number;
  134477. sizeY?: number;
  134478. }
  134479. interface Navigator {
  134480. getVRDisplays(): Promise<VRDisplay[]>;
  134481. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  134482. }
  134483. interface Window {
  134484. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  134485. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  134486. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  134487. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134488. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134489. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  134490. }
  134491. interface Gamepad {
  134492. readonly displayId: number;
  134493. }
  134494. type XRSessionMode =
  134495. | "inline"
  134496. | "immersive-vr"
  134497. | "immersive-ar";
  134498. type XRReferenceSpaceType =
  134499. | "viewer"
  134500. | "local"
  134501. | "local-floor"
  134502. | "bounded-floor"
  134503. | "unbounded";
  134504. type XREnvironmentBlendMode =
  134505. | "opaque"
  134506. | "additive"
  134507. | "alpha-blend";
  134508. type XRVisibilityState =
  134509. | "visible"
  134510. | "visible-blurred"
  134511. | "hidden";
  134512. type XRHandedness =
  134513. | "none"
  134514. | "left"
  134515. | "right";
  134516. type XRTargetRayMode =
  134517. | "gaze"
  134518. | "tracked-pointer"
  134519. | "screen";
  134520. type XREye =
  134521. | "none"
  134522. | "left"
  134523. | "right";
  134524. interface XRSpace extends EventTarget {
  134525. }
  134526. interface XRRenderState {
  134527. depthNear?: number;
  134528. depthFar?: number;
  134529. inlineVerticalFieldOfView?: number;
  134530. baseLayer?: XRWebGLLayer;
  134531. }
  134532. interface XRInputSource {
  134533. handedness: XRHandedness;
  134534. targetRayMode: XRTargetRayMode;
  134535. targetRaySpace: XRSpace;
  134536. gripSpace: XRSpace | undefined;
  134537. gamepad: Gamepad | undefined;
  134538. profiles: Array<string>;
  134539. }
  134540. interface XRSession {
  134541. addEventListener: Function;
  134542. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  134543. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  134544. requestAnimationFrame: Function;
  134545. end(): Promise<void>;
  134546. renderState: XRRenderState;
  134547. inputSources: Array<XRInputSource>;
  134548. }
  134549. interface XRReferenceSpace extends XRSpace {
  134550. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  134551. onreset: any;
  134552. }
  134553. interface XRFrame {
  134554. session: XRSession;
  134555. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  134556. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  134557. }
  134558. interface XRViewerPose extends XRPose {
  134559. views: Array<XRView>;
  134560. }
  134561. interface XRPose {
  134562. transform: XRRigidTransform;
  134563. emulatedPosition: boolean;
  134564. }
  134565. interface XRWebGLLayerOptions {
  134566. antialias ?: boolean;
  134567. depth ?: boolean;
  134568. stencil ?: boolean;
  134569. alpha ?: boolean;
  134570. multiview ?: boolean;
  134571. framebufferScaleFactor ?: number;
  134572. }
  134573. declare var XRWebGLLayer: {
  134574. prototype: XRWebGLLayer;
  134575. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  134576. };
  134577. interface XRWebGLLayer {
  134578. framebuffer: WebGLFramebuffer;
  134579. framebufferWidth: number;
  134580. framebufferHeight: number;
  134581. getViewport: Function;
  134582. }
  134583. interface XRRigidTransform {
  134584. position: DOMPointReadOnly;
  134585. orientation: DOMPointReadOnly;
  134586. matrix: Float32Array;
  134587. inverse: XRRigidTransform;
  134588. }
  134589. interface XRView {
  134590. eye: XREye;
  134591. projectionMatrix: Float32Array;
  134592. transform: XRRigidTransform;
  134593. }
  134594. interface XRInputSourceChangeEvent {
  134595. session: XRSession;
  134596. removed: Array<XRInputSource>;
  134597. added: Array<XRInputSource>;
  134598. }